1
0

alphamgr.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #ifndef _ALPHAMGR_H
  2. #define _ALPHAMGR_H
  3. #include <api/timer/timerclient.h>
  4. class Layout;
  5. #define STATUS_UNKNOWN -1
  6. #define STATUS_OUT_OFF 0
  7. #define STATUS_IN_ON 1
  8. #define STATUS_OUT_FADINGOUT 2
  9. #define STATUS_IN_FADINGON 3
  10. #define STATUS_IN_OFF 4 // when no autoopacity
  11. class AlphaMgrEntry {
  12. public:
  13. AlphaMgrEntry(Layout *l) : layout(l), status(STATUS_UNKNOWN), fade_val(-1), startalpha(-1), lasttime_in(0), next_in(-1) {}
  14. virtual ~AlphaMgrEntry() { }
  15. Layout *getLayout() { return layout; }
  16. int getStatus() { return status; }
  17. void onEnterLeave() { enterleave_time = Wasabi::Std::getTickCount(); }
  18. int getEnterLeaveTime() { return enterleave_time; }
  19. void setEnterLeaveTime(uint32_t t) { enterleave_time = t; }
  20. void setStatus(int s) { status = s; }
  21. int getStartAlpha() { return startalpha; }
  22. void setStartAlpha(int s) { startalpha = s; }
  23. uint32_t getLastTimeIn() { return lasttime_in; }
  24. void onLastIn() { lasttime_in = Wasabi::Std::getTickCount(); }
  25. void setNextIn(int i) { next_in = i; }
  26. int getNextIn() { return next_in; }
  27. private:
  28. Layout *layout;
  29. int status;
  30. int fade_val;
  31. uint32_t enterleave_time;
  32. int startalpha;
  33. uint32_t lasttime_in;
  34. int next_in;
  35. };
  36. class AlphaMgrEntryComparator {
  37. public:
  38. static int compareItem(AlphaMgrEntry *p1, AlphaMgrEntry* p2) {
  39. return CMP3((void*)p1->getLayout(), (void *)p2->getLayout());
  40. }
  41. static int compareAttrib(const wchar_t *attrib, AlphaMgrEntry *item) {
  42. return CMP3((void *)attrib, (void *)item->getLayout());
  43. }
  44. };
  45. class AlphaMgr : public TimerClientDI {
  46. public:
  47. AlphaMgr();
  48. virtual ~AlphaMgr();
  49. void addLayout(Layout *l);
  50. void removeLayout(Layout *l);
  51. virtual void timerclient_timerCallback(int id);
  52. void updateTransparency(Layout *l);
  53. int getTransparency(Layout *l);
  54. int getGlobalAlpha();
  55. void setGlobalAlpha(int a);
  56. int isFocusInLayout(Layout *l);
  57. int isMouseInLayout(Layout *l);
  58. int isPointInLayout(Layout *l, int x, int y, api_region **rgn=NULL);
  59. int needForcedTransparencyFlag(Layout *l);
  60. int hasAutoOpacity(Layout *l);
  61. int hasAutoOpacityOnHover(Layout *l);
  62. int hasAutoOpacityOnFocus(Layout *l);
  63. void setAllLinked(int l) { alllinked = l; resetTimer(); updateAllTransparency(); }
  64. void setAutoOpacify(int l);
  65. int getAllLinked() { return alllinked; }
  66. int getAutoOpacify() { return (autoopacify && alllinked) ? autoopacify : 0; }
  67. void setExtendAutoOpacity(int n) { extend_px = n; }
  68. int getExtendAutoOpacity() { return extend_px; }
  69. int getBigCurTransparency();
  70. void setFadeInTime(int ms) { fadein_ms = MAX(ms, 1); }
  71. void setFadeOutTime(int ms) { fadeout_ms = MAX(ms, 1); }
  72. void setHoldTime(int ms) { holdtime_ms = ms; }
  73. void hoverCheck(Layout *l);
  74. int getAlpha(Layout *l);
  75. private:
  76. void updateAllTransparency();
  77. void updateInList(AlphaMgrEntry *e, int isin);
  78. void setBigStartAlpha(int a);
  79. int getBigStartAlpha() { return big_startalpha; }
  80. void onBigEnterLeave();
  81. uint32_t getBigEnterLeaveTime();
  82. void setBigStatus(int s);
  83. int getBigStatus() { return big_status; }
  84. void initStatus(AlphaMgrEntry *e, int applytransparency=0);
  85. int getAlpha(AlphaMgrEntry *e);
  86. int hasAutoOpacityOnHover(AlphaMgrEntry *e);
  87. int hasAutoOpacityOnFocus(AlphaMgrEntry *e);
  88. int hasAutoOpacity(AlphaMgrEntry *e);
  89. void checkTimer();
  90. void hoverCheck(AlphaMgrEntry *e, int applytransparency=1);
  91. void preHoverCheck(AlphaMgrEntry *e);
  92. int getCurve(AlphaMgrEntry *e);
  93. void doEndCheck(AlphaMgrEntry *e);
  94. void onBigLastIn() { big_lasttimein = Wasabi::Std::getTickCount(); }
  95. uint32_t getBigLastTimeIn() { return big_lasttimein; }
  96. int isFocusingExternalWindow();
  97. int isOverExternalWindow();
  98. int isOurExternalWindow(OSWINDOWHANDLE w);
  99. int isWasabiWindow(OSWINDOWHANDLE w);
  100. int isMenuWindow(OSWINDOWHANDLE w);
  101. void resetTimer();
  102. PtrListQuickSorted<AlphaMgrEntry, AlphaMgrEntryComparator> layouts;
  103. PtrListQuickSortedByPtrVal<AlphaMgrEntry> in_layouts;
  104. Layout *overlayout;
  105. int alllinked;
  106. int autoopacify;
  107. int global_alpha;
  108. int fast_timer_on;
  109. int big_status;
  110. int big_curtransparency;
  111. int big_startalpha;
  112. uint32_t big_enterleave_time;
  113. int big_lasttimein;
  114. int fadein_ms;
  115. int fadeout_ms;
  116. int holdtime_ms;
  117. int extend_px;
  118. };
  119. #endif