Merge lp:~marten-truu/plank/optional-gradients into lp:plank
- optional-gradients
- Merge into trunk
Status: | Needs review |
---|---|
Proposed branch: | lp:~marten-truu/plank/optional-gradients |
Merge into: | lp:plank |
Diff against target: |
374 lines (+211/-30) 6 files modified
data/themes/Glowless/dock.theme (+70/-0) data/themes/Makefile.am (+5/-0) lib/DockRenderer.vala (+5/-5) lib/Drawing/DockTheme.vala (+106/-22) lib/Items/Enums.vala (+22/-0) tests/Drawing.vala (+3/-3) |
To merge this branch: | bzr merge lp:~marten-truu/plank/optional-gradients |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Rico Tzschichholz | Needs Information | ||
Review via email: mp+290819@code.launchpad.net |
Commit message
Description of the change
Pictures should explain the mess I've made better: https:/
It's a link to an earlier modification, but the new options look the same except for the additional option of a solid active item background.
Hopefully something like this would be welcome in plank for people who prefer their dock non-glowy. :)
truu (marten-truu) wrote : | # |
Cool, I'll use git instead then. ^^
I'll try to remove possible need for spacing with bigger circles and see whether height or width could be in relation to something to remove the need for a height setting for underline type indicators.
Rico Tzschichholz (ricotz) wrote : | # |
bzr merges are still preferred though. Of course you can keep developing in git.
truu (marten-truu) wrote : | # |
Oh. :D I'll just keep using bzr for this then.
truu (marten-truu) wrote : | # |
In case of the circle indicator the size is a 50th of the icon size as opposed to a 10th, but it looks roughly the right size when compared to the other indicators. Not sure yet what to do about that.
Rico Tzschichholz (ricotz) wrote : | # |
I pushed some WIP to https:/
Rico Tzschichholz (ricotz) wrote : | # |
IndicatorStyleT
truu (marten-truu) wrote : | # |
I noticed the lines already look nice in the indicator-style branch :D
In my opinion the circles could use a slight boost off the ground and since this branch is pretty outdated now, I'll just paste the idea here. :D
=== modified file 'lib/Drawing/
--- lib/Drawing/
+++ lib/Drawing/
@@ -226,6 +226,10 @@
{
// Force square if needed which eases the placement in renderer
switch (IndicatorStyle) {
+ case IndicatorStyleT
+ height = height + height / 2;
+ width = height;
+ break;
case IndicatorStyleT
if (position == Gtk.PositionTyp
|| position == Gtk.PositionTyp
@@ -273,7 +277,7 @@
case IndicatorStyleT
var x = height / 2, y = x;
cr.move_to (x, y);
- cr.arc (x, y, height / 2, 0, Math.PI * 2);
+ cr.arc (x, y, height / 3, 0, Math.PI * 2);
cr.close_path ();
cr.
break;
Rico Tzschichholz (ricotz) wrote : | # |
To accomplish that there is offset_factor, but I am struggling with implementation details while this hole thing is a bit hacky and needs some further thinking.
truu (marten-truu) wrote : | # |
Oh. Well if I can be of service with that somehow, I'd be happy to help. :)
Unmerged revisions
- 1553. By truu
-
Initial fix for lines when placed to the right and left.
- 1552. By truu
-
Gave the active item gradientless background a smooth transition as well.
- 1551. By truu
-
Removed now unnecessary space additions.
- 1550. By truu
-
Removed Spacing and Height options, probably created a weird style enum in a weird place and put some things where they should've been put all along.
- 1549. By truu
-
Add missing newline.
- 1548. By truu
-
Makes gradients optional by adding a few theming options.
Preview Diff
1 | === added directory 'data/themes/Glowless' |
2 | === added file 'data/themes/Glowless/dock.theme' |
3 | --- data/themes/Glowless/dock.theme 1970-01-01 00:00:00 +0000 |
4 | +++ data/themes/Glowless/dock.theme 2016-04-04 13:31:52 +0000 |
5 | @@ -0,0 +1,70 @@ |
6 | + |
7 | +[PlankTheme] |
8 | +#The roundness of the top corners. |
9 | +TopRoundness=4 |
10 | +#The roundness of the bottom corners. |
11 | +BottomRoundness=0 |
12 | +#The thickness (in pixels) of lines drawn. |
13 | +LineWidth=0 |
14 | +#The color (RGBA) of the outer stroke. |
15 | +OuterStrokeColor=255;;255;;255;;200 |
16 | +#The starting color (RGBA) of the fill gradient. |
17 | +FillStartColor=38;;50;;56;;200 |
18 | +#The ending color (RGBA) of the fill gradient. |
19 | +FillEndColor=38;;50;;56;;200 |
20 | +#The color (RGBA) of the inner stroke. |
21 | +InnerStrokeColor=2;;2;;2;;0 |
22 | + |
23 | +[PlankDockTheme] |
24 | +#The padding on the left/right dock edges, in tenths of a percent of IconSize. |
25 | +HorizPadding=1 |
26 | +#The padding on the top dock edge, in tenths of a percent of IconSize. |
27 | +TopPadding=1 |
28 | +#The padding on the bottom dock edge, in tenths of a percent of IconSize. |
29 | +BottomPadding=1.5 |
30 | +#The padding between items on the dock, in tenths of a percent of IconSize. |
31 | +ItemPadding=2 |
32 | +#The size of item indicators, in tenths of a percent of IconSize. |
33 | +IndicatorSize=5 |
34 | +#Whether an item has an active background glow. If not, active-item-color (RGBA) will be used instead. |
35 | +ActiveGlow=false |
36 | +#The size of the icon-shadow behind every item, in tenths of a percent of IconSize. |
37 | +IconShadowSize=1 |
38 | +#The style of item indicators (values 0 - 3), styles: 0 - circle-glow, 1 - circle-color-glow, 2 - circle, 3 - underline. |
39 | +IndicatorStyle=2 |
40 | +#The color (RGBA) of the indicator. |
41 | +IndicatorColor=225;;225;;225;;255 |
42 | +#The color (RGBA) of the active item background. |
43 | +ActiveItemColor=0;;0;;0;;0 |
44 | +#The height (in percent of IconSize) to bounce an icon when the application sets urgent. |
45 | +UrgentBounceHeight=1.6666666666666667 |
46 | +#The height (in percent of IconSize) to bounce an icon when launching an application. |
47 | +LaunchBounceHeight=0.625 |
48 | +#The opacity value (0 to 1) to fade the dock to when hiding it. |
49 | +FadeOpacity=1 |
50 | +#The amount of time (in ms) for click animations. |
51 | +ClickTime=300 |
52 | +#The amount of time (in ms) to bounce an urgent icon. |
53 | +UrgentBounceTime=600 |
54 | +#The amount of time (in ms) to bounce an icon when launching an application. |
55 | +LaunchBounceTime=600 |
56 | +#The amount of time (in ms) for active window indicator animations. |
57 | +ActiveTime=300 |
58 | +#The amount of time (in ms) to slide icons into/out of the dock. |
59 | +SlideTime=300 |
60 | +#The time (in ms) to fade the dock in/out on a hide (if FadeOpacity is < 1). |
61 | +FadeTime=250 |
62 | +#The time (in ms) to slide the dock in/out on a hide (if FadeOpacity is 1). |
63 | +HideTime=250 |
64 | +#The size of the urgent glow (shown when dock is hidden), in tenths of a percent of IconSize. |
65 | +GlowSize=30 |
66 | +#The total time (in ms) to show the hidden-dock urgent glow. |
67 | +GlowTime=10000 |
68 | +#The time (in ms) of each pulse of the hidden-dock urgent glow. |
69 | +GlowPulseTime=2000 |
70 | +#The hue-shift (-180 to 180) of the urgent indicator color. |
71 | +UrgentHueShift=150 |
72 | +#The time (in ms) to move an item to its new position or its addition/removal to/from the dock. |
73 | +ItemMoveTime=450 |
74 | +#Whether background and icons will unhide/hide with different speeds. The top-border of both will leave/hit the screen-edge at the same time. |
75 | +CascadeHide=true |
76 | |
77 | === modified file 'data/themes/Makefile.am' |
78 | --- data/themes/Makefile.am 2013-11-10 12:52:40 +0000 |
79 | +++ data/themes/Makefile.am 2016-04-04 13:31:52 +0000 |
80 | @@ -14,3 +14,8 @@ |
81 | dist_transparenttheme_DATA = \ |
82 | Transparent/dock.theme \ |
83 | $(NULL) |
84 | + |
85 | +glowlessthemedir = $(pkgdatadir)/themes/Glowless |
86 | +dist_glowlesstheme_DATA = \ |
87 | + Glowless/dock.theme \ |
88 | + $(NULL) |
89 | |
90 | === modified file 'lib/DockRenderer.vala' |
91 | --- lib/DockRenderer.vala 2016-02-28 12:06:16 +0000 |
92 | +++ lib/DockRenderer.vala 2016-04-04 13:31:52 +0000 |
93 | @@ -937,13 +937,13 @@ |
94 | if (indicator_buffer == null) { |
95 | var indicator_color = get_styled_color (); |
96 | indicator_color.set_min_sat (0.4); |
97 | - indicator_buffer = theme.create_indicator (position_manager.IndicatorSize, indicator_color, item_buffer); |
98 | + indicator_buffer = theme.create_indicator (position_manager.IndicatorSize, position_manager.Position, indicator_color, item_buffer); |
99 | } |
100 | if (urgent_indicator_buffer == null) { |
101 | var urgent_indicator_color = get_styled_color (); |
102 | urgent_indicator_color.add_hue (theme.UrgentHueShift); |
103 | urgent_indicator_color.set_sat (1.0); |
104 | - urgent_indicator_buffer = theme.create_indicator (position_manager.IndicatorSize, urgent_indicator_color, item_buffer); |
105 | + urgent_indicator_buffer = theme.create_indicator (position_manager.IndicatorSize, position_manager.Position, urgent_indicator_color, item_buffer); |
106 | } |
107 | |
108 | unowned Surface indicator_surface = (item_state & ItemState.URGENT) != 0 ? urgent_indicator_buffer : indicator_buffer; |
109 | @@ -969,15 +969,15 @@ |
110 | break; |
111 | } |
112 | |
113 | - if (indicator == IndicatorState.SINGLE) { |
114 | + if (indicator == IndicatorState.SINGLE || theme.IndicatorStyle == ItemIndicatorStyle.UNDERLINE) { |
115 | cr.set_source_surface (indicator_surface.Internal, x, y); |
116 | cr.paint (); |
117 | } else { |
118 | var x_offset = 0.0, y_offset = 0.0; |
119 | if (position_manager.is_horizontal_dock ()) |
120 | - x_offset = position_manager.IconSize / 16.0; |
121 | + x_offset = position_manager.IndicatorSize * 0.15; |
122 | else |
123 | - y_offset = position_manager.IconSize / 16.0; |
124 | + y_offset = position_manager.IndicatorSize * 0.15; |
125 | |
126 | cr.set_source_surface (indicator_surface.Internal, x - x_offset, y - y_offset); |
127 | cr.paint (); |
128 | |
129 | === modified file 'lib/Drawing/DockTheme.vala' |
130 | --- lib/Drawing/DockTheme.vala 2016-03-12 15:14:09 +0000 |
131 | +++ lib/Drawing/DockTheme.vala 2016-04-04 13:31:52 +0000 |
132 | @@ -43,6 +43,9 @@ |
133 | [Description(nick = "indicator-size", blurb = "The size of item indicators, in tenths of a percent of IconSize.")] |
134 | public double IndicatorSize { get; set; } |
135 | |
136 | + [Description(nick = "indicator-style", blurb = "The style of item indicators, styles: circle-glow, circle-color-glow, circle, underline.")] |
137 | + public ItemIndicatorStyle IndicatorStyle { get; set; default = ItemIndicatorStyle.CIRCLE_GLOW; } |
138 | + |
139 | [Description(nick = "icon-shadow-size", blurb = "The size of the icon-shadow behind every item, in tenths of a percent of IconSize.")] |
140 | public double IconShadowSize { get; set; } |
141 | |
142 | @@ -94,6 +97,15 @@ |
143 | [Description(nick = "cascade-hide", blurb = "Whether background and icons will unhide/hide with different speeds. The top-border of both will leave/hit the screen-edge at the same time.")] |
144 | public bool CascadeHide { get; set; } |
145 | |
146 | + [Description(nick = "active-glow", blurb = "Whether an item has an active background glow. If not, active-item-color (RGBA) will be used instead.")] |
147 | + public bool ActiveGlow { get; set; } |
148 | + |
149 | + [Description(nick = "indicator-color", blurb = "The color (RGBA) of the indicator.")] |
150 | + public Color IndicatorColor { get; set; } |
151 | + |
152 | + [Description(nick = "active-item-color", blurb = "The color (RGBA) of the active item background.")] |
153 | + public Color ActiveItemColor { get; set; } |
154 | + |
155 | public DockTheme (string name) |
156 | { |
157 | base.with_name (name); |
158 | @@ -112,6 +124,7 @@ |
159 | BottomPadding = 2.5; |
160 | ItemPadding = 2.5; |
161 | IndicatorSize = 5.0; |
162 | + IndicatorStyle = ItemIndicatorStyle.CIRCLE_GLOW; |
163 | IconShadowSize = 1.0; |
164 | UrgentBounceHeight = 5.0 / 3.0; |
165 | LaunchBounceHeight = 0.625; |
166 | @@ -129,6 +142,9 @@ |
167 | UrgentHueShift = 150; |
168 | ItemMoveTime = 450; |
169 | CascadeHide = true; |
170 | + ActiveGlow = true; |
171 | + IndicatorColor = { 255, 255, 255, 1.0 }; |
172 | + ActiveItemColor = { 0.0, 0.0, 0.0, 0.0 }; |
173 | } |
174 | |
175 | /** |
176 | @@ -204,7 +220,7 @@ |
177 | * @param model existing surface to use as basis of new surface |
178 | * @return a new surface with the indicator drawn on it |
179 | */ |
180 | - public Surface create_indicator (int size, Color color, Surface model) |
181 | + public Surface create_indicator (int size, Gtk.PositionType position, Color color, Surface model) |
182 | { |
183 | Logger.verbose ("DockTheme.create_indicator (size = %i)", size); |
184 | |
185 | @@ -213,25 +229,77 @@ |
186 | |
187 | if (size <= 0) |
188 | return surface; |
189 | - |
190 | + |
191 | unowned Cairo.Context cr = surface.Context; |
192 | |
193 | - var x = size / 2; |
194 | - var y = x; |
195 | - |
196 | - cr.move_to (x, y); |
197 | - cr.arc (x, y, size / 2, 0, Math.PI * 2); |
198 | - cr.close_path (); |
199 | - |
200 | - var rg = new Cairo.Pattern.radial (x, y, 0, x, y, size / 2); |
201 | - rg.add_color_stop_rgba (0, 1, 1, 1, 1); |
202 | - rg.add_color_stop_rgba (0.1, color.red, color.green, color.blue, 1); |
203 | - rg.add_color_stop_rgba (0.2, color.red, color.green, color.blue, 0.6); |
204 | - rg.add_color_stop_rgba (0.25, color.red, color.green, color.blue, 0.25); |
205 | - rg.add_color_stop_rgba (0.5, color.red, color.green, color.blue, 0.15); |
206 | - rg.add_color_stop_rgba (1.0, color.red, color.green, color.blue, 0.0); |
207 | - |
208 | - cr.set_source (rg); |
209 | + switch (IndicatorStyle) { |
210 | + case ItemIndicatorStyle.CIRCLE_GLOW: |
211 | + var x = size / 2; |
212 | + var y = x; |
213 | + |
214 | + cr.move_to (x, y); |
215 | + cr.arc (x, y, size / 2, 0, Math.PI * 2); |
216 | + cr.close_path (); |
217 | + |
218 | + var rg = new Cairo.Pattern.radial (x, y, 0, x, y, size / 2); |
219 | + rg.add_color_stop_rgba (0, 1, 1, 1, 1); |
220 | + rg.add_color_stop_rgba (0.1, color.red, color.green, color.blue, 1); |
221 | + rg.add_color_stop_rgba (0.2, color.red, color.green, color.blue, 0.6); |
222 | + rg.add_color_stop_rgba (0.25, color.red, color.green, color.blue, 0.25); |
223 | + rg.add_color_stop_rgba (0.5, color.red, color.green, color.blue, 0.15); |
224 | + rg.add_color_stop_rgba (1.0, color.red, color.green, color.blue, 0.0); |
225 | + |
226 | + cr.set_source (rg); |
227 | + break; |
228 | + case ItemIndicatorStyle.CIRCLE_COLOR_GLOW: |
229 | + var x = size / 2; |
230 | + var y = x; |
231 | + |
232 | + cr.move_to (x, y); |
233 | + cr.arc (x, y, size / 2, 0, Math.PI * 2); |
234 | + cr.close_path (); |
235 | + |
236 | + var rg = new Cairo.Pattern.radial (x, y, 0, x, y, size / 2); |
237 | + rg.add_color_stop_rgba (0, IndicatorColor.red, IndicatorColor.green, IndicatorColor.blue, 1 * IndicatorColor.alpha); |
238 | + rg.add_color_stop_rgba (0.1, IndicatorColor.red, IndicatorColor.green, IndicatorColor.blue, 0.8 * IndicatorColor.alpha); |
239 | + rg.add_color_stop_rgba (0.2, IndicatorColor.red, IndicatorColor.green, IndicatorColor.blue, 0.6 * IndicatorColor.alpha); |
240 | + rg.add_color_stop_rgba (0.25, IndicatorColor.red, IndicatorColor.green, IndicatorColor.blue, 0.25 * IndicatorColor.alpha); |
241 | + rg.add_color_stop_rgba (0.5, IndicatorColor.red, IndicatorColor.green, IndicatorColor.blue, 0.15 * IndicatorColor.alpha); |
242 | + rg.add_color_stop_rgba (1.0, IndicatorColor.red, IndicatorColor.green, IndicatorColor.blue, 0.0 * IndicatorColor.alpha); |
243 | + |
244 | + cr.set_source (rg); |
245 | + break; |
246 | + case ItemIndicatorStyle.CIRCLE: |
247 | + var x = size / 2.0; |
248 | + var y = size / 2.5; |
249 | + |
250 | + cr.move_to (x, y); |
251 | + cr.arc (x, y, size / 10.0, 0, Math.PI * 2); |
252 | + cr.close_path (); |
253 | + cr.set_source_rgba (IndicatorColor.red, IndicatorColor.green, IndicatorColor.blue, IndicatorColor.alpha); |
254 | + break; |
255 | + case ItemIndicatorStyle.UNDERLINE: |
256 | + if (position == Gtk.PositionType.RIGHT || position == Gtk.PositionType.LEFT) { |
257 | + var x = size / 2; |
258 | + var y = 0; |
259 | + cr.move_to (x, y); |
260 | + cr.rel_line_to (0, size); |
261 | + cr.rel_line_to (position == Gtk.PositionType.RIGHT ? size / 8 : -size / 8, 0); |
262 | + cr.rel_line_to (0, -size); |
263 | + cr.rel_line_to (position == Gtk.PositionType.RIGHT ? -size / 8 : size / 8, 0); |
264 | + } else { |
265 | + var x = 0; |
266 | + var y = position == Gtk.PositionType.BOTTOM ? size / 2 : size / 2.5; |
267 | + cr.move_to (x, y); |
268 | + cr.rel_line_to (size, 0); |
269 | + cr.rel_line_to (0, size / 8); |
270 | + cr.rel_line_to (-size, 0); |
271 | + cr.rel_line_to (0, -size / 8); |
272 | + } |
273 | + cr.set_source_rgba (IndicatorColor.red, IndicatorColor.green, IndicatorColor.blue, IndicatorColor.alpha); |
274 | + break; |
275 | + } |
276 | + |
277 | cr.fill (); |
278 | |
279 | return surface; |
280 | @@ -339,12 +407,17 @@ |
281 | |
282 | cr.set_line_width (LineWidth); |
283 | cr.clip (); |
284 | - |
285 | - gradient.add_color_stop_rgba (0, color.red, color.green, color.blue, 0); |
286 | - gradient.add_color_stop_rgba (1, color.red, color.green, color.blue, 0.6 * opacity); |
287 | |
288 | cr.rectangle (rect.x, rect.y, rect.width, rect.height); |
289 | - cr.set_source (gradient); |
290 | + |
291 | + if (ActiveGlow) { |
292 | + gradient.add_color_stop_rgba (0, color.red, color.green, color.blue, 0); |
293 | + gradient.add_color_stop_rgba (1, color.red, color.green, color.blue, 0.6 * opacity); |
294 | + cr.set_source (gradient); |
295 | + } else { |
296 | + cr.set_source_rgba(ActiveItemColor.red, ActiveItemColor.green, ActiveItemColor.blue, ActiveItemColor.alpha * opacity); |
297 | + } |
298 | + |
299 | cr.fill (); |
300 | |
301 | cr.reset_clip (); |
302 | @@ -568,6 +641,11 @@ |
303 | IconShadowSize = MAX_ICON_SHADOW_SIZE; |
304 | break; |
305 | |
306 | + case "IndicatorStyle": |
307 | + if (IndicatorStyle < 0 || IndicatorStyle > 3) |
308 | + IndicatorStyle = ItemIndicatorStyle.CIRCLE_GLOW; |
309 | + break; |
310 | + |
311 | case "UrgentBounceHeight": |
312 | if (UrgentBounceHeight < 0) |
313 | UrgentBounceHeight = 0; |
314 | @@ -641,6 +719,12 @@ |
315 | else if (UrgentHueShift > 180) |
316 | UrgentHueShift = 180; |
317 | break; |
318 | + |
319 | + case "IndicatorColor": |
320 | + break; |
321 | + |
322 | + case "ActiveItemColor": |
323 | + break; |
324 | } |
325 | } |
326 | } |
327 | |
328 | === modified file 'lib/Items/Enums.vala' |
329 | --- lib/Items/Enums.vala 2015-11-03 10:37:19 +0000 |
330 | +++ lib/Items/Enums.vala 2016-04-04 13:31:52 +0000 |
331 | @@ -135,4 +135,26 @@ |
332 | } |
333 | } |
334 | } |
335 | + /** |
336 | + * The style of the item indicator. |
337 | + */ |
338 | + public enum ItemIndicatorStyle |
339 | + { |
340 | + /** |
341 | + * A glowing circle with the default color. |
342 | + */ |
343 | + CIRCLE_GLOW, |
344 | + /** |
345 | + * A glowing circle with a theme-defined color. |
346 | + */ |
347 | + CIRCLE_COLOR_GLOW, |
348 | + /** |
349 | + * A filled circle with a theme-defined color. |
350 | + */ |
351 | + CIRCLE, |
352 | + /** |
353 | + * A line under the icon. |
354 | + */ |
355 | + UNDERLINE |
356 | + } |
357 | } |
358 | |
359 | === modified file 'tests/Drawing.vala' |
360 | --- tests/Drawing.vala 2015-11-03 10:40:13 +0000 |
361 | +++ tests/Drawing.vala 2016-04-04 13:31:52 +0000 |
362 | @@ -421,9 +421,9 @@ |
363 | docktheme = new DockTheme ("Test"); |
364 | Color color = { 0.5, 0.4, 0.3, 1.0 }; |
365 | |
366 | - surface2 = docktheme.create_indicator (-1, color, surface); |
367 | - surface2 = docktheme.create_indicator (64, color, surface); |
368 | - surface2 = docktheme.create_indicator (512, color, surface); |
369 | + surface2 = docktheme.create_indicator (-1, Gtk.PositionType.BOTTOM, color, surface); |
370 | + surface2 = docktheme.create_indicator (64, Gtk.PositionType.RIGHT, color, surface); |
371 | + surface2 = docktheme.create_indicator (512, Gtk.PositionType.LEFT, color, surface); |
372 | } |
373 | |
374 | void drawing_theme_create_urgent_glow () |
Interesting, some quick notes to begin with and this might go through some iterations ;-)
We want to keep it simple and "IndicatorStyle", "IndicatorColor" and "IndicatorSize" should be enough information to draw it. No need for "IndicatorSpacing" and "IndicatorHeight"!
"IndicatorStyle" should be an Enum.
Changes of Theme.vala should be in DockTheme.vala as well.
Btw, the official git repo is https:/ /git.launchpad. net/plank/ (Mirrored to https:/ /github. com/ricotz/ plank)