From c33f759c2687771d0e05e41accd21391411b6f80 Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Wed, 18 Apr 2012 14:19:10 +0200 Subject: [PATCH] Added RocketGui_button --- ogl_editor/src/Editor.c | 9 +++++++++ ogl_editor/src/RocketGui.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/ogl_editor/src/Editor.c b/ogl_editor/src/Editor.c index 5f8790a..2e5dd6c 100644 --- a/ogl_editor/src/Editor.c +++ b/ogl_editor/src/Editor.c @@ -45,6 +45,15 @@ void Editor_guiUpdate() RocketGui_beginHorizontalStackPanelXY(2, 2); + if (RocketGui_button("PressMeNow!")) + { + RocketGui_textLabel("Pressed!"); + } + else + { + RocketGui_textLabel("No Press0r!"); + } + RocketGui_textLabel("Test"); RocketGui_textLabel("Test2"); RocketGui_textLabel("Test"); diff --git a/ogl_editor/src/RocketGui.c b/ogl_editor/src/RocketGui.c index 3562ad1..f75c851 100644 --- a/ogl_editor/src/RocketGui.c +++ b/ogl_editor/src/RocketGui.c @@ -475,6 +475,35 @@ bool RocketGui_buttonImage(const char* filename) return false; } +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +bool RocketGui_button(const char* text) +{ + RocketControlInfo* control; + uint32_t controlId = 0; + + control = RocketGui_textLabel(text); + controlId = s_controlId - 1; + + if (controlId == ~0) + return false; + + control = &g_controls[controlId]; + + if (RocketGui_regionHit(control)) + { + g_rocketGuiState.hotItem = controlId; + if (g_rocketGuiState.activeItem == 0 && g_rocketGuiState.mouseDown) + g_rocketGuiState.activeItem = controlId; + + //highlightControl(control); + } + + if (g_rocketGuiState.mouseDown == 0 && g_rocketGuiState.hotItem == controlId && g_rocketGuiState.activeItem == controlId) + return true; + + return false; +} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////