temporary

This commit is contained in:
vurtun 2015-03-17 14:55:34 +01:00
parent 06aa6a2f34
commit 0633e10938
3 changed files with 12 additions and 5 deletions

10
gui.c
View File

@ -930,7 +930,7 @@ gui_slider_vertical(struct gui_draw_buffer *buffer,
cursor_w = (slider_w - 2 * slider->pad_x);
cursor_h = slider_h - 2 * slider->pad_y;
cursor_w = cursor_h / (((slider_max - slider_min) + slider->step) / slider->step);
cursor_y = slider->y + slider->h - slider->pad_x - (cursor_h * (slider_value - slider_min));
cursor_y = slider->y + slider->h - slider->pad_y - (cursor_h * (slider_value - slider_min));
cursor_x = slider->x + slider->pad_x;
mouse_x = in->mouse_pos.x;
@ -942,12 +942,12 @@ gui_slider_vertical(struct gui_draw_buffer *buffer,
INBOX(clicked_x, clicked_y, slider->x, slider->y, slider_w, slider_h) &&
INBOX(mouse_x, mouse_y, slider->x, slider->y, slider_w, slider_h))
{
const float d = mouse_x - (cursor_x + cursor_w / 2.0f);
const float pxstep = (slider_w - 2 * slider->pad_x) / slider_steps;
const float d = mouse_y - (cursor_y + cursor_h / 2.0f);
const float pxstep = (slider_h - 2 * slider->pad_y) / slider_steps;
if (ABS(d) >= pxstep) {
slider_value += (d < 0) ? -slider->step : slider->step;
slider_value = CLAMP(slider_min, slider_value, slider_max);
cursor_y = slider->y + slider->h - slider->pad_x;
cursor_y = slider->y + slider->h - slider->pad_y;
cursor_y -= (cursor_h * (slider_value - slider_min));
}
}
@ -1008,7 +1008,7 @@ gui_progress_vertical(struct gui_draw_buffer *buffer, const struct gui_progress
if (prog->modifyable && in->mouse_down &&
INBOX(in->mouse_pos.x, in->mouse_pos.y, prog->x, prog->y, prog_w, prog_h)){
gui_float ratio = (gui_float)(in->mouse_pos.y - prog->y) / (gui_float)prog_h;
gui_float ratio = (gui_float)(prog->y + prog->h - in->mouse_pos.y) / (gui_float)prog_h;
prog_value = (gui_size)((gui_float)prog->max * ratio);
}

BIN
mono.sdf Normal file

Binary file not shown.

View File

@ -69,7 +69,9 @@ struct GUI {
gui_size cmd_len;
gui_int typing;
gui_float slider;
gui_float vslider;
gui_size prog;
gui_size vprog;
gui_int spinner;
gui_int selected;
gui_int spinning;
@ -476,8 +478,10 @@ main(int argc, char *argv[])
/* GUI */
gui.win = &xw;
gui.prog = 60;
gui.vprog = 70;
gui.spinner = 100;
gui.slider = 5.0f;
gui.vslider = 2.0f;
gui.font = ldfont("mono.sdf", 16);
gui.memory.memory = xcalloc(MAX_BUFFER, 1);
gui.memory.clip_size = MAX_BUFFER / 16;
@ -518,6 +522,9 @@ main(int argc, char *argv[])
gui.submit = gui_panel_command(&gui.panel, gui.cmd_input, &gui.cmd_len, INPUT_MAX,
&gui.submitting);
gui.spinning = gui_panel_spinner(&gui.panel, 0, &gui.spinner, 250, 10, gui.spinning);
gui_panel_layout(&gui.panel, 100, 2);
gui.vslider = gui_panel_slider(&gui.panel, 0.0f, gui.vslider, 6.0f, 1.0f, GUI_VERTICAL);
gui.vprog = gui_panel_progress(&gui.panel, gui.vprog, 100, gui_true, GUI_VERTICAL);
gui_panel_layout(&gui.panel, 100, 1);
gui_panel_plot(&gui.panel, values, LEN(values));
gui_panel_histo(&gui.panel, values, LEN(values));