app: allow to position overlay widgets absolutely
This commit is contained in:
@ -363,10 +363,10 @@ gimp_overlay_box_add_child (GimpOverlayBox *box,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_overlay_box_set_child_packing (GimpOverlayBox *box,
|
gimp_overlay_box_set_child_alignment (GimpOverlayBox *box,
|
||||||
GtkWidget *widget,
|
GtkWidget *widget,
|
||||||
gdouble xalign,
|
gdouble xalign,
|
||||||
gdouble yalign)
|
gdouble yalign)
|
||||||
{
|
{
|
||||||
GimpOverlayChild *child = gimp_overlay_child_find (box, widget);
|
GimpOverlayChild *child = gimp_overlay_child_find (box, widget);
|
||||||
|
|
||||||
@ -375,13 +375,40 @@ gimp_overlay_box_set_child_packing (GimpOverlayBox *box,
|
|||||||
xalign = CLAMP (xalign, 0.0, 1.0);
|
xalign = CLAMP (xalign, 0.0, 1.0);
|
||||||
yalign = CLAMP (yalign, 0.0, 1.0);
|
yalign = CLAMP (yalign, 0.0, 1.0);
|
||||||
|
|
||||||
if (child->xalign != xalign ||
|
if (child->has_position ||
|
||||||
|
child->xalign != xalign ||
|
||||||
child->yalign != yalign)
|
child->yalign != yalign)
|
||||||
{
|
{
|
||||||
gimp_overlay_child_invalidate (box, child);
|
gimp_overlay_child_invalidate (box, child);
|
||||||
|
|
||||||
child->xalign = xalign;
|
child->has_position = FALSE;
|
||||||
child->yalign = yalign;
|
child->xalign = xalign;
|
||||||
|
child->yalign = yalign;
|
||||||
|
|
||||||
|
gtk_widget_queue_resize (widget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_overlay_box_set_child_position (GimpOverlayBox *box,
|
||||||
|
GtkWidget *widget,
|
||||||
|
gdouble x,
|
||||||
|
gdouble y)
|
||||||
|
{
|
||||||
|
GimpOverlayChild *child = gimp_overlay_child_find (box, widget);
|
||||||
|
|
||||||
|
if (child)
|
||||||
|
{
|
||||||
|
if (! child->has_position ||
|
||||||
|
child->x != x ||
|
||||||
|
child->y != y)
|
||||||
|
{
|
||||||
|
gimp_overlay_child_invalidate (box, child);
|
||||||
|
|
||||||
|
child->has_position = TRUE;
|
||||||
|
child->x = x;
|
||||||
|
child->y = y;
|
||||||
|
|
||||||
gtk_widget_queue_resize (widget);
|
gtk_widget_queue_resize (widget);
|
||||||
}
|
}
|
||||||
@ -453,13 +480,21 @@ gimp_overlay_box_scroll (GimpOverlayBox *box,
|
|||||||
|
|
||||||
/* Undraw all overlays */
|
/* Undraw all overlays */
|
||||||
for (list = box->children; list; list = g_list_next (list))
|
for (list = box->children; list; list = g_list_next (list))
|
||||||
gimp_overlay_child_invalidate (box, list->data);
|
{
|
||||||
|
GimpOverlayChild *child = list->data;
|
||||||
|
|
||||||
|
gimp_overlay_child_invalidate (box, child);
|
||||||
|
}
|
||||||
|
|
||||||
gdk_window_scroll (window, offset_x, offset_y);
|
gdk_window_scroll (window, offset_x, offset_y);
|
||||||
|
|
||||||
/* Re-draw all overlays */
|
/* Re-draw all overlays */
|
||||||
for (list = box->children; list; list = g_list_next (list))
|
for (list = box->children; list; list = g_list_next (list))
|
||||||
gimp_overlay_child_invalidate (box, list->data);
|
{
|
||||||
|
GimpOverlayChild *child = list->data;
|
||||||
|
|
||||||
|
gimp_overlay_child_invalidate (box, child);
|
||||||
|
}
|
||||||
|
|
||||||
/* Make sure expose events are processed before scrolling again */
|
/* Make sure expose events are processed before scrolling again */
|
||||||
gdk_window_process_updates (window, FALSE);
|
gdk_window_process_updates (window, FALSE);
|
||||||
|
@ -45,28 +45,32 @@ struct _GimpOverlayBoxClass
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
GType gimp_overlay_box_get_type (void) G_GNUC_CONST;
|
GType gimp_overlay_box_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GtkWidget * gimp_overlay_box_new (void);
|
GtkWidget * gimp_overlay_box_new (void);
|
||||||
|
|
||||||
void gimp_overlay_box_add_child (GimpOverlayBox *canvas,
|
void gimp_overlay_box_add_child (GimpOverlayBox *box,
|
||||||
GtkWidget *child,
|
GtkWidget *child,
|
||||||
gdouble xalign,
|
gdouble xalign,
|
||||||
gdouble yalign);
|
gdouble yalign);
|
||||||
void gimp_overlay_box_set_child_packing (GimpOverlayBox *canvas,
|
void gimp_overlay_box_set_child_alignment (GimpOverlayBox *box,
|
||||||
GtkWidget *child,
|
GtkWidget *child,
|
||||||
gdouble xalign,
|
gdouble xalign,
|
||||||
gdouble yalign);
|
gdouble yalign);
|
||||||
void gimp_overlay_box_set_child_angle (GimpOverlayBox *canvas,
|
void gimp_overlay_box_set_child_position (GimpOverlayBox *box,
|
||||||
GtkWidget *child,
|
GtkWidget *child,
|
||||||
gdouble angle);
|
gdouble x,
|
||||||
void gimp_overlay_box_set_child_opacity (GimpOverlayBox *canvas,
|
gdouble y);
|
||||||
GtkWidget *child,
|
void gimp_overlay_box_set_child_angle (GimpOverlayBox *box,
|
||||||
gdouble opacity);
|
GtkWidget *child,
|
||||||
|
gdouble angle);
|
||||||
|
void gimp_overlay_box_set_child_opacity (GimpOverlayBox *box,
|
||||||
|
GtkWidget *child,
|
||||||
|
gdouble opacity);
|
||||||
|
|
||||||
void gimp_overlay_box_scroll (GimpOverlayBox *canvas,
|
void gimp_overlay_box_scroll (GimpOverlayBox *box,
|
||||||
gint offset_x,
|
gint offset_x,
|
||||||
gint offset_y);
|
gint offset_y);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_OVERLAY_BOX_H__ */
|
#endif /* __GIMP_OVERLAY_BOX_H__ */
|
||||||
|
@ -69,11 +69,14 @@ gimp_overlay_child_new (GimpOverlayBox *box,
|
|||||||
|
|
||||||
child = g_slice_new0 (GimpOverlayChild);
|
child = g_slice_new0 (GimpOverlayChild);
|
||||||
|
|
||||||
child->widget = widget;
|
child->widget = widget;
|
||||||
child->xalign = CLAMP (xalign, 0.0, 1.0);
|
child->xalign = CLAMP (xalign, 0.0, 1.0);
|
||||||
child->yalign = CLAMP (yalign, 0.0, 1.0);
|
child->yalign = CLAMP (yalign, 0.0, 1.0);
|
||||||
child->angle = angle;
|
child->x = 0.0;
|
||||||
child->opacity = CLAMP (opacity, 0.0, 1.0);
|
child->y = 0.0;
|
||||||
|
child->has_position = FALSE;
|
||||||
|
child->angle = angle;
|
||||||
|
child->opacity = CLAMP (opacity, 0.0, 1.0);
|
||||||
|
|
||||||
cairo_matrix_init_identity (&child->matrix);
|
cairo_matrix_init_identity (&child->matrix);
|
||||||
|
|
||||||
@ -271,14 +274,22 @@ gimp_overlay_child_size_allocate (GimpOverlayBox *box,
|
|||||||
available_width = allocation.width - 2 * border;
|
available_width = allocation.width - 2 * border;
|
||||||
available_height = allocation.height - 2 * border;
|
available_height = allocation.height - 2 * border;
|
||||||
|
|
||||||
x = border;
|
if (child->has_position)
|
||||||
y = border;
|
{
|
||||||
|
x = child->x;
|
||||||
|
y = child->y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = border;
|
||||||
|
y = border;
|
||||||
|
|
||||||
if (available_width > bounds.width)
|
if (available_width > bounds.width)
|
||||||
x += child->xalign * (available_width - bounds.width) - bounds.x;
|
x += child->xalign * (available_width - bounds.width) - bounds.x;
|
||||||
|
|
||||||
if (available_height > bounds.height)
|
if (available_height > bounds.height)
|
||||||
y += child->yalign * (available_height - bounds.height) - bounds.y;
|
y += child->yalign * (available_height - bounds.height) - bounds.y;
|
||||||
|
}
|
||||||
|
|
||||||
cairo_matrix_init_translate (&child->matrix, x, y);
|
cairo_matrix_init_translate (&child->matrix, x, y);
|
||||||
|
|
||||||
|
@ -29,8 +29,13 @@ struct _GimpOverlayChild
|
|||||||
{
|
{
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GdkWindow *window;
|
GdkWindow *window;
|
||||||
|
|
||||||
|
gboolean has_position;
|
||||||
gdouble xalign;
|
gdouble xalign;
|
||||||
gdouble yalign;
|
gdouble yalign;
|
||||||
|
gdouble x;
|
||||||
|
gdouble y;
|
||||||
|
|
||||||
gdouble angle;
|
gdouble angle;
|
||||||
gdouble opacity;
|
gdouble opacity;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user