Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ColleagueRiley committed Aug 27, 2024
1 parent 34a7193 commit 4553248
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 47 deletions.
6 changes: 2 additions & 4 deletions RSGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,7 @@ void RSGL_openContainer(const char* name, RSGL_rect* r, RSGL_color background, u
return;
}

RSGL_rectF rect = RSGL_RECTF(r->x, r->y - 30, r->w - (rect.w * 0.10), 30);
RSGL_rectF rect = RSGL_RECTF(r->x, r->y - 30, r->w - (r->w * 0.10), 30);

b8 oldGrab = *grabbed;
RSGL_grab(rect, args | RSGL_NO_SHAPE, grabbed);
Expand Down Expand Up @@ -2055,9 +2055,7 @@ b8 RSGL_checkbox(RSGL_rectF rect, RSGL_widgetStyle args, b8* checked) {
void RSGL_openSubContainer(RSGL_rectF rect, u32 args, b8* open) {
if (RSGL_widgetInfo.canDraw == 0)
return;

b8 state = RSGL_doToggleButton(rect, args, open);


RSGL_button(rect, args);

RSGL_scaleRect(&rect, args);
Expand Down
4 changes: 1 addition & 3 deletions examples/widgets/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ int main(void) {

RSGL_setFont(RSGL_loadFont("Super Easy.ttf"));

float slider_value = 0.0;
b8 slider_grabbed = 0,
checkbox = 0,
b8 checkbox = 0,
toggle = 0,
combo_open = 0;

Expand Down
6 changes: 2 additions & 4 deletions examples/widgets/styles.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,15 @@ int main(void) {

/* check all the buttons*/
u32 drawMode = (!darkToggle) ? RSGL_STYLE_DARK : RSGL_STYLE_LIGHT;
RSGL_toggleButton(RSGL_RECTF(20, 20, 50, 25), drawMode | RSGL_STYLE_ROUND, &darkToggle);
RSGL_toggleButton(RSGL_RECTF(20, 20, 50, 25), drawMode | RSGL_STYLE_ROUND, &darkToggle);

size_t startColor = log2(RSGL_STYLE_RED) - 1;

u32 i;
for (i = 0; i < 7; i++) {
/*
this sets the style to RSGL_STYLE_RED (the first color) + the current row
making it so it loops through each color
*/
u32 styleColor = (1 << startColor + i) | drawMode;
u32 styleColor = (1 << (startColor + i)) | drawMode;

RSGL_openBlankContainer(RSGL_RECT(0, 0, win->r.w, win->r.h));

Expand Down
53 changes: 17 additions & 36 deletions examples/widgets/textbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,30 @@


int main(void) {
RSGL_window* win = RSGL_createWindow("name", (RSGL_rect){500, 500, 500, 500}, RSGL_CENTER);
RGFW_window* win = RGFW_createWindow("name", (RSGL_rect){500, 500, 500, 500}, RGFW_CENTER);

RSGL_setFont(RSGL_loadFont("COMICSANS.ttf"));
RSGL_textbox* tb = RSGL_initTextbox(0);
RSGL_textbox_setTextInfo(tb, RSGL_CIRCLE(0, 0, 20), RSGL_RGB(100, 100, 100));

RSGL_textbox_setRect(tb, RSGL_RECT(20, 20, 200, 30));
RSGL_textbox_setStyle(tb, RSGL_STYLE_DARK);
RSGL_textbox_alignText(tb, RSGL_ALIGN_CENTER | RSGL_ALIGN_MIDDLE);
// RSGL_textbox_setTextInfo(tb, RSGL_CIRCLE(0, 0, 20), RSGL_RGB(100, 100, 100));
// RSGL_textbox_setRect(tb, RSGL_RECT(20, 20, 200, 30));

RSGL_textbox* tb2 = RSGL_initTextbox(0);
RSGL_textbox_setTextInfo(tb2, RSGL_CIRCLE(0, 0, 20), RSGL_RGB(100, 100, 100));
// RSGL_textbox_setTextInfo(tb2, RSGL_CIRCLE(0, 0, 20), RSGL_RGB(100, 100, 100));
// RSGL_textbox_setRect(tb2, RSGL_RECT(20, 100, 300, 300));

RSGL_textbox_setRect(tb2, RSGL_RECT(20, 100, 300, 300));
RSGL_textbox_setStyle(tb2, RSGL_STYLE_DARK);
RSGL_textbox_alignText(tb2, RSGL_ALIGN_LEFT | RSGL_ALIGN_UP);

RSGL_textbox_setWindow(tb2, win);

bool running = true;
bool running = true;
while (running) {
while (RSGL_window_checkEvent(win)) {
while (RSGL_checkEvent(win)) {
if (win->event.type == RGFW_quit) {
running = false;
break;
}

RSGL_textbox_update(tb2, win->event);


if (win->event.type == RGFW_keyPressed && !(RSGL_between(win->event.keyCode, '0', '9') || win->event.keyCode == RGFW_BackSpace))
continue;

RSGL_textbox_update(tb, win->event);
}

RSGL_textbox_draw(tb);
RSGL_textbox_draw(tb2);

RSGL_window_clear(win, RSGL_RGB(20, 20, 60));
}

RSGL_textbox_free(tb);
RSGL_textbox_free(tb2);

RSGL_window_close(win);
}
}

RSGL_clear(RSGL_RGB(20, 20, 60));
RGFW_window_swapBuffers(win);
}

RSGL_free();
RGFW_window_close(win);
}

0 comments on commit 4553248

Please sign in to comment.