Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
thumbtable_internal.h
Go to the documentation of this file.
1/*
2 This file is part of Ansel,
3 Copyright (C) 2026 Aurélien PIERRE.
4
5 Ansel is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Ansel is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Ansel. If not, see <http://www.gnu.org/licenses/>.
17*/
31#pragma once
32
33#include "dtgtk/thumbtable.h"
34#include "dtgtk/thumbnail.h"
35
36#include <gtk/gtk.h>
37#include <gdk/gdk.h>
38
39
40// Clamp a row id to the valid collection range, and detect collection edges.
41// Both reference the enclosing scope's `table`, matching how they were used inline.
42#define CLAMP_ROW(rowid) CLAMP(rowid, 0, table->collection_count - 1)
43#define IS_COLLECTION_EDGE(rowid) (rowid < 0 || rowid >= table->collection_count)
44
45
57
58
68{
69 // Create the content widget stored in table->grid. The grid uses a GtkFixed (pinned to the
70 // viewport width, vertical scroll only); the filmstrip uses a GtkLayout, which implements
71 // GtkScrollable so it goes straight into the GtkScrolledWindow with no implicit GtkViewport -
72 // that viewport is what collapsed the strip width and broke horizontal scrolling (issue #877).
73 GtkWidget *(*create_content_widget)(void);
74
75 // Compute the viewport size + per-row count + individual thumbnail size from the parent
76 // allocation. Fills all five out-params; the engine handles the "too small" reset and the
77 // change detection. (was: dt_thumbtable_configure per-mode block)
78 void (*configure_dims)(dt_thumbtable_t *table, int *new_width, int *new_height,
79 int *per_row, int *thumb_width, int *thumb_height);
80
81 // Map a rowid to the north-west pixel corner of its cell, and back. (was: _rowid_to_position /
82 // _position_to_rowid)
83 void (*rowid_to_position)(dt_thumbtable_t *table, int rowid, int *x, int *y);
84 int (*position_to_rowid)(dt_thumbtable_t *table, const double x, const double y);
85
86 // Visible rowid range at the current scroll step, and single-rowid visibility test. The engine
87 // wraps these with the shared "configured + scrollbars present" guard. (was: _get_row_ids /
88 // _is_rowid_visible)
89 void (*get_row_ids)(dt_thumbtable_t *table, int *rowid_min, int *rowid_max);
90 gboolean (*is_rowid_visible)(dt_thumbtable_t *table, int rowid);
91
92 // Set the virtual size of the content widget so the scrollbars span the whole collection.
93 // (was: _update_grid_area per-mode block)
95
96 // Add the mode-specific group-border flags for a grouped thumbnail. The engine has already
97 // reset the flags and checked that the image is grouped and borders are enabled.
98 // (was: _add_thumbnail_group_borders per-mode block)
100
101 // Put a freshly-added thumbnail widget in the content widget / move an existing one. thumb->x,y
102 // are already computed. (was: gtk_fixed_put / gtk_fixed_move)
105
106 // Scrollbar predicates. The engine performs the actual update scheduling; these only decide
107 // whether an event matters for this mode (and record scrollbar geometry as a side effect for
108 // relevant_scrollbar_changed). (was: _scrollbar_value_changed / _scrollbar_page_size_notify /
109 // _scrollbar_widget_size_allocate branches)
110 gboolean (*wants_scroll_value)(dt_thumbtable_t *table, GtkAdjustment *adjustment);
111 gboolean (*wants_page_size_notify)(dt_thumbtable_t *table, GObject *object);
112 gboolean (*relevant_scrollbar_changed)(dt_thumbtable_t *table, GtkWidget *widget, GtkAllocation *allocation);
113
114 // The mode's source of truth for the "highlighted" (selected-looking) thumbnail state: the
115 // lighttable selection for the grid, the active/developed image(s) for the filmstrip. The engine
116 // repaints highlights from this on BOTH selection and active-image changes, so whichever the mode
117 // actually tracks stays in sync (issue #954: clearing the selection on darkroom entry must not
118 // clear the filmstrip's developed-image marker).
119 gboolean (*is_thumb_highlighted)(dt_thumbtable_t *table, int32_t imgid);
120
121 // Per-thumbnail selection / action state applied when a thumbnail enters the viewport.
122 // (was: _add_thumbnail_at_rowid selection block)
124
125 // Commit the hovered image at drag-begin (filmstrip raises a signal, grid extends selection).
126 // (was: _event_dnd_begin branch)
127 void (*on_drag_begin)(dt_thumbtable_t *table, int32_t imgid);
128
129 // Build the parent overlay scroll stack, widget name, help link and scroll policy.
130 // (was: dt_thumbtable_set_parent per-mode block)
132
133 // Nullable. Grab keyboard focus for the content widget before scroll-to-selection.
134 // (was: _grab_focus FILEMANAGER block)
136
137 // Nullable. Handle a mode-specific navigation/selection key. Return TRUE if consumed. Shared
138 // keys (Left/Right/Page/Home/End/Return/Alt/Delete) are handled by the engine.
139 // (was: dt_thumbtable_key_pressed_grid FILEMANAGER-only cases)
140 gboolean (*handle_key)(dt_thumbtable_t *table, GdkEventKey *event, guint key, int32_t imgid);
141
142 // Nullable. Select the image about to be opened by a Return/activate key (grid only).
143 void (*pre_activate)(dt_thumbtable_t *table, int32_t imgid);
145
146
147// Frontend vtable accessors (defined in filemanager.c / filmstrip.c).
150
151
152// --- Engine internals shared with the frontends -----------------------------------------------
153
154// Extra extent one .thumb-cell adds beyond the layout stride (see thumbtable.c for the rationale).
156
157// Coalesced focus/scroll-to-selection scheduling (used by grid-only zoom & grid-config API).
158void dt_thumbtable_schedule_focus(dt_thumbtable_t *table, const gint priority);
159
160// LUT lookup: collection index of an imgid, or UNKNOWN_IMAGE. Caller MUST hold table->lock
161// (matches every existing call site; the helper does not lock internally).
162int dt_thumbtable_find_rowid_from_imgid(dt_thumbtable_t *table, const int32_t imgid);
163
164// Keyboard navigation step inside the collection (used by the grid frontend's handle_key).
165void dt_thumbtable_move_in_grid(dt_thumbtable_t *table, GdkEventKey *event,
166 dt_thumbtable_direction_t direction, int origin_imgid);
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
char * key
static const float x
struct _GtkWidget GtkWidget
Definition splash.h:29
Per-mode layout strategy. One instance per frontend, shared (const) by all tables of that mode and st...
void(* pre_activate)(dt_thumbtable_t *table, int32_t imgid)
void(* on_drag_begin)(dt_thumbtable_t *table, int32_t imgid)
int(* position_to_rowid)(dt_thumbtable_t *table, const double x, const double y)
void(* configure_dims)(dt_thumbtable_t *table, int *new_width, int *new_height, int *per_row, int *thumb_width, int *thumb_height)
void(* get_row_ids)(dt_thumbtable_t *table, int *rowid_min, int *rowid_max)
gboolean(* wants_page_size_notify)(dt_thumbtable_t *table, GObject *object)
void(* move_child)(dt_thumbtable_t *table, dt_thumbnail_t *thumb)
void(* group_borders)(dt_thumbtable_t *table, dt_thumbnail_t *thumb, dt_thumbnail_border_t *borders)
gboolean(* wants_scroll_value)(dt_thumbtable_t *table, GtkAdjustment *adjustment)
void(* update_content_size)(dt_thumbtable_t *table)
void(* grab_focus)(dt_thumbtable_t *table)
gboolean(* is_rowid_visible)(dt_thumbtable_t *table, int rowid)
void(* rowid_to_position)(dt_thumbtable_t *table, int rowid, int *x, int *y)
void(* on_thumbnail_added)(dt_thumbtable_t *table, dt_thumbnail_t *thumb)
gboolean(* relevant_scrollbar_changed)(dt_thumbtable_t *table, GtkWidget *widget, GtkAllocation *allocation)
gboolean(* is_thumb_highlighted)(dt_thumbtable_t *table, int32_t imgid)
gboolean(* handle_key)(dt_thumbtable_t *table, GdkEventKey *event, guint key, int32_t imgid)
void(* place_child)(dt_thumbtable_t *table, dt_thumbnail_t *thumb)
void(* setup_parent)(dt_thumbtable_t *table)
dt_thumbnail_border_t
Definition thumbnail.h:49
A widget to manage and display image thumbnails in Ansel's lighttable and filmstrip views.
const dt_thumbtable_layout_ops_t * dt_thumbtable_filmstrip_ops(void)
Definition filmstrip.c:249
dt_thumbtable_direction_t
@ DT_TT_MOVE_LEFT
@ DT_TT_MOVE_RIGHT
@ DT_TT_MOVE_DOWN
@ DT_TT_MOVE_NEXT_PAGE
@ DT_TT_MOVE_UP
@ DT_TT_MOVE_START
@ DT_TT_MOVE_PREVIOUS_PAGE
@ DT_TT_MOVE_END
int dt_thumbtable_thumb_cell_decoration(void)
Definition thumbtable.c:522
void dt_thumbtable_schedule_focus(dt_thumbtable_t *table, const gint priority)
Definition thumbtable.c:191
int dt_thumbtable_find_rowid_from_imgid(dt_thumbtable_t *table, const int32_t imgid)
Definition thumbtable.c:400
const dt_thumbtable_layout_ops_t * dt_thumbtable_grid_ops(void)
void dt_thumbtable_move_in_grid(dt_thumbtable_t *table, GdkEventKey *event, dt_thumbtable_direction_t direction, int origin_imgid)