Skip to content

Commit 7216815

Browse files
authored
Fixed termbox2 demo build, added scroll functionality (#523)
1 parent 8312999 commit 7216815

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

examples/termbox2-demo/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set(FETCHCONTENT_QUIET FALSE)
88
FetchContent_Declare(
99
termbox2
1010
GIT_REPOSITORY "https://github.com/termbox/termbox2.git"
11-
GIT_TAG "9c9281a9a4c971a2be57f8645e828ec99fd555e8"
11+
GIT_TAG "ffd159c2a6106dd5eef338a6702ad15d4d4aa809"
1212
GIT_PROGRESS TRUE
1313
GIT_SHALLOW TRUE
1414
)
@@ -17,7 +17,7 @@ FetchContent_MakeAvailable(termbox2)
1717
FetchContent_Declare(
1818
stb
1919
GIT_REPOSITORY "https://github.com/nothings/stb.git"
20-
GIT_TAG "f58f558c120e9b32c217290b80bad1a0729fbb2c"
20+
GIT_TAG "fede005abaf93d9d7f3a679d1999b2db341b360f"
2121
GIT_PROGRESS TRUE
2222
GIT_SHALLOW TRUE
2323
)

examples/termbox2-demo/main.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void component_text_pair(const char *key, const char *value)
9090

9191
void component_termbox_settings(void)
9292
{
93-
CLAY_AUTO_ID({
93+
CLAY(CLAY_ID("Termbox Settings"), {
9494
.floating = {
9595
.attachTo = CLAY_ATTACH_TO_PARENT,
9696
.zIndex = 1,
@@ -509,13 +509,18 @@ Clay_RenderCommandArray CreateLayout(clay_tb_image *image1, clay_tb_image *image
509509
{
510510
Clay_BeginLayout();
511511
CLAY_AUTO_ID({
512+
.clip = {
513+
.vertical = false,
514+
.horizontal = true,
515+
.childOffset = Clay_GetScrollOffset(),
516+
},
512517
.layout = {
513518
.sizing = {
514519
.width = CLAY_SIZING_GROW(),
515520
.height = CLAY_SIZING_GROW()
516521
},
517522
.childAlignment = {
518-
.x = CLAY_ALIGN_X_CENTER,
523+
.x = CLAY_ALIGN_X_LEFT,
519524
.y = CLAY_ALIGN_Y_CENTER
520525
},
521526
.childGap = 64
@@ -714,12 +719,12 @@ void handle_termbox_events(void)
714719
break;
715720
}
716721
case TB_KEY_MOUSE_WHEEL_UP: {
717-
Clay_Vector2 scrollDelta = { 0, 1 * Clay_Termbox_Cell_Height() };
722+
Clay_Vector2 scrollDelta = { 0.5 * Clay_Termbox_Cell_Width(), 0 };
718723
Clay_UpdateScrollContainers(false, scrollDelta, 1);
719724
break;
720725
}
721726
case TB_KEY_MOUSE_WHEEL_DOWN: {
722-
Clay_Vector2 scrollDelta = { 0, -1 * Clay_Termbox_Cell_Height() };
727+
Clay_Vector2 scrollDelta = { -0.5 * Clay_Termbox_Cell_Width(), 0 };
723728
Clay_UpdateScrollContainers(false, scrollDelta, 1);
724729
break;
725730
}

0 commit comments

Comments
 (0)