Fix clipping of wxSlider thumb with some GTK3 themes See #24106
... | ... | @@ -314,14 +314,22 @@ bool wxSlider::Create(wxWindow *parent, |
314 | 314 | |
315 | 315 | // Note that wxSL_LEFT or wxSL_RIGHT imply vertical layout too, as in wxMSW.
|
316 | 316 | const bool isVertical = (style & (wxSL_LEFT | wxSL_RIGHT | wxSL_VERTICAL)) != 0;
|
317 | + m_widget =
|
|
317 | 318 | m_scale = gtk_scale_new(GtkOrientation(isVertical), nullptr);
|
318 | 319 | |
319 | - if (style & wxSL_MIN_MAX_LABELS)
|
|
320 | + const bool showMinMaxLabels = (style & wxSL_MIN_MAX_LABELS) != 0;
|
|
321 | +#ifndef __WXGTK3__
|
|
322 | + if (showMinMaxLabels)
|
|
323 | +#endif
|
|
320 | 324 | {
|
321 | 325 | gtk_widget_show( m_scale );
|
322 | 326 | |
323 | 327 | m_widget = gtk_box_new(GtkOrientation(isVertical), 0);
|
324 | - |
|
328 | + }
|
|
329 | + m_minLabel = nullptr;
|
|
330 | + m_maxLabel = nullptr;
|
|
331 | + if (showMinMaxLabels)
|
|
332 | + {
|
|
325 | 333 | m_minLabel = gtk_label_new(nullptr);
|
326 | 334 | gtk_widget_show( m_minLabel );
|
327 | 335 | |
... | ... | @@ -332,12 +340,12 @@ bool wxSlider::Create(wxWindow *parent, |
332 | 340 | gtk_box_pack_start(GTK_BOX(m_widget), m_scale, true, true, 0);
|
333 | 341 | gtk_box_pack_start(GTK_BOX(m_widget), m_maxLabel, false, false, 0);
|
334 | 342 | }
|
343 | +#ifdef __WXGTK3__
|
|
335 | 344 | else
|
336 | 345 | {
|
337 | - m_widget = m_scale;
|
|
338 | - m_maxLabel = nullptr;
|
|
339 | - m_minLabel = nullptr;
|
|
346 | + gtk_box_pack_start(GTK_BOX(m_widget), m_scale, true, true, 0);
|
|
340 | 347 | }
|
348 | +#endif
|
|
341 | 349 | g_object_ref(m_widget);
|
342 | 350 | |
343 | 351 | const bool showValueLabel = (style & wxSL_VALUE_LABEL) != 0;
|
... | ... | @@ -390,6 +398,39 @@ bool wxSlider::Create(wxWindow *parent, |
390 | 398 | wxGCC_WARNING_RESTORE()
|
391 | 399 | }
|
392 | 400 | }
|
401 | +#ifdef __WXGTK3__
|
|
402 | + if (showValueLabel || !showMinMaxLabels)
|
|
403 | + {
|
|
404 | + // Some themes draw the slider partially outside the GtkScale's allocation.
|
|
405 | + // This is known to occur with Mint-Y, and even slightly with Adwaita.
|
|
406 | + // To avoid clipping, add some extra space.
|
|
407 | + |
|
408 | + GtkBorder margin = { };
|
|
409 | + |
|
410 | + if (!showMinMaxLabels)
|
|
411 | + {
|
|
412 | + const int extraEnd = 1;
|
|
413 | + |
|
414 | + if (isVertical)
|
|
415 | + margin.top = margin.bottom = extraEnd;
|
|
416 | + else
|
|
417 | + margin.left = margin.right = extraEnd;
|
|
418 | + }
|
|
419 | + if (showValueLabel)
|
|
420 | + {
|
|
421 | + const int extraSide = 5;
|
|
422 | + |
|
423 | + if (isVertical)
|
|
424 | + (style & wxSL_LEFT ? margin.left : margin.right) = extraSide;
|
|
425 | + else
|
|
426 | + (style & wxSL_TOP ? margin.top : margin.bottom) = extraSide;
|
|
427 | + }
|
|
428 | + gtk_widget_set_margin_left(m_scale, margin.left);
|
|
429 | + gtk_widget_set_margin_right(m_scale, margin.right);
|
|
430 | + gtk_widget_set_margin_top(m_scale, margin.top);
|
|
431 | + gtk_widget_set_margin_bottom(m_scale, margin.bottom);
|
|
432 | + }
|
|
433 | +#endif
|
|
393 | 434 | |
394 | 435 | // Keep full precision in position value
|
395 | 436 | gtk_scale_set_digits(GTK_SCALE (m_scale), -1);
|
—
View it on GitLab.
You're receiving this email because of your account on gitlab.com. Manage all notifications · Help