Shortcut for collapsing active module

Hi guys,

Quick question. I was wondering if there is a way to assign a shortkey to quickly collapse an active module. I couldn’t find it.
The reason I would like to have this option is because, especially when working with masks, the only way to collapse a module is to move the module view upwards with your mouse (mouse wheel doesn’t work afaik, because its used to change the sliders).
This is quite time consuming and takes away from some of the nice flow editing in darktable creates.

How do you guys go about this? Is there something I missed?

Hope to hear from you.

Wouter

I am not sure if this answers your question, but I just click on the name bar of the module to expand or collapse it. Also in the preferences you can set only one module to be expanded at a time which I find helpful.

1 Like

in the shortcuts dialog (or preferences tab) double click on processing modules\<focused> and press the key you want to assign.

This will only allow you to collapse the currently focused module. You can then not expand it again, because it is no longer focused so doesn’t respond to this shortcut anymore.

2 Likes

I’m not able to try it right now, but I think this is the thing I was looking for!
Ill let you know tomorrow!

Thanks!

It works! You are a life saver. This will make the experience so much smoother for me.

Thanks alot!

1 Like

Dan could we ever have the possibility to freeze the header a module that has the focus like you do in excel with column headers. This would keep it visible even when the module is long and you are down deep in the module. Then maybe if there is an open modifier left clicking the header (as it would always be visible) could bring the user to the top?? Just thinking out loud. Maybe page up and down could be used… Even if we didn’t activate any functionality I think it might be nice to be able to freeze the module header. Scrolling up with the cursor inside the panel would go up within the module and using the scrollbars or scrolling outside the panel will move up the whole list. Maybe too complicated and too little to be gained…

Who is this Dan you are talking to and how does he know so much about dt and gtk?

Anyway, your suggestion is a really good one, but not necessarily trivial to implement. There’s two possible approaches:

  1. temporarily move (reparent) the header of the topmost module into the top of the panel. The problem with this is that this would take it outside of the scrollable window, so it doesn’t fit within the vertical scrollbar anymore (and therefore would be slightly wider, so you’d see the size jump back and forth). Also keeping track of which module is the topmost one is not so easy. See also the problem with 2.
  2. Add a GtkOverlay widget to each module. Put the body in there as the main widget, with an added margin at the top the height of the header. Put the header as an overlay widget. Now you can move the overlay across the body by adjusting its top margin. Every time you draw the widget, you check if it is partially off the top of the screen and push the header down if needed.

So in dtgtk_expander_new instead of

  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);

do

  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);
  g_signal_connect(expander, "draw", G_CALLBACK(_adjust_header_position), header);

with

static gboolean _adjust_header_position(GtkWidget *widget, cairo_t *cr, GtkWidget *header)
{
  GtkWidget *sw = gtk_widget_get_ancestor(widget, GTK_TYPE_SCROLLED_WINDOW);
  if(!sw) return FALSE;

  GtkAllocation allocation;
  gtk_widget_get_allocation(widget, &allocation);

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

  gtk_widget_set_margin_top(header, MAX(value - allocation.y, 0)); // TODO don't push header off the bottom
  return FALSE;
}

and initialise the spacing for the header at the top as soon as we know how tall the header is, so let’s say, for now, at the start of _expander_resize

  GtkDarktableExpander *expander = DTGTK_EXPANDER(widget);
  gtk_widget_set_margin_top(expander->frame, gtk_widget_get_allocated_height(expander->header));

OK, all good and it sort of works (if you add background-color: @bg_color; to #module-header in darktable.css otherwise the body shines through the header.
_Except the GtkScrolledWindow buffers the drawing of the widgets it contains. So the module does not necessarily get re"draw"n each time it moves so we don’t get a chance to move the header. (Generally, if you drag the scrollbar it will update the header in jumps a few times and if it is then not at the top you can make it update again by moving the mouse over the module).
OK, we could monitor the scrollbar and check all modules (even the ones that are not being drawn because they are completely off the screen) but that is a major hassle that I don’t want to get into.
Maybe there’s another signal that fires conveniently? Suggestions welcome.

Ha really sorry I had been looking at something else on the github site @dtorop is Dan… I need to give my head a shake…Thanks for being so kind to respond despite my brain fart… :slight_smile:

1 Like

Adding

g_signal_connect_swapped(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(container)), "value-changed", G_CALLBACK(gtk_widget_queue_draw), widget);

after

widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);

in _ui_init_panel_container_center works reasonably well by continuously forcing a redraw of everything when scrolling. There’s jittering, as expected.

1 Like

I guess I got thinking that it might be possible because I had set DT to adjust the sliders even though its nice to use it also to scroll the panel…but I found that with narrow scroll bars if I was outside of them or anywhere near them I could scroll the panel so I didn’t have to use the function modifier I could do both mouse wheel actions, ie the sliders and then just using mouse location scroll the panel… I guess that had me thinking that somehow if you were in the panel boundry they it could be such that it scrolled the module in focus with the frozen header and then if you moved the mouse out to the scrollbar or it seems it can be outside that then the panel would scroll. Selecting a new module would then reset the whole cycle again…but I can see its not quite so simple likely and so many things to keep track of that the average user like myself has no appreication for…I applaude your talent and that of the other devs… I do hope one day soon when I retire to take a run at a little bit of coding just for the sake of personal understanding and appreciation if nothing else…

Test PR here RFC always show header of topmost module by dterrahe · Pull Request #18323 · darktable-org/darktable

If this is deemed useful, it would require finding fixes for the two issues I mention in the PR.

2 Likes

I believe issues are fixed. Please have a look at #18323 and provide feedback/vote/test if you can/care.