Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
scroll_wrap.c File Reference
#include "widgets/scroll_wrap.h"
#include "system/macros.h"
#include "system/mem_alloc.h"
#include "widgets/resize_handle.h"
#include "widgets/widget_settings.h"
#include "widgets/widget_style.h"
#include <glib/gi18n.h>
#include "widgets/container.h"
Include dependency graph for scroll_wrap.c:

Go to the source code of this file.

Data Structures

struct  dt_ui_resizable_area_t

Typedefs

typedef struct dt_ui_resizable_area_t dt_ui_resizable_area_t

Functions

static gboolean _treeview_fit_rows (GtkTreeView *treeview, GtkTreeModel *model, GtkTreeIter *parent, const gint nominal, const gint limit, gint *used)
static gint _get_container_row_heigth (GtkWidget *w)
static GtkWidget * _search_parent_scrolled_window (GtkWidget *w)
static int _treeview_visible_height (GtkTreeView *treeview, GtkTreeModel *model, GtkTreeIter *parent, const gint nominal)
static int _textview_count_visible_rows (GtkWidget *textview)
static void _widget_auto_disconnect_model (dt_gui_widget_auto_height_t *state, GtkWidget *treeview)
static void _widget_auto_disconnect_buffer (dt_gui_widget_auto_height_t *state)
static gint _resizable_scroll_max_height (void)
 Window-height ceiling shared by the auto-size rule and the drag handle.
static void _resizable_scroll_apply (GtkWidget *w)
 The single sizing rule for every dt_ui_scroll_wrap area.
static void _widget_auto_update (GtkWidget *widget)
static gboolean _resizable_scroll_draw (GtkWidget *w, cairo_t *cr, gpointer user_data)
static void _resizable_scroll_realize (GtkWidget *w, gpointer user_data)
static int _resizable_scroll_handle_get_size (gpointer user_data)
static int _resizable_scroll_handle_resize (int requested_size, gboolean finished, gpointer user_data)
static void _widget_auto_model_row_inserted (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data)
static void _widget_auto_model_row_deleted (GtkTreeModel *model, GtkTreePath *path, gpointer user_data)
static void _widget_auto_model_row_changed (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data)
static void _widget_auto_model_rows_reordered (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gint *new_order, gpointer user_data)
static void _widget_auto_model_row_expanded (GtkTreeView *tree_view, GtkTreeIter *expanded_iter, GtkTreePath *path, gpointer user_data)
static void _widget_auto_model_row_collapsed (GtkTreeView *tree_view, GtkTreeIter *collapsed_iter, GtkTreePath *path, gpointer user_data)
static void _widget_auto_text_buffer_changed (GtkTextBuffer *buffer, gpointer user_data)
static void _widget_auto_connect_model (GtkWidget *treeview)
static void _widget_auto_connect_buffer (GtkWidget *textview)
static void _widget_auto_on_model_changed (GObject *treeview, GParamSpec *pspec, gpointer user_data)
static void _widget_auto_on_buffer_changed (GObject *textview, GParamSpec *pspec, gpointer user_data)
static void _widget_auto_height_free (gpointer data)
GtkWidget * dt_ui_scroll_wrap (GtkWidget *w, gint min_size, const char *config_str, dt_ui_resize_mode_t mode)
 Wrap a scrollable content widget in a recessed, vertically resizable scrolled window.
GtkWidget * dt_ui_scroll_wrap_get_scrolled_window (GtkWidget *wrapper)
 Return the inner scrolled window of a dt_ui_scroll_wrap() wrapper, or NULL.
void dt_ui_scroll_wrap_reserve_trailing_row (GtkWidget *content_widget)
 Make a DT_UI_RESIZE_DYNAMIC list or text view ask for one blank row past its content.
static void _resizable_area_free (gpointer data)
static int _resizable_area_get_size (gpointer user_data)
static int _resizable_area_resize (int requested_size, gboolean finished, gpointer user_data)
GtkWidget * dt_ui_resizable_drawing_area (GtkWidget *area, char *config_str, int default_height, int min_height)
 Make a self-drawing widget (typically a GtkDrawingArea graph or scope) vertically resizable.

Variables

static const char *const DT_GUI_WIDGET_AUTO_HEIGHT_KEY = "dt-gui-widget-auto-height"
static const char *const DT_UI_RESIZABLE_AREA_KEY = "dt-ui-resizable-area"

Typedef Documentation

◆ dt_ui_resizable_area_t

typedef struct dt_ui_resizable_area_t dt_ui_resizable_area_t

Function Documentation

◆ _get_container_row_heigth()

gint _get_container_row_heigth ( GtkWidget * w)
static

Definition at line 92 of file scroll_wrap.c.

References dt_gui_container_first_child(), DT_PIXEL_APPLY_DPI, and height.

Referenced by _resizable_scroll_apply().

◆ _resizable_area_free()

void _resizable_area_free ( gpointer data)
static

Definition at line 636 of file scroll_wrap.c.

References data, dt_free, g_free(), IS_NULL_PTR, and state.

Referenced by dt_ui_resizable_drawing_area().

◆ _resizable_area_get_size()

int _resizable_area_get_size ( gpointer user_data)
static

Definition at line 644 of file scroll_wrap.c.

References DT_UI_RESIZABLE_AREA_KEY, and state.

Referenced by dt_ui_resizable_drawing_area().

◆ _resizable_area_resize()

int _resizable_area_resize ( int requested_size,
gboolean finished,
gpointer user_data )
static

◆ _resizable_scroll_apply()

void _resizable_scroll_apply ( GtkWidget * w)
static

The single sizing rule for every dt_ui_scroll_wrap area.

Height = clamp(min(content, cap), min_size, 75% window), where the cap is the user's persisted height when set, otherwise the window ceiling so the area auto-grows to its content. This makes small content shrink to fit, lets nested lists grow and have their parent panel scroll until the user drags the handle to cap them, and snaps lists/textviews to whole rows to avoid clipped half-rows. The computed bare height – before the scrolled window's own padding and border are added back – is cached for the drag handle.

Definition at line 262 of file scroll_wrap.c.

References _get_container_row_heigth(), _resizable_scroll_max_height(), _search_parent_scrolled_window(), _textview_count_visible_rows(), _treeview_fit_rows(), _treeview_visible_height(), DT_GUI_WIDGET_AUTO_HEIGHT_KEY, DT_UI_RESIZE_STATIC, dt_widget_stored_int(), height, IS_NULL_PTR, MAX, MIN, and state.

Referenced by _resizable_scroll_draw(), _resizable_scroll_handle_resize(), _resizable_scroll_realize(), and _widget_auto_update().

◆ _resizable_scroll_draw()

gboolean _resizable_scroll_draw ( GtkWidget * w,
cairo_t * cr,
gpointer user_data )
static

Definition at line 365 of file scroll_wrap.c.

References _resizable_scroll_apply(), and FALSE.

Referenced by dt_ui_scroll_wrap().

◆ _resizable_scroll_handle_get_size()

int _resizable_scroll_handle_get_size ( gpointer user_data)
static

Definition at line 377 of file scroll_wrap.c.

References DT_GUI_WIDGET_AUTO_HEIGHT_KEY, and state.

Referenced by dt_ui_scroll_wrap().

◆ _resizable_scroll_handle_resize()

int _resizable_scroll_handle_resize ( int requested_size,
gboolean finished,
gpointer user_data )
static

◆ _resizable_scroll_max_height()

gint _resizable_scroll_max_height ( void )
static

Window-height ceiling shared by the auto-size rule and the drag handle.

The full main-window height: a resizable area may grow as tall as the window (the parent panel scrolls to reach it). Content shorter than this still shrinks to fit, so this only bounds how far the user can drag.

Definition at line 246 of file scroll_wrap.c.

References DT_PIXEL_APPLY_DPI, and dt_widget_root_window().

Referenced by _resizable_area_resize(), _resizable_scroll_apply(), _resizable_scroll_handle_resize(), and dt_ui_resizable_drawing_area().

◆ _resizable_scroll_realize()

void _resizable_scroll_realize ( GtkWidget * w,
gpointer user_data )
static

Definition at line 371 of file scroll_wrap.c.

References _resizable_scroll_apply().

Referenced by dt_ui_scroll_wrap().

◆ _search_parent_scrolled_window()

GtkWidget * _search_parent_scrolled_window ( GtkWidget * w)
static

Definition at line 132 of file scroll_wrap.c.

Referenced by _resizable_scroll_apply().

◆ _textview_count_visible_rows()

int _textview_count_visible_rows ( GtkWidget * textview)
static

Definition at line 184 of file scroll_wrap.c.

References MAX.

Referenced by _resizable_scroll_apply().

◆ _treeview_fit_rows()

gboolean _treeview_fit_rows ( GtkTreeView * treeview,
GtkTreeModel * model,
GtkTreeIter * parent,
const gint nominal,
const gint limit,
gint * used )
static

Definition at line 54 of file scroll_wrap.c.

References _treeview_fit_rows(), FALSE, model, row, and TRUE.

Referenced by _resizable_scroll_apply(), and _treeview_fit_rows().

◆ _treeview_visible_height()

int _treeview_visible_height ( GtkTreeView * treeview,
GtkTreeModel * model,
GtkTreeIter * parent,
const gint nominal )
static

Definition at line 154 of file scroll_wrap.c.

References _treeview_visible_height(), height, and model.

Referenced by _resizable_scroll_apply(), and _treeview_visible_height().

◆ _widget_auto_connect_buffer()

void _widget_auto_connect_buffer ( GtkWidget * textview)
static

◆ _widget_auto_connect_model()

◆ _widget_auto_disconnect_buffer()

void _widget_auto_disconnect_buffer ( dt_gui_widget_auto_height_t * state)
static

Definition at line 224 of file scroll_wrap.c.

References IS_NULL_PTR, and state.

Referenced by _widget_auto_connect_buffer(), and _widget_auto_height_free().

◆ _widget_auto_disconnect_model()

void _widget_auto_disconnect_model ( dt_gui_widget_auto_height_t * state,
GtkWidget * treeview )
static

Definition at line 195 of file scroll_wrap.c.

References IS_NULL_PTR, model, and state.

Referenced by _widget_auto_connect_model(), and _widget_auto_height_free().

◆ _widget_auto_height_free()

void _widget_auto_height_free ( gpointer data)
static

◆ _widget_auto_model_row_changed()

void _widget_auto_model_row_changed ( GtkTreeModel * model,
GtkTreePath * path,
GtkTreeIter * iter,
gpointer user_data )
static

Definition at line 412 of file scroll_wrap.c.

References _widget_auto_update(), model, and void().

Referenced by _widget_auto_connect_model().

◆ _widget_auto_model_row_collapsed()

void _widget_auto_model_row_collapsed ( GtkTreeView * tree_view,
GtkTreeIter * collapsed_iter,
GtkTreePath * path,
gpointer user_data )
static

Definition at line 440 of file scroll_wrap.c.

References _widget_auto_update(), and void().

Referenced by _widget_auto_connect_model().

◆ _widget_auto_model_row_deleted()

void _widget_auto_model_row_deleted ( GtkTreeModel * model,
GtkTreePath * path,
gpointer user_data )
static

Definition at line 405 of file scroll_wrap.c.

References _widget_auto_update(), model, and void().

Referenced by _widget_auto_connect_model().

◆ _widget_auto_model_row_expanded()

void _widget_auto_model_row_expanded ( GtkTreeView * tree_view,
GtkTreeIter * expanded_iter,
GtkTreePath * path,
gpointer user_data )
static

Definition at line 431 of file scroll_wrap.c.

References _widget_auto_update(), and void().

Referenced by _widget_auto_connect_model().

◆ _widget_auto_model_row_inserted()

void _widget_auto_model_row_inserted ( GtkTreeModel * model,
GtkTreePath * path,
GtkTreeIter * iter,
gpointer user_data )
static

Definition at line 396 of file scroll_wrap.c.

References _widget_auto_update(), model, and void().

Referenced by _widget_auto_connect_model().

◆ _widget_auto_model_rows_reordered()

void _widget_auto_model_rows_reordered ( GtkTreeModel * model,
GtkTreePath * path,
GtkTreeIter * iter,
gint * new_order,
gpointer user_data )
static

Definition at line 421 of file scroll_wrap.c.

References _widget_auto_update(), model, and void().

Referenced by _widget_auto_connect_model().

◆ _widget_auto_on_buffer_changed()

void _widget_auto_on_buffer_changed ( GObject * textview,
GParamSpec * pspec,
gpointer user_data )
static

Definition at line 513 of file scroll_wrap.c.

References _widget_auto_connect_buffer(), _widget_auto_update(), and void().

Referenced by dt_ui_scroll_wrap().

◆ _widget_auto_on_model_changed()

void _widget_auto_on_model_changed ( GObject * treeview,
GParamSpec * pspec,
gpointer user_data )
static

Definition at line 505 of file scroll_wrap.c.

References _widget_auto_connect_model(), _widget_auto_update(), and void().

Referenced by dt_ui_scroll_wrap().

◆ _widget_auto_text_buffer_changed()

void _widget_auto_text_buffer_changed ( GtkTextBuffer * buffer,
gpointer user_data )
static

Definition at line 451 of file scroll_wrap.c.

References _widget_auto_update(), and void().

Referenced by _widget_auto_connect_buffer().

◆ _widget_auto_update()

◆ dt_ui_resizable_drawing_area()

GtkWidget * dt_ui_resizable_drawing_area ( GtkWidget * area,
char * config_str,
int default_height,
int min_height )

Make a self-drawing widget (typically a GtkDrawingArea graph or scope) vertically resizable.

The widget is given a fixed height-request (persisted under config_str) and a drag grip floating on its bottom edge – the same grip used by panels, scroll wrappers and the histogram scope. The content is not scrolled: it keeps drawing to its live allocation, only the height-request changes. Returns a wrapper overlay to pack in place of area.

Parameters
areathe drawing widget (its callbacks/refs stay valid; pack the returned overlay).
config_strconf key persisting the user-chosen height (copied internally).
default_heightdefault height in device-independent px (rescaled by DT_PIXEL_APPLY_DPI).
min_heightminimum height floor in device-independent px.

Definition at line 665 of file scroll_wrap.c.

References _resizable_area_free(), _resizable_area_get_size(), _resizable_area_resize(), _resizable_scroll_max_height(), DT_PIXEL_APPLY_DPI, DT_UI_RESIZABLE_AREA_KEY, dt_widget_stored_int(), dtgtk_resize_handle_new(), FALSE, height, MAX, and state.

Referenced by gui_init(), gui_init(), and gui_init().

◆ dt_ui_scroll_wrap()

GtkWidget * dt_ui_scroll_wrap ( GtkWidget * w,
gint min_size,
const char * config_str,
dt_ui_resize_mode_t mode )

Wrap a scrollable content widget in a recessed, vertically resizable scrolled window.

Wrap a scrollable widget in a recessed, vertically resizable scrolled window with a drag handle.

Returns an overlay wrapping the scrolled window, with a themed drag grip floating on its bottom edge (the same grip primitive used by panels and the histogram scope). The grip takes no layout space and is invisible until hovered. Sizing follows mode: DT_UI_RESIZE_DYNAMIC auto-fits the content up to the user height, DT_UI_RESIZE_STATIC keeps a fixed height (see _resizable_scroll_apply).

The returned widget is the wrapper overlay, not the scrolled window; callers needing the inner scrolled window (e.g. to tweak its scroll policy) must use dt_ui_scroll_wrap_get_scrolled_window().

Parameters
wcontent widget (treeview, textview or any container)
min_sizeminimum height floor in device pixels (also the static default, for a key without one)
config_strconf key persisting the user-chosen height (copied internally)
modeDT_UI_RESIZE_DYNAMIC (auto-fit) or DT_UI_RESIZE_STATIC (fixed height)

Definition at line 547 of file scroll_wrap.c.

References _resizable_scroll_draw(), _resizable_scroll_handle_get_size(), _resizable_scroll_handle_resize(), _resizable_scroll_realize(), _widget_auto_connect_buffer(), _widget_auto_connect_model(), _widget_auto_height_free(), _widget_auto_on_buffer_changed(), _widget_auto_on_model_changed(), _widget_auto_update(), dt_gui_add_class(), DT_GUI_WIDGET_AUTO_HEIGHT_KEY, DT_PIXEL_APPLY_DPI, DT_UI_RESIZE_DYNAMIC, dtgtk_resize_handle_new(), FALSE, MAX, and state.

Referenced by _mem_list(), _modchooser_run(), dt_iop_gui_init_masks(), and gui_init().

◆ dt_ui_scroll_wrap_get_scrolled_window()

GtkWidget * dt_ui_scroll_wrap_get_scrolled_window ( GtkWidget * wrapper)

Return the inner scrolled window of a dt_ui_scroll_wrap() wrapper, or NULL.

Return the inner GtkScrolledWindow of a dt_ui_scroll_wrap() wrapper, or NULL.

Definition at line 609 of file scroll_wrap.c.

Referenced by _mem_list(), and gui_init().

◆ dt_ui_scroll_wrap_reserve_trailing_row()

void dt_ui_scroll_wrap_reserve_trailing_row ( GtkWidget * content_widget)

Make a DT_UI_RESIZE_DYNAMIC list or text view ask for one blank row past its content.

A list filled edge to edge cannot be told from one with more rows hidden below; the blank row says it ends there. Part of the sizing rule rather than a one-off resize of the window around it, so it holds through every content change and every re-layout. A list capped below its content still snaps to whole rows and scrolls, with no blank row.

Parameters
content_widgetthe widget passed to dt_ui_scroll_wrap(). Ignored when it was not wrapped.

Definition at line 626 of file scroll_wrap.c.

References _widget_auto_update(), DT_GUI_WIDGET_AUTO_HEIGHT_KEY, IS_NULL_PTR, state, and TRUE.

Referenced by gui_init().

Variable Documentation

◆ DT_GUI_WIDGET_AUTO_HEIGHT_KEY

◆ DT_UI_RESIZABLE_AREA_KEY

const char* const DT_UI_RESIZABLE_AREA_KEY = "dt-ui-resizable-area"
static