aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game.c23
-rw-r--r--src/ui.c35
2 files changed, 42 insertions, 16 deletions
diff --git a/src/game.c b/src/game.c
index 36b1d94..317f96b 100644
--- a/src/game.c
+++ b/src/game.c
@@ -47,14 +47,23 @@ void resetScreenScale(Game* game)
FocusCommand testFloatingWindowCallback(FloatingWindow* window, Game* game)
{
- DrawText("test", window->rect.x + 10,
- window->rect.y + 10 + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT, 15, BLUE);
+ float x = window->rect.x + window->scroll.x;
+ float y = window->rect.y + window->scroll.y;
+
+ DrawText("test", x + 10, y + 10 + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT, 15,
+ BLUE);
+
+ // Content size test.
+ if (window->contentSize.x != 0.0)
+ {
+ DrawText("content size test", x + 150.0, y + 150.0, 20, RED);
+ }
- if (GuiButton((Rectangle){window->rect.x + 10.0, window->rect.y + 50.0,
- 40.0, 20.0}, "A"))
+ // Button test.
+ if (GuiButton((Rectangle){x + 10.0, y + 50.0, 40.0, 20.0}, "A")
+ && window->hasFocus)
{
puts("hi");
- return DEMAND_FOCUS;
}
return NO_FOCUS_ACTION;
@@ -111,10 +120,14 @@ void initGame(Game* game)
window = createFloatingWindow("test3",
(Rectangle){300.0, 300.0, 100.0, 100.0});
+ window.callback = testFloatingWindowCallback;
+ window.contentSize = (Vector2){500.0, 500.0};
addWindowToWindowManager(&game->wm, window);
window = createFloatingWindow("test4",
(Rectangle){400.0, 400.0, 100.0, 100.0});
+ window.callback = testFloatingWindowCallback;
+ window.contentSize = (Vector2){500.0, 500.0};
addWindowToWindowManager(&game->wm, window);
disableGameCursor(game);
diff --git a/src/ui.c b/src/ui.c
index 6fbc250..6cd8d43 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -158,18 +158,31 @@ FocusCommand updateFloatingWindowNotMinimized(FloatingWindow* window,
if (window->callback != NULL)
{
Rectangle scissor;
-
- GuiScrollPanel(
- (Rectangle){
- window->rect.x, window->rect.y + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT,
+
+ // Handle scrolling.
+ if (window->hasFocus)
+ {
+ GuiScrollPanel(
+ (Rectangle){
+ window->rect.x, window->rect.y + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT,
+ window->rect.width,
+ window->rect.height - RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT},
+ NULL,
+ (Rectangle){
+ window->rect.x, window->rect.y,
+ window->contentSize.x, window->contentSize.y},
+ &window->scroll,
+ &scissor);
+ }
+ else
+ {
+ scissor = (Rectangle){
+ window->rect.x,
+ window->rect.y + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT,
window->rect.width,
- window->rect.height - RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT},
- NULL,
- (Rectangle){
- window->rect.x, window->rect.y,
- window->contentSize.x, window->contentSize.y},
- &window->scroll,
- &scissor);
+ window->rect.height - RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT
+ };
+ }
bool requireScissor = window->rect.width < window->contentSize.x
|| window->rect.height < window->contentSize.x;