mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-06 22:08:41 +00:00
ui: further improvements to double/triple dragging detection; df: use double/triple dragging to determine mouse-drag-range. dbl -> use token range, triple -> use line. pick appropriate side of mouse drag range on drag based on side of mark.
This commit is contained in:
@@ -387,6 +387,14 @@ txt_rng_union(TxtRng a, TxtRng b)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal B32
|
||||||
|
txt_rng_contains(TxtRng r, TxtPt pt)
|
||||||
|
{
|
||||||
|
B32 result = ((txt_pt_less_than(r.min, pt) || txt_pt_match(r.min, pt)) &&
|
||||||
|
txt_pt_less_than(pt, r.max));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Toolchain/Environment Enum Functions
|
//~ rjf: Toolchain/Environment Enum Functions
|
||||||
|
|
||||||
|
|||||||
@@ -738,6 +738,7 @@ internal TxtPt txt_pt_max(TxtPt a, TxtPt b);
|
|||||||
internal TxtRng txt_rng(TxtPt min, TxtPt max);
|
internal TxtRng txt_rng(TxtPt min, TxtPt max);
|
||||||
internal TxtRng txt_rng_intersect(TxtRng a, TxtRng b);
|
internal TxtRng txt_rng_intersect(TxtRng a, TxtRng b);
|
||||||
internal TxtRng txt_rng_union(TxtRng a, TxtRng b);
|
internal TxtRng txt_rng_union(TxtRng a, TxtRng b);
|
||||||
|
internal B32 txt_rng_contains(TxtRng r, TxtPt pt);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Toolchain/Environment Enum Functions
|
//~ rjf: Toolchain/Environment Enum Functions
|
||||||
|
|||||||
+43
-2
@@ -9963,6 +9963,28 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
|
|||||||
result.mouse_pt = mouse_pt;
|
result.mouse_pt = mouse_pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
//- rjf: mouse point -> mouse token range, mouse line range
|
||||||
|
//
|
||||||
|
TxtRng mouse_token_rng = txt_rng(mouse_pt, mouse_pt);
|
||||||
|
TxtRng mouse_line_rng = txt_rng(mouse_pt, mouse_pt);
|
||||||
|
if(contains_1s64(params->line_num_range, mouse_pt.line))
|
||||||
|
{
|
||||||
|
TXT_TokenArray *line_tokens = ¶ms->line_tokens[mouse_pt.line-params->line_num_range.min];
|
||||||
|
Rng1U64 line_range = params->line_ranges[mouse_pt.line-params->line_num_range.min];
|
||||||
|
U64 mouse_pt_off = (mouse_pt.column-1) + line_range.min;
|
||||||
|
for(U64 line_token_idx = 0; line_token_idx < line_tokens->count; line_token_idx += 1)
|
||||||
|
{
|
||||||
|
TXT_Token *line_token = &line_tokens->v[line_token_idx];
|
||||||
|
if(contains_1u64(line_token->range, mouse_pt_off))
|
||||||
|
{
|
||||||
|
mouse_token_rng = txt_rng(txt_pt(mouse_pt.line, 1+line_token->range.min-line_range.min), txt_pt(mouse_pt.line, 1+line_token->range.max-line_range.min));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mouse_line_rng = txt_rng(txt_pt(mouse_pt.line, 1), txt_pt(mouse_pt.line, 1+line_range.max));
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- rjf: interact with margin box & text box
|
//- rjf: interact with margin box & text box
|
||||||
//
|
//
|
||||||
@@ -9970,6 +9992,17 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
|
|||||||
UI_Signal text_container_sig = ui_signal_from_box(text_container_box);
|
UI_Signal text_container_sig = ui_signal_from_box(text_container_box);
|
||||||
DF_Entity *line_drag_entity = &df_g_nil_entity;
|
DF_Entity *line_drag_entity = &df_g_nil_entity;
|
||||||
{
|
{
|
||||||
|
//- rjf: determine mouse drag range
|
||||||
|
TxtRng mouse_drag_rng = txt_rng(mouse_pt, mouse_pt);
|
||||||
|
if(text_container_sig.f & UI_SignalFlag_LeftTripleDragging)
|
||||||
|
{
|
||||||
|
mouse_drag_rng = mouse_line_rng;
|
||||||
|
}
|
||||||
|
else if(text_container_sig.f & UI_SignalFlag_LeftDoubleDragging)
|
||||||
|
{
|
||||||
|
mouse_drag_rng = mouse_token_rng;
|
||||||
|
}
|
||||||
|
|
||||||
//- rjf: clicking/dragging over the text container
|
//- rjf: clicking/dragging over the text container
|
||||||
if(!ctrlified && ui_dragging(text_container_sig))
|
if(!ctrlified && ui_dragging(text_container_sig))
|
||||||
{
|
{
|
||||||
@@ -9987,9 +10020,17 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
|
|||||||
}
|
}
|
||||||
if(ui_pressed(text_container_sig))
|
if(ui_pressed(text_container_sig))
|
||||||
{
|
{
|
||||||
*mark = mouse_pt;
|
*cursor = mouse_drag_rng.max;
|
||||||
|
*mark = mouse_drag_rng.min;
|
||||||
|
}
|
||||||
|
if(txt_pt_less_than(mouse_pt, *mark))
|
||||||
|
{
|
||||||
|
*cursor = mouse_drag_rng.min;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*cursor = mouse_drag_rng.max;
|
||||||
}
|
}
|
||||||
*cursor = mouse_pt;
|
|
||||||
*preferred_column = cursor->column;
|
*preferred_column = cursor->column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-2
@@ -2464,8 +2464,11 @@ ui_signal_from_box(UI_Box *box)
|
|||||||
sizeof(ui_state->press_timestamp_history_us[evt_mouse_button_kind][0]) * ArrayCount(ui_state->press_timestamp_history_us[evt_mouse_button_kind])-1);
|
sizeof(ui_state->press_timestamp_history_us[evt_mouse_button_kind][0]) * ArrayCount(ui_state->press_timestamp_history_us[evt_mouse_button_kind])-1);
|
||||||
MemoryCopy(&ui_state->press_key_history[evt_mouse_button_kind][1], &ui_state->press_key_history[evt_mouse_button_kind][0],
|
MemoryCopy(&ui_state->press_key_history[evt_mouse_button_kind][1], &ui_state->press_key_history[evt_mouse_button_kind][0],
|
||||||
sizeof(ui_state->press_key_history[evt_mouse_button_kind][0]) * ArrayCount(ui_state->press_key_history[evt_mouse_button_kind])-1);
|
sizeof(ui_state->press_key_history[evt_mouse_button_kind][0]) * ArrayCount(ui_state->press_key_history[evt_mouse_button_kind])-1);
|
||||||
|
MemoryCopy(&ui_state->press_pos_history[evt_mouse_button_kind][1], &ui_state->press_pos_history[evt_mouse_button_kind][0],
|
||||||
|
sizeof(ui_state->press_pos_history[evt_mouse_button_kind][0]) * ArrayCount(ui_state->press_pos_history[evt_mouse_button_kind])-1);
|
||||||
ui_state->press_timestamp_history_us[evt_mouse_button_kind][0] = evt->timestamp_us;
|
ui_state->press_timestamp_history_us[evt_mouse_button_kind][0] = evt->timestamp_us;
|
||||||
ui_state->press_key_history[evt_mouse_button_kind][0] = box->key;
|
ui_state->press_key_history[evt_mouse_button_kind][0] = box->key;
|
||||||
|
ui_state->press_pos_history[evt_mouse_button_kind][0] = evt_mouse;
|
||||||
taken = 1;
|
taken = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2652,7 +2655,8 @@ ui_signal_from_box(UI_Box *box)
|
|||||||
if(sig.f & (UI_SignalFlag_LeftDragging<<k) &&
|
if(sig.f & (UI_SignalFlag_LeftDragging<<k) &&
|
||||||
ui_key_match(ui_state->press_key_history[k][0], box->key) &&
|
ui_key_match(ui_state->press_key_history[k][0], box->key) &&
|
||||||
ui_key_match(ui_state->press_key_history[k][1], box->key) &&
|
ui_key_match(ui_state->press_key_history[k][1], box->key) &&
|
||||||
ui_state->press_timestamp_history_us[k][0] - ui_state->press_timestamp_history_us[k][1] <= 1000000*os_double_click_time())
|
ui_state->press_timestamp_history_us[k][0] - ui_state->press_timestamp_history_us[k][1] <= 1000000*os_double_click_time() &&
|
||||||
|
length_2f32(sub_2f32(ui_state->press_pos_history[k][0], ui_state->press_pos_history[k][1])) < 10.f)
|
||||||
{
|
{
|
||||||
sig.f |= (UI_SignalFlag_LeftDoubleDragging<<k);
|
sig.f |= (UI_SignalFlag_LeftDoubleDragging<<k);
|
||||||
}
|
}
|
||||||
@@ -2671,7 +2675,9 @@ ui_signal_from_box(UI_Box *box)
|
|||||||
ui_key_match(ui_state->press_key_history[k][1], box->key) &&
|
ui_key_match(ui_state->press_key_history[k][1], box->key) &&
|
||||||
ui_key_match(ui_state->press_key_history[k][2], box->key) &&
|
ui_key_match(ui_state->press_key_history[k][2], box->key) &&
|
||||||
ui_state->press_timestamp_history_us[k][0] - ui_state->press_timestamp_history_us[k][1] <= 1000000*os_double_click_time() &&
|
ui_state->press_timestamp_history_us[k][0] - ui_state->press_timestamp_history_us[k][1] <= 1000000*os_double_click_time() &&
|
||||||
ui_state->press_timestamp_history_us[k][1] - ui_state->press_timestamp_history_us[k][2] <= 1000000*os_double_click_time())
|
ui_state->press_timestamp_history_us[k][1] - ui_state->press_timestamp_history_us[k][2] <= 1000000*os_double_click_time() &&
|
||||||
|
length_2f32(sub_2f32(ui_state->press_pos_history[k][0], ui_state->press_pos_history[k][1])) < 10.f &&
|
||||||
|
length_2f32(sub_2f32(ui_state->press_pos_history[k][1], ui_state->press_pos_history[k][2])) < 10.f)
|
||||||
{
|
{
|
||||||
sig.f |= (UI_SignalFlag_LeftTripleDragging<<k);
|
sig.f |= (UI_SignalFlag_LeftTripleDragging<<k);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -496,6 +496,7 @@ struct UI_State
|
|||||||
UI_Key clipboard_copy_key;
|
UI_Key clipboard_copy_key;
|
||||||
U64 press_timestamp_history_us[UI_MouseButtonKind_COUNT][3];
|
U64 press_timestamp_history_us[UI_MouseButtonKind_COUNT][3];
|
||||||
UI_Key press_key_history[UI_MouseButtonKind_COUNT][3];
|
UI_Key press_key_history[UI_MouseButtonKind_COUNT][3];
|
||||||
|
Vec2F32 press_pos_history[UI_MouseButtonKind_COUNT][3];
|
||||||
Vec2F32 drag_start_mouse;
|
Vec2F32 drag_start_mouse;
|
||||||
Arena *drag_state_arena;
|
Arena *drag_state_arena;
|
||||||
String8 drag_state_data;
|
String8 drag_state_data;
|
||||||
|
|||||||
Reference in New Issue
Block a user