зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1574291 - Render restore button, not just icon, when drawing titlebar. r=stransky
And attach it to the maximized headerbar, not to the regular one. Breeze styles the button with background-image rather than icon-source. Differential Revision: https://phabricator.services.mozilla.com/D179389
This commit is contained in:
Родитель
85655a550c
Коммит
34bff4f0ed
|
@ -661,13 +661,13 @@ bool IsSolidCSDStyleUsed() {
|
|||
|
||||
static void CreateHeaderBarButtons() {
|
||||
GtkWidget* headerBar = sWidgetStorage[MOZ_GTK_HEADER_BAR];
|
||||
MOZ_ASSERT(headerBar != nullptr, "We're missing header bar widget!");
|
||||
MOZ_ASSERT(headerBar, "We're missing header bar widget!");
|
||||
|
||||
gint buttonSpacing = 6;
|
||||
g_object_get(headerBar, "spacing", &buttonSpacing, nullptr);
|
||||
|
||||
GtkWidget* buttonBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, buttonSpacing);
|
||||
gtk_container_add(GTK_CONTAINER(GetWidget(MOZ_GTK_HEADER_BAR)), buttonBox);
|
||||
gtk_container_add(GTK_CONTAINER(headerBar), buttonBox);
|
||||
// We support only LTR headerbar layout for now.
|
||||
gtk_style_context_add_class(gtk_widget_get_style_context(buttonBox),
|
||||
GTK_STYLE_CLASS_LEFT);
|
||||
|
@ -686,7 +686,7 @@ static void CreateHeaderBarButtons() {
|
|||
CreateHeaderBarButton(buttonBox, MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE);
|
||||
// We don't pack "restore" headerbar button to box as it's an icon
|
||||
// placeholder. Pack it only to header bar to get correct style.
|
||||
CreateHeaderBarButton(GetWidget(MOZ_GTK_HEADER_BAR),
|
||||
CreateHeaderBarButton(GetWidget(MOZ_GTK_HEADER_BAR_MAXIMIZED),
|
||||
MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE_RESTORE);
|
||||
}
|
||||
if (IsToolbarButtonEnabled(buttonLayout, activeButtons,
|
||||
|
@ -1163,11 +1163,6 @@ static GtkStyleContext* GetCssNodeStyleInternal(WidgetNodeType aNodeType) {
|
|||
GtkWidget* widget = GetWidget(MOZ_GTK_NOTEBOOK);
|
||||
return gtk_widget_get_style_context(widget);
|
||||
}
|
||||
case MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE_RESTORE: {
|
||||
NS_ASSERTION(
|
||||
false, "MOZ_GTK_HEADER_BAR_BUTTON_RESTORE is used as an icon only!");
|
||||
return nullptr;
|
||||
}
|
||||
case MOZ_GTK_WINDOW_DECORATION: {
|
||||
GtkStyleContext* parentStyle =
|
||||
CreateSubStyleWithClass(MOZ_GTK_WINDOW, "csd");
|
||||
|
|
|
@ -499,19 +499,16 @@ static gint moz_gtk_header_bar_button_paint(cairo_t* cr,
|
|||
GtkReliefStyle relief,
|
||||
WidgetNodeType aIconWidgetType,
|
||||
GtkTextDirection direction) {
|
||||
WidgetNodeType buttonWidgetType =
|
||||
(aIconWidgetType == MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE_RESTORE)
|
||||
? MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE
|
||||
: aIconWidgetType;
|
||||
|
||||
GdkRectangle rect = *aRect;
|
||||
// We need to inset our calculated margin because it also
|
||||
// contains titlebar button spacing.
|
||||
const ToolbarButtonGTKMetrics* metrics =
|
||||
GetToolbarButtonMetrics(buttonWidgetType);
|
||||
const ToolbarButtonGTKMetrics* metrics = GetToolbarButtonMetrics(
|
||||
aIconWidgetType == MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE_RESTORE
|
||||
? MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE
|
||||
: aIconWidgetType);
|
||||
Inset(&rect, metrics->buttonMargin);
|
||||
|
||||
GtkWidget* buttonWidget = GetWidget(buttonWidgetType);
|
||||
GtkWidget* buttonWidget = GetWidget(aIconWidgetType);
|
||||
if (!buttonWidget) {
|
||||
return MOZ_GTK_UNKNOWN_WIDGET;
|
||||
}
|
||||
|
@ -533,9 +530,6 @@ static gint moz_gtk_header_bar_button_paint(cairo_t* cr,
|
|||
StyleContextSetScale(style, state->image_scale);
|
||||
gtk_style_context_set_state(style, state_flags);
|
||||
|
||||
const ToolbarButtonGTKMetrics* metrics =
|
||||
GetToolbarButtonMetrics(buttonWidgetType);
|
||||
|
||||
/* This is available since Gtk+ 3.10 as well as GtkHeaderBar */
|
||||
gtk_render_icon_surface(style, cr, surface, rect.x + metrics->iconXPosition,
|
||||
rect.y + metrics->iconYPosition);
|
||||
|
|
Загрузка…
Ссылка в новой задаче