Avoid clipping wxCheckBox focus indicator on GTK3
GtkCheckButton "outline" is drawn outside of widget's allocation with Adwaita theme See #18353, #18043
This commit is contained in:
@@ -2220,10 +2220,28 @@ size_allocate(GtkWidget* WXUNUSED_IN_GTK2(widget), GtkAllocation* alloc, wxWindo
|
|||||||
#if GTK_CHECK_VERSION(3,14,0)
|
#if GTK_CHECK_VERSION(3,14,0)
|
||||||
if (wx_is_at_least_gtk3(14))
|
if (wx_is_at_least_gtk3(14))
|
||||||
{
|
{
|
||||||
|
// Prevent under-allocated widgets from drawing outside their allocation
|
||||||
GtkAllocation clip;
|
GtkAllocation clip;
|
||||||
gtk_widget_get_clip(widget, &clip);
|
gtk_widget_get_clip(widget, &clip);
|
||||||
if (clip.width > w || clip.height > h)
|
if (clip.width > w || clip.height > h)
|
||||||
gtk_widget_set_clip(widget, alloc);
|
{
|
||||||
|
GtkStyleContext* sc = gtk_widget_get_style_context(widget);
|
||||||
|
int outline_offset, outline_width;
|
||||||
|
gtk_style_context_get(sc, gtk_style_context_get_state(sc),
|
||||||
|
"outline-offset", &outline_offset, "outline-width", &outline_width, NULL);
|
||||||
|
const int outline = outline_offset + outline_width;
|
||||||
|
GtkAllocation a = *alloc;
|
||||||
|
if (outline > 0)
|
||||||
|
{
|
||||||
|
// Allow enough room for focus indicator "outline", it's drawn
|
||||||
|
// outside of GtkCheckButton allocation with Adwaita theme
|
||||||
|
a.x -= outline;
|
||||||
|
a.y -= outline;
|
||||||
|
a.width += outline + outline;
|
||||||
|
a.height += outline + outline;
|
||||||
|
}
|
||||||
|
gtk_widget_set_clip(widget, &a);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (win->m_wxwindow)
|
if (win->m_wxwindow)
|
||||||
|
Reference in New Issue
Block a user