Commit e60e1764 authored by mrobinson@webkit.org's avatar mrobinson@webkit.org
Browse files

2010-09-06 Martin Robinson <mrobinson@igalia.com>

        Reviewed by Gustavo Noronha Silva.

        [GTK] ScrollbarThemeGtk should support secondary steppers
        https://bugs.webkit.org/show_bug.cgi?id=44791

        Add support to ScrollbarThemeGtk for drawing alternate steppers. Adjust
        the algorithms for calculating forward and back button rects, if they
        are active in the theme. Expose this information via GtkScrollbarMetrics.

        * platform/gtk/ScrollbarThemeGtk.cpp:
        (WebCore::ScrollbarThemeGtk::updateThemeProperties): Access the secondary stepper properties
        of GtkScrollbarMetrics when updating the style cache.
        (WebCore::ScrollbarThemeGtk::backButtonRect): Account for alternate steppers.
        (WebCore::ScrollbarThemeGtk::forwardButtonRect): Ditto.
        (WebCore::ScrollbarThemeGtk::trackRect): Ditto.
        (WebCore::ScrollbarThemeGtk::paintButton): Ditto.
        * platform/gtk/ScrollbarThemeGtk.h:
        * platform/gtk/gtk2drawing.c: Expose whether or not the style uses alternate steppers
        via GtkScrollbarMetrics.
        * platform/gtk/gtkdrawing.h: Added fields to GtkScrollbarMetrics.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66845 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 312bb28b
2010-09-06 Martin Robinson <mrobinson@igalia.com>
Reviewed by Gustavo Noronha Silva.
[GTK] ScrollbarThemeGtk should support secondary steppers
https://bugs.webkit.org/show_bug.cgi?id=44791
Add support to ScrollbarThemeGtk for drawing alternate steppers. Adjust
the algorithms for calculating forward and back button rects, if they
are active in the theme. Expose this information via GtkScrollbarMetrics.
* platform/gtk/ScrollbarThemeGtk.cpp:
(WebCore::ScrollbarThemeGtk::updateThemeProperties): Access the secondary stepper properties
of GtkScrollbarMetrics when updating the style cache.
(WebCore::ScrollbarThemeGtk::backButtonRect): Account for alternate steppers.
(WebCore::ScrollbarThemeGtk::forwardButtonRect): Ditto.
(WebCore::ScrollbarThemeGtk::trackRect): Ditto.
(WebCore::ScrollbarThemeGtk::paintButton): Ditto.
* platform/gtk/ScrollbarThemeGtk.h:
* platform/gtk/gtk2drawing.c: Expose whether or not the style uses alternate steppers
via GtkScrollbarMetrics.
* platform/gtk/gtkdrawing.h: Added fields to GtkScrollbarMetrics.
2010-09-06 Tony Gentilcore <tonyg@chromium.org>
 
Reviewed by Adam Barth.
......@@ -82,6 +82,8 @@ void ScrollbarThemeGtk::updateThemeProperties()
m_stepperSpacing = metrics.stepper_spacing;
m_minThumbLength = metrics.min_slider_size;
m_troughUnderSteppers = metrics.trough_under_steppers;
m_hasForwardButtonStartPart = metrics.has_secondary_forward_stepper;
m_hasBackButtonEndPart = metrics.has_secondary_backward_stepper;
if (!gScrollbars)
return;
......@@ -120,30 +122,45 @@ bool ScrollbarThemeGtk::hasThumb(Scrollbar* scrollbar)
IntRect ScrollbarThemeGtk::backButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool)
{
// We do not support multiple steppers per end yet.
if (part == BackButtonEndPart)
if (part == BackButtonEndPart && !m_hasBackButtonEndPart)
return IntRect();
int x = scrollbar->x() + m_troughBorderWidth;
int y = scrollbar->y() + m_troughBorderWidth;
IntSize size = buttonSize(scrollbar);
return IntRect(scrollbar->x() + m_troughBorderWidth, scrollbar->y() + m_troughBorderWidth, size.width(), size.height());
if (part == BackButtonStartPart)
return IntRect(x, y, size.width(), size.height());
// BackButtonEndPart (alternate button)
if (scrollbar->orientation() == HorizontalScrollbar)
return IntRect(scrollbar->x() + scrollbar->width() - m_troughBorderWidth - (2 * size.width()), y, size.width(), size.height());
// VerticalScrollbar alternate button
return IntRect(x, scrollbar->y() + scrollbar->height() - m_troughBorderWidth - (2 * size.height()), size.width(), size.height());
}
IntRect ScrollbarThemeGtk::forwardButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool)
{
// We do not support multiple steppers per end yet.
if (part == ForwardButtonStartPart)
if (part == ForwardButtonStartPart && !m_hasForwardButtonStartPart)
return IntRect();
IntSize size = buttonSize(scrollbar);
int x, y;
if (scrollbar->orientation() == HorizontalScrollbar) {
x = scrollbar->x() + scrollbar->width() - size.width() - m_troughBorderWidth;
y = scrollbar->y() + m_troughBorderWidth;
} else {
x = scrollbar->x() + m_troughBorderWidth;
y = scrollbar->y() + scrollbar->height() - size.height() - m_troughBorderWidth;
int y = scrollbar->y() + m_troughBorderWidth;
if (part == ForwardButtonEndPart)
return IntRect(scrollbar->x() + scrollbar->width() - size.width() - m_troughBorderWidth, y, size.width(), size.height());
// ForwardButtonStartPart (alternate button)
return IntRect(scrollbar->x() + m_troughBorderWidth + size.width(), y, size.width(), size.height());
}
return IntRect(x, y, size.width(), size.height());
// VerticalScrollbar
int x = scrollbar->x() + m_troughBorderWidth;
if (part == ForwardButtonEndPart)
return IntRect(x, scrollbar->y() + scrollbar->height() - size.height() - m_troughBorderWidth, size.width(), size.height());
// ForwardButtonStartPart (alternate button)
return IntRect(x, scrollbar->y() + m_troughBorderWidth + size.height(), size.width(), size.height());
}
IntRect ScrollbarThemeGtk::trackRect(Scrollbar* scrollbar, bool)
......@@ -157,17 +174,28 @@ IntRect ScrollbarThemeGtk::trackRect(Scrollbar* scrollbar, bool)
// The fatness of the scrollbar on the non-movement axis.
int thickness = scrollbarThickness(scrollbar->controlSize());
int alternateButtonOffset = 0;
int alternateButtonWidth = 0;
if (m_hasForwardButtonStartPart) {
alternateButtonOffset += m_stepperSize;
alternateButtonWidth += m_stepperSize;
}
if (m_hasBackButtonEndPart)
alternateButtonWidth += m_stepperSize;
if (scrollbar->orientation() == HorizontalScrollbar) {
// Once the scrollbar becomes smaller than the natural size of the
// two buttons, the track disappears.
if (scrollbar->width() < 2 * thickness)
return IntRect();
return IntRect(scrollbar->x() + movementAxisPadding, scrollbar->y(), scrollbar->width() - (2 * movementAxisPadding), thickness);
return IntRect(scrollbar->x() + movementAxisPadding + alternateButtonOffset, scrollbar->y(),
scrollbar->width() - (2 * movementAxisPadding) - alternateButtonWidth, thickness);
}
if (scrollbar->height() < 2 * thickness)
return IntRect();
return IntRect(scrollbar->x(), scrollbar->y() + movementAxisPadding, thickness, scrollbar->height() - (2 * movementAxisPadding));
return IntRect(scrollbar->x(), scrollbar->y() + movementAxisPadding + alternateButtonOffset,
thickness, scrollbar->height() - (2 * movementAxisPadding) - alternateButtonWidth);
}
void ScrollbarThemeGtk::paintTrackBackground(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect)
......@@ -304,10 +332,10 @@ void ScrollbarThemeGtk::paintButton(GraphicsContext* context, Scrollbar* scrollb
if (scrollbar->orientation() == VerticalScrollbar)
flags |= MOZ_GTK_STEPPER_VERTICAL;
if (part == ForwardButtonEndPart) {
if (part == ForwardButtonEndPart)
flags |= (MOZ_GTK_STEPPER_DOWN | MOZ_GTK_STEPPER_BOTTOM);
if (part == ForwardButtonStartPart)
flags |= MOZ_GTK_STEPPER_DOWN;
flags |= MOZ_GTK_STEPPER_BOTTOM;
}
GtkWidgetState state;
state.focused = TRUE;
......@@ -315,7 +343,9 @@ void ScrollbarThemeGtk::paintButton(GraphicsContext* context, Scrollbar* scrollb
state.canDefault = TRUE;
if ((BackButtonStartPart == part && scrollbar->currentPos())
|| (ForwardButtonEndPart == part && scrollbar->currentPos() != scrollbar->maximum())) {
|| (BackButtonEndPart == part && scrollbar->currentPos())
|| (ForwardButtonEndPart == part && scrollbar->currentPos() != scrollbar->maximum())
|| (ForwardButtonStartPart == part && scrollbar->currentPos() != scrollbar->maximum())) {
state.disabled = FALSE;
state.active = part == scrollbar->pressedPart();
state.inHover = part == scrollbar->hoveredPart();
......
......@@ -68,6 +68,8 @@ protected:
int m_stepperSpacing;
int m_minThumbLength;
bool m_troughUnderSteppers;
bool m_hasForwardButtonStartPart;
bool m_hasBackButtonEndPart;
};
}
......
......@@ -3079,6 +3079,8 @@ moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics *metrics)
"stepper_size", &metrics->stepper_size,
"stepper_spacing", &metrics->stepper_spacing,
"trough_under_steppers", &metrics->trough_under_steppers,
"has_secondary_forward_stepper", &metrics->has_secondary_forward_stepper,
"has_secondary_backward_stepper", &metrics->has_secondary_backward_stepper,
NULL);
metrics->min_slider_size = gtk_range_get_min_slider_size(GTK_RANGE(gParts->horizScrollbarWidget));
......
......@@ -76,6 +76,8 @@ typedef struct {
gint stepper_spacing;
gint min_slider_size;
gboolean trough_under_steppers;
gboolean has_secondary_forward_stepper;
gboolean has_secondary_backward_stepper;
} MozGtkScrollbarMetrics;
typedef struct _GtkThemeParts {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment