fix some escape-to-cancel & context menu behavior; notes

This commit is contained in:
Ryan Fleury
2024-06-24 16:14:06 -07:00
parent 15d42027e7
commit b4b8f5f0ab
3 changed files with 56 additions and 62 deletions
+11 -46
View File
@@ -10343,15 +10343,8 @@ df_entity_desc_button(DF_Window *ws, DF_Entity *entity, FuzzyMatchRangeList *nam
else if(ui_right_clicked(sig))
{
DF_Handle handle = df_handle_from_entity(entity);
if(ui_ctx_menu_is_open(ws->entity_ctx_menu_key) && df_handle_match(ws->entity_ctx_menu_entity, handle))
{
ui_ctx_menu_close();
}
else
{
ui_ctx_menu_open(ws->entity_ctx_menu_key, sig.box->key, v2f32(0, sig.box->rect.y1 - sig.box->rect.y0));
ws->entity_ctx_menu_entity = handle;
}
ui_ctx_menu_open(ws->entity_ctx_menu_key, sig.box->key, v2f32(0, sig.box->rect.y1 - sig.box->rect.y0));
ws->entity_ctx_menu_entity = handle;
}
// rjf: drag+drop
@@ -10837,15 +10830,8 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
if(ui_right_clicked(thread_sig))
{
DF_Handle handle = df_handle_from_entity(thread);
if(ui_ctx_menu_is_open(ws->entity_ctx_menu_key) && df_handle_match(ws->entity_ctx_menu_entity, handle))
{
ui_ctx_menu_close();
}
else
{
ui_ctx_menu_open(ws->entity_ctx_menu_key, thread_box->key, v2f32(0, thread_box->rect.y1-thread_box->rect.y0));
ws->entity_ctx_menu_entity = handle;
}
ui_ctx_menu_open(ws->entity_ctx_menu_key, thread_box->key, v2f32(0, thread_box->rect.y1-thread_box->rect.y0));
ws->entity_ctx_menu_entity = handle;
}
// rjf: drag start
@@ -11001,15 +10987,8 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
if(ui_right_clicked(thread_sig))
{
DF_Handle handle = df_handle_from_entity(thread);
if(ui_ctx_menu_is_open(ws->entity_ctx_menu_key) && df_handle_match(ws->entity_ctx_menu_entity, handle))
{
ui_ctx_menu_close();
}
else
{
ui_ctx_menu_open(ws->entity_ctx_menu_key, thread_box->key, v2f32(0, thread_box->rect.y1-thread_box->rect.y0));
ws->entity_ctx_menu_entity = handle;
}
ui_ctx_menu_open(ws->entity_ctx_menu_key, thread_box->key, v2f32(0, thread_box->rect.y1-thread_box->rect.y0));
ws->entity_ctx_menu_entity = handle;
}
// rjf: double click => select
@@ -11109,15 +11088,8 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
if(ui_right_clicked(bp_sig))
{
DF_Handle handle = df_handle_from_entity(bp);
if(ui_ctx_menu_is_open(ws->entity_ctx_menu_key) && df_handle_match(ws->entity_ctx_menu_entity, handle))
{
ui_ctx_menu_close();
}
else
{
ui_ctx_menu_open(ws->entity_ctx_menu_key, bp_box->key, v2f32(0, bp_box->rect.y1-bp_box->rect.y0));
ws->entity_ctx_menu_entity = handle;
}
ui_ctx_menu_open(ws->entity_ctx_menu_key, bp_box->key, v2f32(0, bp_box->rect.y1-bp_box->rect.y0));
ws->entity_ctx_menu_entity = handle;
}
}
@@ -11176,15 +11148,8 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
if(ui_right_clicked(pin_sig))
{
DF_Handle handle = df_handle_from_entity(pin);
if(ui_ctx_menu_is_open(ws->entity_ctx_menu_key) && df_handle_match(ws->entity_ctx_menu_entity, handle))
{
ui_ctx_menu_close();
}
else
{
ui_ctx_menu_open(ws->entity_ctx_menu_key, pin_box->key, v2f32(0, pin_box->rect.y1-pin_box->rect.y0));
ws->entity_ctx_menu_entity = handle;
}
ui_ctx_menu_open(ws->entity_ctx_menu_key, pin_box->key, v2f32(0, pin_box->rect.y1-pin_box->rect.y0));
ws->entity_ctx_menu_entity = handle;
}
}
}
@@ -11417,7 +11382,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
payload.entity = df_handle_from_entity(pin);
df_drag_begin(&payload);
}
if(ui_clicked(sig) || ui_right_clicked(sig))
if(ui_right_clicked(sig))
{
ui_ctx_menu_open(ws->entity_ctx_menu_key, sig.box->key, v2f32(0, sig.box->rect.y1-sig.box->rect.y0));
ws->entity_ctx_menu_entity = df_handle_from_entity(pin);
+15 -16
View File
@@ -125,12 +125,6 @@
// [ ] It'd be nice to have a "goto byte" option for source views, for jumping
// to error messages that are byte-based instead of line-based.
//
// [ ] I found the "context menu" convention to be confusing. For example, if
// I left-click on a tab, it selects the tab. If I right-click on a tab,
// it opens the context menu. However, if I left-click on a module, it
// opens the context window. It seems like maybe menus should be right,
// and left should do the default action, more consistently?
//
// [ ] It wasn't clear to me how you save a user or project file. I can see
// how to load them, but not how you save them. Obviously I can just copy
// the files myself in the shell, but it seemed weird that there was no
@@ -169,16 +163,6 @@
// that is "page up" / "page down", but here it is "smooth scroll upward"
// / "smooth scroll downward" for some reason?
//
// [ ] Hitting ESC during a color picker drag should abort the color picking
// and revert to the previous color. Currently, it just accepts the last
// drag result as the new color.
//
// [ ] It was not clear to me why a small "tab picker" appeared when I got to
// a certain number of tabs. It seemed to appear even if the tabs were
// quite large, and there was no need to a drop-down menu to pick them. It
// feels like either it should always be there, or it should only show up
// if at least one tab gets small enough to have its name cut off?
//
// [ ] can it ignore stepping into _RTC_CheckStackVars generated functions?
// [ ] mouse back button should make view to go back after I double clicked
// on function to open it
@@ -392,6 +376,21 @@
// [x] Many of the UI elements, like the menus, would like better if they had
// a little bit of margin. Having the text right next to the edges, and
// with no line spacing, makes it harder to read things quickly.
// [x] colors: memory view
// [x] Hitting ESC during a color picker drag should abort the color picking
// and revert to the previous color. Currently, it just accepts the last
// drag result as the new color.
// [x] It was not clear to me why a small "tab picker" appeared when I got to
// a certain number of tabs. It seemed to appear even if the tabs were
// quite large, and there was no need to a drop-down menu to pick them. It
// feels like either it should always be there, or it should only show up
// if at least one tab gets small enough to have its name cut off?
// [x] I found the "context menu" convention to be confusing. For example, if
// I left-click on a tab, it selects the tab. If I right-click on a tab,
// it opens the context menu. However, if I left-click on a module, it
// opens the context window. It seems like maybe menus should be right,
// and left should do the default action, more consistently?
//
#ifndef RADDBG_H
#define RADDBG_H
+30
View File
@@ -614,6 +614,18 @@ ui_sat_val_picker(F32 hue, F32 *out_sat, F32 *out_val, String8 string)
*out_sat = Clamp(0, *out_sat, 1);
*out_val = Clamp(0, *out_val, 1);
ui_do_color_tooltip_hsv(v3f32(hue, *out_sat, *out_val));
if(ui_pressed(sig))
{
Vec2F32 data = v2f32(*out_sat, *out_val);
ui_store_drag_struct(&data);
}
if(ui_slot_press(UI_EventActionSlot_Cancel))
{
Vec2F32 data = *ui_get_drag_struct(Vec2F32);
*out_sat = data.x;
*out_val = data.y;
ui_kill_action();
}
}
// rjf: fill draw data
@@ -709,6 +721,15 @@ ui_hue_picker(F32 *out_hue, F32 sat, F32 val, String8 string)
*out_hue = (ui_mouse().y - box->rect.y0) / dim.y;
*out_hue = Clamp(0, *out_hue, 1);
ui_do_color_tooltip_hsv(v3f32(*out_hue, sat, val));
if(ui_pressed(sig))
{
ui_store_drag_struct(out_hue);
}
if(ui_slot_press(UI_EventActionSlot_Cancel))
{
*out_hue = *ui_get_drag_struct(F32);
ui_kill_action();
}
}
// rjf: fill draw data
@@ -787,6 +808,15 @@ ui_alpha_picker(F32 *out_alpha, String8 string)
F32 drag_pct = (ui_mouse().y - box->rect.y0) / dim.y;
drag_pct = Clamp(0, drag_pct, 1);
*out_alpha = 1-drag_pct;
if(ui_pressed(sig))
{
ui_store_drag_struct(out_alpha);
}
if(ui_slot_press(UI_EventActionSlot_Cancel))
{
*out_alpha = *ui_get_drag_struct(F32);
ui_kill_action();
}
}
// rjf: fill draw data