mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 410489 - "gtk: wrong scrollbar in nodoka theme (git)" (make it possible for GTK themes to distinguish secondary steppers) [p=twanno@lycos.nl (Teune van Steeg) r+sr=roc a1.9=schrep]
This commit is contained in:
parent
f188122a00
commit
885d5db188
@ -760,7 +760,8 @@ calculate_arrow_dimensions(GdkRectangle* rect, GdkRectangle* arrow_rect)
|
||||
static gint
|
||||
moz_gtk_scrollbar_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
||||
GdkRectangle* cliprect, GtkWidgetState* state,
|
||||
GtkArrowType type, GtkTextDirection direction)
|
||||
GtkScrollbarButtonFlags flags,
|
||||
GtkTextDirection direction)
|
||||
{
|
||||
GtkStateType state_type = ConvertGtkState(state);
|
||||
GtkShadowType shadow_type = (state->active) ?
|
||||
@ -768,38 +769,59 @@ moz_gtk_scrollbar_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
||||
GdkRectangle button_rect;
|
||||
GdkRectangle arrow_rect;
|
||||
GtkStyle* style;
|
||||
GtkAdjustment *adj;
|
||||
GtkScrollbar *scrollbar;
|
||||
GtkWidget *scrollbar;
|
||||
GtkArrowType arrow_type;
|
||||
const char* detail = (flags & MOZ_GTK_STEPPER_VERTICAL) ?
|
||||
"vscrollbar" : "hscrollbar";
|
||||
|
||||
ensure_scrollbar_widget();
|
||||
|
||||
if (type < 2)
|
||||
scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
|
||||
if (flags & MOZ_GTK_STEPPER_VERTICAL)
|
||||
scrollbar = gVertScrollbarWidget;
|
||||
else
|
||||
scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget);
|
||||
scrollbar = gHorizScrollbarWidget;
|
||||
|
||||
gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
|
||||
gtk_widget_set_direction(scrollbar, direction);
|
||||
|
||||
/* Some theme engines (i.e., ClearLooks) check the scrollbar's allocation
|
||||
to determine where it should paint rounded corners on the buttons.
|
||||
We need to trick them into drawing the buttons the way we want them. */
|
||||
|
||||
GTK_WIDGET(scrollbar)->allocation.x = rect->x;
|
||||
GTK_WIDGET(scrollbar)->allocation.y = rect->y;
|
||||
GTK_WIDGET(scrollbar)->allocation.width = rect->width;
|
||||
GTK_WIDGET(scrollbar)->allocation.height = rect->height;
|
||||
scrollbar->allocation.x = rect->x;
|
||||
scrollbar->allocation.y = rect->y;
|
||||
scrollbar->allocation.width = rect->width;
|
||||
scrollbar->allocation.height = rect->height;
|
||||
|
||||
if (type < 2) {
|
||||
GTK_WIDGET(scrollbar)->allocation.height *= 3;
|
||||
if (type == GTK_ARROW_DOWN)
|
||||
GTK_WIDGET(scrollbar)->allocation.y -= 2 * rect->height;
|
||||
if (flags & MOZ_GTK_STEPPER_VERTICAL) {
|
||||
scrollbar->allocation.height *= 5;
|
||||
if (flags & MOZ_GTK_STEPPER_DOWN) {
|
||||
arrow_type = GTK_ARROW_DOWN;
|
||||
if (flags & MOZ_GTK_STEPPER_BOTTOM)
|
||||
scrollbar->allocation.y -= 4 * rect->height;
|
||||
else
|
||||
scrollbar->allocation.y -= rect->height;
|
||||
|
||||
} else {
|
||||
arrow_type = GTK_ARROW_UP;
|
||||
if (flags & MOZ_GTK_STEPPER_BOTTOM)
|
||||
scrollbar->allocation.y -= 3 * rect->height;
|
||||
}
|
||||
} else {
|
||||
GTK_WIDGET(scrollbar)->allocation.width *= 3;
|
||||
if (type == GTK_ARROW_RIGHT)
|
||||
GTK_WIDGET(scrollbar)->allocation.x -= 2 * rect->width;
|
||||
scrollbar->allocation.width *= 5;
|
||||
if (flags & MOZ_GTK_STEPPER_DOWN) {
|
||||
arrow_type = GTK_ARROW_RIGHT;
|
||||
if (flags & MOZ_GTK_STEPPER_BOTTOM)
|
||||
scrollbar->allocation.x -= 4 * rect->width;
|
||||
else
|
||||
scrollbar->allocation.x -= rect->width;
|
||||
} else {
|
||||
arrow_type = GTK_ARROW_LEFT;
|
||||
if (flags & MOZ_GTK_STEPPER_BOTTOM)
|
||||
scrollbar->allocation.x -= 3 * rect->width;
|
||||
}
|
||||
}
|
||||
|
||||
style = GTK_WIDGET(scrollbar)->style;
|
||||
style = scrollbar->style;
|
||||
|
||||
ensure_arrow_widget();
|
||||
|
||||
@ -807,10 +829,8 @@ moz_gtk_scrollbar_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
||||
TSOffsetStyleGCs(style, button_rect.x, button_rect.y);
|
||||
|
||||
gtk_paint_box(style, drawable, state_type, shadow_type, cliprect,
|
||||
GTK_WIDGET(scrollbar),
|
||||
(type < 2) ? "vscrollbar" : "hscrollbar",
|
||||
button_rect.x, button_rect.y, button_rect.width,
|
||||
button_rect.height);
|
||||
scrollbar, detail, button_rect.x, button_rect.y,
|
||||
button_rect.width, button_rect.height);
|
||||
|
||||
arrow_rect.width = button_rect.width / 2;
|
||||
arrow_rect.height = button_rect.height / 2;
|
||||
@ -819,10 +839,8 @@ moz_gtk_scrollbar_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
||||
(button_rect.height - arrow_rect.height) / 2;
|
||||
|
||||
gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
|
||||
GTK_WIDGET(scrollbar), (type < 2) ?
|
||||
"vscrollbar" : "hscrollbar",
|
||||
type, TRUE, arrow_rect.x, arrow_rect.y, arrow_rect.width,
|
||||
arrow_rect.height);
|
||||
scrollbar, detail, arrow_type, TRUE, arrow_rect.x,
|
||||
arrow_rect.y, arrow_rect.width, arrow_rect.height);
|
||||
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
@ -2487,8 +2505,8 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
|
||||
direction);
|
||||
break;
|
||||
case MOZ_GTK_SCROLLBAR_BUTTON:
|
||||
return moz_gtk_scrollbar_button_paint(drawable, rect, cliprect,
|
||||
state, (GtkArrowType) flags,
|
||||
return moz_gtk_scrollbar_button_paint(drawable, rect, cliprect, state,
|
||||
(GtkScrollbarButtonFlags) flags,
|
||||
direction);
|
||||
break;
|
||||
case MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL:
|
||||
|
@ -78,6 +78,12 @@ typedef struct {
|
||||
gint min_slider_size;
|
||||
} MozGtkScrollbarMetrics;
|
||||
|
||||
typedef enum {
|
||||
MOZ_GTK_STEPPER_DOWN = 1 << 0,
|
||||
MOZ_GTK_STEPPER_BOTTOM = 1 << 1,
|
||||
MOZ_GTK_STEPPER_VERTICAL = 1 << 2
|
||||
} GtkScrollbarButtonFlags;
|
||||
|
||||
/** flags for tab state **/
|
||||
typedef enum {
|
||||
/* first eight bits are used to pass a margin */
|
||||
|
@ -281,8 +281,14 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
|
||||
aWidgetType == NS_THEME_SCROLLBAR_BUTTON_DOWN ||
|
||||
aWidgetType == NS_THEME_SCROLLBAR_BUTTON_LEFT ||
|
||||
aWidgetType == NS_THEME_SCROLLBAR_BUTTON_RIGHT) {
|
||||
if (CheckBooleanAttr(aFrame, nsWidgetAtoms::active))
|
||||
aState->active = PR_TRUE;
|
||||
if (CheckBooleanAttr(aFrame, nsWidgetAtoms::active))
|
||||
aState->active = PR_TRUE;
|
||||
|
||||
if (aWidgetFlags) {
|
||||
*aWidgetFlags = GetScrollbarButtonType(aFrame);
|
||||
if (aWidgetType - NS_THEME_SCROLLBAR_BUTTON_UP < 2)
|
||||
*aWidgetFlags |= MOZ_GTK_STEPPER_VERTICAL;
|
||||
}
|
||||
}
|
||||
|
||||
// menu item state is determined by the attribute "_moz-menuactive",
|
||||
@ -354,8 +360,6 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
|
||||
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
|
||||
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
|
||||
case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
|
||||
if (aWidgetFlags)
|
||||
*aWidgetFlags = GtkArrowType(aWidgetType - NS_THEME_SCROLLBAR_BUTTON_UP);
|
||||
aGtkWidgetType = MOZ_GTK_SCROLLBAR_BUTTON;
|
||||
break;
|
||||
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
|
||||
|
@ -169,6 +169,30 @@ nsNativeTheme::IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame,
|
||||
aPresContext->HasAuthorSpecifiedBorderOrBackground(aFrame);
|
||||
}
|
||||
|
||||
// scrollbar button:
|
||||
PRInt32
|
||||
nsNativeTheme::GetScrollbarButtonType(nsIFrame* aFrame)
|
||||
{
|
||||
if (!aFrame)
|
||||
return 0;
|
||||
|
||||
static nsIContent::AttrValuesArray strings[] =
|
||||
{&nsWidgetAtoms::scrollbarDownBottom, &nsWidgetAtoms::scrollbarDownTop,
|
||||
&nsWidgetAtoms::scrollbarUpBottom, &nsWidgetAtoms::scrollbarUpTop,
|
||||
nsnull};
|
||||
|
||||
switch (aFrame->GetContent()->FindAttrValueIn(kNameSpaceID_None,
|
||||
nsWidgetAtoms::sbattr,
|
||||
strings, eCaseMatters)) {
|
||||
case 0: return eScrollbarButton_Down | eScrollbarButton_Bottom;
|
||||
case 1: return eScrollbarButton_Down;
|
||||
case 2: return eScrollbarButton_Bottom;
|
||||
case 3: return eScrollbarButton_UpTop;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// treeheadercell:
|
||||
nsNativeTheme::TreeSortDirection
|
||||
nsNativeTheme::GetTreeSortDirection(nsIFrame* aFrame)
|
||||
|
@ -55,6 +55,12 @@ class nsNativeTheme
|
||||
{
|
||||
protected:
|
||||
|
||||
enum ScrollbarButtonType {
|
||||
eScrollbarButton_UpTop = 0,
|
||||
eScrollbarButton_Down = 1 << 0,
|
||||
eScrollbarButton_Bottom = 1 << 1
|
||||
};
|
||||
|
||||
enum TreeSortDirection {
|
||||
eTreeSortDirection_Descending,
|
||||
eTreeSortDirection_Natural,
|
||||
@ -97,6 +103,9 @@ class nsNativeTheme
|
||||
PRBool IsFocused(nsIFrame* aFrame) {
|
||||
return CheckBooleanAttr(aFrame, nsWidgetAtoms::focused);
|
||||
}
|
||||
|
||||
// scrollbar button:
|
||||
PRInt32 GetScrollbarButtonType(nsIFrame* aFrame);
|
||||
|
||||
// tab:
|
||||
PRBool IsSelectedTab(nsIFrame* aFrame) {
|
||||
@ -107,7 +116,7 @@ class nsNativeTheme
|
||||
PRBool IsCheckedButton(nsIFrame* aFrame) {
|
||||
return CheckBooleanAttr(aFrame, nsWidgetAtoms::checked);
|
||||
}
|
||||
|
||||
|
||||
// treeheadercell:
|
||||
TreeSortDirection GetTreeSortDirection(nsIFrame* aFrame);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user