BsGUILayoutOptions.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #include "BsGUILayoutOptions.h"
  2. #include "BsGUIElementStyle.h"
  3. #include "BsGUIOptions.h"
  4. namespace BansheeEngine
  5. {
  6. GUILayoutOptions GUILayoutOptions::create()
  7. {
  8. return GUILayoutOptions();
  9. }
  10. GUILayoutOptions GUILayoutOptions::create(const GUIOptions& options)
  11. {
  12. GUILayoutOptions layoutOptions;
  13. for(auto& option : options.mOptions)
  14. {
  15. switch(option.type)
  16. {
  17. case GUIOption::Type::FixedWidth:
  18. layoutOptions.fixedWidth = true;
  19. layoutOptions.width = option.min;
  20. layoutOptions.overridenWidth = true;
  21. break;
  22. case GUIOption::Type::FixedHeight:
  23. layoutOptions.fixedHeight = true;
  24. layoutOptions.height = option.min;
  25. layoutOptions.overridenHeight = true;
  26. break;
  27. case GUIOption::Type::FlexibleWidth:
  28. layoutOptions.fixedWidth = false;
  29. layoutOptions.minWidth = option.min;
  30. layoutOptions.maxWidth = option.max;
  31. layoutOptions.overridenWidth = true;
  32. break;
  33. case GUIOption::Type::FlexibleHeight:
  34. layoutOptions.fixedHeight = false;
  35. layoutOptions.minHeight = option.min;
  36. layoutOptions.maxHeight = option.max;
  37. layoutOptions.overridenHeight = true;
  38. break;
  39. }
  40. }
  41. return layoutOptions;
  42. }
  43. void GUILayoutOptions::updateWithStyle(const GUIElementStyle* style)
  44. {
  45. if(!overridenWidth)
  46. {
  47. fixedWidth = style->fixedWidth;
  48. width = style->width;
  49. minWidth = style->minWidth;
  50. maxWidth = style->maxWidth;
  51. }
  52. if(!overridenHeight)
  53. {
  54. fixedHeight = style->fixedHeight;
  55. height = style->height;
  56. minHeight = style->minHeight;
  57. maxHeight = style->maxHeight;
  58. }
  59. }
  60. GUILayoutOptions::GUILayoutOptions()
  61. :width(0), height(0), minWidth(0), maxWidth(0),
  62. minHeight(0), maxHeight(0), fixedWidth(false), fixedHeight(false),
  63. overridenWidth(false), overridenHeight(false)
  64. {
  65. }
  66. }