File: | ctk/ctkrevealer.c |
Warning: | line 486, column 7 Value stored to 'bin_x' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | /* |
3 | * Copyright 2013, 2015 Red Hat, Inc. |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU Lesser General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or (at your |
8 | * option) any later version. |
9 | * |
10 | * This program is distributed in the hope that it will be useful, but |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
13 | * License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Lesser General Public License |
16 | * along with this program; if not, write to the Free Software Foundation, |
17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
18 | * |
19 | * Author: Alexander Larsson <alexl@redhat.com> |
20 | * Carlos Soriano <csoriano@gnome.org> |
21 | */ |
22 | |
23 | #include "config.h" |
24 | #include "ctkrevealer.h" |
25 | #include <cdk/cdk.h> |
26 | #include "ctktypebuiltins.h" |
27 | #include "ctkprivate.h" |
28 | #include "ctksettingsprivate.h" |
29 | #include "ctkprogresstrackerprivate.h" |
30 | #include "ctkintl.h" |
31 | |
32 | #include "fallback-c89.c" |
33 | |
34 | /** |
35 | * SECTION:ctkrevealer |
36 | * @Short_description: Hide and show with animation |
37 | * @Title: CtkRevealer |
38 | * @See_also: #CtkExpander |
39 | * |
40 | * The CtkRevealer widget is a container which animates |
41 | * the transition of its child from invisible to visible. |
42 | * |
43 | * The style of transition can be controlled with |
44 | * ctk_revealer_set_transition_type(). |
45 | * |
46 | * These animations respect the #CtkSettings:ctk-enable-animations |
47 | * setting. |
48 | * |
49 | * # CSS nodes |
50 | * |
51 | * CtkRevealer has a single CSS node with name revealer. |
52 | * |
53 | * The CtkRevealer widget was added in CTK+ 3.10. |
54 | */ |
55 | |
56 | /** |
57 | * CtkRevealerTransitionType: |
58 | * @CTK_REVEALER_TRANSITION_TYPE_NONE: No transition |
59 | * @CTK_REVEALER_TRANSITION_TYPE_CROSSFADE: Fade in |
60 | * @CTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT: Slide in from the left |
61 | * @CTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT: Slide in from the right |
62 | * @CTK_REVEALER_TRANSITION_TYPE_SLIDE_UP: Slide in from the bottom |
63 | * @CTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN: Slide in from the top |
64 | * |
65 | * These enumeration values describe the possible transitions |
66 | * when the child of a #CtkRevealer widget is shown or hidden. |
67 | */ |
68 | |
69 | enum { |
70 | PROP_0, |
71 | PROP_TRANSITION_TYPE, |
72 | PROP_TRANSITION_DURATION, |
73 | PROP_REVEAL_CHILD, |
74 | PROP_CHILD_REVEALED, |
75 | LAST_PROP |
76 | }; |
77 | |
78 | typedef struct { |
79 | CtkRevealerTransitionType transition_type; |
80 | guint transition_duration; |
81 | |
82 | CdkWindow* bin_window; |
83 | CdkWindow* view_window; |
84 | |
85 | gdouble current_pos; |
86 | gdouble source_pos; |
87 | gdouble target_pos; |
88 | |
89 | guint tick_id; |
90 | CtkProgressTracker tracker; |
91 | } CtkRevealerPrivate; |
92 | |
93 | static GParamSpec *props[LAST_PROP] = { NULL((void*)0), }; |
94 | |
95 | static void ctk_revealer_real_realize (CtkWidget *widget); |
96 | static void ctk_revealer_real_unrealize (CtkWidget *widget); |
97 | static void ctk_revealer_real_add (CtkContainer *widget, |
98 | CtkWidget *child); |
99 | static void ctk_revealer_real_size_allocate (CtkWidget *widget, |
100 | CtkAllocation *allocation); |
101 | static void ctk_revealer_real_map (CtkWidget *widget); |
102 | static void ctk_revealer_real_unmap (CtkWidget *widget); |
103 | static gboolean ctk_revealer_real_draw (CtkWidget *widget, |
104 | cairo_t *cr); |
105 | static void ctk_revealer_real_get_preferred_height (CtkWidget *widget, |
106 | gint *minimum_height, |
107 | gint *natural_height); |
108 | static void ctk_revealer_real_get_preferred_height_for_width (CtkWidget *widget, |
109 | gint width, |
110 | gint *minimum_height, |
111 | gint *natural_height); |
112 | static void ctk_revealer_real_get_preferred_width (CtkWidget *widget, |
113 | gint *minimum_width, |
114 | gint *natural_width); |
115 | static void ctk_revealer_real_get_preferred_width_for_height (CtkWidget *widget, |
116 | gint height, |
117 | gint *minimum_width, |
118 | gint *natural_width); |
119 | |
120 | G_DEFINE_TYPE_WITH_PRIVATE (CtkRevealer, ctk_revealer, CTK_TYPE_BIN)static void ctk_revealer_init (CtkRevealer *self); static void ctk_revealer_class_init (CtkRevealerClass *klass); static GType ctk_revealer_get_type_once (void); static gpointer ctk_revealer_parent_class = ((void*)0); static gint CtkRevealer_private_offset; static void ctk_revealer_class_intern_init (gpointer klass) { ctk_revealer_parent_class = g_type_class_peek_parent (klass); if (CtkRevealer_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkRevealer_private_offset ); ctk_revealer_class_init ((CtkRevealerClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_revealer_get_instance_private (CtkRevealer *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkRevealer_private_offset)))); } GType ctk_revealer_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_revealer_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_revealer_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( ctk_bin_get_type ()), g_intern_static_string ("CtkRevealer"), sizeof (CtkRevealerClass), (GClassInitFunc)(void (*)(void)) ctk_revealer_class_intern_init , sizeof (CtkRevealer), (GInstanceInitFunc)(void (*)(void)) ctk_revealer_init , (GTypeFlags) 0); { {{ CtkRevealer_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkRevealerPrivate)); };} } return g_define_type_id; } |
121 | |
122 | static void |
123 | ctk_revealer_get_padding (CtkRevealer *revealer, |
124 | CtkBorder *padding) |
125 | { |
126 | CtkWidget *widget = CTK_WIDGET (revealer)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((revealer)), ((ctk_widget_get_type ())))))); |
127 | CtkStyleContext *context; |
128 | CtkStateFlags state; |
129 | |
130 | context = ctk_widget_get_style_context (widget); |
131 | state = ctk_style_context_get_state (context); |
132 | |
133 | ctk_style_context_get_padding (context, state, padding); |
134 | } |
135 | |
136 | static void |
137 | ctk_revealer_init (CtkRevealer *revealer) |
138 | { |
139 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
140 | |
141 | priv->transition_type = CTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN; |
142 | priv->transition_duration = 250; |
143 | priv->current_pos = 0.0; |
144 | priv->target_pos = 0.0; |
145 | |
146 | ctk_widget_set_has_window ((CtkWidget*) revealer, TRUE(!(0))); |
147 | } |
148 | |
149 | static void |
150 | ctk_revealer_finalize (GObject *obj) |
151 | { |
152 | CtkRevealer *revealer = CTK_REVEALER (obj)((((CtkRevealer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((obj)), ((ctk_revealer_get_type ())))))); |
153 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
154 | |
155 | if (priv->tick_id != 0) |
156 | ctk_widget_remove_tick_callback (CTK_WIDGET (revealer)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((revealer)), ((ctk_widget_get_type ())))))), priv->tick_id); |
157 | priv->tick_id = 0; |
158 | |
159 | G_OBJECT_CLASS (ctk_revealer_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_revealer_parent_class)), (((GType) ((20) << (2 ))))))))->finalize (obj); |
160 | } |
161 | |
162 | static void |
163 | ctk_revealer_get_property (GObject *object, |
164 | guint property_id, |
165 | GValue *value, |
166 | GParamSpec *pspec) |
167 | { |
168 | CtkRevealer *revealer = CTK_REVEALER (object)((((CtkRevealer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_revealer_get_type ())))))); |
169 | |
170 | switch (property_id) |
171 | { |
172 | case PROP_TRANSITION_TYPE: |
173 | g_value_set_enum (value, ctk_revealer_get_transition_type (revealer)); |
174 | break; |
175 | case PROP_TRANSITION_DURATION: |
176 | g_value_set_uint (value, ctk_revealer_get_transition_duration (revealer)); |
177 | break; |
178 | case PROP_REVEAL_CHILD: |
179 | g_value_set_boolean (value, ctk_revealer_get_reveal_child (revealer)); |
180 | break; |
181 | case PROP_CHILD_REVEALED: |
182 | g_value_set_boolean (value, ctk_revealer_get_child_revealed (revealer)); |
183 | break; |
184 | default: |
185 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctkrevealer.c", 185, ("property"), _glib__property_id, _glib__pspec ->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) ( _glib__pspec))->g_class))->g_type)))), (g_type_name ((( (((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
186 | break; |
187 | } |
188 | } |
189 | |
190 | static void |
191 | ctk_revealer_set_property (GObject *object, |
192 | guint property_id, |
193 | const GValue *value, |
194 | GParamSpec *pspec) |
195 | { |
196 | CtkRevealer *revealer = CTK_REVEALER (object)((((CtkRevealer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_revealer_get_type ())))))); |
197 | |
198 | switch (property_id) |
199 | { |
200 | case PROP_TRANSITION_TYPE: |
201 | ctk_revealer_set_transition_type (revealer, g_value_get_enum (value)); |
202 | break; |
203 | case PROP_TRANSITION_DURATION: |
204 | ctk_revealer_set_transition_duration (revealer, g_value_get_uint (value)); |
205 | break; |
206 | case PROP_REVEAL_CHILD: |
207 | ctk_revealer_set_reveal_child (revealer, g_value_get_boolean (value)); |
208 | break; |
209 | default: |
210 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctkrevealer.c", 210, ("property"), _glib__property_id, _glib__pspec ->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) ( _glib__pspec))->g_class))->g_type)))), (g_type_name ((( (((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
211 | break; |
212 | } |
213 | } |
214 | |
215 | static void |
216 | ctk_revealer_class_init (CtkRevealerClass *klass) |
217 | { |
218 | GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))); |
219 | CtkWidgetClass *widget_class = CTK_WIDGET_CLASS(klass)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((ctk_widget_get_type ())))))); |
220 | CtkContainerClass *container_class = CTK_CONTAINER_CLASS (klass)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((ctk_container_get_type ())))))); |
221 | |
222 | object_class->get_property = ctk_revealer_get_property; |
223 | object_class->set_property = ctk_revealer_set_property; |
224 | object_class->finalize = ctk_revealer_finalize; |
225 | |
226 | widget_class->realize = ctk_revealer_real_realize; |
227 | widget_class->unrealize = ctk_revealer_real_unrealize; |
228 | widget_class->size_allocate = ctk_revealer_real_size_allocate; |
229 | widget_class->map = ctk_revealer_real_map; |
230 | widget_class->unmap = ctk_revealer_real_unmap; |
231 | widget_class->draw = ctk_revealer_real_draw; |
232 | widget_class->get_preferred_height = ctk_revealer_real_get_preferred_height; |
233 | widget_class->get_preferred_height_for_width = ctk_revealer_real_get_preferred_height_for_width; |
234 | widget_class->get_preferred_width = ctk_revealer_real_get_preferred_width; |
235 | widget_class->get_preferred_width_for_height = ctk_revealer_real_get_preferred_width_for_height; |
236 | |
237 | container_class->add = ctk_revealer_real_add; |
238 | |
239 | props[PROP_TRANSITION_TYPE] = |
240 | g_param_spec_enum ("transition-type", |
241 | P_("Transition type")g_dgettext("ctk30" "-properties","Transition type"), |
242 | P_("The type of animation used to transition")g_dgettext("ctk30" "-properties","The type of animation used to transition" ), |
243 | CTK_TYPE_REVEALER_TRANSITION_TYPE(ctk_revealer_transition_type_get_type ()), |
244 | CTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN, |
245 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_CONSTRUCT | G_PARAM_EXPLICIT_NOTIFY); |
246 | |
247 | props[PROP_TRANSITION_DURATION] = |
248 | g_param_spec_uint ("transition-duration", |
249 | P_("Transition duration")g_dgettext("ctk30" "-properties","Transition duration"), |
250 | P_("The animation duration, in milliseconds")g_dgettext("ctk30" "-properties","The animation duration, in milliseconds" ), |
251 | 0, G_MAXUINT(2147483647 *2U +1U), 250, |
252 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_CONSTRUCT | G_PARAM_EXPLICIT_NOTIFY); |
253 | |
254 | props[PROP_REVEAL_CHILD] = |
255 | g_param_spec_boolean ("reveal-child", |
256 | P_("Reveal Child")g_dgettext("ctk30" "-properties","Reveal Child"), |
257 | P_("Whether the container should reveal the child")g_dgettext("ctk30" "-properties","Whether the container should reveal the child" ), |
258 | FALSE(0), |
259 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_CONSTRUCT | G_PARAM_EXPLICIT_NOTIFY); |
260 | |
261 | props[PROP_CHILD_REVEALED] = |
262 | g_param_spec_boolean ("child-revealed", |
263 | P_("Child Revealed")g_dgettext("ctk30" "-properties","Child Revealed"), |
264 | P_("Whether the child is revealed and the animation target reached")g_dgettext("ctk30" "-properties","Whether the child is revealed and the animation target reached" ), |
265 | FALSE(0), |
266 | G_PARAM_READABLE); |
267 | |
268 | g_object_class_install_properties (object_class, LAST_PROP, props); |
269 | |
270 | ctk_widget_class_set_css_name (widget_class, "revealer"); |
271 | } |
272 | |
273 | /** |
274 | * ctk_revealer_new: |
275 | * |
276 | * Creates a new #CtkRevealer. |
277 | * |
278 | * Returns: a newly created #CtkRevealer |
279 | * |
280 | * Since: 3.10 |
281 | */ |
282 | CtkWidget * |
283 | ctk_revealer_new (void) |
284 | { |
285 | return g_object_new (CTK_TYPE_REVEALER(ctk_revealer_get_type ()), NULL((void*)0)); |
286 | } |
287 | |
288 | static CtkRevealerTransitionType |
289 | effective_transition (CtkRevealer *revealer) |
290 | { |
291 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
292 | |
293 | if (ctk_widget_get_direction (CTK_WIDGET (revealer)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((revealer)), ((ctk_widget_get_type ()))))))) == CTK_TEXT_DIR_RTL) |
294 | { |
295 | if (priv->transition_type == CTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT) |
296 | return CTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT; |
297 | else if (priv->transition_type == CTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT) |
298 | return CTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT; |
299 | } |
300 | |
301 | return priv->transition_type; |
302 | } |
303 | |
304 | static void |
305 | ctk_revealer_get_child_allocation (CtkRevealer *revealer, |
306 | CtkAllocation *allocation, |
307 | CtkAllocation *child_allocation) |
308 | { |
309 | CtkWidget *child; |
310 | CtkRevealerTransitionType transition; |
311 | CtkBorder padding; |
312 | gint vertical_padding, horizontal_padding; |
313 | |
314 | g_return_if_fail (revealer != NULL)do { if ((revealer != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "revealer != NULL"); return ; } } while (0); |
315 | g_return_if_fail (allocation != NULL)do { if ((allocation != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "allocation != NULL"); return ; } } while (0); |
316 | |
317 | /* See explanation on ctk_revealer_real_size_allocate */ |
318 | ctk_revealer_get_padding (revealer, &padding); |
319 | vertical_padding = padding.top + padding.bottom; |
320 | horizontal_padding = padding.left + padding.right; |
321 | |
322 | child_allocation->x = 0; |
323 | child_allocation->y = 0; |
324 | child_allocation->width = 0; |
325 | child_allocation->height = 0; |
326 | |
327 | child = ctk_bin_get_child (CTK_BIN (revealer)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((revealer)), ((ctk_bin_get_type ()))))))); |
328 | if (child != NULL((void*)0) && ctk_widget_get_visible (child)) |
329 | { |
330 | transition = effective_transition (revealer); |
331 | if (transition == CTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT || |
332 | transition == CTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT) |
333 | ctk_widget_get_preferred_width_for_height (child, MAX (0, allocation->height - vertical_padding)(((0) > (allocation->height - vertical_padding)) ? (0) : (allocation->height - vertical_padding)), NULL((void*)0), |
334 | &child_allocation->width); |
335 | else |
336 | ctk_widget_get_preferred_height_for_width (child, MAX (0, allocation->width - horizontal_padding)(((0) > (allocation->width - horizontal_padding)) ? (0) : (allocation->width - horizontal_padding)), NULL((void*)0), |
337 | &child_allocation->height); |
338 | } |
339 | |
340 | child_allocation->width = MAX (child_allocation->width, allocation->width - horizontal_padding)(((child_allocation->width) > (allocation->width - horizontal_padding )) ? (child_allocation->width) : (allocation->width - horizontal_padding )); |
341 | child_allocation->height = MAX (child_allocation->height, allocation->height - vertical_padding)(((child_allocation->height) > (allocation->height - vertical_padding)) ? (child_allocation->height) : (allocation ->height - vertical_padding)); |
342 | } |
343 | |
344 | static void |
345 | ctk_revealer_real_realize (CtkWidget *widget) |
346 | { |
347 | CtkRevealer *revealer = CTK_REVEALER (widget)((((CtkRevealer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_revealer_get_type ())))))); |
348 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
349 | CtkAllocation allocation; |
350 | CdkWindowAttr attributes = { 0 }; |
351 | CdkWindowAttributesType attributes_mask; |
352 | CtkAllocation child_allocation; |
353 | CtkWidget *child; |
354 | CtkRevealerTransitionType transition; |
355 | CtkBorder padding; |
356 | |
357 | ctk_widget_set_realized (widget, TRUE(!(0))); |
358 | |
359 | ctk_widget_get_allocation (widget, &allocation); |
360 | |
361 | attributes.x = allocation.x; |
362 | attributes.y = allocation.y; |
363 | attributes.width = allocation.width; |
364 | attributes.height = allocation.height; |
365 | attributes.window_type = CDK_WINDOW_CHILD; |
366 | attributes.wclass = CDK_INPUT_OUTPUT; |
367 | attributes.visual = ctk_widget_get_visual (widget); |
368 | attributes.event_mask = |
369 | ctk_widget_get_events (widget); |
370 | attributes_mask = (CDK_WA_X | CDK_WA_Y) | CDK_WA_VISUAL; |
371 | |
372 | priv->view_window = |
373 | cdk_window_new (ctk_widget_get_parent_window ((CtkWidget*) revealer), |
374 | &attributes, attributes_mask); |
375 | ctk_widget_set_window (widget, priv->view_window); |
376 | ctk_widget_register_window (widget, priv->view_window); |
377 | |
378 | ctk_revealer_get_child_allocation (revealer, &allocation, &child_allocation); |
379 | |
380 | ctk_revealer_get_padding (revealer, &padding); |
381 | attributes.x = 0; |
382 | attributes.y = 0; |
383 | attributes.width = child_allocation.width; |
384 | attributes.height = child_allocation.height; |
385 | |
386 | /* See explanation on ctk_revealer_real_size_allocate */ |
387 | transition = effective_transition (revealer); |
388 | if (transition == CTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN) |
389 | { |
390 | attributes.y = allocation.height - child_allocation.height - padding.bottom; |
391 | attributes.x = padding.left; |
392 | } |
393 | else if (transition == CTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT) |
394 | { |
395 | attributes.y = padding.top; |
396 | attributes.x = allocation.width - child_allocation.width - padding.right; |
397 | } |
398 | else |
399 | { |
400 | attributes.y = padding.top; |
401 | attributes.x = padding.left; |
402 | } |
403 | |
404 | priv->bin_window = |
405 | cdk_window_new (priv->view_window, &attributes, attributes_mask); |
406 | ctk_widget_register_window (widget, priv->bin_window); |
407 | |
408 | child = ctk_bin_get_child (CTK_BIN (revealer)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((revealer)), ((ctk_bin_get_type ()))))))); |
409 | if (child != NULL((void*)0)) |
410 | ctk_widget_set_parent_window (child, priv->bin_window); |
411 | |
412 | cdk_window_show (priv->bin_window); |
413 | } |
414 | |
415 | static void |
416 | ctk_revealer_real_unrealize (CtkWidget *widget) |
417 | { |
418 | CtkRevealer *revealer = CTK_REVEALER (widget)((((CtkRevealer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_revealer_get_type ())))))); |
419 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
420 | |
421 | ctk_widget_unregister_window (widget, priv->bin_window); |
422 | cdk_window_destroy (priv->bin_window); |
423 | priv->view_window = NULL((void*)0); |
424 | |
425 | CTK_WIDGET_CLASS (ctk_revealer_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_revealer_parent_class)), ((ctk_widget_get_type ()))) )))->unrealize (widget); |
426 | } |
427 | |
428 | static void |
429 | ctk_revealer_real_add (CtkContainer *container, |
430 | CtkWidget *child) |
431 | { |
432 | CtkRevealer *revealer = CTK_REVEALER (container)((((CtkRevealer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_revealer_get_type ())))))); |
433 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
434 | |
435 | g_return_if_fail (child != NULL)do { if ((child != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "child != NULL"); return ; } } while (0); |
436 | |
437 | ctk_widget_set_parent_window (child, priv->bin_window); |
438 | ctk_widget_set_child_visible (child, priv->current_pos != 0.0); |
439 | |
440 | CTK_CONTAINER_CLASS (ctk_revealer_parent_class)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_revealer_parent_class)), ((ctk_container_get_type () ))))))->add (container, child); |
441 | } |
442 | |
443 | static void |
444 | ctk_revealer_real_size_allocate (CtkWidget *widget, |
445 | CtkAllocation *allocation) |
446 | { |
447 | CtkRevealer *revealer = CTK_REVEALER (widget)((((CtkRevealer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_revealer_get_type ())))))); |
448 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
449 | CtkAllocation child_allocation; |
450 | CtkWidget *child; |
451 | gboolean window_visible; |
452 | CtkRevealerTransitionType transition; |
453 | CtkBorder padding; |
454 | |
455 | g_return_if_fail (allocation != NULL)do { if ((allocation != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "allocation != NULL"); return ; } } while (0); |
456 | |
457 | ctk_widget_set_allocation (widget, allocation); |
458 | ctk_revealer_get_child_allocation (revealer, allocation, &child_allocation); |
459 | |
460 | child = ctk_bin_get_child (CTK_BIN (revealer)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((revealer)), ((ctk_bin_get_type ()))))))); |
461 | if (child != NULL((void*)0) && ctk_widget_get_visible (child)) |
462 | ctk_widget_size_allocate (child, &child_allocation); |
463 | |
464 | if (ctk_widget_get_realized (widget)) |
465 | { |
466 | int bin_x, bin_y; |
467 | |
468 | if (ctk_widget_get_mapped (widget)) |
469 | { |
470 | window_visible = allocation->width > 0 && allocation->height > 0; |
471 | |
472 | if (!window_visible && cdk_window_is_visible (priv->view_window)) |
473 | cdk_window_hide (priv->view_window); |
474 | |
475 | if (window_visible && !cdk_window_is_visible (priv->view_window)) |
476 | cdk_window_show (priv->view_window); |
477 | } |
478 | |
479 | /* The view window will follow the revealer allocation, which is modified |
480 | * along the animation */ |
481 | cdk_window_move_resize (priv->view_window, |
482 | allocation->x, allocation->y, |
483 | allocation->width, allocation->height); |
484 | |
485 | ctk_revealer_get_padding (revealer, &padding); |
486 | bin_x = 0; |
Value stored to 'bin_x' is never read | |
487 | bin_y = 0; |
488 | |
489 | transition = effective_transition (revealer); |
490 | /* The child allocation is fixed (it is not modified by the animation), |
491 | * and it's origin is relative to the bin_window. |
492 | * The bin_window has the same allocation as the child, and then the bin_window |
493 | * deals with the relative positioning with respect to the revealer taking |
494 | * into account the paddings of the revealer. |
495 | * |
496 | * For most of transitions, the bin_window moves along with the revealer, |
497 | * as its allocation changes. |
498 | * However for CTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN |
499 | * we need to first move the bin_window upwards and then slide it down in |
500 | * the revealer. |
501 | * Otherwise the child would appear as static and the revealer will allocate |
502 | * following the animation, clipping the child. |
503 | * To calculate the correct y position for this case: |
504 | * allocation->height - child_allocation.height is the relative position |
505 | * towards the revealer taking into account the animation progress with |
506 | * both vertical paddings added, therefore we need to substract the part |
507 | * that we don't want to take into account for the y position, which |
508 | * in this case is the bottom padding. |
509 | * |
510 | * The same special treatment is needed for CTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT. |
511 | */ |
512 | if (transition == CTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN) |
513 | { |
514 | bin_y = allocation->height - child_allocation.height - padding.bottom; |
515 | bin_x = padding.left; |
516 | } |
517 | else if (transition == CTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT) |
518 | { |
519 | bin_y = padding.top; |
520 | bin_x = allocation->width - child_allocation.width - padding.right; |
521 | } |
522 | else |
523 | { |
524 | bin_x = padding.left; |
525 | bin_y = padding.top; |
526 | } |
527 | |
528 | cdk_window_move_resize (priv->bin_window, |
529 | bin_x, bin_y, |
530 | child_allocation.width, child_allocation.height); |
531 | } |
532 | } |
533 | |
534 | static void |
535 | ctk_revealer_set_position (CtkRevealer *revealer, |
536 | gdouble pos) |
537 | { |
538 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
539 | gboolean new_visible; |
540 | CtkWidget *child; |
541 | CtkRevealerTransitionType transition; |
542 | |
543 | priv->current_pos = pos; |
544 | |
545 | /* We check target_pos here too, because we want to ensure we set |
546 | * child_visible immediately when starting a reveal operation |
547 | * otherwise the child widgets will not be properly realized |
548 | * after the reveal returns. |
549 | */ |
550 | new_visible = priv->current_pos != 0.0 || priv->target_pos != 0.0; |
551 | |
552 | child = ctk_bin_get_child (CTK_BIN (revealer)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((revealer)), ((ctk_bin_get_type ()))))))); |
553 | if (child != NULL((void*)0) && |
554 | new_visible != ctk_widget_get_child_visible (child)) |
555 | ctk_widget_set_child_visible (child, new_visible); |
556 | |
557 | transition = effective_transition (revealer); |
558 | if (transition == CTK_REVEALER_TRANSITION_TYPE_CROSSFADE) |
559 | { |
560 | ctk_widget_set_opacity (CTK_WIDGET (revealer)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((revealer)), ((ctk_widget_get_type ())))))), priv->current_pos); |
561 | ctk_widget_queue_draw (CTK_WIDGET (revealer)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((revealer)), ((ctk_widget_get_type ()))))))); |
562 | } |
563 | else |
564 | { |
565 | ctk_widget_queue_resize (CTK_WIDGET (revealer)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((revealer)), ((ctk_widget_get_type ()))))))); |
566 | } |
567 | |
568 | if (priv->current_pos == priv->target_pos) |
569 | g_object_notify_by_pspec (G_OBJECT (revealer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((revealer)), (((GType) ((20) << (2)))))))), props[PROP_CHILD_REVEALED]); |
570 | } |
571 | |
572 | static gboolean |
573 | ctk_revealer_animate_cb (CtkWidget *widget, |
574 | CdkFrameClock *frame_clock, |
575 | gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__))) |
576 | { |
577 | CtkRevealer *revealer = CTK_REVEALER (widget)((((CtkRevealer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_revealer_get_type ())))))); |
578 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
579 | gdouble ease; |
580 | |
581 | ctk_progress_tracker_advance_frame (&priv->tracker, |
582 | cdk_frame_clock_get_frame_time (frame_clock)); |
583 | ease = ctk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE(0)); |
584 | ctk_revealer_set_position (revealer, |
585 | priv->source_pos + (ease * (priv->target_pos - priv->source_pos))); |
586 | |
587 | if (ctk_progress_tracker_get_state (&priv->tracker) == CTK_PROGRESS_STATE_AFTER) |
588 | { |
589 | priv->tick_id = 0; |
590 | return FALSE(0); |
591 | } |
592 | |
593 | return TRUE(!(0)); |
594 | } |
595 | |
596 | static void |
597 | ctk_revealer_start_animation (CtkRevealer *revealer, |
598 | gdouble target) |
599 | { |
600 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
601 | CtkWidget *widget = CTK_WIDGET (revealer)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((revealer)), ((ctk_widget_get_type ())))))); |
602 | CtkRevealerTransitionType transition; |
603 | |
604 | if (priv->target_pos == target) |
605 | return; |
606 | |
607 | priv->target_pos = target; |
608 | g_object_notify_by_pspec (G_OBJECT (revealer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((revealer)), (((GType) ((20) << (2)))))))), props[PROP_REVEAL_CHILD]); |
609 | |
610 | transition = effective_transition (revealer); |
611 | if (ctk_widget_get_mapped (widget) && |
612 | priv->transition_duration != 0 && |
613 | transition != CTK_REVEALER_TRANSITION_TYPE_NONE && |
614 | ctk_settings_get_enable_animations (ctk_widget_get_settings (widget))) |
615 | { |
616 | priv->source_pos = priv->current_pos; |
617 | if (priv->tick_id == 0) |
618 | priv->tick_id = |
619 | ctk_widget_add_tick_callback (widget, ctk_revealer_animate_cb, revealer, NULL((void*)0)); |
620 | ctk_progress_tracker_start (&priv->tracker, |
621 | priv->transition_duration * 1000, |
622 | 0, |
623 | 1.0); |
624 | } |
625 | else |
626 | { |
627 | ctk_revealer_set_position (revealer, target); |
628 | } |
629 | } |
630 | |
631 | static void |
632 | ctk_revealer_stop_animation (CtkRevealer *revealer) |
633 | { |
634 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
635 | if (priv->current_pos != priv->target_pos) |
636 | ctk_revealer_set_position (revealer, priv->target_pos); |
637 | if (priv->tick_id != 0) |
638 | { |
639 | ctk_widget_remove_tick_callback (CTK_WIDGET (revealer)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((revealer)), ((ctk_widget_get_type ())))))), priv->tick_id); |
640 | priv->tick_id = 0; |
641 | } |
642 | } |
643 | |
644 | static void |
645 | ctk_revealer_real_map (CtkWidget *widget) |
646 | { |
647 | CtkRevealer *revealer = CTK_REVEALER (widget)((((CtkRevealer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_revealer_get_type ())))))); |
648 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
649 | CtkAllocation allocation; |
650 | |
651 | if (!ctk_widget_get_mapped (widget)) |
652 | { |
653 | ctk_widget_get_allocation (widget, &allocation); |
654 | |
655 | if (allocation.width > 0 && allocation.height > 0) |
656 | cdk_window_show (priv->view_window); |
657 | } |
658 | |
659 | CTK_WIDGET_CLASS (ctk_revealer_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_revealer_parent_class)), ((ctk_widget_get_type ()))) )))->map (widget); |
660 | } |
661 | |
662 | static void |
663 | ctk_revealer_real_unmap (CtkWidget *widget) |
664 | { |
665 | CtkRevealer *revealer = CTK_REVEALER (widget)((((CtkRevealer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_revealer_get_type ())))))); |
666 | |
667 | CTK_WIDGET_CLASS (ctk_revealer_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_revealer_parent_class)), ((ctk_widget_get_type ()))) )))->unmap (widget); |
668 | |
669 | ctk_revealer_stop_animation (revealer); |
670 | } |
671 | |
672 | static gboolean |
673 | ctk_revealer_real_draw (CtkWidget *widget, |
674 | cairo_t *cr) |
675 | { |
676 | CtkRevealer *revealer = CTK_REVEALER (widget)((((CtkRevealer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_revealer_get_type ())))))); |
677 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
678 | |
679 | if (ctk_cairo_should_draw_window (cr, priv->bin_window)) |
680 | CTK_WIDGET_CLASS (ctk_revealer_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_revealer_parent_class)), ((ctk_widget_get_type ()))) )))->draw (widget, cr); |
681 | |
682 | return CDK_EVENT_PROPAGATE((0)); |
683 | } |
684 | |
685 | /** |
686 | * ctk_revealer_set_reveal_child: |
687 | * @revealer: a #CtkRevealer |
688 | * @reveal_child: %TRUE to reveal the child |
689 | * |
690 | * Tells the #CtkRevealer to reveal or conceal its child. |
691 | * |
692 | * The transition will be animated with the current |
693 | * transition type of @revealer. |
694 | * |
695 | * Since: 3.10 |
696 | */ |
697 | void |
698 | ctk_revealer_set_reveal_child (CtkRevealer *revealer, |
699 | gboolean reveal_child) |
700 | { |
701 | g_return_if_fail (CTK_IS_REVEALER (revealer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((revealer)); GType __t = ((ctk_revealer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_REVEALER (revealer)"); return; } } while (0); |
702 | |
703 | if (reveal_child) |
704 | ctk_revealer_start_animation (revealer, 1.0); |
705 | else |
706 | ctk_revealer_start_animation (revealer, 0.0); |
707 | } |
708 | |
709 | /** |
710 | * ctk_revealer_get_reveal_child: |
711 | * @revealer: a #CtkRevealer |
712 | * |
713 | * Returns whether the child is currently |
714 | * revealed. See ctk_revealer_set_reveal_child(). |
715 | * |
716 | * This function returns %TRUE as soon as the transition |
717 | * is to the revealed state is started. To learn whether |
718 | * the child is fully revealed (ie the transition is completed), |
719 | * use ctk_revealer_get_child_revealed(). |
720 | * |
721 | * Returns: %TRUE if the child is revealed. |
722 | * |
723 | * Since: 3.10 |
724 | */ |
725 | gboolean |
726 | ctk_revealer_get_reveal_child (CtkRevealer *revealer) |
727 | { |
728 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
729 | |
730 | g_return_val_if_fail (CTK_IS_REVEALER (revealer), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((revealer)); GType __t = ((ctk_revealer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_REVEALER (revealer)"); return ((0)); } } while (0 ); |
731 | |
732 | return priv->target_pos != 0.0; |
733 | } |
734 | |
735 | /** |
736 | * ctk_revealer_get_child_revealed: |
737 | * @revealer: a #CtkRevealer |
738 | * |
739 | * Returns whether the child is fully revealed, in other words whether |
740 | * the transition to the revealed state is completed. |
741 | * |
742 | * Returns: %TRUE if the child is fully revealed |
743 | * |
744 | * Since: 3.10 |
745 | */ |
746 | gboolean |
747 | ctk_revealer_get_child_revealed (CtkRevealer *revealer) |
748 | { |
749 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
750 | gboolean animation_finished = (priv->target_pos == priv->current_pos); |
751 | gboolean reveal_child = ctk_revealer_get_reveal_child (revealer); |
752 | |
753 | if (animation_finished) |
754 | return reveal_child; |
755 | else |
756 | return !reveal_child; |
757 | } |
758 | |
759 | /* These all report only the natural size, ignoring the minimal size, |
760 | * because its not really possible to allocate the right size during |
761 | * animation if the child size can change (without the child |
762 | * re-arranging itself during the animation). |
763 | */ |
764 | |
765 | static void |
766 | set_height_with_paddings (CtkRevealer *revealer, |
767 | gint preferred_minimum_height, |
768 | gint preferred_natural_height, |
769 | gint *minimum_height_out, |
770 | gint *natural_height_out) |
771 | { |
772 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
773 | gint minimum_height; |
774 | gint natural_height; |
775 | CtkRevealerTransitionType transition; |
776 | CtkBorder padding; |
777 | gint vertical_padding; |
778 | |
779 | ctk_revealer_get_padding (revealer, &padding); |
780 | vertical_padding = padding.top + padding.bottom; |
781 | minimum_height = preferred_minimum_height + vertical_padding; |
782 | natural_height = preferred_natural_height + vertical_padding; |
783 | |
784 | transition = effective_transition (revealer); |
785 | if (transition == CTK_REVEALER_TRANSITION_TYPE_NONE || |
786 | transition == CTK_REVEALER_TRANSITION_TYPE_SLIDE_UP || |
787 | transition == CTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN) |
788 | { |
789 | /* Padding are included in the animation */ |
790 | minimum_height = round (minimum_height * priv->current_pos); |
791 | natural_height = round (natural_height * priv->current_pos); |
792 | } |
793 | |
794 | *minimum_height_out = MIN (minimum_height, natural_height)(((minimum_height) < (natural_height)) ? (minimum_height) : (natural_height)); |
795 | *natural_height_out = natural_height; |
796 | } |
797 | |
798 | static void |
799 | ctk_revealer_real_get_preferred_height (CtkWidget *widget, |
800 | gint *minimum_height_out, |
801 | gint *natural_height_out) |
802 | { |
803 | CtkRevealer *revealer = CTK_REVEALER (widget)((((CtkRevealer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_revealer_get_type ())))))); |
804 | gint minimum_height; |
805 | gint natural_height; |
806 | |
807 | CTK_WIDGET_CLASS (ctk_revealer_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_revealer_parent_class)), ((ctk_widget_get_type ()))) )))->get_preferred_height (widget, &minimum_height, &natural_height); |
808 | |
809 | set_height_with_paddings (revealer, minimum_height, natural_height, |
810 | minimum_height_out, natural_height_out); |
811 | } |
812 | |
813 | static void |
814 | ctk_revealer_real_get_preferred_height_for_width (CtkWidget *widget, |
815 | gint width, |
816 | gint *minimum_height_out, |
817 | gint *natural_height_out) |
818 | { |
819 | CtkRevealer *revealer = CTK_REVEALER (widget)((((CtkRevealer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_revealer_get_type ())))))); |
820 | gint minimum_height; |
821 | gint natural_height; |
822 | |
823 | CTK_WIDGET_CLASS (ctk_revealer_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_revealer_parent_class)), ((ctk_widget_get_type ()))) )))->get_preferred_height_for_width (widget, width, &minimum_height, &natural_height); |
824 | |
825 | set_height_with_paddings (revealer, minimum_height, natural_height, |
826 | minimum_height_out, natural_height_out); |
827 | } |
828 | |
829 | static void |
830 | set_width_with_paddings (CtkRevealer *revealer, |
831 | gint preferred_minimum_width, |
832 | gint preferred_natural_width, |
833 | gint *minimum_width_out, |
834 | gint *natural_width_out) |
835 | { |
836 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
837 | gint minimum_width; |
838 | gint natural_width; |
839 | CtkRevealerTransitionType transition; |
840 | CtkBorder padding; |
841 | gint horizontal_padding; |
842 | |
843 | ctk_revealer_get_padding (revealer, &padding); |
844 | horizontal_padding = padding.left + padding.right; |
845 | minimum_width = preferred_minimum_width + horizontal_padding; |
846 | natural_width = preferred_natural_width + horizontal_padding; |
847 | |
848 | transition = effective_transition (revealer); |
849 | if (transition == CTK_REVEALER_TRANSITION_TYPE_NONE || |
850 | transition == CTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT || |
851 | transition == CTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT) |
852 | { |
853 | /* Paddings are included in the animation */ |
854 | minimum_width = round (minimum_width * priv->current_pos); |
855 | natural_width = round (natural_width * priv->current_pos); |
856 | } |
857 | |
858 | *minimum_width_out = MIN (minimum_width, natural_width)(((minimum_width) < (natural_width)) ? (minimum_width) : ( natural_width)); |
859 | *natural_width_out = natural_width; |
860 | } |
861 | |
862 | static void |
863 | ctk_revealer_real_get_preferred_width (CtkWidget *widget, |
864 | gint *minimum_width_out, |
865 | gint *natural_width_out) |
866 | { |
867 | CtkRevealer *revealer = CTK_REVEALER (widget)((((CtkRevealer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_revealer_get_type ())))))); |
868 | gint minimum_width; |
869 | gint natural_width; |
870 | |
871 | CTK_WIDGET_CLASS (ctk_revealer_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_revealer_parent_class)), ((ctk_widget_get_type ()))) )))->get_preferred_width (widget, &minimum_width, &natural_width); |
872 | set_width_with_paddings (revealer, minimum_width, natural_width, |
873 | minimum_width_out, natural_width_out); |
874 | } |
875 | |
876 | static void |
877 | ctk_revealer_real_get_preferred_width_for_height (CtkWidget *widget, |
878 | gint height, |
879 | gint *minimum_width_out, |
880 | gint *natural_width_out) |
881 | { |
882 | CtkRevealer *revealer = CTK_REVEALER (widget)((((CtkRevealer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_revealer_get_type ())))))); |
883 | gint minimum_width; |
884 | gint natural_width; |
885 | |
886 | CTK_WIDGET_CLASS (ctk_revealer_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_revealer_parent_class)), ((ctk_widget_get_type ()))) )))->get_preferred_width_for_height (widget, height, &minimum_width, &natural_width); |
887 | |
888 | set_width_with_paddings (revealer, minimum_width, natural_width, |
889 | minimum_width_out, natural_width_out); |
890 | } |
891 | |
892 | /** |
893 | * ctk_revealer_get_transition_duration: |
894 | * @revealer: a #CtkRevealer |
895 | * |
896 | * Returns the amount of time (in milliseconds) that |
897 | * transitions will take. |
898 | * |
899 | * Returns: the transition duration |
900 | * |
901 | * Since: 3.10 |
902 | */ |
903 | guint |
904 | ctk_revealer_get_transition_duration (CtkRevealer *revealer) |
905 | { |
906 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
907 | |
908 | g_return_val_if_fail (CTK_IS_REVEALER (revealer), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((revealer)); GType __t = ((ctk_revealer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_REVEALER (revealer)"); return (0); } } while (0); |
909 | |
910 | return priv->transition_duration; |
911 | } |
912 | |
913 | /** |
914 | * ctk_revealer_set_transition_duration: |
915 | * @revealer: a #CtkRevealer |
916 | * @duration: the new duration, in milliseconds |
917 | * |
918 | * Sets the duration that transitions will take. |
919 | * |
920 | * Since: 3.10 |
921 | */ |
922 | void |
923 | ctk_revealer_set_transition_duration (CtkRevealer *revealer, |
924 | guint value) |
925 | { |
926 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
927 | |
928 | g_return_if_fail (CTK_IS_REVEALER (revealer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((revealer)); GType __t = ((ctk_revealer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_REVEALER (revealer)"); return; } } while (0); |
929 | |
930 | if (priv->transition_duration == value) |
931 | return; |
932 | |
933 | priv->transition_duration = value; |
934 | g_object_notify_by_pspec (G_OBJECT (revealer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((revealer)), (((GType) ((20) << (2)))))))), props[PROP_TRANSITION_DURATION]); |
935 | } |
936 | |
937 | /** |
938 | * ctk_revealer_get_transition_type: |
939 | * @revealer: a #CtkRevealer |
940 | * |
941 | * Gets the type of animation that will be used |
942 | * for transitions in @revealer. |
943 | * |
944 | * Returns: the current transition type of @revealer |
945 | * |
946 | * Since: 3.10 |
947 | */ |
948 | CtkRevealerTransitionType |
949 | ctk_revealer_get_transition_type (CtkRevealer *revealer) |
950 | { |
951 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
952 | |
953 | g_return_val_if_fail (CTK_IS_REVEALER (revealer), CTK_REVEALER_TRANSITION_TYPE_NONE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((revealer)); GType __t = ((ctk_revealer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_REVEALER (revealer)"); return (CTK_REVEALER_TRANSITION_TYPE_NONE ); } } while (0); |
954 | |
955 | return priv->transition_type; |
956 | } |
957 | |
958 | /** |
959 | * ctk_revealer_set_transition_type: |
960 | * @revealer: a #CtkRevealer |
961 | * @transition: the new transition type |
962 | * |
963 | * Sets the type of animation that will be used for |
964 | * transitions in @revealer. Available types include |
965 | * various kinds of fades and slides. |
966 | * |
967 | * Since: 3.10 |
968 | */ |
969 | void |
970 | ctk_revealer_set_transition_type (CtkRevealer *revealer, |
971 | CtkRevealerTransitionType transition) |
972 | { |
973 | CtkRevealerPrivate *priv = ctk_revealer_get_instance_private (revealer); |
974 | |
975 | g_return_if_fail (CTK_IS_REVEALER (revealer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((revealer)); GType __t = ((ctk_revealer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_REVEALER (revealer)"); return; } } while (0); |
976 | |
977 | if (priv->transition_type == transition) |
978 | return; |
979 | |
980 | priv->transition_type = transition; |
981 | ctk_widget_queue_resize (CTK_WIDGET (revealer)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((revealer)), ((ctk_widget_get_type ()))))))); |
982 | g_object_notify_by_pspec (G_OBJECT (revealer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((revealer)), (((GType) ((20) << (2)))))))), props[PROP_TRANSITION_TYPE]); |
983 | } |