api_playlist_colouriser.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #ifndef NULLSOFT_API_PLAYLIST_COLOURISER_H
  2. #define NULLSOFT_API_PLAYLIST_COLOURISER_H
  3. /*
  4. ** Wasabi Playlist Colouriser API Interface v1.0
  5. ** Note: This requires JTFE v1.2 and higher to work
  6. ** (Released: 28/09/2010)
  7. **
  8. **
  9. ** This header file provides the interfaces implemented by the JTFE plugin for other plugins and services to
  10. ** be able to make use of it's playlist colouriser which allows for highlighting of playlist entries in a
  11. ** different style to that currently defined by the skin in use to make for example queued items more visible.
  12. **
  13. ** The interface allows for controlling aspects of the text colour and the background of playlist item entries
  14. ** as long as they exist in the playlist editor or there is data to show e.g. you cannot change the text colour
  15. ** of the time entry if there is no time entry shown such as for missing files or streams of unknown length).
  16. **
  17. ** When specifying a colour, if you want the default skin colours to be used then you need to set the colour to
  18. ** be -1
  19. **
  20. ** To use this api assumes you know already how to make use of the wasabi service based system
  21. ** (see the more complete examples provided in the SDK).
  22. **
  23. **
  24. ** Example:
  25. **
  26. ** The following psuedo code shows how to show a flashing inverted selection on the first item being queried in
  27. ** the current playlist editor's contents.
  28. **
  29. ** // this will setup an inverted entry when the playlist is queried to be painted
  30. ** // you could setup a timer to cause a playlist painting event to make it flash
  31. ** // if you toggle the returned state on and off in the ExampleCheck(..) callback
  32. ** Colouriser ExampleColouriser = {COLOURISER_FULL_BKGND | COLOURISER_FULL_TEXT |
  33. ** COLOURISER_INVERTED | COLOURISER_INVERTED_TEXT,
  34. ** 0,-1,-1,-1,-1, ExampleCheck};
  35. **
  36. ** int ExampleCheck(int idx, wchar_t* file){
  37. ** // will only apply the colouring on the first playlist item
  38. ** return (idx == 0);
  39. ** }
  40. **
  41. ** // use this to get an instance of the service (returns null or 1 on error or not supported)
  42. ** if(!WASABI_API_COLOURISER) ServiceBuild(WASABI_API_COLOURISER,PlaylistColouriserApiGUID);
  43. **
  44. **
  45. ** // this can be used to add or update an existing colouriser instance
  46. ** // using COLOURISER_DISABLED in the flags to disable it if not needed
  47. ** if(!WASABI_API_COLOURISER->ColouriserExists(&ExampleColouriser)){
  48. ** WASABI_API_COLOURISER->AddColouriser(&ExampleColouriser);
  49. ** }
  50. ** else{
  51. ** WASABI_API_COLOURISER->UpdateColouriser(&ExampleColouriser);
  52. ** }
  53. **
  54. ** // with the above, if you wanted to change the code to just change the text
  55. ** // colour of playlist item then you could use something like the following:
  56. ** ExampleColouriser.flags = COLOURISER_FULL_TEXT;
  57. ** ExampleColouriser.main_text = ExcludeColouriser.time_text = <specify_your_colour>;
  58. */
  59. #if (_MSC_VER <= 1200)
  60. typedef int intptr_t;
  61. #endif
  62. #ifdef __cplusplus
  63. #include <bfc/dispatch.h>
  64. typedef struct{
  65. #define COLOURISER_TIME_BKGND 0x01 // override the time column background colour - uses time_bkgnd
  66. #define COLOURISER_MAIN_BKGND 0x02 // override the main column background colour - uses main_bkgnd
  67. #define COLOURISER_MAIN_BKGND_ALT 0x04 // allows for a different colour for the main column background
  68. #define COLOURISER_FULL_BKGND COLOURISER_MAIN_BKGND | COLOURISER_TIME_BKGND
  69. #define COLOURISER_TIME_TEXT 0x10 // override the time column text colour - uses time_text
  70. #define COLOURISER_MAIN_TEXT 0x20 // override the main column text colour - uses main_text
  71. #define COLOURISER_FULL_TEXT COLOURISER_TIME_TEXT | COLOURISER_MAIN_TEXT
  72. #define COLOURISER_BLEND 0x40 // will attempt to blend the colour with the existing colours
  73. #define COLOURISER_DISABLED 0x1000 // set this when you require your colouriser to be ignored
  74. #define COLOURISER_INVERTED 0x2000 // if colours are specified as -1 then use the inverse of the current skin values
  75. #define COLOURISER_INVERTED_TEXT 0x4000 // if colours are specified as -1 then use the inverse of the current skin values
  76. // this will only be used if COLOURISER_INVERTED is already specified
  77. int flags; // determine which colours are to be used / handled
  78. int _me; // used to identify the colouriser - don't alter!!!
  79. // when using ColouriserColour(..) the value for query_colour is shown to the right
  80. COLORREF time_bkgnd; // 0
  81. COLORREF main_bkgnd; // 1
  82. COLORREF time_text; // 2
  83. COLORREF main_text; // 3
  84. // callback function to see if the colouriser's colours need to be used on the passed playlist item
  85. int (*check)(int entry_index, wchar_t* entry_filepath);
  86. } Colouriser;
  87. class api_playlist_colouriser : public Dispatchable
  88. {
  89. protected:
  90. api_playlist_colouriser() {}
  91. ~api_playlist_colouriser() {}
  92. public:
  93. BOOL AddColouriser(Colouriser* colouriser);
  94. Colouriser* UpdateColouriser(Colouriser* colouriser);
  95. BOOL ColourPicker(HWND parent_hwnd, UINT control_id, UINT options_id, Colouriser* colouriser, wchar_t* window_title, wchar_t* button_text);
  96. BOOL ColouriserExists(Colouriser* colouriser);
  97. COLORREF ColouriserColour(COLORREF current_colour, UINT query_colour);
  98. public:
  99. DISPATCH_CODES
  100. {
  101. API_COLOURISER_ADD = 1,
  102. API_COLOURISER_UPDATE = 2,
  103. API_COLOURISER_COLOURPICKER = 3,
  104. API_COLOURISER_EXISTS = 4,
  105. API_COLOURISER_COLOUR = 5,
  106. };
  107. };
  108. inline BOOL api_playlist_colouriser::AddColouriser(Colouriser* colouriser)
  109. {
  110. return _call(API_COLOURISER_ADD, (BOOL)0, colouriser);
  111. }
  112. inline Colouriser* api_playlist_colouriser::UpdateColouriser(Colouriser* colouriser)
  113. {
  114. return _call(API_COLOURISER_UPDATE, (Colouriser*)0, colouriser);
  115. }
  116. inline BOOL api_playlist_colouriser::ColourPicker(HWND parent_hwnd, UINT control_id, UINT options_id, Colouriser* colouriser, wchar_t* window_title, wchar_t* button_text)
  117. {
  118. return _call(API_COLOURISER_COLOURPICKER, (BOOL)0, parent_hwnd, control_id, options_id, colouriser, window_title, button_text);
  119. }
  120. inline BOOL api_playlist_colouriser::ColouriserExists(Colouriser* colouriser)
  121. {
  122. return _call(API_COLOURISER_EXISTS, (BOOL)0, colouriser);
  123. }
  124. inline COLORREF api_playlist_colouriser::ColouriserColour(COLORREF current_colour, UINT query_colour)
  125. {
  126. return _call(API_COLOURISER_COLOUR, (COLORREF)0, current_colour, query_colour);
  127. }
  128. #endif
  129. // {B8B8DA7C-1F35-4a6d-95FA-C7E9651D5DC0}
  130. static const GUID PlaylistColouriserApiGUID =
  131. { 0xb8b8da7c, 0x1f35, 0x4a6d, { 0x95, 0xfa, 0xc7, 0xe9, 0x65, 0x1d, 0x5d, 0xc0 } };
  132. #endif