Skip to content

Commit e9492b7

Browse files
committed
Remove UI elements
1 parent a2d7282 commit e9492b7

File tree

2 files changed

+0
-146
lines changed

2 files changed

+0
-146
lines changed

src/xyz_gui.c

-134
Original file line numberDiff line numberDiff line change
@@ -1306,15 +1306,6 @@ void gui_loop(void) {
13061306
// draw_line3d(line_data, line_size, line_color, line_lw);
13071307
// draw_image(10, 10, image_data, width, height, channels);
13081308

1309-
// ui_menu(&menu_bounds);
1310-
// if (ui_button("Button", button_bounds) == 1) {
1311-
// printf("Button pressed!\n");
1312-
// }
1313-
//
1314-
// if (ui_checkbox("Checkbox", checkbox_bounds) == 1) {
1315-
// printf("Button pressed!\n");
1316-
// }
1317-
13181309
// Update
13191310
if ((time_now - last_frame) >= fps_limit) {
13201311
glfwSwapBuffers(_window);
@@ -2920,128 +2911,3 @@ void gl_model_draw(const gl_model_t *model, const gl_camera_t *camera) {
29202911
gl_mesh_draw(&model->meshes[i], model->program_id);
29212912
}
29222913
}
2923-
2924-
// UI-UTILS //////////////////////////////////////////////////////////////////
2925-
2926-
static int ui_intercept(const gl_bounds_t bounds) {
2927-
const int x = bounds.x;
2928-
const int y = bounds.y;
2929-
const int w = bounds.w;
2930-
const int h = bounds.h;
2931-
const int within_x = (x <= _cursor_x && _cursor_x <= x + w);
2932-
const int within_y = (y <= _cursor_y && _cursor_y <= y + h);
2933-
return (within_x && within_y) ? 1 : 0;
2934-
}
2935-
2936-
void ui_menu(gl_bounds_t *bounds) {
2937-
// Menu
2938-
gl_color_t color = (gl_color_t){1.0f, 1.0f, 1.0f};
2939-
2940-
// Toolbar
2941-
gl_color_t toolbar_color = (gl_color_t){0.7f, 0.7f, 0.7f};
2942-
gl_bounds_t toolbar_bounds;
2943-
toolbar_bounds.x = bounds->x;
2944-
toolbar_bounds.y = bounds->y;
2945-
toolbar_bounds.w = bounds->w;
2946-
toolbar_bounds.h = 16.0f;
2947-
2948-
if (ui_intercept(toolbar_bounds) && _cursor_is_dragging) {
2949-
bounds->x += _cursor_dx;
2950-
bounds->y += _cursor_dy;
2951-
toolbar_bounds.x += _cursor_dx;
2952-
toolbar_bounds.y += _cursor_dy;
2953-
_ui_engaged = 1;
2954-
}
2955-
2956-
draw_rect(bounds, &color);
2957-
draw_rect(&toolbar_bounds, &toolbar_color);
2958-
}
2959-
2960-
int ui_button(const char *label, gl_bounds_t bounds) {
2961-
gl_color_t text_color = (gl_color_t){0.0f, 0.0f, 0.0f};
2962-
gl_color_t color = (gl_color_t){1.0f, 1.0f, 1.0f};
2963-
gl_color_t color_press = (gl_color_t){0.0f, 0.0f, 1.0f};
2964-
2965-
gl_float_t text_w = 0.0f;
2966-
gl_float_t text_h = 0.0f;
2967-
text_width_height(label, &text_w, &text_h);
2968-
gl_float_t text_x = bounds.x + (bounds.w / 2.0f - text_w / 2.0f);
2969-
gl_float_t text_y = bounds.y + (bounds.h / 2.0f - text_h / 2.0f);
2970-
2971-
// Button color
2972-
int button_on = 0;
2973-
if (ui_intercept(bounds) && _mouse_button_left == GLFW_PRESS) {
2974-
color = color_press;
2975-
if (_ui_engaged == 0) {
2976-
_ui_engaged = 1;
2977-
button_on = 1;
2978-
}
2979-
}
2980-
2981-
// Draw button
2982-
draw_rect(&bounds, &color);
2983-
draw_text(label, text_x, text_y, text_color);
2984-
2985-
return button_on;
2986-
}
2987-
2988-
int ui_checkbox(const char *label, gl_bounds_t bounds) {
2989-
gl_color_t text_color = (gl_color_t){0.0f, 0.0f, 0.0f};
2990-
gl_color_t color = (gl_color_t){1.0f, 1.0f, 1.0f};
2991-
// gl_color_t color_hover = (gl_color_t){1.0f, 0.0f, 0.0f};
2992-
// gl_color_t color_press = (gl_color_t){0.0f, 0.0f, 1.0f};
2993-
2994-
gl_float_t text_w = 0.0f;
2995-
gl_float_t text_h = 0.0f;
2996-
text_width_height(label, &text_w, &text_h);
2997-
gl_float_t text_x = bounds.x + (bounds.w / 2.0f - text_w / 2.0f);
2998-
gl_float_t text_y = bounds.y + (bounds.h / 2.0f - text_h / 2.0f);
2999-
3000-
// Button color
3001-
int button_on = 0;
3002-
// const int button_hover = ui_intercept(bounds);
3003-
3004-
gl_bounds_t cb_bounds;
3005-
cb_bounds.w = 12.0f;
3006-
cb_bounds.h = 12.0f;
3007-
cb_bounds.x = bounds.x + 10.0f;
3008-
cb_bounds.y = bounds.y + bounds.h / 2.0f - cb_bounds.h / 2.0f;
3009-
3010-
gl_bounds_t on_bounds;
3011-
on_bounds.w = 8.0f;
3012-
on_bounds.h = 8.0f;
3013-
on_bounds.x = bounds.x + 12.0f;
3014-
on_bounds.y = bounds.y + bounds.h / 2.0f - on_bounds.h / 2.0f;
3015-
3016-
gl_color_t off_color = (gl_color_t){0.2f, 0.2f, 0.2f};
3017-
gl_color_t on_color = (gl_color_t){1.0f, 1.0f, 1.0f};
3018-
3019-
// Checkbox color
3020-
// int button_on = 0;
3021-
// if (ui_intercept(on_bounds) && _mouse_button_left == GLFW_PRESS) {
3022-
// color = on_color;
3023-
// if (_ui_engaged == 0) {
3024-
// _ui_engaged = 1;
3025-
// button_on = 1;
3026-
// }
3027-
// }
3028-
3029-
// if (button_hover == 1 && button_pressed == 0) {
3030-
// color = color_hover;
3031-
// _ui_engaged = 0;
3032-
// } else if (button_hover == 1 && button_pressed == 1) {
3033-
// color = color_press;
3034-
// if (_ui_engaged == 0) {
3035-
// button_on = 1;
3036-
// _ui_engaged = 1;
3037-
// }
3038-
// }
3039-
3040-
// Draw button
3041-
draw_rect(&bounds, &color);
3042-
draw_rect(&cb_bounds, &off_color);
3043-
draw_rect(&on_bounds, &on_color);
3044-
draw_text(label, text_x, text_y, text_color);
3045-
3046-
return button_on;
3047-
}

src/xyz_gui.h

-12
Original file line numberDiff line numberDiff line change
@@ -450,15 +450,3 @@ typedef struct gl_model_t {
450450
gl_model_t *gl_model_load(const char *model_path);
451451
void gl_model_free(gl_model_t *model);
452452
void gl_model_draw(const gl_model_t *model, const gl_camera_t *camera);
453-
454-
// UI ////////////////////////////////////////////////////////////////////////
455-
456-
void ui_menu(gl_bounds_t *bounds);
457-
int ui_button(const char *label, gl_bounds_t bounds);
458-
int ui_checkbox(const char *label, gl_bounds_t bounds);
459-
460-
// TODO: IMPLEMENT THE FOLLOWING UI ELEMENTS
461-
// UI-CHECKBOX ///////////////////////////////////////////////////////////////
462-
// UI-SLIDER ////////////////////////////////////////////////////////////////
463-
// UI-DROPDOWN ///////////////////////////////////////////////////////////////
464-
// UI-TEXTBOX ////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)