UIDrag.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include "Sample.h"
  5. namespace Urho3D
  6. {
  7. class Node;
  8. class Scene;
  9. }
  10. /// GUI test example.
  11. /// This sample demonstrates:
  12. /// - Creating GUI elements from C++
  13. /// - Loading GUI Style from xml
  14. /// - Subscribing to GUI drag events and handling them
  15. /// - Working with GUI elements with specific tags.
  16. class UIDrag : public Sample
  17. {
  18. URHO3D_OBJECT(UIDrag, Sample);
  19. public:
  20. /// Construct.
  21. explicit UIDrag(Context* context);
  22. /// Setup after engine initialization and before running the main loop.
  23. void Start() override;
  24. protected:
  25. /// Return XML patch instructions for screen joystick layout for a specific sample app, if any.
  26. String GetScreenJoystickPatchString() const override { return
  27. "<patch>"
  28. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Hat0']]\">"
  29. " <attribute name=\"Is Visible\" value=\"false\" />"
  30. " </add>"
  31. "</patch>";
  32. }
  33. private:
  34. /// Construct the GUI.
  35. void CreateGUI();
  36. /// Construct an instruction text to the UI.
  37. void CreateInstructions();
  38. /// Subscribe to application-wide logic update events.
  39. void SubscribeToEvents();
  40. void HandleUpdate(StringHash eventType, VariantMap& eventData);
  41. void HandleClick(StringHash eventType, VariantMap& eventData);
  42. void HandleDragBegin(StringHash eventType, VariantMap& eventData);
  43. void HandleDragMove(StringHash eventType, VariantMap& eventData);
  44. void HandleDragCancel(StringHash eventType, VariantMap& eventData);
  45. };