1
0

uioptions.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #include <precomp.h>
  2. #include "uioptions.h"
  3. #include <api/wndmgr/layout.h>
  4. #include <api/config/items/attribs.h>
  5. #include <api/config/items/attrcb.h>
  6. #include <api/skin/skinparse.h>
  7. #include <api/wndmgr/alphamgr.h>
  8. // {9149C445-3C30-4e04-8433-5A518ED0FDDE}
  9. const GUID uioptions_guid =
  10. { 0x9149c445, 0x3c30, 0x4e04, { 0x84, 0x33, 0x5a, 0x51, 0x8e, 0xd0, 0xfd, 0xde } };
  11. _bool cfg_uioptions_desktopalpha(L"Enable desktop alpha", DEFAULT_DESKTOPALPHA);
  12. _bool cfg_uioptions_linkratio(L"Link layouts scale", DEFAULT_LINKLAYOUTSCALE);
  13. _bool cfg_uioptions_linkalpha(L"Link layouts alpha", DEFAULT_LINKLAYOUTSALPHA);
  14. _bool cfg_uioptions_linkallalpha(L"Link All layouts alpha", DEFAULT_LINKALLALPHA);
  15. _bool cfg_uioptions_linkallratio(L"Link All layouts scale", DEFAULT_LINKALLRATIO);
  16. _int cfg_uioptions_linkedalpha(L"Linked layouts alpha", DEFAULT_LINKEDALPHA);
  17. _int cfg_uioptions_autoopacitytime(L"Auto Opacity hold time", DEFAULT_AUTOOPACITYTIME);
  18. _int cfg_uioptions_autoopacityfadein(L"Auto Opacity fade in time", DEFAULT_AUTOOPACITYFADEIN);
  19. _int cfg_uioptions_autoopacityfadeout(L"Auto Opacity fade out time", DEFAULT_AUTOOPACITYFADEOUT);
  20. _int cfg_uioptions_autoopacitylinked(L"Use Auto Opacity", DEFAULT_AUTOOPACITYTYPE);
  21. _int cfg_uioptions_extendautoopacity(L"Auto Opacity extend by", DEFAULT_EXTENDAUTOOPACITY);
  22. _bool cfg_uioptions_uselocks(L"Use layout scale locks", DEFAULT_USERATIOLOCKS);
  23. _int cfg_uioptions_timerresolution(L"Multiplexed timers resolution", DEFAULT_TIMERRESOLUTION);
  24. _bool cfg_uioptions_tooltips(L"Enable tooltips", DEFAULT_TOOLTIPS);
  25. _float cfg_uioptions_textspeed(L"Text Ticker Speed", DEFAULT_TEXTSPEED);
  26. _int cfg_uioptions_textincrement(L"Text Ticker Increment", DEFAULT_TEXTINCREMENT);
  27. _int cfg_uioptions_appbarshidetime(L"Appbar Hide Time", DEFAULT_APPBARHIDETIME);
  28. _int cfg_uioptions_appbarsshowtime(L"Appbar Show Time", DEFAULT_APPBARSHOWTIME);
  29. void onSetOpacityTime(int n) {
  30. Layout *l = SkinParser::getMainLayout();
  31. if (l) l->getAlphaMgr()->setHoldTime(n);
  32. }
  33. void onSetOpacityFadeIn(int n) {
  34. Layout *l = SkinParser::getMainLayout();
  35. if (l) l->getAlphaMgr()->setFadeInTime(n);
  36. }
  37. void onSetOpacityFadeOut(int n) {
  38. Layout *l = SkinParser::getMainLayout();
  39. if (l) l->getAlphaMgr()->setFadeOutTime(n);
  40. }
  41. void onSetAllRatio(int on) {
  42. if (on) {
  43. Layout *l = SkinParser::getMainLayout();
  44. if (l) l->setRenderRatio(l->getRenderRatio());
  45. }
  46. }
  47. void onSetAllAlpha(int on) {
  48. Layout *l = SkinParser::getMainLayout();
  49. if (l) l->getAlphaMgr()->setAllLinked(on);
  50. }
  51. void onSetLinkedAlpha(int a) {
  52. Layout *l = SkinParser::getMainLayout();
  53. if (l) l->getAlphaMgr()->setGlobalAlpha(a);
  54. }
  55. void onSetLinkedAuto100(int v) {
  56. Layout *l = SkinParser::getMainLayout();
  57. if (l) l->getAlphaMgr()->setAutoOpacify(v);
  58. }
  59. void onSetExtendAutoOpacity(int v) {
  60. Layout *l = SkinParser::getMainLayout();
  61. if (l) l->getAlphaMgr()->setExtendAutoOpacity(v);
  62. }
  63. UIOptions::UIOptions(const wchar_t *name) : CfgItemI(name ? name : L"Skins and UI Tweaks", uioptions_guid)
  64. {
  65. registerAttribute(&cfg_uioptions_linkratio);
  66. registerAttribute(&cfg_uioptions_linkalpha);
  67. registerAttribute(&cfg_uioptions_uselocks);
  68. registerAttribute(&cfg_uioptions_autoopacitylinked, new int_attrCB(onSetLinkedAuto100));
  69. registerAttribute(&cfg_uioptions_linkallratio, new int_attrCB(onSetAllRatio));
  70. registerAttribute(&cfg_uioptions_linkallalpha, new int_attrCB(onSetAllAlpha));
  71. registerAttribute(&cfg_uioptions_desktopalpha, new int_attrCB(Layout::onGlobalEnableDesktopAlpha));
  72. registerAttribute(&cfg_uioptions_linkedalpha, new int_attrCB(onSetLinkedAlpha));
  73. registerAttribute(&cfg_uioptions_tooltips);
  74. registerAttribute(&cfg_uioptions_timerresolution);
  75. registerAttribute(&cfg_uioptions_textspeed);
  76. registerAttribute(&cfg_uioptions_textincrement);
  77. registerAttribute(&cfg_uioptions_appbarshidetime);
  78. registerAttribute(&cfg_uioptions_appbarsshowtime);
  79. registerAttribute(&cfg_uioptions_autoopacitytime, new int_attrCB(onSetOpacityTime));
  80. registerAttribute(&cfg_uioptions_autoopacityfadein, new int_attrCB(onSetOpacityFadeIn));
  81. registerAttribute(&cfg_uioptions_autoopacityfadeout, new int_attrCB(onSetOpacityFadeOut));
  82. registerAttribute(&cfg_uioptions_extendautoopacity, new int_attrCB(onSetExtendAutoOpacity));
  83. registerAttribute(new _int(L"Timer refresh rate", 30), new int_attrCB(onTimerRefreshRate));
  84. registerAttribute(new _int(L"Popup menu alpha", 240));
  85. registerAttribute(new _int(L"Spectrum analyzer mode",1));
  86. }
  87. void UIOptions::onTimerRefreshRate(int rate) {
  88. if(rate==0 || rate<9 || rate>70) return;
  89. int res=1000/rate;
  90. CfgItem *ci=WASABI_API_CONFIG->config_getCfgItemByGuid(uioptions_guid);
  91. if(!ci) return;
  92. ci->setDataAsInt(L"Multiplexed timers resolution",res);
  93. }