forked from AuroraMiddleware/gtk
label: Don't clip text shadows
The previous code for computing the clip rectangle forgot to respect the text-shadow CSS property. This is usually not very visible because text shadows usually don't extend the ink rectangle by very much. See attached testcase for an example.
This commit is contained in:
parent
a235dd6a6c
commit
a3d1db608b
@ -30,6 +30,7 @@
|
||||
#include "gtklabel.h"
|
||||
#include "gtklabelprivate.h"
|
||||
#include "gtkaccellabel.h"
|
||||
#include "gtkcssshadowsvalueprivate.h"
|
||||
#include "gtkdnd.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkpango.h"
|
||||
@ -46,6 +47,7 @@
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkimage.h"
|
||||
#include "gtkshow.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtktooltip.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
@ -3960,17 +3962,21 @@ gtk_label_get_ink_rect (GtkLabel *label,
|
||||
GdkRectangle *rect)
|
||||
{
|
||||
GtkLabelPrivate *priv = label->priv;
|
||||
GtkStyleContext *context;
|
||||
PangoRectangle ink_rect;
|
||||
GtkBorder extents;
|
||||
int x, y;
|
||||
|
||||
gtk_label_ensure_layout (label);
|
||||
get_layout_location (label, &x, &y);
|
||||
pango_layout_get_pixel_extents (priv->layout, &ink_rect, NULL);
|
||||
context = gtk_widget_get_style_context (GTK_WIDGET (label));
|
||||
_gtk_css_shadows_value_get_extents (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_TEXT_SHADOW), &extents);
|
||||
|
||||
rect->x = x + ink_rect.x;
|
||||
rect->width = ink_rect.width;
|
||||
rect->y = y + ink_rect.y;
|
||||
rect->height = ink_rect.height;
|
||||
rect->x = x + ink_rect.x - extents.left;
|
||||
rect->width = ink_rect.width + extents.left + extents.right;
|
||||
rect->y = y + ink_rect.y - extents.top;
|
||||
rect->height = ink_rect.height + extents.top + extents.bottom;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -266,6 +266,8 @@ testdata = \
|
||||
label-sizing.ui \
|
||||
label-small-ellipsized.ref.ui \
|
||||
label-small-ellipsized.ui \
|
||||
label-text-shadow-clipping.ref.ui \
|
||||
label-text-shadow-clipping.ui \
|
||||
label-width-chars-dont-shrink.ref.ui \
|
||||
label-width-chars-dont-shrink.ui \
|
||||
label-wrap-justify.ref.ui \
|
||||
|
18
testsuite/reftests/label-text-shadow-clipping.ref.ui
Normal file
18
testsuite/reftests/label-text-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">500</property>
|
||||
<property name="height_request">100</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="type">popup</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Hello World</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
32
testsuite/reftests/label-text-shadow-clipping.ui
Normal file
32
testsuite/reftests/label-text-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">500</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="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Hello World</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
Loading…
Reference in New Issue
Block a user