win32_app
This commit is contained in:
@@ -29,7 +29,7 @@ ui_signal_t ui_interact(app_event_t *ev, r2f64_t rect) {
|
||||
return sig;
|
||||
}
|
||||
|
||||
b32 ui_button(gfx2d_t *gfx, app_event_t *ev, r2f64_t rect, char *title) {
|
||||
b32 ui_button(gfx_t *gfx, app_event_t *ev, r2f64_t rect, char *title) {
|
||||
v2f64_t text_pos = ui_calc_text_pos(rect, title);
|
||||
ui_signal_t sig = ui_interact(ev, rect);
|
||||
|
||||
@@ -39,15 +39,15 @@ b32 ui_button(gfx2d_t *gfx, app_event_t *ev, r2f64_t rect, char *title) {
|
||||
rect_color = primary_color_global;
|
||||
}
|
||||
|
||||
gfx2d_set_clip(gfx, rect);
|
||||
gfx2d_rect(gfx, rect, rect_color);
|
||||
gfx2d_text(gfx, text_pos, text_color, s8_from_char(title));
|
||||
gfx2d_set_clip(gfx, r2f64(-1000, -1000, 1000000, 1000000));
|
||||
gfx_set_clip(gfx, rect);
|
||||
gfx_rect(gfx, rect, rect_color);
|
||||
gfx_text(gfx, text_pos, text_color, s8_from_char(title));
|
||||
gfx_set_clip(gfx, r2f64(-1000, -1000, 1000000, 1000000));
|
||||
|
||||
return sig.pressed;
|
||||
}
|
||||
|
||||
b32 ui_checkbox(gfx2d_t *gfx, app_event_t *ev, r2f64_t rect, b32 *value, char *title) {
|
||||
b32 ui_checkbox(gfx_t *gfx, app_event_t *ev, r2f64_t rect, b32 *value, char *title) {
|
||||
v2f64_t text_pos = ui_calc_text_pos(rect, title);
|
||||
ui_signal_t sig = ui_interact(ev, rect);
|
||||
if (sig.pressed) *value = !*value;
|
||||
@@ -61,10 +61,10 @@ b32 ui_checkbox(gfx2d_t *gfx, app_event_t *ev, r2f64_t rect, b32 *value, char *t
|
||||
rect_color = v4f32_lerp(rect_color, accent2_color_global, 0.5);
|
||||
}
|
||||
|
||||
gfx2d_set_clip(gfx, rect);
|
||||
gfx2d_rect(gfx, rect, rect_color);
|
||||
gfx2d_text(gfx, text_pos, text_color, s8_from_char(title));
|
||||
gfx2d_set_clip(gfx, r2f64(-1000, -1000, 1000000, 1000000));
|
||||
gfx_set_clip(gfx, rect);
|
||||
gfx_rect(gfx, rect, rect_color);
|
||||
gfx_text(gfx, text_pos, text_color, s8_from_char(title));
|
||||
gfx_set_clip(gfx, r2f64(-1000, -1000, 1000000, 1000000));
|
||||
|
||||
return *value;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ ui_id_t ui_string_to_id(const char *string, i32 len) { // FNV HASH (1a?)
|
||||
#define ui_location_id() ui_string_to_id(FILE_AND_LINE, sizeof(FILE_AND_LINE) - 1)
|
||||
ui_id_t ui_active_element = {0};
|
||||
|
||||
void ui_slider(gfx2d_t *gfx, app_event_t *ev, r2f64_t rect, ui_id_t id, f64 *value, char *title) {
|
||||
void ui_slider(gfx_t *gfx, app_event_t *ev, r2f64_t rect, ui_id_t id, f64 *value, char *title) {
|
||||
v2f64_t text_pos = ui_calc_text_pos(rect, title);
|
||||
ui_signal_t sig = ui_interact(ev, rect);
|
||||
b32 interacting = false;
|
||||
@@ -113,24 +113,24 @@ void ui_slider(gfx2d_t *gfx, app_event_t *ev, r2f64_t rect, ui_id_t id, f64 *val
|
||||
if (sig.overlapping) slider_color = v4f32_lerp(slider_color, accent2_color_global, 0.2);
|
||||
v4f32_t text_color = black_color_global;
|
||||
|
||||
gfx2d_set_clip(gfx, rect);
|
||||
gfx2d_rect(gfx, rect, rect_color);
|
||||
gfx2d_rect(gfx, slider_rect, slider_color);
|
||||
gfx2d_text(gfx, text_pos, text_color, s8_from_char(title));
|
||||
gfx2d_set_clip(gfx, r2f64(-1000, -1000, 1000000, 1000000));
|
||||
gfx_set_clip(gfx, rect);
|
||||
gfx_rect(gfx, rect, rect_color);
|
||||
gfx_rect(gfx, slider_rect, slider_color);
|
||||
gfx_text(gfx, text_pos, text_color, s8_from_char(title));
|
||||
gfx_set_clip(gfx, r2f64(-1000, -1000, 1000000, 1000000));
|
||||
}
|
||||
|
||||
void ui_demo(gfx2d_t *gfx, app_event_t *ev) {
|
||||
void ui_demo(gfx_t *gfx, app_event_t *ev) {
|
||||
if (ev->kind == app_event_kind_mouse_up) {
|
||||
ui_active_element = (ui_id_t){0};
|
||||
}
|
||||
|
||||
r2f64_t window_rect = (r2f64_t){(v2f64_t){0}, ev->window_size};
|
||||
r2f64_t top_bar_rect = r2f64_cut_top(&window_rect, get_font_height() + 20);
|
||||
gfx2d_rect(gfx, window_rect, primary_color_global);
|
||||
gfx_rect(gfx, window_rect, primary_color_global);
|
||||
|
||||
f64 padding = 50;
|
||||
gfx2d_rect(gfx, top_bar_rect, secondary_color_global);
|
||||
gfx_rect(gfx, top_bar_rect, secondary_color_global);
|
||||
|
||||
static b32 open_file_panel;
|
||||
f64 open_file_panel_xsize = 0;
|
||||
@@ -143,7 +143,7 @@ void ui_demo(gfx2d_t *gfx, app_event_t *ev) {
|
||||
if (ui_checkbox(gfx, ev, rect, &open_file_panel, title)) {
|
||||
}
|
||||
r2f64_t gap_rect = r2f64_cut_left(&top_bar_rect, 1);
|
||||
gfx2d_rect(gfx, gap_rect, black_color_global);
|
||||
gfx_rect(gfx, gap_rect, black_color_global);
|
||||
}
|
||||
|
||||
if (open_file_panel) {
|
||||
@@ -180,7 +180,7 @@ void ui_demo(gfx2d_t *gfx, app_event_t *ev) {
|
||||
if (ui_button(gfx, ev, rect, title)) {
|
||||
}
|
||||
r2f64_t gap_rect = r2f64_cut_left(&top_bar_rect, 1);
|
||||
gfx2d_rect(gfx, gap_rect, black_color_global);
|
||||
gfx_rect(gfx, gap_rect, black_color_global);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -189,7 +189,7 @@ void ui_demo(gfx2d_t *gfx, app_event_t *ev) {
|
||||
if (ui_button(gfx, ev, rect, title)) {
|
||||
}
|
||||
r2f64_t gap_rect = r2f64_cut_left(&top_bar_rect, 1);
|
||||
gfx2d_rect(gfx, gap_rect, black_color_global);
|
||||
gfx_rect(gfx, gap_rect, black_color_global);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user