BsGUIToggleField.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "BsGUIToggleField.h"
  2. #include "BsGUIArea.h"
  3. #include "BsGUILayout.h"
  4. #include "BsGUILabel.h"
  5. #include "BsGUIToggle.h"
  6. #include "BsBuiltinResources.h"
  7. #include "BsGUIWidget.h"
  8. #include "BsGUIMouseEvent.h"
  9. #include "BsGUIWidget.h"
  10. using namespace CamelotFramework;
  11. using namespace BansheeEngine;
  12. namespace BansheeEditor
  13. {
  14. GUIToggleField::GUIToggleField(const PrivatelyConstruct& dummy, GUIWidget& parent, const GUIContent& labelContent,
  15. UINT32 labelWidth, GUIElementStyle* labelStyle, GUIElementStyle* toggleStyle, const GUILayoutOptions& layoutOptions, bool withLabel)
  16. :TGUIField(dummy, parent, labelContent, labelWidth, labelStyle, layoutOptions, withLabel), mToggle(nullptr)
  17. {
  18. const GUIElementStyle* curToggleStyle = toggleStyle;
  19. if(curToggleStyle == nullptr)
  20. curToggleStyle = parent.getSkin().getStyle("Toggle");
  21. mToggle = GUIToggle::create(parent, HString(L""), curToggleStyle);
  22. mLayout->addElement(mToggle);
  23. }
  24. bool GUIToggleField::getValue() const
  25. {
  26. return mToggle->isToggled();
  27. }
  28. void GUIToggleField::setValue(bool value)
  29. {
  30. if(value)
  31. mToggle->toggleOn();
  32. else
  33. mToggle->toggleOff();
  34. }
  35. const String& GUIToggleField::getGUITypeName()
  36. {
  37. static String typeName = "GUIToggleField";
  38. return typeName;
  39. }
  40. }