image: Implement clipping support for icon-shadow
Testcase is attached.
This commit is contained in:
@ -38,6 +38,9 @@
|
||||
#include "gtkintl.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkcssshadowsvalueprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
#include "a11y/gtkimageaccessible.h"
|
||||
|
||||
@ -146,6 +149,8 @@ struct _GtkImagePrivate
|
||||
#define DEFAULT_ICON_SIZE GTK_ICON_SIZE_BUTTON
|
||||
static gint gtk_image_draw (GtkWidget *widget,
|
||||
cairo_t *cr);
|
||||
static void gtk_image_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation*allocation);
|
||||
static void gtk_image_unmap (GtkWidget *widget);
|
||||
static void gtk_image_realize (GtkWidget *widget);
|
||||
static void gtk_image_unrealize (GtkWidget *widget);
|
||||
@ -218,6 +223,7 @@ gtk_image_class_init (GtkImageClass *class)
|
||||
widget_class->get_preferred_width = gtk_image_get_preferred_width;
|
||||
widget_class->get_preferred_height = gtk_image_get_preferred_height;
|
||||
widget_class->get_preferred_height_and_baseline_for_width = gtk_image_get_preferred_height_and_baseline_for_width;
|
||||
widget_class->size_allocate = gtk_image_size_allocate;
|
||||
widget_class->unmap = gtk_image_unmap;
|
||||
widget_class->realize = gtk_image_realize;
|
||||
widget_class->unrealize = gtk_image_unrealize;
|
||||
@ -1522,6 +1528,26 @@ gtk_image_reset_anim_iter (GtkImage *image)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_image_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
{
|
||||
GtkBorder extents;
|
||||
GtkAllocation clip;
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_image_parent_class)->size_allocate (widget, allocation);
|
||||
|
||||
/* XXX: This is not strictly correct, we could compute the area
|
||||
* actually occupied by the image, but I'm lazy...
|
||||
*/
|
||||
_gtk_css_shadows_value_get_extents (_gtk_style_context_peek_property (gtk_widget_get_style_context (widget), GTK_CSS_PROPERTY_ICON_SHADOW), &extents);
|
||||
clip.x = allocation->x - extents.left;
|
||||
clip.width = allocation->width + extents.left + extents.right;
|
||||
clip.y = allocation->y - extents.top;
|
||||
clip.height = allocation->height + extents.top + extents.bottom;
|
||||
_gtk_widget_set_simple_clip (widget, &clip);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_image_unmap (GtkWidget *widget)
|
||||
{
|
||||
|
||||
@ -268,6 +268,9 @@ testdata = \
|
||||
iconview-empty.css \
|
||||
iconview-empty.ui \
|
||||
iconview-empty.ref.ui \
|
||||
image-icon-shadow-clipping.css \
|
||||
image-icon-shadow-clipping.ref.ui \
|
||||
image-icon-shadow-clipping.ui \
|
||||
image-load-from-file.css \
|
||||
image-load-from-file.ref.ui \
|
||||
image-load-from-file.ui \
|
||||
|
||||
5
testsuite/reftests/image-icon-shadow-clipping.css
Normal file
5
testsuite/reftests/image-icon-shadow-clipping.css
Normal file
@ -0,0 +1,5 @@
|
||||
@import "reset-to-defaults.css";
|
||||
|
||||
GtkImage {
|
||||
icon-shadow: 20px 20px tomato;
|
||||
}
|
||||
18
testsuite/reftests/image-icon-shadow-clipping.ref.ui
Normal file
18
testsuite/reftests/image-icon-shadow-clipping.ref.ui
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.18.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.12"/>
|
||||
<object class="GtkWindow" id="window1">
|
||||
<property name="width_request">100</property>
|
||||
<property name="height_request">100</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="type">popup</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">edit-delete</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
32
testsuite/reftests/image-icon-shadow-clipping.ui
Normal file
32
testsuite/reftests/image-icon-shadow-clipping.ui
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.18.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.12"/>
|
||||
<object class="GtkWindow" id="window1">
|
||||
<property name="width_request">100</property>
|
||||
<property name="height_request">100</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="type">popup</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">edit-delete</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
Reference in New Issue
Block a user