Skip to content

Commit e2658ff

Browse files
megaxkhurshid-alam
authored andcommitted
[Gtk-3.20] Refactor toolbar code. Fixes #486
Now that out button code has changed, it is necessary to refactor & restructure toolbar code to keep things synchronized.
1 parent ff98d44 commit e2658ff

3 files changed

Lines changed: 112 additions & 71 deletions

File tree

gtk-3.20/scss/apps/_nemo.scss

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,6 @@
2828

2929
.linked > button { @include linked_button($bg_color); }
3030

31-
combobox button {
32-
padding: $spacing - 1px;
33-
34-
&.text-button {
35-
padding: $spacing;
36-
}
37-
38-
&.image-button {
39-
padding: ($spacing + 1px) ($spacing - 1px) ($spacing + 1px) $spacing;
40-
}
41-
}
42-
4331
separator, separator:disabled {
4432
color: shade($bg_color, ($contrast + .1));
4533
border-color: currentColor;

gtk-3.20/scss/apps/_unity.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
.top {
2828
border: 1px solid $wm_border_focused;
2929
border-bottom: 0;
30-
border-radius: 2px 2px 0 0;
31-
padding: 1px ($spacing * 2) 0;
30+
border-radius: $roundness $roundness 0 0;
31+
padding: 1px ($spacing + 3px) 0 ($spacing + 3px);
3232
background-color: $titlebar_bg_color;
3333
color: mix($titlebar_fg_color, $titlebar_bg_color, .1);
3434
text-shadow: none;
@@ -40,9 +40,9 @@
4040
}
4141

4242
.left, .right, .bottom {
43-
background-color: $wm_border_focused;
43+
background-color: $titlebar_bg_color;
4444

45-
&:backdrop { background-color: $wm_border_unfocused; }
45+
&:backdrop { background-color: mix(shade($titlebar_bg_color, .7), $titlebar_fg_color, .21); }
4646
}
4747
}
4848

gtk-3.20/scss/widgets/_toolbar.scss

Lines changed: 108 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
@include linear-gradient($bg);
1010
@include border($bg);
1111

12-
padding: $spacing * 2;
1312
color: $fg;
1413

1514
&:disabled {
@@ -33,86 +32,94 @@
3332
.linked > button { @include linked_button($bg); }
3433

3534
combobox, button {
36-
padding: $spacing - 1px;
35+
padding: $spacing;
3736

3837
&.text-button { padding: $spacing; }
3938

40-
&.image-button { padding: ($spacing + 1px) ($spacing - 1px) ($spacing + 1px) $spacing; }
39+
&.image-button { padding: $spacing; }
4140
}
4241

43-
// toolbar separators
44-
&.horizontal separator { margin: 0 ($spacing + 2px) 1px ($spacing + 2px); }
45-
46-
&.vertical separator { margin: ($spacing + 2px) 1px ($spacing + 2px) 0; }
42+
separator {
43+
&, &:disabled {
44+
color: shade($bg, ($contrast - .2));
45+
border-color: currentColor;
4746

48-
separator, separator:disabled {
49-
color: shade($bg, ($contrast - .2));
50-
border-color: currentColor;
51-
52-
-GtkWidget-window-dragging: true;
47+
-GtkWidget-window-dragging: true;
48+
}
5349
}
54-
55-
.menubar, menubar { -GtkToolbar-button-relief: normal; }
5650
}
5751

58-
@include exports("toolbar") {
59-
toolbar {
60-
@include toolbar($toolbar_bg_color, $toolbar_fg_color);
52+
@mixin inline-toolbar($bg, $fg) {
53+
background-image: none;
54+
border-width: 0 1px 1px;
55+
border-style: solid;
56+
border-color: $borders_color;
57+
background-color: mix($borders_color, $bg_color, .7);
58+
59+
&:backdrop {
60+
border-color: $backdrop_borders_color;
61+
background-color: $backdrop_dark_fill;
62+
transition: 200ms ease-out;
63+
}
6164

62-
border-style: none;
65+
button { @include button($toolbar_bg_color, $toolbar_fg_color); }
6366

64-
&.inline-toolbar {
65-
background-image: none;
66-
border-width: 0 1px 1px;
67-
border-style: solid;
68-
border-color: $borders_color;
69-
background-color: mix($borders_color, $bg_color, .7);
67+
toolbutton,
68+
toolbutton:backdrop {
69+
> button.flat { @extend %linked_middle; }
7070

71-
&:backdrop {
72-
border-color: $backdrop_borders_color;
73-
background-color: $backdrop_dark_fill;
74-
transition: 200ms ease-out;
75-
}
71+
&:first-child > button.flat { @extend %linked_button:first-child; }
7672

77-
button { @include button($toolbar_bg_color, $toolbar_fg_color); }
73+
&:last-child > button.flat { @extend %linked_button:last-child; }
7874

79-
toolbutton,
80-
toolbutton:backdrop {
81-
> button.flat { @extend %linked_middle; }
75+
&:only-child > button.flat { @extend %linked_button:only-child; }
76+
}
77+
}
8278

83-
&:first-child > button.flat { @extend %linked_button:first-child; }
79+
@include exports("toolbar_extends") {
80+
%toolbar {
81+
padding: $spacing - 1px;
82+
border-style: none;
8483

85-
&:last-child > button.flat { @extend %linked_button:last-child; }
84+
// toolbar separators
85+
&.horizontal separator { margin: 0 ($spacing + 2px) 1px; }
8686

87-
&:only-child > button.flat { @extend %linked_button:only-child; }
88-
}
89-
}
87+
&.vertical separator { margin: ($spacing + 2px) 1px ($spacing + 2px) 0; }
9088
}
9189

92-
headerbar {
93-
@include toolbar($titlebar_bg_color, $titlebar_fg_color);
94-
90+
%headerbar {
9591
border-width: 0 0 1px;
9692
border-style: solid;
9793

94+
// add vertical margins to common widget on the headerbar to avoid them spanning the whole height
95+
entry,
96+
spinbutton,
97+
separator,
98+
switch,
99+
button { // Size height
100+
margin-top: $spacing + 3px;
101+
margin-bottom: $spacing + 3px;
102+
}
103+
104+
switch { // Size height
105+
margin-top: $spacing + 1px;
106+
margin-bottom: $spacing + 1px;
107+
}
108+
98109
window:not(.tiled):not(.maximized) separator:first-child + &, // tackles the paned container case
99110
window:not(.tiled):not(.maximized) &:first-child { &:backdrop, & { border-top-left-radius: $roundness; } }
100111

101112
window:not(.tiled):not(.maximized) &:last-child { &:backdrop, & { border-top-right-radius: $roundness; } }
102113
}
103114

104-
.background:not(.tiled):not(.maximized) .titlebar {
105-
&:backdrop, & {
106-
border-top-left-radius: $roundness;
107-
border-top-right-radius: $roundness;
108-
}
109-
}
110-
111-
.titlebar {
115+
%titlebar { // Default headerbar and titlebar code.
116+
@include toolbar($titlebar_bg_color, $titlebar_fg_color);
112117
@include linear-gradient($titlebar_bg_color);
113118

114119
border-radius: $roundness $roundness 0 0;
115120
color: mix($titlebar_fg_color, $titlebar_bg_color, .1);
121+
padding: 0 $spacing;
122+
min-height: 42px;
116123

117124
&:backdrop {
118125
@include linear-gradient($titlebar_bg_color);
@@ -121,24 +128,32 @@
121128
text-shadow: none;
122129
}
123130

124-
&.default-decoration {
125-
border: 0;
131+
&.default-decoration { // Default titlebar (old metacity)
132+
min-height: 24px;
126133
box-shadow: none;
134+
border: 0;
135+
136+
button.titlebutton {
137+
min-height: 16px;
138+
min-width: 16px;
139+
margin: 0;
140+
padding: 0;
141+
}
127142
}
128143

129-
.tiled &, .maximized & { border-radius: 0; }
144+
.tiled &,
145+
.maximized & { &:backdrop, & { border-radius: 0; } } // squared corners when the window is maximized or tiled
130146

131147
.title { font-weight: bold; }
132148

133-
separator.titlebutton { margin-left: $spacing * 2; }
149+
separator.titlebutton { margin-left: $spacing; }
134150

135151
button.titlebutton + separator.titlebutton {
136152
margin-left: 0;
137-
margin-right: $spacing * 2;
153+
margin-right: $spacing;
138154
}
139155

140156
button.titlebutton {
141-
padding: $spacing;
142157
border: 0;
143158
background-image: none;
144159
background-color: transparent;
@@ -167,3 +182,41 @@
167182
}
168183
}
169184
}
185+
186+
@include exports("toolbar") {
187+
toolbar {
188+
@include toolbar($toolbar_bg_color, $toolbar_fg_color);
189+
190+
@extend %toolbar;
191+
192+
&.inline-toolbar { @include inline-toolbar($toolbar_bg_color, $toolbar_fg_color); }
193+
}
194+
195+
headerbar {
196+
@extend %titlebar;
197+
@extend %headerbar;
198+
}
199+
200+
.titlebar:not(headerbar) {
201+
window.csd > & {
202+
// in csd we assume every titlebar is a headerbar so reset anything, this is needed for split toolbars cases
203+
padding: 0;
204+
background-color: transparent;
205+
background-image: none;
206+
border-style: none;
207+
border-color: transparent;
208+
box-shadow: none;
209+
}
210+
211+
> separator { background-color: shade($titlebar_bg_color, .88); } // $borders_color
212+
213+
@extend %titlebar;
214+
}
215+
216+
.background:not(.tiled):not(.maximized) .titlebar {
217+
&:backdrop, & {
218+
border-top-left-radius: $roundness;
219+
border-top-right-radius: $roundness;
220+
}
221+
}
222+
}

0 commit comments

Comments
 (0)