Color Picker.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /******************************************************************************/
  2. const_mem_addr STRUCT(ColorPicker , Window) // !! must be stored in constant memory address !!
  3. //{
  4. MemberDesc md;
  5. // manage
  6. ColorPicker& create(C Str &name);
  7. // get / set
  8. C Vec4 & operator()( )C {return _rgba;} // get current color in RGBA format
  9. ColorPicker& set (C Vec4 &color, SET_MODE mode=SET_DEFAULT); // set current color from RGBA values
  10. ColorPicker& setRGB (C Vec &rgb , SET_MODE mode=SET_DEFAULT); // set current color from RGB values
  11. ColorPicker& setHSB (C Vec &hsb , SET_MODE mode=SET_DEFAULT); // set current color from HSB values
  12. ColorPicker& setAlpha ( Flt alpha, SET_MODE mode=SET_DEFAULT); // set current alpha
  13. ColorPicker& func(void (*func)(Ptr user), Ptr user=null, Bool immediate=false); // set function called when color value has changed, with 'user' as its parameter, 'immediate'=if call the function immediately when a change occurs (this will happen inside object update function where you cannot delete any objects) if set to false then the function will get called after all objects finished updating (there you can delete objects)
  14. T1(TYPE) ColorPicker& func(void (*func)(TYPE *user), TYPE *user , Bool immediate=false) {return T.func((void(*)(Ptr))func, user, immediate);} // set function called when color value has changed, with 'user' as its parameter, 'immediate'=if call the function immediately when a change occurs (this will happen inside object update function where you cannot delete any objects) if set to false then the function will get called after all objects finished updating (there you can delete objects)
  15. T1(TYPE) ColorPicker& func(void (*func)(TYPE &user), TYPE &user , Bool immediate=false) {return T.func((void(*)(Ptr))func, &user, immediate);} // set function called when color value has changed, with 'user' as its parameter, 'immediate'=if call the function immediately when a change occurs (this will happen inside object update function where you cannot delete any objects) if set to false then the function will get called after all objects finished updating (there you can delete objects)
  16. // operations
  17. ColorPicker& show( );
  18. ColorPicker& mode(Bool real); // change value display mode ('real'=0..1 range, or byte=0..255 range)
  19. virtual void update(C GuiPC &gpc);
  20. ColorPicker();
  21. #if !EE_PRIVATE
  22. private:
  23. #endif
  24. STRUCT(SatLum , GuiCustom)
  25. //{
  26. virtual void update(C GuiPC &gpc);
  27. virtual void draw (C GuiPC &gpc);
  28. };
  29. STRUCT(Hue , GuiCustom)
  30. //{
  31. virtual void update(C GuiPC &gpc);
  32. virtual void draw (C GuiPC &gpc);
  33. };
  34. STRUCT(Colors , GuiCustom)
  35. //{
  36. virtual void update(C GuiPC &gpc);
  37. virtual void draw (C GuiPC &gpc);
  38. };
  39. Bool _real, _func_immediate;
  40. Vec _hsb;
  41. Vec4 _rgba, _old;
  42. Memx<Property> _props;
  43. SatLum _sat_lum;
  44. Hue _hue;
  45. Colors _color;
  46. Text _tnew, _told;
  47. Button _mode;
  48. Ptr _func_user;
  49. void (*_func)(Ptr user);
  50. #if EE_PRIVATE
  51. void call ();
  52. void toGui (Bool rgb=true, Bool alpha=true, Bool hsb=true, Bool rgba=true);
  53. void _set (C Vec4 &color, SET_MODE mode=SET_DEFAULT); // set without 'toGui'
  54. void _setRGB (C Vec &rgb , SET_MODE mode=SET_DEFAULT); // set without 'toGui'
  55. void _setHSB (C Vec &hsb , SET_MODE mode=SET_DEFAULT); // set without 'toGui'
  56. void _setAlpha( Flt alpha, SET_MODE mode=SET_DEFAULT); // set without 'toGui'
  57. void setOld ();
  58. static void SetTextStyle();
  59. #endif
  60. };
  61. /******************************************************************************/