code_uiinlineselect.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // UIInlineSelect application source code
  2. #include <Atomic/UI/UIInlineSelect.h>
  3. #include <Atomic/UI/UISlider.h>
  4. #include "PeriodicApp.h"
  5. void PeriodicApp::setup_uiinlineselect( UIWidget *layout )
  6. {
  7. PODVector<UIWidget*> dest;
  8. layout->SearchWidgetClass( "TBButton", dest );
  9. for (unsigned ii = 0; ii < dest.Size(); ii++)
  10. SubscribeToEvent(dest[ii], E_WIDGETEVENT, ATOMIC_HANDLER(PeriodicApp, HandleUiinlineselectEvent ));
  11. UISlider *steps = static_cast<UISlider*>(layout->GetWidget("ilsstep"));
  12. if(steps)
  13. SubscribeToEvent(steps, E_WIDGETEVENT, ATOMIC_HANDLER(PeriodicApp, HandleUiinlineselectEvent ));
  14. UIInlineSelect *ils = static_cast<UIInlineSelect*>(layout->GetWidget("inlineselectdemo"));
  15. if (ils)
  16. SubscribeToEvent( ils, E_WIDGETEVENT, ATOMIC_HANDLER(PeriodicApp, HandleUiinlineselectEvent ));
  17. }
  18. void PeriodicApp::HandleUiinlineselectEvent(StringHash eventType, VariantMap& eventData)
  19. {
  20. using namespace WidgetEvent;
  21. UIWidget* widget = static_cast<UIWidget*>(eventData[P_TARGET].GetPtr());
  22. if ( widget == NULL ) return;
  23. if (eventData[P_TYPE] == UI_EVENT_TYPE_CLICK)
  24. {
  25. if (widget->GetId() == "uiinlineselectcode" )
  26. {
  27. AppLog( "UIInlineSelect support : " + widget->GetId() + " was pressed " );
  28. ViewCode ( "Components/code_uiinlineselect.cpp", widget->GetParent() );
  29. }
  30. if (widget->GetId() == "uiinlineselectlayout" )
  31. {
  32. AppLog( "UIInlineSelect support : " + widget->GetId() + " was pressed ");
  33. ViewCode ( "Scenes/layout_uiinlineselect.ui.txt", widget->GetParent() );
  34. }
  35. }
  36. else if (eventData[P_TYPE] == UI_EVENT_TYPE_CHANGED )
  37. {
  38. if (widget->GetId() == "inlineselectdemo" )
  39. {
  40. UIInlineSelect *ils = static_cast<UIInlineSelect*>(widget);
  41. if(ils)
  42. {
  43. AppLog( "UIInlineSelect event : " + widget->GetId() + " changed value to " + String (ils->GetValue()) );
  44. }
  45. }
  46. if (widget->GetId() == "ilsstep" )
  47. {
  48. UISlider *steps = static_cast<UISlider*>(widget);
  49. if(steps)
  50. {
  51. UIInlineSelect *ils = static_cast<UIInlineSelect*>(widget->FindWidget("inlineselectdemo"));
  52. if(ils)
  53. {
  54. ils->SetStepSize (steps->GetValue());
  55. }
  56. AppLog( "UIInlineSelect event : " + widget->GetId() + " step size changed to " + String (steps->GetValue()));
  57. }
  58. }
  59. }
  60. }