Ansel
0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
scroll_wrap.h
Go to the documentation of this file.
1
/*
2
* This file is part of Ansel,
3
* Copyright (C) 2026 Aurélien PIERRE.
4
* Copyright (C) 2026 Guillaume Stutin.
5
*
6
* Ansel is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* Ansel is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with Ansel. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#ifndef DT_WIDGETS_SCROLL_WRAP_H
21
#define DT_WIDGETS_SCROLL_WRAP_H
22
23
/* Vertically resizable containers with a drag grip, and the height persistence behind them.
24
*
25
* Two shapes, both giving the user a grip on the bottom edge and remembering where they left
26
* it: a scrolled window around scrollable content (tree views, text views), and a bare
27
* height-request around a self-drawing area (graphs, scopes). */
28
29
#include <gtk/gtk.h>
30
31
G_BEGIN_DECLS
32
33
enum
34
{
35
TREE_LIST_MIN_ROWS
= 3,
36
TREE_LIST_MAX_ROWS
= 11
37
};
38
39
typedef
enum
dt_ui_resize_mode_t
40
{
41
// Auto-fit: the area shrinks to its content (up to the user/max height). Best for widgets
42
// updated rarely; their height following content is helpful, not disruptive.
43
DT_UI_RESIZE_DYNAMIC
= 0,
44
// Fixed: the area keeps the user-set (or default) height regardless of content, so it never
45
// shifts the surrounding layout when its content changes. Best for widgets that refresh on
46
// hover/selection (tags, notes) and the collection/library list.
47
DT_UI_RESIZE_STATIC
48
}
dt_ui_resize_mode_t
;
49
50
typedef
struct
dt_gui_widget_auto_height_t
51
{
52
char
*
config_str
;
// conf key persisting the user-chosen height (px); owned
53
int
min_size
;
// minimum height floor in device pixels
54
int
last_height
;
// last applied bare (pre-padding) height, shared with the drag handle
55
dt_ui_resize_mode_t
mode
;
56
gboolean
trailing_row
;
// one blank row past the content, see dt_ui_scroll_wrap_reserve_trailing_row()
57
GtkTreeModel *
model
;
58
GtkTextBuffer *
buffer
;
59
gulong
model_row_inserted
;
60
gulong
model_row_deleted
;
61
gulong
model_row_changed
;
62
gulong
model_rows_reordered
;
63
gulong
model_row_expanded
;
64
gulong
model_row_collapsed
;
65
gulong
buffer_changed
;
66
}
dt_gui_widget_auto_height_t
;
67
87
GtkWidget
*
dt_ui_scroll_wrap
(
GtkWidget
*w, gint min_size,
const
char
*config_str,
dt_ui_resize_mode_t
mode);
88
92
GtkWidget
*
dt_ui_scroll_wrap_get_scrolled_window
(
GtkWidget
*wrapper);
93
104
void
dt_ui_scroll_wrap_reserve_trailing_row
(
GtkWidget
*content_widget);
105
120
GtkWidget
*
dt_ui_resizable_drawing_area
(
GtkWidget
*area,
char
*config_str,
int
default_height,
int
min_height);
121
122
G_END_DECLS
123
124
#endif
// DT_WIDGETS_SCROLL_WRAP_H
125
126
// clang-format off
127
// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
128
// vim: shiftwidth=2 expandtab tabstop=2 cindent
129
// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
130
// clang-format on
GtkWidget
struct _GtkWidget GtkWidget
GtkWidget, opaque, spelled exactly as GTK spells it.
Definition
colorspaces.h:98
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.
Definition
scroll_wrap.c:626
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.
Definition
scroll_wrap.c:665
dt_ui_scroll_wrap_get_scrolled_window
GtkWidget * dt_ui_scroll_wrap_get_scrolled_window(GtkWidget *wrapper)
Return the inner GtkScrolledWindow of a dt_ui_scroll_wrap() wrapper, or NULL.
Definition
scroll_wrap.c:609
TREE_LIST_MIN_ROWS
@ TREE_LIST_MIN_ROWS
Definition
scroll_wrap.h:35
TREE_LIST_MAX_ROWS
@ TREE_LIST_MAX_ROWS
Definition
scroll_wrap.h:36
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 widget in a recessed, vertically resizable scrolled window with a drag handle.
Definition
scroll_wrap.c:547
dt_ui_resize_mode_t
dt_ui_resize_mode_t
Definition
scroll_wrap.h:40
DT_UI_RESIZE_STATIC
@ DT_UI_RESIZE_STATIC
Definition
scroll_wrap.h:47
DT_UI_RESIZE_DYNAMIC
@ DT_UI_RESIZE_DYNAMIC
Definition
scroll_wrap.h:43
dt_gui_widget_auto_height_t
Definition
scroll_wrap.h:51
dt_gui_widget_auto_height_t::config_str
char * config_str
Definition
scroll_wrap.h:52
dt_gui_widget_auto_height_t::last_height
int last_height
Definition
scroll_wrap.h:54
dt_gui_widget_auto_height_t::model_row_expanded
gulong model_row_expanded
Definition
scroll_wrap.h:63
dt_gui_widget_auto_height_t::mode
dt_ui_resize_mode_t mode
Definition
scroll_wrap.h:55
dt_gui_widget_auto_height_t::min_size
int min_size
Definition
scroll_wrap.h:53
dt_gui_widget_auto_height_t::model_row_collapsed
gulong model_row_collapsed
Definition
scroll_wrap.h:64
dt_gui_widget_auto_height_t::buffer_changed
gulong buffer_changed
Definition
scroll_wrap.h:65
dt_gui_widget_auto_height_t::model_row_inserted
gulong model_row_inserted
Definition
scroll_wrap.h:59
dt_gui_widget_auto_height_t::model
GtkTreeModel * model
Definition
scroll_wrap.h:57
dt_gui_widget_auto_height_t::model_row_changed
gulong model_row_changed
Definition
scroll_wrap.h:61
dt_gui_widget_auto_height_t::model_rows_reordered
gulong model_rows_reordered
Definition
scroll_wrap.h:62
dt_gui_widget_auto_height_t::trailing_row
gboolean trailing_row
Definition
scroll_wrap.h:56
dt_gui_widget_auto_height_t::model_row_deleted
gulong model_row_deleted
Definition
scroll_wrap.h:60
dt_gui_widget_auto_height_t::buffer
GtkTextBuffer * buffer
Definition
scroll_wrap.h:58
src
widgets
scroll_wrap.h
Generated by
1.15.0