Skip to content
Draft
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
24 changes: 12 additions & 12 deletions DefineOptions.cmake
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
option(USE_CAMERA_SUPPORT "Detect and use camera support if available." ON)
option(USE_COLORD "Enable colord support" ON)
option(USE_MAP "Build Map View parts" ON)
option(USE_LUA "Build lua scripting support" ON)
option(USE_CAMERA_SUPPORT "Detect and use camera support if available." OFF)
option(USE_COLORD "Enable colord support" OFF)
option(USE_MAP "Build Map View parts" OFF)
option(USE_LUA "Build lua scripting support" OFF)
option(DONT_USE_INTERNAL_LUA "Never fall back to the intree copy of lua" ON)
option(USE_KWALLET "Build kwallet password storage back-end" ON)
option(USE_LIBSECRET "Build libsecret password storage back-end" ON)
option(USE_KWALLET "Build kwallet password storage back-end" OFF)
option(USE_LIBSECRET "Build libsecret password storage back-end" OFF)
option(USE_UNITY "Use libunity to report progress in the launcher" OFF)
option(USE_OPENMP "Use OpenMP threading support." ON)
option(USE_OPENCL "Use OpenCL support." ON)
option(USE_GRAPHICSMAGICK "Use GraphicsMagick library for image import." ON)
option(USE_GRAPHICSMAGICK "Use GraphicsMagick library for image import." OFF)
option(USE_IMAGEMAGICK "Use ImageMagick library for image import." OFF)
option(USE_DARKTABLE_PROFILING OFF)
option(CUSTOM_CFLAGS "Don't override compiler optimization flags." OFF)
option(BINARY_PACKAGE_BUILD "Sets march optimization to generic" OFF)
option(USE_XMLLINT "Run xmllint to test if darktableconfig.xml is valid" ON)
option(USE_PORTMIDI "Enable MIDI device support using PortMidi" ON)
option(USE_PORTMIDI "Enable MIDI device support using PortMidi" OFF)
option(USE_OPENJPEG "Enable JPEG 2000 support" ON)
option(USE_JXL "Enable JPEG XL support" ON)
option(USE_WEBP "Enable WebP support" ON)
Expand All @@ -26,17 +26,17 @@ option(USE_LIBRAW "Enable LibRaw support" ON)
option(DONT_USE_INTERNAL_LIBRAW "If possible, use system instead of intree copy of LibRaw" OFF)
option(BUILD_CMSTEST "Build a test program to check your system's color management setup" ON)
option(USE_OPENEXR "Enable OpenEXR support" ON)
option(BUILD_PRINT "Build the print module" ON)
option(BUILD_PRINT "Build the print module" OFF)
option(BUILD_RS_IDENTIFY "Build the darktable-rs-identify debug aid" ON)
option(BUILD_SSE2_CODEPATHS "(EXPERIMENTAL OPTION, DO NOT DISABLE) Building SSE2-optimized codepaths" ON)
option(VALIDATE_APPDATA_FILE "Use appstream-util (if found) to validate the .appdata file" OFF)
option(BUILD_MSYS2_INSTALL "Build an MSYS2 version of the install, aka for Windows platform, but without dependency installs" OFF)
option(BUILD_NOISE_TOOLS "Build tools for generating noise profiles" OFF)
option(BUILD_CURVE_TOOLS "Build tools for generating base and tone curves" OFF)
option(USE_GMIC "Use G'MIC image processing framework." ON)
option(USE_GMIC "Use G'MIC image processing framework." OFF)
option(USE_ICU "Use ICU - International Components for Unicode." ON)
option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." OFF)
option(USE_SDL2 "Enable SDL2 support" ON)
option(USE_SDL2 "Enable SDL2 support" OFF)

if (USE_OPENCL)
option(TESTBUILD_OPENCL_PROGRAMS "Test-compile OpenCL programs (needs LLVM and Clang 7+)" ON)
Expand All @@ -45,7 +45,7 @@ else ()
endif ()

if(APPLE)
option(USE_MAC_INTEGRATION "Enable macOS integration" ON)
option(USE_MAC_INTEGRATION "Enable macOS integration" OFF)
else(APPLE)
set(USE_MAC_INTEGRATION OFF)
endif(APPLE)
4 changes: 4 additions & 0 deletions cmake/modules/FindGTK4.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.18)

find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK4 REQUIRED IMPORTED_TARGET gtk4)
11 changes: 5 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ FILE(GLOB SOURCE_FILES
"dtgtk/drawingarea.c"
"dtgtk/expander.c"
"dtgtk/gradientslider.c"
"dtgtk/icon.c"
"dtgtk/paint.c"
"dtgtk/range.c"
"dtgtk/resetlabel.c"
Expand Down Expand Up @@ -294,11 +293,11 @@ include_directories(SYSTEM ${Glib_INCLUDE_DIRS})
list(APPEND LIBS ${Glib_LIBRARIES})

# GTK3 pulls in ATK, GDK, GDK-PIXBUF, CAIRO, GLIB, PANGO
find_package(GTK3 3.24.15 REQUIRED)
add_definitions("-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_24")
#add_definitions("-DGDK_VERSION_MAX_ALLOWED=GDK_VERSION_MIN_REQUIRED")
include_directories(SYSTEM ${GTK3_INCLUDE_DIRS})
list(APPEND LIBS ${GTK3_LIBRARIES})
find_package(GTK4 4.8.3 REQUIRED)
add_definitions("-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_4_0")
add_definitions("-DGDK_VERSION_MAX_ALLOWED=GDK_VERSION_4_18")
include_directories(SYSTEM ${GTK4_INCLUDE_DIRS})
list(APPEND LIBS ${GTK4_LIBRARIES})

# Check for libxml2 / broken cmake module can't be included in the foreach() below
find_package(LibXml2 2.6 REQUIRED)
Expand Down
129 changes: 68 additions & 61 deletions src/bauhaus/bauhaus.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@
#include "control/conf.h"
#include "develop/develop.h"
#include "develop/imageop.h"
#include "dtgtk/drawingarea.h"
#include "gui/accelerators.h"
#include "gui/color_picker_proxy.h"
#include "gui/gtk.h"
#ifdef GDK_WINDOWING_QUARTZ
#include "osx/osx.h"
#endif
#ifdef GDK_WINDOWING_WAYLAND
#include <gdk/gdkwayland.h>
#endif

#include <strings.h>

Expand Down Expand Up @@ -766,7 +764,7 @@ static void _widget_finalize(GObject *widget)
void dt_bauhaus_load_theme()
{
GtkWidget *root_window = dt_ui_main_window(darktable.gui->ui);
GtkStyleContext *ctx = gtk_style_context_new();
GtkStyleContext *ctx = gtk_widget_get_style_context(root_window);
GtkWidgetPath *path = gtk_widget_path_new();
const int pos = gtk_widget_path_append_type(path, GTK_TYPE_WIDGET);
gtk_widget_path_iter_add_class(path, pos, "dt_bauhaus");
Expand Down Expand Up @@ -1128,7 +1126,7 @@ gchar *dt_bauhaus_widget_get_tooltip_markup(GtkWidget *widget,
&& DT_IS_BAUHAUS_WIDGET(widget)
&& DT_BAUHAUS_WIDGET(widget)->tooltip
? g_markup_escape_text(DT_BAUHAUS_WIDGET(widget)->tooltip, -1)
: gtk_widget_get_tooltip_markup(widget);
: g_strdup(gtk_widget_get_tooltip_markup(widget));
if(!darktable.control->mapping_widget
&& dt_bauhaus_widget_get_type(widget) == DT_BAUHAUS_SLIDER)
{
Expand Down Expand Up @@ -2606,11 +2604,17 @@ static gboolean _popup_draw(GtkWidget *widget,
return TRUE;
}

static gboolean _widget_draw(GtkWidget *widget,
cairo_t *cr)

static void _widget_snapshot(GtkWidget* widget,
GtkSnapshot* snapshot)
{
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);

graphene_rect_t bounds;
graphene_rect_init(&bounds, 0, 0, allocation.width, allocation.height);
cairo_t* cr = gtk_snapshot_append_cairo(snapshot, &bounds);

dt_bauhaus_widget_t *w = DT_BAUHAUS_WIDGET(widget);
const int width = allocation.width, height = allocation.height;
GtkStyleContext *context = gtk_widget_get_style_context(widget);
Expand All @@ -2624,7 +2628,9 @@ static gboolean _widget_draw(GtkWidget *widget,
gtk_style_context_get_color(context, state, text_color);

gtk_style_context_get_color(context, state, fg_color);
gtk_style_context_get(context, state, "background-color", &bg_color, NULL);
// gtk_style_context_get(context, state, "background-color", &bg_color, NULL);
GdkRGBA color = {.red = 0.0f, .green = 0.0f, .blue = 0.0f, .alpha = 1.0f};
bg_color = gdk_rgba_copy(&color);

// translate to account for the widget spacing
const int h2 = height - w->margin.top - w->margin.bottom;
Expand Down Expand Up @@ -2759,8 +2765,6 @@ static gboolean _widget_draw(GtkWidget *widget,
gdk_rgba_free(text_color);
gdk_rgba_free(fg_color);
gdk_rgba_free(bg_color);

return TRUE;
}

static gint _natural_width(GtkWidget *widget,
Expand Down Expand Up @@ -2832,34 +2836,35 @@ static gint _natural_width(GtkWidget *widget,
return natural_size;
}

static void _widget_get_preferred_width(GtkWidget *widget,
gint *minimum_width,
gint *natural_width)
{
dt_bauhaus_widget_t *w = (dt_bauhaus_widget_t *)widget;
_margins_retrieve(w);

*natural_width = _natural_width(widget, FALSE)
+ w->margin.left + w->margin.right + w->padding.left + w->padding.right;
}

static void _widget_get_preferred_height(GtkWidget *widget,
gint *minimum_height,
gint *natural_height)
static void _widget_measure(GtkWidget* widget,
GtkOrientation orientation,
int for_size,
int* minimum,
int* natural,
int* minimum_baseline,
int* natural_baseline)
{
dt_bauhaus_widget_t *w = (dt_bauhaus_widget_t *)widget;
_margins_retrieve(w);

*minimum_height = w->margin.top + w->margin.bottom + w->padding.top + w->padding.bottom
+ darktable.bauhaus->line_height;
if(w->type == DT_BAUHAUS_SLIDER)
if(orientation == GTK_ORIENTATION_HORIZONTAL)
{
// the lower thing to draw is indicator. See _draw_baseline for compute details
*minimum_height += INNER_PADDING
+ darktable.bauhaus->baseline_size + 1.5f * darktable.bauhaus->border_width;

*natural = _natural_width(widget, FALSE)
+ w->margin.left + w->margin.right + w->padding.left + w->padding.right;
}
else
{
*minimum = w->margin.top + w->margin.bottom + w->padding.top + w->padding.bottom
+ darktable.bauhaus->line_height;
if(w->type == DT_BAUHAUS_SLIDER)
{
// the lower thing to draw is indicator. See _draw_baseline for compute details
*minimum += INNER_PADDING
+ darktable.bauhaus->baseline_size + 1.5f * darktable.bauhaus->border_width;
}

*natural_height = *minimum_height;
*natural = *minimum;
}
}

static void _popup_hide()
Expand All @@ -2886,6 +2891,7 @@ static void _popup_hide()

static void _popup_show(GtkWidget *widget)
{
return; // GTK4
dt_bauhaus_widget_t *w = DT_BAUHAUS_WIDGET(widget);
dt_bauhaus_t *bh = darktable.bauhaus;
dt_bauhaus_popup_t *pop = &bh->popup;
Expand Down Expand Up @@ -3064,19 +3070,21 @@ static void _slider_add_step(GtkWidget *widget,
dt_bauhaus_slider_set(widget, CLAMP(value + delta, d->min, d->max));
}

static gboolean _widget_scroll(GtkWidget *widget,
GdkEventScroll *event)
static gboolean _widget_scroll(GtkEventControllerScroll* self,
gdouble dx,
gdouble dy,
GtkWidget *widget)
{
if(dt_gui_ignore_scroll(event)) return FALSE;
// GTK4
// if(dt_gui_ignore_scroll(event)) return FALSE;

// handle speed adjustment in mapping mode in dispatcher
if(darktable.control->mapping_widget)
return dt_shortcut_dispatcher(widget, (GdkEvent*)event, NULL);
// // handle speed adjustment in mapping mode in dispatcher
// if(darktable.control->mapping_widget)
// return dt_shortcut_dispatcher(widget, (GdkEvent*)event, NULL);

gtk_widget_grab_focus(widget);

int delta_y = 0;
if(dt_gui_get_scroll_unit_delta(event, &delta_y))
int delta_y = dx + dy;
{
if(delta_y == 0) return TRUE;

Expand All @@ -3085,15 +3093,17 @@ static gboolean _widget_scroll(GtkWidget *widget,

if(w->type == DT_BAUHAUS_SLIDER)
{
gboolean force = darktable.control->element == DT_ACTION_ELEMENT_FORCE
&& event->window == gtk_widget_get_window(widget);
if(force && dt_modifier_is(event->state, GDK_SHIFT_MASK | GDK_CONTROL_MASK))
{
_slider_zoom_range(w, delta_y);
_slider_zoom_toast(w);
}
else
_slider_add_step(widget, - delta_y, event->state, force);
// GTK4
// gboolean force = darktable.control->element == DT_ACTION_ELEMENT_FORCE
// && event->window == gtk_widget_get_window(widget);
// if(force && dt_modifier_is(event->state, GDK_SHIFT_MASK | GDK_CONTROL_MASK))
// {
// _slider_zoom_range(w, delta_y);
// _slider_zoom_toast(w);
// }
// else
// _slider_add_step(widget, - delta_y, event->state, force);
_slider_add_step(widget, - delta_y, gtk_event_controller_get_current_event_state(GTK_EVENT_CONTROLLER(self)), FALSE);
}
else
_combobox_next_sensitive(w, delta_y, 0, FALSE);
Expand Down Expand Up @@ -3556,7 +3566,7 @@ static void _widget_button_press(GtkGestureSingle *gesture,
}
else if(button == GDK_BUTTON_SECONDARY || w->type == DT_BAUHAUS_COMBOBOX)
{
bh->opentime = gdk_event_get_time(gtk_get_current_event());
bh->opentime = gtk_event_controller_get_current_event_time(GTK_EVENT_CONTROLLER(gesture));
bh->mouse_x = x;
bh->mouse_y = y;
_popup_show(widget);
Expand Down Expand Up @@ -3669,20 +3679,17 @@ static void dt_bh_class_init(DtBauhausWidgetClass *class)
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);

GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(class);
widget_class->draw = _widget_draw;
// widget_class->snapshot = _widget_snapshot;
widget_class->scroll_event = _widget_scroll;
widget_class->key_press_event = _widget_key_press;
widget_class->get_preferred_width = _widget_get_preferred_width;
widget_class->get_preferred_height = _widget_get_preferred_height;
// widget_class->measure = _widget_measure;
widget_class->snapshot = _widget_snapshot;
// widget_class->scroll_event = _widget_scroll;
// widget_class->key_press_event = _widget_key_press;
widget_class->measure = _widget_measure;
G_OBJECT_CLASS(class)->finalize = _widget_finalize;

// for histogram -> exposure proxy
bh->press = _widget_button_press;
bh->release = _widget_button_release;
bh->motion = _widget_motion;
bh->scroll = _widget_scroll;
// bh->scroll = _widget_scroll; GTK4
}

static void dt_bh_init(DtBauhausWidget *w)
Expand All @@ -3707,9 +3714,9 @@ static void dt_bh_init(DtBauhausWidget *w)

dt_gui_connect_motion(w, _widget_motion, _widget_enter, _widget_leave, widget);

// GtkEventController *controller = gtk_event_controller_scroll_new(GTK_EVENT_CONTROLLER_SCROLL_BOTH_AXES | GTK_EVENT_CONTROLLER_SCROLL_DISCRETE);
// gtk_widget_add_controller(GTK_WIDGET(w), GTK_EVENT_CONTROLLER(controller));
// g_signal_connect(controller, "scroll", G_CALLBACK(_widget_scroll), w);
GtkEventController *controller = gtk_event_controller_scroll_new(GTK_EVENT_CONTROLLER_SCROLL_BOTH_AXES | GTK_EVENT_CONTROLLER_SCROLL_DISCRETE);
gtk_widget_add_controller(GTK_WIDGET(w), GTK_EVENT_CONTROLLER(controller));
g_signal_connect(controller, "scroll", G_CALLBACK(_widget_scroll), w);

gtk_widget_set_can_focus(widget, TRUE);
dt_gui_add_class(widget, "dt_bauhaus");
Expand Down
Loading
Loading