Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always show header of topmost module #18323

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data/themes/darktable.css
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ dialog .sidebar row:selected:hover label,
#module-header
{
border-bottom: 1px solid @plugin_bg_color;
background-color: @bg_color;
padding: 0.5em;
}

Expand Down
3 changes: 2 additions & 1 deletion src/develop/imageop.c
Original file line number Diff line number Diff line change
Expand Up @@ -2503,9 +2503,10 @@ void dt_iop_gui_set_expanded(dt_iop_module_t *module,
while(iop)
{
dt_iop_module_t *m = iop->data;
if(m != module && (dt_iop_shown_in_group(m, current_group) || !group_only))
if(m != module && m->expander && (dt_iop_shown_in_group(m, current_group) || !group_only))
{
all_other_closed = all_other_closed && !m->expanded;
gtk_widget_set_margin_top(DTGTK_EXPANDER(m->expander)->header_evb, 0); // don't scroll to module if at top
_gui_set_single_expanded(m, FALSE);
}

Expand Down
38 changes: 36 additions & 2 deletions src/dtgtk/expander.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ GtkWidget *dtgtk_expander_get_body_event_box(GtkDarktableExpander *expander)
static GtkWidget *_scroll_widget = NULL;
static GtkWidget *_last_expanded = NULL;
static GtkWidget *_drop_widget = NULL;
static GtkWidget *_collapsing_top = NULL;
static GtkAllocation _start_pos = {0};

void dtgtk_expander_set_expanded(GtkDarktableExpander *expander, gboolean expanded)
Expand All @@ -90,6 +91,11 @@ void dtgtk_expander_set_expanded(GtkDarktableExpander *expander, gboolean expand
_start_pos.x = gtk_adjustment_get_value(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(sw)));
}
}
else
{
if(gtk_widget_get_margin_top(expander->header_evb) > 0)
_collapsing_top = GTK_WIDGET(expander);
}

GtkWidget *frame = expander->body;
if(frame)
Expand Down Expand Up @@ -169,14 +175,18 @@ static gboolean _expander_scroll(GtkWidget *widget, GdkFrameClock *frame_clock,

static void _expander_resize(GtkWidget *widget, GdkRectangle *allocation, gpointer user_data)
{
GtkDarktableExpander *expander = DTGTK_EXPANDER(widget);
gtk_widget_set_margin_top(expander->frame, gtk_widget_get_allocated_height(expander->header));

if(widget == _scroll_widget ||
_drop_widget ? widget != _drop_widget :
_collapsing_top ? widget != _collapsing_top :
((!(gtk_widget_get_state_flags(user_data) & GTK_STATE_FLAG_SELECTED) ||
gtk_widget_get_allocated_height(widget) == _start_pos.height) &&
(!darktable.lib->gui_module || darktable.lib->gui_module->expander != widget)))
return;

_collapsing_top = NULL;
_scroll_widget = widget;
GdkFrameClock *clock = gtk_widget_get_frame_clock(widget);
if(clock)
Expand Down Expand Up @@ -258,6 +268,25 @@ static void dtgtk_expander_init(GtkDarktableExpander *expander)
{
}

static gboolean _adjust_header_position(GtkWidget *widget, cairo_t *cr, GtkWidget *header)
{
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
if(allocation.height <= 1) return FALSE;

GtkWidget *sw = gtk_widget_get_ancestor(widget, GTK_TYPE_SCROLLED_WINDOW);
if(!sw) return FALSE;

GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(sw));
gdouble value = gtk_adjustment_get_value(adjustment);

gtk_widget_set_margin_top(header,
CLAMP(value - allocation.y, 0, allocation.height - gtk_widget_get_allocated_height(header)));
dt_gui_widget_reallocate_now(widget);

return FALSE;
}

// public functions
GtkWidget *dtgtk_expander_new(GtkWidget *header, GtkWidget *body)
{
Expand All @@ -283,8 +312,13 @@ GtkWidget *dtgtk_expander_new(GtkWidget *header, GtkWidget *body)
gtk_revealer_set_reveal_child(GTK_REVEALER(expander->frame), TRUE);
gtk_container_add(GTK_CONTAINER(expander->frame), frame);

gtk_box_pack_start(GTK_BOX(expander), expander->header_evb, TRUE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(expander), expander->frame, TRUE, FALSE, 0);
GtkWidget *overlay = gtk_overlay_new();
gtk_container_add(GTK_CONTAINER(overlay), expander->frame);
gtk_overlay_add_overlay(GTK_OVERLAY(overlay), expander->header_evb);
gtk_widget_set_valign(expander->header_evb, GTK_ALIGN_START);
gtk_container_add(GTK_CONTAINER(expander), overlay);
if(!g_strcmp0(gtk_widget_get_name(header), "module-header"))
g_signal_connect(expander, "draw", G_CALLBACK(_adjust_header_position), expander->header_evb);

g_signal_connect(expander->header_evb, "drag-begin", G_CALLBACK(_expander_drag_begin), NULL);
g_signal_connect(expander->header_evb, "drag-end", G_CALLBACK(_expander_drag_end), NULL);
Expand Down
1 change: 1 addition & 0 deletions src/gui/gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2429,6 +2429,7 @@ static GtkWidget *_ui_init_panel_container_center(GtkWidget *container,
gtk_widget_set_name(widget, "plugins_vbox_left");
gtk_container_add(GTK_CONTAINER(container), widget);
g_signal_connect_swapped(widget, "draw", G_CALLBACK(_side_panel_draw), NULL);
g_signal_connect_swapped(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(container)), "value-changed", G_CALLBACK(gtk_widget_queue_draw), widget);

GtkWidget *empty = gtk_event_box_new();
gtk_widget_set_tooltip_text(empty, _("right-click to show/hide modules"));
Expand Down
Loading