summaryrefslogtreecommitdiffhomepage
path: root/src/layout_editor.c
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-08 14:31:17 +0900
committerAdam Malczewski <[email protected]>2026-06-08 14:31:17 +0900
commit0d154d253110dbe9e27790354c755f50fe47dd22 (patch)
tree2cc9a7e6116e7c5deece492f406bb5b5ad38b0cb /src/layout_editor.c
parent60c084ce1f9b1ff237b275ecbc89634468660077 (diff)
downloadstudy-player-0d154d253110dbe9e27790354c755f50fe47dd22.tar.gz
study-player-0d154d253110dbe9e27790354c755f50fe47dd22.zip
ui: make smart play button and section nav configurable
- UILayout gains smartPlayY and secNavY fields - Smart play HOLD button now uses layout.smartPlayY - Section nav prev/next buttons use layout.secNavY - Both are draggable in Layout editor tab - config_load/config_save handle new fields
Diffstat (limited to 'src/layout_editor.c')
-rw-r--r--src/layout_editor.c66
1 files changed, 65 insertions, 1 deletions
diff --git a/src/layout_editor.c b/src/layout_editor.c
index a728548..ef01640 100644
--- a/src/layout_editor.c
+++ b/src/layout_editor.c
@@ -51,10 +51,36 @@ void layout_editor_draw(const char *exePath, UILayout *layout)
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
dragIndex = -1;
- /* Check element 4 first (Help), then 3, 2, 1, 0.
+ /* Check element 6 first, then 5, 4, 3, 2, 1, 0.
Later checks overwrite earlier ones if they overlap —
priority goes to elements drawn last / on top. */
+ /* 6: Section nav buttons (two circles) */
+ {
+ float secPrevX = (float)screenW / 2.0f - 65.0f;
+ float secNextX = (float)screenW / 2.0f + 65.0f;
+ float secBtnRadius = 35.0f;
+ float dx1 = mouse.x - secPrevX;
+ float dy1 = mouse.y - layout->secNavY;
+ float dx2 = mouse.x - secNextX;
+ float dy2 = mouse.y - layout->secNavY;
+ if ((dx1 * dx1 + dy1 * dy1 <= secBtnRadius * secBtnRadius) ||
+ (dx2 * dx2 + dy2 * dy2 <= secBtnRadius * secBtnRadius)) {
+ dragIndex = 6;
+ dragOffsetY = mouse.y - layout->secNavY;
+ }
+ }
+
+ /* 5: Smart play button (HOLD) */
+ {
+ Rectangle r = { (float)screenW / 2.0f - 100.0f,
+ layout->smartPlayY, 200.0f, 80.0f };
+ if (CheckCollisionPointRec(mouse, r)) {
+ dragIndex = 5;
+ dragOffsetY = mouse.y - layout->smartPlayY;
+ }
+ }
+
/* 4: Help */
{
Rectangle r = { 40.0f, layout->helpY, HELP_W, HELP_H };
@@ -130,6 +156,12 @@ void layout_editor_draw(const char *exePath, UILayout *layout)
case 4: /* Help */
layout->helpY = mouse.y - dragOffsetY;
break;
+ case 5: /* Smart play */
+ layout->smartPlayY = mouse.y - dragOffsetY;
+ break;
+ case 6: /* Section nav */
+ layout->secNavY = mouse.y - dragOffsetY;
+ break;
}
}
@@ -203,4 +235,36 @@ void layout_editor_draw(const char *exePath, UILayout *layout)
Rectangle r = { 40.0f, layout->helpY, HELP_W, HELP_H };
draw_label("Help", r, f, borderColor);
}
+
+ /* --- 5: Smart play button --- */
+ {
+ Color f = (dragIndex == 5) ? highlightColor : fillColor;
+ Rectangle r = { (float)screenW / 2.0f - 100.0f,
+ layout->smartPlayY, 200.0f, 80.0f };
+ draw_label("HOLD", r, f, borderColor);
+ }
+
+ /* --- 6: Section nav buttons --- */
+ {
+ Color f = (dragIndex == 6) ? highlightColor : fillColor;
+ float secBtnRadius = 35.0f;
+ float secPrevX = (float)screenW / 2.0f - 65.0f;
+ float secNextX = (float)screenW / 2.0f + 65.0f;
+ float secCenterY = layout->secNavY;
+
+ DrawCircle((int)secPrevX, (int)secCenterY, secBtnRadius, f);
+ DrawCircleLines((int)secPrevX, (int)secCenterY, secBtnRadius, borderColor);
+ DrawText("<", (int)secPrevX - MeasureText("<", labelFontSize) / 2,
+ (int)secCenterY - labelFontSize / 2, labelFontSize, labelColor);
+
+ DrawCircle((int)secNextX, (int)secCenterY, secBtnRadius, f);
+ DrawCircleLines((int)secNextX, (int)secCenterY, secBtnRadius, borderColor);
+ DrawText(">", (int)secNextX - MeasureText(">", labelFontSize) / 2,
+ (int)secCenterY - labelFontSize / 2, labelFontSize, labelColor);
+
+ const char *secLabel = "Sec";
+ int secLabelW = MeasureText(secLabel, labelFontSize);
+ DrawText(secLabel, (int)((float)screenW / 2.0f - secLabelW / 2.0f),
+ (int)secCenterY - labelFontSize / 2, labelFontSize, labelColor);
+ }
}