Closed Bug 255911 Opened 20 years ago Closed 20 years ago

native theme button cleanups for gtk2

Categories

(Core Graveyard :: GFX: Gtk, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: bryner, Assigned: bryner)

References

Details

(Keywords: fixed-aviary1.0, fixed1.7.5)

Attachments

(2 files)

There are a number of things that need to be cleaned up for gtk2 button,
toolbarbutton, and menubutton.  In particular:

- buttons need to honor the interior-focus, focus-line-width, and focus-padding
style properties
- buttons need to include focus padding in their border
- CSS padding for buttons' button-box, and for toolbarbutton, needs to _not_
apply when native theming is enabled since all of the padding is included in the
native theme border
- gnomestripe theme needs the dualbutton and dualbutton-dropdown moz-appearance
restored for menubuttons
Flags: blocking-aviary1.0?
Attached patch patchSplinter Review
Rather than adding more interior boxes, as I did for checkboxes and
radiobuttons awhile back, I decided to take a better approach to supporting
having CSS style apply when native theming is disabled.  The main problem
currently is that GetWidgetBorder() is expected to include the padding as well.
 This means that you can't use CSS padding on that element for the case when
native theming is disabled, since it will be added in on top of the native
theme border when native theming _is_ enabled.

To try to alleviate this, I added nsITheme::GetWidgetPadding().  Eventually the
goal is to actually separate out the border and padding values that nsITheme
returns.  But in the meantime, I'm just using it as a way to say "when native
theming is enabled for this widget, force the CSS padding to 0."
Attachment #156363 - Flags: superreview?(roc)
Attachment #156363 - Flags: review?(caillon)
Comment on attachment 156363 [details] [diff] [review]
patch

>+// An interior box in a button, used for painting a focus outline.
>+#define NS_THEME_BUTTON_INTERIOR                           154

Why not just call this NS_THEME_BUTTON_FOCUS ?

r=me for the rest.  Make sure you have a followup bug filed.
Attachment #156363 - Flags: review?(caillon) → review+
Comment on attachment 156363 [details] [diff] [review]
patch

+	     x += gButtonWidget->style->xthickness + focus_pad;
+	     y += gButtonWidget->style->ythickness + focus_pad;

why gButtonWidget and not widget?

+    nsIContent* content = frame->GetContent();
+    if (content) {
+      nsCOMPtr<nsIDocument> doc = content->GetDocument();
+      if (doc) {
+	 nsIPresShell *shell = doc->GetShellAt(0);
+	 nsPresContext *context = shell->GetPresContext();

Why not just frame->GetPresContext()?
Comment on attachment 156363 [details] [diff] [review]
patch

bryner agreed with me on IRC
Attachment #156363 - Flags: superreview?(roc) → superreview+
I made one more change to the way NS_THEME_TOOLBAR_DUAL_BUTTON is handled.  When
you hover over the toolbar button, I want a border to draw all the way around
the entire button, then a border around the inner button if you're over that
(which will overlap with the outer border on the top and left).  This is how it
looks on Windows, and is really the only way I see to get good hover feedback
without making these things be too tall.  Here's what I added to achieve this:

@@ -337,6 +331,7 @@ nsNativeThemeGTK::GetGtkWidgetAndState(P
   switch (aWidgetType) {
   case NS_THEME_BUTTON:
   case NS_THEME_TOOLBAR_BUTTON:
+  case NS_THEME_TOOLBAR_DUAL_BUTTON:
     if (aWidgetFlags)
       *aWidgetFlags = (aWidgetType == NS_THEME_BUTTON) ? GTK_RELIEF_NORMAL :
GTK_RELIEF_NONE;
     aGtkWidgetType = MOZ_GTK_BUTTON;
@@ -543,6 +538,14 @@ nsNativeThemeGTK::GetWidgetBorder(nsIDev
     // gtk's 'toolbar' for purposes of painting the widget background,
     // we don't use the toolbar border for toolbox.
     break;
+  case NS_THEME_TOOLBAR_DUAL_BUTTON:
+    // TOOLBAR_DUAL_BUTTON is an interesting case.  We want a border to draw
+    // around the entire button + dropdown, and also an inner border if you're
+    // over the button part.  But, we want the inner button to be right up
+    // against the edge of the outer button so that the borders overlap.
+    // To make this happen, we draw a button border for the outer button,
+    // but don't reserve any space for it.
+    break;
   default:
     {
       GtkThemeWidgetType gtkWidgetType;
(In reply to comment #5)
> (which will overlap with the outer border on the top and left)
                                               ^^^^^^^^^^^^^^^^^

and bottom
Comment on attachment 156363 [details] [diff] [review]
patch

oops, wrong flag.
Attachment #156363 - Flags: approval-aviary+
Flags: blocking-aviary1.0? → blocking-aviary1.0+
Comment on attachment 157987 [details] [diff] [review]
patch merged to aviary branch

requesting branch approval
Attachment #157987 - Flags: approval-aviary?
Comment on attachment 157987 [details] [diff] [review]
patch merged to aviary branch

requesting 1.7 approval as well
Attachment #157987 - Flags: approval1.7.x?
Comment on attachment 157987 [details] [diff] [review]
patch merged to aviary branch

a=asa for aviary checkin.
Attachment #157987 - Flags: approval1.7.x?
Attachment #157987 - Flags: approval1.7.x+
Attachment #157987 - Flags: approval-aviary?
Attachment #157987 - Flags: approval-aviary+
checked in on the trunk, aviary, and 1.7 branches.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: