checkpoint on new universal drag/drop stuff

This commit is contained in:
Ryan Fleury
2024-09-17 11:26:13 -07:00
parent ca9ee9a658
commit a368d04e3b
2 changed files with 50 additions and 43 deletions
+4 -4
View File
@@ -5948,7 +5948,7 @@ rd_window_frame(RD_Window *ws)
//
{
RD_View *drag_view = rd_view_from_handle(rd_state->drag_drop_regs->view);
if(rd_drag_is_active() && !rd_view_is_nil(drag_view))
if(rd_drag_is_active() && rd_state->drag_drop_regs_slot == RD_RegSlot_View && !rd_view_is_nil(drag_view))
{
//- rjf: params
F32 drop_site_major_dim_px = ceil_f32(ui_top_font_size()*7.f);
@@ -6288,7 +6288,7 @@ rd_window_frame(RD_Window *ws)
//
{
RD_View *view = rd_view_from_handle(rd_state->drag_drop_regs->view);
if(rd_drag_is_active() && !rd_view_is_nil(view) && contains_2f32(panel_rect, ui_mouse()))
if(rd_drag_is_active() && rd_state->drag_drop_regs_slot == RD_RegSlot_View && !rd_view_is_nil(view) && contains_2f32(panel_rect, ui_mouse()))
{
F32 drop_site_dim_px = ceil_f32(ui_top_font_size()*7.f);
Vec2F32 drop_site_half_dim = v2f32(drop_site_dim_px/2, drop_site_dim_px/2);
@@ -6707,7 +6707,7 @@ rd_window_frame(RD_Window *ws)
// rjf: if before this tab is the prev-view of the current tab drag,
// draw empty space
if(rd_drag_is_active() && catchall_drop_site_hovered)
if(rd_drag_is_active() && rd_state->drag_drop_regs_slot == RD_RegSlot_View && catchall_drop_site_hovered)
{
RD_Panel *dst_panel = rd_panel_from_handle(rd_last_drag_drop_panel);
RD_View *drag_view = rd_view_from_handle(rd_state->drag_drop_regs->view);
@@ -6901,7 +6901,7 @@ rd_window_frame(RD_Window *ws)
{
Vec2F32 mouse = ui_mouse();
RD_View *view = rd_view_from_handle(rd_state->drag_drop_regs->view);
if(rd_drag_is_active() && window_is_focused && contains_2f32(panel_rect, mouse) && !rd_view_is_nil(view))
if(rd_drag_is_active() && rd_state->drag_drop_regs_slot == RD_RegSlot_View && window_is_focused && contains_2f32(panel_rect, mouse) && !rd_view_is_nil(view))
{
// rjf: mouse => hovered drop site
F32 min_distance = 0;
+46 -39
View File
@@ -1745,7 +1745,10 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
UI_Signal priority_margin_container_sig = ui_signal_from_box(priority_margin_container_box);
UI_Signal catchall_margin_container_sig = ui_signal_from_box(catchall_margin_container_box);
UI_Signal text_container_sig = ui_signal_from_box(text_container_box);
B32 line_drag_drop = 0;
RD_Entity *line_drag_entity = &d_nil_entity;
CTRL_Entity *line_drag_ctrl_entity = &ctrl_entity_nil;
Vec4F32 line_drag_drop_color = rd_rgba_from_theme_color(RD_ThemeColor_DropSiteOverlay);
{
//- rjf: determine mouse drag range
TxtRng mouse_drag_rng = txt_rng(mouse_pt, mouse_pt);
@@ -1817,12 +1820,26 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
// drop target
if(rd_drag_is_active() && contains_2f32(clipped_top_container_rect, ui_mouse()))
{
CTRL_Entity *thread = ctrl_entity_from_handle(d_state->ctrl_entity_store, rd_state->drag_drop_regs->thread);
RD_Entity *entity = rd_entity_from_handle(rd_state->drag_drop_regs->entity);
if(entity->kind == RD_EntityKind_Thread ||
entity->kind == RD_EntityKind_WatchPin ||
entity->kind == RD_EntityKind_Breakpoint)
if(rd_state->drag_drop_regs_slot == RD_RegSlot_Entity &&
(entity->kind == RD_EntityKind_WatchPin ||
entity->kind == RD_EntityKind_Breakpoint))
{
line_drag_drop = 1;
line_drag_entity = entity;
if(entity->flags & RD_EntityFlag_HasColor)
{
line_drag_drop_color = rd_rgba_from_entity(entity);
line_drag_drop_color.w *= 0.5f;
}
}
if(rd_state->drag_drop_regs_slot == RD_RegSlot_Thread)
{
line_drag_drop = 1;
line_drag_ctrl_entity = thread;
line_drag_drop_color = rd_rgba_from_ctrl_entity(thread);
line_drag_drop_color.w *= 0.5f;
}
}
@@ -1834,39 +1851,34 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
S64 line_num = mouse_pt.line;
U64 line_idx = line_num - params->line_num_range.min;
U64 line_vaddr = params->line_vaddrs[line_idx];
switch(dropped_entity->kind)
rd_cmd(RD_CmdKind_RelocateEntity,
.entity = rd_handle_from_entity(dropped_entity),
.file_path = rd_regs()->file_path,
.cursor = txt_pt(line_num, 1),
.vaddr = line_vaddr);
}
if(line_drag_ctrl_entity != &ctrl_entity_nil && rd_drag_drop() && contains_1s64(params->line_num_range, mouse_pt.line))
{
S64 line_num = mouse_pt.line;
U64 line_idx = line_num - params->line_num_range.min;
U64 line_vaddr = params->line_vaddrs[line_idx];
CTRL_Entity *thread = line_drag_ctrl_entity;
U64 new_rip_vaddr = line_vaddr;
if(rd_regs()->file_path.size != 0)
{
default:{}break;
case RD_EntityKind_Breakpoint:
case RD_EntityKind_WatchPin:
D_LineList *lines = &params->line_infos[line_idx];
for(D_LineNode *n = lines->first; n != 0; n = n->next)
{
rd_cmd(RD_CmdKind_RelocateEntity,
.entity = rd_handle_from_entity(dropped_entity),
.file_path = rd_regs()->file_path,
.cursor = txt_pt(line_num, 1),
.vaddr = line_vaddr);
}break;
case RD_EntityKind_Thread:
{
CTRL_Entity *thread = ctrl_entity_from_handle(d_state->ctrl_entity_store, dropped_entity->ctrl_handle);
U64 new_rip_vaddr = line_vaddr;
if(rd_regs()->file_path.size != 0)
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, d_state->ctrl_entity_store, &n->v.dbgi_key);
CTRL_Entity *module = ctrl_module_from_thread_candidates(d_state->ctrl_entity_store, thread, &modules);
if(module != &ctrl_entity_nil)
{
D_LineList *lines = &params->line_infos[line_idx];
for(D_LineNode *n = lines->first; n != 0; n = n->next)
{
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, d_state->ctrl_entity_store, &n->v.dbgi_key);
CTRL_Entity *module = ctrl_module_from_thread_candidates(d_state->ctrl_entity_store, thread, &modules);
if(module != &ctrl_entity_nil)
{
new_rip_vaddr = ctrl_vaddr_from_voff(module, n->v.voff_range.min);
break;
}
}
new_rip_vaddr = ctrl_vaddr_from_voff(module, n->v.voff_range.min);
break;
}
rd_cmd(RD_CmdKind_SetThreadIP, .thread = thread->handle, .vaddr = new_rip_vaddr);
}break;
}
}
rd_cmd(RD_CmdKind_SetThreadIP, .thread = thread->handle, .vaddr = new_rip_vaddr);
}
}
@@ -1955,19 +1967,14 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
}
//////////////////////////////
//- rjf: dragging entity which applies to lines over this slice -> visualize
//- rjf: dragging/dropping which applies to lines over this slice -> visualize
//
if(!rd_entity_is_nil(line_drag_entity) && contains_2f32(clipped_top_container_rect, ui_mouse()))
if(line_drag_drop && contains_2f32(clipped_top_container_rect, ui_mouse()))
{
Vec4F32 color = rd_rgba_from_theme_color(RD_ThemeColor_DropSiteOverlay);
if(line_drag_entity->flags & RD_EntityFlag_HasColor)
{
color = rd_rgba_from_entity(line_drag_entity);
color.w /= 2;
}
DR_Bucket *bucket = dr_bucket_make();
D_BucketScope(bucket)
{
Vec4F32 color = line_drag_drop_color;
Rng2F32 drop_line_rect = r2f32p(top_container_box->rect.x0,
top_container_box->rect.y0 + (mouse_pt.line - params->line_num_range.min) * params->line_height_px,
top_container_box->rect.x1,