1
0

AlbumArt.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #ifndef NULLSOFT_GEN_FF_ALBUMART_H
  2. #define NULLSOFT_GEN_FF_ALBUMART_H
  3. #include <api/wnd/wndclass/bufferpaintwnd.h>
  4. #include <api/skin/widgets/layer.h>
  5. #include <api/syscb/callbacks/metacb.h>
  6. //#include <api/syscb/callbacks/corecbi.h>
  7. //#define ALBUMART_PARENT GuiObjectWnd
  8. //#define ALBUMART_PARENT BufferPaintWnd
  9. #define ALBUMART_PARENT Layer
  10. // {6DCB05E4-8AC4-48c2-B193-49F0910EF54A}
  11. static const GUID albumArtGuid =
  12. { 0x6dcb05e4, 0x8ac4, 0x48c2, { 0xb1, 0x93, 0x49, 0xf0, 0x91, 0xe, 0xf5, 0x4a } };
  13. class AlbumArtScriptController : public LayerScriptController
  14. {
  15. public:
  16. virtual const wchar_t *getClassName();
  17. virtual const wchar_t *getAncestorClassName();
  18. virtual ScriptObjectController *getAncestorController() { return layerController; }
  19. virtual int getNumFunctions();
  20. virtual const function_descriptor_struct *getExportedFunctions();
  21. virtual GUID getClassGuid();
  22. virtual ScriptObject *instantiate();
  23. virtual void destroy(ScriptObject *o);
  24. virtual void *encapsulate(ScriptObject *o);
  25. virtual void deencapsulate(void *o);
  26. private:
  27. static function_descriptor_struct exportedFunction[];
  28. };
  29. extern AlbumArtScriptController *albumartController;
  30. class AlbumArtThreadContext;
  31. class AlbumArt : public ALBUMART_PARENT,
  32. public CoreCallbackI, /* to get song change updates */
  33. public MetadataCallbackI /* to find out when album art changes */
  34. // public SkinCallbackI /* to get color theme changes */
  35. {
  36. public:
  37. AlbumArt();
  38. ~AlbumArt();
  39. protected:
  40. void metacb_ArtUpdated(const wchar_t *filename);
  41. virtual int corecb_onUrlChange(const wchar_t *filename);
  42. virtual int onInit();
  43. //virtual int onBufferPaint(BltCanvas *canvas, int w, int h);
  44. int setXuiParam(int _xuihandle, int attrid, const wchar_t *name, const wchar_t *strval);
  45. int skincb_onColorThemeChanged(const wchar_t *newcolortheme);
  46. bool LoadArt(AlbumArtThreadContext *context, HANDLE thread_to_notify);
  47. /* Layer */
  48. SkinBitmap *getBitmap();
  49. bool layer_isInvalid();
  50. void onSetVisible(int show);
  51. /*
  52. virtual int getWidth();
  53. virtual int getHeight();
  54. */
  55. /*static */void CreateXMLParameters(int master_handle);
  56. private:
  57. void layer_adjustDest(RECT *r);
  58. int w,h;
  59. int valign; // 0 = center, 1 = bottom, -1 = top
  60. int align; // 0 = center, 1 = right, -1 = left
  61. bool stretched;
  62. bool forceRefresh;
  63. bool noAutoRefresh;
  64. bool noMakiCallback;
  65. volatile int isLoading;
  66. void ArtLoaded(int _w, int _h, ARGB32 *_bits);
  67. StringW src_file;
  68. ARGB32 *bits;
  69. SkinBitmap *artBitmap;
  70. AutoSkinBitmap missing_art_image;
  71. volatile LONG iterator;
  72. HANDLE thread_semaphore, hMainThread;
  73. friend class AlbumArtThreadContext;
  74. private:
  75. /* XML Parameters */
  76. enum
  77. {
  78. ALBUMART_NOTFOUNDIMAGE,
  79. ALBUMART_SOURCE,
  80. ALBUMART_VALIGN,
  81. ALBUMART_ALIGN,
  82. ALBUMART_STRETCHED,
  83. ALBUMART_NOREFRESH
  84. };
  85. static XMLParamPair params[];
  86. int xuihandle;
  87. public:
  88. static scriptVar script_vcpu_refresh(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  89. static scriptVar script_vcpu_onAlbumArtLoaded(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar success);
  90. static scriptVar script_vcpu_isLoading(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  91. };
  92. extern const wchar_t albumArtXuiObjectStr[];
  93. extern char albumArtXuiSvcName[];
  94. class AlbumArtXuiSvc : public XuiObjectSvc<AlbumArt, albumArtXuiObjectStr, albumArtXuiSvcName> {};
  95. #endif