Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
drawingarea.c
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2014-2015 Roman Lebedev.
4 Copyright (C) 2016 johannes hanika.
5 Copyright (C) 2016 Tobias Ellinghaus.
6 Copyright (C) 2020 Pascal Obry.
7 Copyright (C) 2022 Martin Baƙinka.
8
9 darktable is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 darktable is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with darktable. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include "dtgtk/drawingarea.h"
24
25G_DEFINE_TYPE(GtkDarktableDrawingArea, dtgtk_drawing_area, GTK_TYPE_DRAWING_AREA);
26
27static GtkSizeRequestMode dtgtk_drawing_area_get_request_mode(GtkWidget *widget)
28{
29 return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
30};
31
33 gint *min_height, gint *nat_height)
34{
36
37 *min_height = *nat_height = for_width * da->aspect;
38}
39
41{
42 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(class);
43
44 widget_class->get_request_mode = dtgtk_drawing_area_get_request_mode;
45 widget_class->get_preferred_height_for_width = dtgtk_drawing_area_get_preferred_height_for_width;
46}
47
49{
50 gtk_widget_set_hexpand(GTK_WIDGET(da), TRUE);
51}
52
53// public functions
55{
57 da = g_object_new(dtgtk_drawing_area_get_type(), NULL);
58 da->aspect = aspect;
59
60 return (GtkWidget *)da;
61}
62
64{
66 da->aspect = aspect;
67 gtk_widget_queue_resize(widget);
68}
69
70// clang-format off
71// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
72// vim: shiftwidth=2 expandtab tabstop=2 cindent
73// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
74// clang-format on
75
#define TRUE
Definition ashift_lsd.c:162
G_DEFINE_TYPE(GtkDarktableDrawingArea, dtgtk_drawing_area, GTK_TYPE_DRAWING_AREA)
static GtkSizeRequestMode dtgtk_drawing_area_get_request_mode(GtkWidget *widget)
Definition drawingarea.c:27
static void dtgtk_drawing_area_class_init(GtkDarktableDrawingAreaClass *class)
Definition drawingarea.c:40
static void dtgtk_drawing_area_get_preferred_height_for_width(GtkWidget *widget, gint for_width, gint *min_height, gint *nat_height)
Definition drawingarea.c:32
static void dtgtk_drawing_area_init(GtkDarktableDrawingArea *da)
Definition drawingarea.c:48
GtkWidget * dtgtk_drawing_area_new_with_aspect_ratio(double aspect)
Definition drawingarea.c:54
void dtgtk_drawing_area_set_aspect_ratio(GtkWidget *widget, double aspect)
Definition drawingarea.c:63
GType dtgtk_drawing_area_get_type(void)
#define DTGTK_DRAWING_AREA(obj)
Definition drawingarea.h:31
struct _GtkWidget GtkWidget
Definition splash.h:29