Panel.h 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /******************************************************************************/
  2. struct Panel
  3. {
  4. Bool center_stretch, // if stretch center image to fit the whole rectangle, default=false
  5. side_stretch, // if stretch side images to fit the whole side , default=false, this affects 'top_image', 'bottom_image', 'left_right_image', 'top_corner_image' and 'bottom_corner_image'
  6. center_shadow ; // if include a shadow underneath the center , default=false, if shadows are enabled then normally they will be drawn around the center image, however if 'center_shadow' is enabled, then shadows will be also draw underneath the center
  7. Byte shadow_opacity; // shadow opacity, 0..255, default=170
  8. Color center_color , // center color , default=WHITE, this is affects 'center_image' and 'panel_image'
  9. border_color , // border color , default=WHITE, this is affects 'border_image'
  10. side_color , // side image color , default=WHITE, this is affects 'top_image', 'bottom_image', 'left_right_image', 'top_corner_image' and 'bottom_corner_image'
  11. blur_color ; // blur color , default=TRANSPARENT
  12. Flt shadow_radius , // shadow radius , default=0.035
  13. shadow_offset , // shadow offset , default=0
  14. border_size , // border size , default=0
  15. center_scale , // center scale , default=1
  16. top_size , // top size , default=0.1
  17. bottom_size , // bottom size , default=0.1
  18. left_right_size , // left/right size , default=0.1
  19. top_corner_size , // top corner size , default=0.1
  20. bottom_corner_size , // bottom corner size , default=0.1
  21. top_offset , // top offset , default=0
  22. bottom_offset ; // bottom offset , default=0
  23. Vec2 left_right_offset , // left/right offset , default=Vec2(0, 0)
  24. top_corner_offset , // top corner offset , default=Vec2(0, 0)
  25. bottom_corner_offset ; // bottom corner offset , default=Vec2(0, 0)
  26. ImagePtr center_image , // center image , default=null
  27. border_image , // border image , default=null
  28. top_image , // top image , default=null
  29. bottom_image , // bottom image , default=null
  30. left_right_image , // left/right image , default=null
  31. top_corner_image , // top corner image , default=null
  32. bottom_corner_image ; // bottom corner image , default=null
  33. PanelImagePtr panel_image ; // panel image , default=null
  34. // get
  35. void extendedRect (C Rect &rect, Rect &extended )C; // get rectangle containing panel drawn at 'rect' rectangle
  36. void innerPadding (C Rect &rect, Rect &padding )C;
  37. void defaultInnerPadding ( Rect &padding )C;
  38. void defaultInnerPaddingSize( Vec2 &padd_size)C;
  39. #if EE_PRIVATE
  40. Bool pixelBorder()C; // if this panel draws a 1 pixel border
  41. Bool getSideScale(C Rect &rect, Flt &scale)C;
  42. #endif
  43. // operations
  44. void reset ( ); // reset to default values
  45. void scaleBorder(Flt scale); // scale border size, top, bottom, side and corner images according to specified parameter
  46. // draw
  47. virtual void draw( C Rect &rect)C; // draw at rectangle
  48. virtual void draw(C Color &color, C Rect &rect)C; // draw at rectangle with specified color multiplier
  49. void drawLines(C Color &line_color, C Rect &rect)C; // draw lines
  50. // io
  51. void operator=(C Str &name) ; // load, Exit on fail
  52. Bool save (C Str &name)C; // save, false on fail
  53. Bool load (C Str &name) ; // load, false on fail
  54. Bool save(File &f, CChar *path=null)C; // save to file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  55. Bool load(File &f, CChar *path=null) ; // load from file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  56. Panel() {reset();}
  57. };
  58. /******************************************************************************/
  59. DECLARE_CACHE(Panel, Panels, PanelPtr); // 'Panels' cache storing 'Panel' objects which can be accessed by 'PanelPtr' pointer
  60. /******************************************************************************/