Merge lp:~docky-core/plank/indicator-style into lp:plank

Proposed by Rico Tzschichholz
Status: Work in progress
Proposed branch: lp:~docky-core/plank/indicator-style
Merge into: lp:plank
Diff against target: 649 lines (+378/-47)
8 files modified
data/themes/Glowless/dock.theme (+70/-0)
data/themes/Makefile.am (+5/-0)
docs/Makefile.am (+1/-0)
lib/DockRenderer.vala (+35/-42)
lib/Drawing/DockTheme.vala (+193/-5)
lib/Drawing/Enums.vala (+63/-0)
lib/Makefile.am (+1/-0)
lib/libplank.symbols (+10/-0)
To merge this branch: bzr merge lp:~docky-core/plank/indicator-style
Reviewer Review Type Date Requested Status
truu (community) testing Needs Information
Docky Core Pending
Review via email: mp+290904@code.launchpad.net

Description of the change

* Reworked indicator-drawing while adding some styles

(Branch will get rebased and squashed in self-contained/logical commits)

TODO:
* Naming of new theme-settings needs some more thinking
* Add new theme "Modern" / "Flat" (?) which makes use of the new features

THOUGHTS:
* Moving caching in the theme rather than handle it in the renderer?

To post a comment you must log in.
Revision history for this message
truu (marten-truu) wrote :

Theme naming:
I'd vote for "flat" in case of a theme with the line type indicator and "modern" in case of the circle.

Looks:
The circular ones look better if their center is in the middle of bottom padding: http://imgur.com/co1S0t7
An extra slight bump off the ground instead might look better too.

The circles also end up a bit too close together at times, depending on the size set (indicatorsize 1 looked to be too close, while 1.2 looked fine at icon size 48)
http://imgur.com/sUCYEoN

In my opinion lines should not indicate several instances being open, as it appears strange :D
Neither chrome os nor windows seem to provide such information while having that kind of indicators. It feels as if the application were somehow divided into smaller fragments.

review: Needs Information (testing)
lp:~docky-core/plank/indicator-style updated
1550. By Rico Tzschichholz

surface: Some minor cleaning

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

> Theme naming:
> I'd vote for "flat" in case of a theme with the line type indicator and
> "modern" in case of the circle.

Let's see how this turns out when the styles are finished ;-)

> Looks:
> The circular ones look better if their center is in the middle of bottom
> padding: http://imgur.com/co1S0t7
> An extra slight bump off the ground instead might look better too.

I am not really convinced here.

> The circles also end up a bit too close together at times, depending on the
> size set (indicatorsize 1 looked to be too close, while 1.2 looked fine at
> icon size 48)
> http://imgur.com/sUCYEoN

Should be better now

> In my opinion lines should not indicate several instances being open, as it
> appears strange :D
> Neither chrome os nor windows seem to provide such information while having
> that kind of indicators. It feels as if the application were somehow divided
> into smaller fragments.

I agree here.

Revision history for this message
truu (marten-truu) wrote :

stroke_preserve seems to make the indicators strangely fuzzy :D
Can't really tell with circles but it's very noticeable with lines.

The lines are also now lifted slightly off the ground by about the amount that I like the indicators to be. But I suppose that's a up to personal preference.

I'll also add a side-by-side of the lifted and not circles with values I'd actually use:
http://imgur.com/oicu9Kp
Perhaps of some use as reference when deciding which way to go.

tldr: imo the lines should be grounded and not fuzzy.

lp:~docky-core/plank/indicator-style updated
1551. By Rico Tzschichholz

drawing/color: Add support for HSL and some convenience functions

1555. By Rico Tzschichholz

WIP

1556. By Rico Tzschichholz

WIP

1557. By Rico Tzschichholz

WIP

1558. By Rico Tzschichholz

WIP

1559. By Rico Tzschichholz

WIP

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

Unmerged revisions

1559. By Rico Tzschichholz

WIP

1558. By Rico Tzschichholz

WIP

1557. By Rico Tzschichholz

WIP

1556. By Rico Tzschichholz

WIP

1555. By Rico Tzschichholz

WIP

1554. 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.

1553. By truu

Add missing newline.

1552. By truu

Makes gradients optional by adding a few theming options.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'data/themes/Glowless'
=== added file 'data/themes/Glowless/dock.theme'
--- data/themes/Glowless/dock.theme 1970-01-01 00:00:00 +0000
+++ data/themes/Glowless/dock.theme 2016-04-10 16:22:24 +0000
@@ -0,0 +1,70 @@
1
2[PlankTheme]
3#The roundness of the top corners.
4TopRoundness=4
5#The roundness of the bottom corners.
6BottomRoundness=0
7#The thickness (in pixels) of lines drawn.
8LineWidth=0
9#The color (RGBA) of the outer stroke.
10OuterStrokeColor=255;;255;;255;;200
11#The starting color (RGBA) of the fill gradient.
12FillStartColor=38;;50;;56;;200
13#The ending color (RGBA) of the fill gradient.
14FillEndColor=38;;50;;56;;200
15#The color (RGBA) of the inner stroke.
16InnerStrokeColor=2;;2;;2;;0
17
18[PlankDockTheme]
19#The padding on the left/right dock edges, in tenths of a percent of IconSize.
20HorizPadding=1
21#The padding on the top dock edge, in tenths of a percent of IconSize.
22TopPadding=1
23#The padding on the bottom dock edge, in tenths of a percent of IconSize.
24BottomPadding=1.5
25#The padding between items on the dock, in tenths of a percent of IconSize.
26ItemPadding=2
27#The size of item indicators, in tenths of a percent of IconSize.
28IndicatorSize=5
29#The size of the icon-shadow behind every item, in tenths of a percent of IconSize.
30IconShadowSize=1
31#The style of item indicators (values 0 - 3), styles: 0 - circle-glow, 1 - circle-color-glow, 2 - circle, 3 - underline.
32IndicatorStyle=2
33#The color (RGBA) of the indicator.
34IndicatorColor=225;;225;;225;;255
35#The height (in percent of IconSize) to bounce an icon when the application sets urgent.
36UrgentBounceHeight=1.6666666666666667
37#The height (in percent of IconSize) to bounce an icon when launching an application.
38LaunchBounceHeight=0.625
39#The opacity value (0 to 1) to fade the dock to when hiding it.
40FadeOpacity=1
41#The amount of time (in ms) for click animations.
42ClickTime=300
43#The amount of time (in ms) to bounce an urgent icon.
44UrgentBounceTime=600
45#The amount of time (in ms) to bounce an icon when launching an application.
46LaunchBounceTime=600
47#The amount of time (in ms) for active window indicator animations.
48ActiveTime=300
49#The amount of time (in ms) to slide icons into/out of the dock.
50SlideTime=300
51#The time (in ms) to fade the dock in/out on a hide (if FadeOpacity is < 1).
52FadeTime=250
53#The time (in ms) to slide the dock in/out on a hide (if FadeOpacity is 1).
54HideTime=250
55#The size of the urgent glow (shown when dock is hidden), in tenths of a percent of IconSize.
56GlowSize=30
57#The total time (in ms) to show the hidden-dock urgent glow.
58GlowTime=10000
59#The time (in ms) of each pulse of the hidden-dock urgent glow.
60GlowPulseTime=2000
61#The hue-shift (-180 to 180) of the urgent indicator color.
62UrgentHueShift=150
63#The time (in ms) to move an item to its new position or its addition/removal to/from the dock.
64ItemMoveTime=450
65#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.
66CascadeHide=true
67#Whether an item has an active background glow. If not, active-item-color (RGBA) will be used instead.
68SelectionStyle=1
69#The color (RGBA) of the active item background.
70SelectionColor=0;;0;;0;;0
071
=== modified file 'data/themes/Makefile.am'
--- data/themes/Makefile.am 2013-11-10 12:52:40 +0000
+++ data/themes/Makefile.am 2016-04-10 16:22:24 +0000
@@ -14,3 +14,8 @@
14dist_transparenttheme_DATA = \14dist_transparenttheme_DATA = \
15 Transparent/dock.theme \15 Transparent/dock.theme \
16 $(NULL)16 $(NULL)
17
18glowlessthemedir = $(pkgdatadir)/themes/Glowless
19dist_glowlesstheme_DATA = \
20 Glowless/dock.theme \
21 $(NULL)
1722
=== modified file 'docs/Makefile.am'
--- docs/Makefile.am 2016-02-28 12:06:16 +0000
+++ docs/Makefile.am 2016-04-10 16:22:24 +0000
@@ -34,6 +34,7 @@
34 $(top_srcdir)/lib/Drawing/DrawingService.vala \34 $(top_srcdir)/lib/Drawing/DrawingService.vala \
35 $(top_srcdir)/lib/Drawing/DockTheme.vala \35 $(top_srcdir)/lib/Drawing/DockTheme.vala \
36 $(top_srcdir)/lib/Drawing/Easing.vala \36 $(top_srcdir)/lib/Drawing/Easing.vala \
37 $(top_srcdir)/lib/Drawing/Enums.vala \
37 $(top_srcdir)/lib/Drawing/Renderer.vala \38 $(top_srcdir)/lib/Drawing/Renderer.vala \
38 $(top_srcdir)/lib/Drawing/Surface.vala \39 $(top_srcdir)/lib/Drawing/Surface.vala \
39 $(top_srcdir)/lib/Drawing/SurfaceCache.vala \40 $(top_srcdir)/lib/Drawing/SurfaceCache.vala \
4041
=== modified file 'lib/DockRenderer.vala'
--- lib/DockRenderer.vala 2016-02-28 12:06:16 +0000
+++ lib/DockRenderer.vala 2016-04-10 16:22:24 +0000
@@ -59,8 +59,8 @@
59 59
60 Surface? background_buffer = null;60 Surface? background_buffer = null;
61 Gdk.Rectangle background_rect;61 Gdk.Rectangle background_rect;
62 Surface? indicator_buffer = null;62 Surface[] indicator_buffer = new Surface[2];
63 Surface? urgent_indicator_buffer = null;63 Surface[] urgent_indicator_buffer = new Surface[2];
64 Surface? urgent_glow_buffer = null;64 Surface? urgent_glow_buffer = null;
65 65
66 int64 last_hide = 0LL;66 int64 last_hide = 0LL;
@@ -209,8 +209,10 @@
209 shadow_buffer = null;209 shadow_buffer = null;
210 210
211 background_buffer = null;211 background_buffer = null;
212 indicator_buffer = null;212 indicator_buffer[0] = null;
213 urgent_indicator_buffer = null;213 indicator_buffer[1] = null;
214 urgent_indicator_buffer[0] = null;
215 urgent_indicator_buffer[1] = null;
214 urgent_glow_buffer = null;216 urgent_glow_buffer = null;
215 217
216 animated_draw ();218 animated_draw ();
@@ -819,7 +821,8 @@
819 if ((item.State & ItemState.ACTIVE) == 0)821 if ((item.State & ItemState.ACTIVE) == 0)
820 opacity = 1 - opacity;822 opacity = 1 - opacity;
821 if (opacity > 0) {823 if (opacity > 0) {
822 theme.draw_active_glow (item_buffer, background_rect, draw_value.background_region, item.AverageIconColor, opacity, position);824 var color = (theme.SelectionStyle == SelectionStyleType.LEGACY ? item.AverageIconColor : theme.SelectionColor);
825 theme.draw_active_glow (item_buffer, background_rect, draw_value.background_region, color, opacity, position);
823 }826 }
824 827
825 // draw the icon828 // draw the icon
@@ -837,7 +840,7 @@
837 cr.restore ();840 cr.restore ();
838 841
839 // draw indicators842 // draw indicators
840 if (draw_value.show_indicator && item.Indicator != IndicatorState.NONE)843 if (draw_value.show_indicator)
841 draw_indicator_state (cr, draw_value.hover_region, item.Indicator, item.State);844 draw_indicator_state (cr, draw_value.hover_region, item.Indicator, item.State);
842 }845 }
843 846
@@ -877,7 +880,7 @@
877 var surface = new Surface.with_surface (width, height, model);880 var surface = new Surface.with_surface (width, height, model);
878 881
879 var icon_size = int.min (width, height);882 var icon_size = int.min (width, height);
880 var urgent_color = get_styled_color ();883 var urgent_color = (theme.IndicatorStyle == IndicatorStyleType.LEGACY ? get_styled_color () : theme.IndicatorColor);
881 urgent_color.add_hue (theme.UrgentHueShift);884 urgent_color.add_hue (theme.UrgentHueShift);
882 885
883 // draw item's count886 // draw item's count
@@ -930,60 +933,50 @@
930 return surface;933 return surface;
931 }934 }
932 935
933 void draw_indicator_state (Cairo.Context cr, Gdk.Rectangle item_rect, IndicatorState indicator, ItemState item_state)936 void draw_indicator_state (Cairo.Context cr, Gdk.Rectangle item_rect, IndicatorState indicator_state, ItemState item_state)
934 {937 {
938 if (indicator_state == IndicatorState.NONE || theme.IndicatorSize <= 0)
939 return;
940
935 unowned PositionManager position_manager = controller.position_manager;941 unowned PositionManager position_manager = controller.position_manager;
936 942 unowned Surface indicator_surface;
937 if (indicator_buffer == null) {943 var index = indicator_state - 1;
938 var indicator_color = get_styled_color ();944
939 indicator_color.set_min_sat (0.4);945 if ((item_state & ItemState.URGENT) == 0) {
940 indicator_buffer = theme.create_indicator (position_manager.IndicatorSize, indicator_color, item_buffer);946 if (indicator_buffer[index] == null)
941 }947 indicator_buffer[index] = theme.create_indicator_for_state (indicator_state, ItemState.NORMAL,
942 if (urgent_indicator_buffer == null) {948 position_manager.IconSize, position_manager.Position, item_buffer);
943 var urgent_indicator_color = get_styled_color ();949 indicator_surface = indicator_buffer[index];
944 urgent_indicator_color.add_hue (theme.UrgentHueShift);950 } else {
945 urgent_indicator_color.set_sat (1.0);951 if (urgent_indicator_buffer[index] == null)
946 urgent_indicator_buffer = theme.create_indicator (position_manager.IndicatorSize, urgent_indicator_color, item_buffer);952 urgent_indicator_buffer[index] = theme.create_indicator_for_state (indicator_state, ItemState.URGENT,
947 }953 position_manager.IconSize, position_manager.Position, item_buffer);
948 954 indicator_surface = urgent_indicator_buffer[index];
949 unowned Surface indicator_surface = (item_state & ItemState.URGENT) != 0 ? urgent_indicator_buffer : indicator_buffer;955 }
950 956
951 var x = 0.0, y = 0.0;957 var x = 0.0, y = 0.0;
952 switch (position_manager.Position) {958 switch (position_manager.Position) {
953 default:959 default:
954 case Gtk.PositionType.BOTTOM:960 case Gtk.PositionType.BOTTOM:
955 x = item_rect.x + item_rect.width / 2.0 - indicator_surface.Width / 2.0;961 x = item_rect.x + item_rect.width / 2.0 - indicator_surface.Width / 2.0;
956 y = item_buffer.Height - indicator_surface.Height / 2.0 - 2.0 * theme.get_bottom_offset () - indicator_surface.Height / 24.0;962 y = item_buffer.Height - theme.get_bottom_offset () - indicator_surface.Height;
957 break;963 break;
958 case Gtk.PositionType.TOP:964 case Gtk.PositionType.TOP:
959 x = item_rect.x + item_rect.width / 2.0 - indicator_surface.Width / 2.0;965 x = item_rect.x + item_rect.width / 2.0 - indicator_surface.Width / 2.0;
960 y = - indicator_surface.Height / 2.0 + 2.0 * theme.get_bottom_offset () + indicator_surface.Height / 24.0;966 y = theme.get_bottom_offset ();
961 break;967 break;
962 case Gtk.PositionType.LEFT:968 case Gtk.PositionType.LEFT:
963 x = - indicator_surface.Width / 2.0 + 2.0 * theme.get_bottom_offset () + indicator_surface.Width / 24.0;969 x = theme.get_bottom_offset ();
964 y = item_rect.y + item_rect.height / 2.0 - indicator_surface.Height / 2.0;970 y = item_rect.y + item_rect.height / 2.0 - indicator_surface.Height / 2.0;
965 break;971 break;
966 case Gtk.PositionType.RIGHT:972 case Gtk.PositionType.RIGHT:
967 x = item_buffer.Width - indicator_surface.Width / 2.0 - 2.0 * theme.get_bottom_offset () - indicator_surface.Width / 24.0;973 x = item_buffer.Width - theme.get_bottom_offset () - indicator_surface.Width;
968 y = item_rect.y + item_rect.height / 2.0 - indicator_surface.Height / 2.0;974 y = item_rect.y + item_rect.height / 2.0 - indicator_surface.Height / 2.0;
969 break;975 break;
970 }976 }
971 977
972 if (indicator == IndicatorState.SINGLE) {978 cr.set_source_surface (indicator_surface.Internal, x, y);
973 cr.set_source_surface (indicator_surface.Internal, x, y);979 cr.paint ();
974 cr.paint ();
975 } else {
976 var x_offset = 0.0, y_offset = 0.0;
977 if (position_manager.is_horizontal_dock ())
978 x_offset = position_manager.IconSize / 16.0;
979 else
980 y_offset = position_manager.IconSize / 16.0;
981
982 cr.set_source_surface (indicator_surface.Internal, x - x_offset, y - y_offset);
983 cr.paint ();
984 cr.set_source_surface (indicator_surface.Internal, x + x_offset, y + y_offset);
985 cr.paint ();
986 }
987 }980 }
988 981
989 void draw_urgent_glow (DockItem item, Cairo.Context cr, int64 frame_time)982 void draw_urgent_glow (DockItem item, Cairo.Context cr, int64 frame_time)
@@ -999,7 +992,7 @@
999 var x_offset = 0, y_offset = 0;992 var x_offset = 0, y_offset = 0;
1000 993
1001 if (urgent_glow_buffer == null) {994 if (urgent_glow_buffer == null) {
1002 var urgent_color = get_styled_color ();995 var urgent_color = (theme.IndicatorStyle == IndicatorStyleType.LEGACY ? get_styled_color () : theme.IndicatorColor);
1003 urgent_color.add_hue (theme.UrgentHueShift);996 urgent_color.add_hue (theme.UrgentHueShift);
1004 urgent_color.set_sat (1.0);997 urgent_color.set_sat (1.0);
1005 urgent_glow_buffer = theme.create_urgent_glow (position_manager.GlowSize, urgent_color, main_buffer);998 urgent_glow_buffer = theme.create_urgent_glow (position_manager.GlowSize, urgent_color, main_buffer);
1006999
=== modified file 'lib/Drawing/DockTheme.vala'
--- lib/Drawing/DockTheme.vala 2016-03-12 15:14:09 +0000
+++ lib/Drawing/DockTheme.vala 2016-04-10 16:22:24 +0000
@@ -40,9 +40,15 @@
40 [Description(nick = "item-padding", blurb = "The padding between items on the dock, in tenths of a percent of IconSize.")]40 [Description(nick = "item-padding", blurb = "The padding between items on the dock, in tenths of a percent of IconSize.")]
41 public double ItemPadding { get; set; }41 public double ItemPadding { get; set; }
42 42
43 [Description(nick = "indicator-color", blurb = "The color (RGBA) of the indicator.")]
44 public Color IndicatorColor { get; set; }
45
43 [Description(nick = "indicator-size", blurb = "The size of item indicators, in tenths of a percent of IconSize.")]46 [Description(nick = "indicator-size", blurb = "The size of item indicators, in tenths of a percent of IconSize.")]
44 public double IndicatorSize { get; set; }47 public double IndicatorSize { get; set; }
45 48
49 [Description(nick = "indicator-style", blurb = "The style of item indicators, styles: circle-glow, circle-color-glow, circle, underline.")]
50 public IndicatorStyleType IndicatorStyle { get; set; }
51
46 [Description(nick = "icon-shadow-size", blurb = "The size of the icon-shadow behind every item, in tenths of a percent of IconSize.")]52 [Description(nick = "icon-shadow-size", blurb = "The size of the icon-shadow behind every item, in tenths of a percent of IconSize.")]
47 public double IconShadowSize { get; set; }53 public double IconShadowSize { get; set; }
48 54
@@ -94,6 +100,12 @@
94 [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.")]100 [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.")]
95 public bool CascadeHide { get; set; }101 public bool CascadeHide { get; set; }
96 102
103 [Description(nick = "selection-style", blurb = "Whether an item has an active background glow. If not, active-item-color (RGBA) will be used instead.")]
104 public SelectionStyleType SelectionStyle { get; set; }
105
106 [Description(nick = "selection-color", blurb = "The color (RGBA) of the active item background.")]
107 public Color SelectionColor { get; set; }
108
97 public DockTheme (string name)109 public DockTheme (string name)
98 {110 {
99 base.with_name (name);111 base.with_name (name);
@@ -111,7 +123,9 @@
111 TopPadding = -11.0;123 TopPadding = -11.0;
112 BottomPadding = 2.5;124 BottomPadding = 2.5;
113 ItemPadding = 2.5;125 ItemPadding = 2.5;
126 IndicatorColor = { 1.0, 1.0, 1.0, 1.0 };
114 IndicatorSize = 5.0;127 IndicatorSize = 5.0;
128 IndicatorStyle = IndicatorStyleType.LEGACY;
115 IconShadowSize = 1.0;129 IconShadowSize = 1.0;
116 UrgentBounceHeight = 5.0 / 3.0;130 UrgentBounceHeight = 5.0 / 3.0;
117 LaunchBounceHeight = 0.625;131 LaunchBounceHeight = 0.625;
@@ -129,6 +143,8 @@
129 UrgentHueShift = 150;143 UrgentHueShift = 150;
130 ItemMoveTime = 450;144 ItemMoveTime = 450;
131 CascadeHide = true;145 CascadeHide = true;
146 SelectionColor = { 0.0, 0.0, 0.0, 1.0 };
147 SelectionStyle = SelectionStyleType.LEGACY;
132 }148 }
133 149
134 /**150 /**
@@ -238,6 +254,112 @@
238 }254 }
239 255
240 /**256 /**
257 * Creates a surface of an indicator for the given states.
258 *
259 * @param indicator_state the state of indicator
260 * @param item_state the state of item
261 * @param icon_size the size of icons
262 * @param color the color of the indicator
263 * @param position the position of the dock
264 * @param model existing surface to use as basis of new surface
265 * @return a new surface with the indicator drawn on it
266 */
267 public Surface create_indicator_for_state (IndicatorState indicator_state, ItemState item_state, int icon_size,
268 Gtk.PositionType position, Surface model)
269 {
270 double width = icon_size;
271 double height = icon_size / 3.0 + get_bottom_offset ();
272 var size = (int) (IndicatorSize * icon_size / 10.0);
273
274 Logger.verbose ("DockTheme.create_indicator (width = %i, height = %i, state = [%i,%i])", (int) width, (int) height, indicator_state, item_state);
275
276 var surface = new Surface.with_surface ((int) width, (int) height, model);
277 surface.clear ();
278
279 if (width <= 0 || height <= 0 || size <= 0 || indicator_state == IndicatorState.NONE)
280 return surface;
281
282 Color color;
283 if ((item_state & ItemState.URGENT) != 0) {
284 color = (IndicatorStyle == IndicatorStyleType.LEGACY ? get_styled_color () : IndicatorColor);
285 color.add_hue (UrgentHueShift);
286 color.set_sat (1.0);
287 } else {
288 if (IndicatorStyle == IndicatorStyleType.LEGACY) {
289 color = get_styled_color ();
290 color.set_min_sat (0.4);
291 } else {
292 color = IndicatorColor;
293 }
294 }
295
296 unowned Cairo.Context cr = surface.Context;
297 cr.save ();
298 cr.set_line_width (1.0);
299
300 switch (IndicatorStyle) {
301 default:
302 case IndicatorStyleType.LEGACY:
303 case IndicatorStyleType.GLOW:
304 var x = 0.0;
305 var y = Math.round (height - size / 12.0 - get_bottom_offset ());
306
307 for (var i = 0; i < indicator_state; i++) {
308 x = Math.round (width / 2.0 + (2.0 * i - (indicator_state - 1)) * size / 8.0);
309
310 cr.move_to (x, y);
311 cr.arc (x, y, height / 2, 0, Math.PI * 2);
312 cr.close_path ();
313
314 var rg = new Cairo.Pattern.radial (x, y, 0, x, y, size / 2);
315 rg.add_color_stop_rgba (0, 1, 1, 1, 1);
316 rg.add_color_stop_rgba (0.1, color.red, color.green, color.blue, 1);
317 rg.add_color_stop_rgba (0.2, color.red, color.green, color.blue, 0.6);
318 rg.add_color_stop_rgba (0.25, color.red, color.green, color.blue, 0.25);
319 rg.add_color_stop_rgba (0.5, color.red, color.green, color.blue, 0.15);
320 rg.add_color_stop_rgba (1.0, color.red, color.green, color.blue, 0.0);
321
322 cr.set_source (rg);
323 cr.fill ();
324 }
325 break;
326 case IndicatorStyleType.CIRCLE:
327 var x = 0.0;
328 var y = Math.round (height - size / 1.666 - get_bottom_offset ());
329
330 for (var i = 0; i < indicator_state; i++) {
331 x = Math.round (width / 2.0 + (2.0 * i - (indicator_state - 1)) * size / 1.2);
332
333 cr.move_to (x, y);
334 cr.arc (x, y, size / 2, 0, Math.PI * 2);
335 cr.close_path ();
336
337 cr.set_source_rgba (color.red, color.green, color.blue, color.alpha);
338 cr.stroke_preserve ();
339 cr.fill ();
340 }
341 break;
342 case IndicatorStyleType.LINE:
343 var x = Math.round (icon_size / 10.0);
344 var y = Math.round (height - size - get_bottom_offset () - icon_size / 30.0);
345 width = Math.round (width - icon_size / 5.0);
346
347 cr.rectangle (x, y, width, size);
348 cr.set_source_rgba (color.red, color.green, color.blue, color.alpha);
349 cr.stroke_preserve ();
350 cr.fill ();
351 break;
352 }
353
354 cr.restore ();
355
356 if (position != Gtk.PositionType.BOTTOM)
357 surface = rotate_for_position ((owned) surface, position);
358
359 return surface;
360 }
361
362 /**
241 * Creates a surface for an urgent glow.363 * Creates a surface for an urgent glow.
242 *364 *
243 * @param size the size of the urgent glow365 * @param size the size of the urgent glow
@@ -339,12 +461,17 @@
339 461
340 cr.set_line_width (LineWidth);462 cr.set_line_width (LineWidth);
341 cr.clip ();463 cr.clip ();
342
343 gradient.add_color_stop_rgba (0, color.red, color.green, color.blue, 0);
344 gradient.add_color_stop_rgba (1, color.red, color.green, color.blue, 0.6 * opacity);
345 464
346 cr.rectangle (rect.x, rect.y, rect.width, rect.height);465 cr.rectangle (rect.x, rect.y, rect.width, rect.height);
347 cr.set_source (gradient);466
467 if (SelectionStyle == SelectionStyleType.LEGACY) {
468 gradient.add_color_stop_rgba (0, color.red, color.green, color.blue, 0);
469 gradient.add_color_stop_rgba (1, color.red, color.green, color.blue, 0.6 * opacity);
470 cr.set_source (gradient);
471 } else {
472 cr.set_source_rgba (color.red, color.green, color.blue, color.alpha * opacity);
473 }
474
348 cr.fill ();475 cr.fill ();
349 476
350 cr.reset_clip ();477 cr.reset_clip ();
@@ -568,6 +695,11 @@
568 IconShadowSize = MAX_ICON_SHADOW_SIZE;695 IconShadowSize = MAX_ICON_SHADOW_SIZE;
569 break;696 break;
570 697
698 case "IndicatorStyle":
699 if (IndicatorStyle < 0 || IndicatorStyle > 3)
700 IndicatorStyle = IndicatorStyleType.LEGACY;
701 break;
702
571 case "UrgentBounceHeight":703 case "UrgentBounceHeight":
572 if (UrgentBounceHeight < 0)704 if (UrgentBounceHeight < 0)
573 UrgentBounceHeight = 0;705 UrgentBounceHeight = 0;
@@ -641,7 +773,63 @@
641 else if (UrgentHueShift > 180)773 else if (UrgentHueShift > 180)
642 UrgentHueShift = 180;774 UrgentHueShift = 180;
643 break;775 break;
644 }776
777 case "IndicatorColor":
778 break;
779
780 case "ActiveItemColor":
781 break;
782 }
783 }
784
785 static Surface rotate_for_position (owned Surface surface, Gtk.PositionType position)
786 {
787 if (position == Gtk.PositionType.BOTTOM)
788 return surface;
789
790 Surface result;
791 var width = surface.Width;
792 var height = surface.Height;
793 var rotate = 0.0;
794
795 if (position == Gtk.PositionType.TOP)
796 result = new Surface.with_surface (width, height, surface);
797 else
798 result = new Surface.with_surface (height, width, surface);
799
800 unowned Cairo.Context cr = result.Context;
801
802 switch (position) {
803 case Gtk.PositionType.TOP:
804 rotate = Math.PI;
805 break;
806 case Gtk.PositionType.LEFT:
807 rotate = Math.PI_2;
808 break;
809 case Gtk.PositionType.RIGHT:
810 rotate = -Math.PI_2;
811 break;
812 default:
813 assert_not_reached ();
814 }
815
816 cr.save ();
817 cr.translate (result.Width / 2.0, result.Height / 2.0);
818 cr.rotate (rotate);
819 cr.translate (- width / 2.0, - height / 2.0);
820 cr.set_source_surface (surface.Internal, 0.0, 0.0);
821 cr.paint ();
822 cr.restore ();
823
824 return result;
825 }
826
827 Color get_styled_color ()
828 {
829 unowned Gtk.StyleContext context = get_style_context ();
830 var color = (Color) context.get_background_color (context.get_state ());
831 color.set_min_val (90 / (double) uint16.MAX);
832 return color;
645 }833 }
646 }834 }
647}835}
648836
=== added file 'lib/Drawing/Enums.vala'
--- lib/Drawing/Enums.vala 1970-01-01 00:00:00 +0000
+++ lib/Drawing/Enums.vala 2016-04-10 16:22:24 +0000
@@ -0,0 +1,63 @@
1//
2// Copyright (C) 2016 Rico Tzschichholz
3//
4// This file is part of Plank.
5//
6// Plank is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// Plank is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <http://www.gnu.org/licenses/>.
18//
19
20namespace Plank
21{
22 /**
23 * The style of the item indicator.
24 */
25 public enum IndicatorStyleType
26 {
27 /**
28 * A glowing dot which is gtk-theme-colored.
29 */
30 LEGACY,
31 /**
32 * A glowing dot.
33 */
34 GLOW,
35 /**
36 * A solid circle.
37 */
38 CIRCLE,
39 /**
40 * A solid line.
41 */
42 LINE
43 }
44
45 /**
46 * The style of the item indicator.
47 */
48 public enum SelectionStyleType
49 {
50 /**
51 * A vertical gradient which is colored based of the item's icon'.
52 */
53 LEGACY,
54 /**
55 * A vertical gradient.
56 */
57 GRADIENT,
58 /**
59 * A solid color.
60 */
61 SOLID
62 }
63}
064
=== modified file 'lib/Makefile.am'
--- lib/Makefile.am 2016-02-28 12:06:16 +0000
+++ lib/Makefile.am 2016-04-10 16:22:24 +0000
@@ -75,6 +75,7 @@
75 Drawing/DrawingService.vala \75 Drawing/DrawingService.vala \
76 Drawing/DockTheme.vala \76 Drawing/DockTheme.vala \
77 Drawing/Easing.vala \77 Drawing/Easing.vala \
78 Drawing/Enums.vala \
78 Drawing/Renderer.vala \79 Drawing/Renderer.vala \
79 Drawing/Surface.vala \80 Drawing/Surface.vala \
80 Drawing/SurfaceCache.vala \81 Drawing/SurfaceCache.vala \
8182
=== modified file 'lib/libplank.symbols'
--- lib/libplank.symbols 2016-04-10 09:00:49 +0000
+++ lib/libplank.symbols 2016-04-10 16:22:24 +0000
@@ -340,10 +340,13 @@
340plank_dock_theme_construct340plank_dock_theme_construct
341plank_dock_theme_create_background341plank_dock_theme_create_background
342plank_dock_theme_create_indicator342plank_dock_theme_create_indicator
343plank_dock_theme_create_indicator_for_state
343plank_dock_theme_create_urgent_glow344plank_dock_theme_create_urgent_glow
344plank_dock_theme_draw_active_glow345plank_dock_theme_draw_active_glow
345plank_dock_theme_draw_item_count346plank_dock_theme_draw_item_count
346plank_dock_theme_draw_item_progress347plank_dock_theme_draw_item_progress
348plank_dock_theme_get_ActiveGlow
349plank_dock_theme_get_ActiveItemColor
347plank_dock_theme_get_ActiveTime350plank_dock_theme_get_ActiveTime
348plank_dock_theme_get_BottomPadding351plank_dock_theme_get_BottomPadding
349plank_dock_theme_get_CascadeHide352plank_dock_theme_get_CascadeHide
@@ -356,7 +359,9 @@
356plank_dock_theme_get_HideTime359plank_dock_theme_get_HideTime
357plank_dock_theme_get_HorizPadding360plank_dock_theme_get_HorizPadding
358plank_dock_theme_get_IconShadowSize361plank_dock_theme_get_IconShadowSize
362plank_dock_theme_get_IndicatorColor
359plank_dock_theme_get_IndicatorSize363plank_dock_theme_get_IndicatorSize
364plank_dock_theme_get_IndicatorStyle
360plank_dock_theme_get_ItemMoveTime365plank_dock_theme_get_ItemMoveTime
361plank_dock_theme_get_ItemPadding366plank_dock_theme_get_ItemPadding
362plank_dock_theme_get_LaunchBounceHeight367plank_dock_theme_get_LaunchBounceHeight
@@ -368,6 +373,8 @@
368plank_dock_theme_get_UrgentBounceTime373plank_dock_theme_get_UrgentBounceTime
369plank_dock_theme_get_UrgentHueShift374plank_dock_theme_get_UrgentHueShift
370plank_dock_theme_new375plank_dock_theme_new
376plank_dock_theme_set_ActiveGlow
377plank_dock_theme_set_ActiveItemColor
371plank_dock_theme_set_ActiveTime378plank_dock_theme_set_ActiveTime
372plank_dock_theme_set_BottomPadding379plank_dock_theme_set_BottomPadding
373plank_dock_theme_set_CascadeHide380plank_dock_theme_set_CascadeHide
@@ -380,7 +387,9 @@
380plank_dock_theme_set_HideTime387plank_dock_theme_set_HideTime
381plank_dock_theme_set_HorizPadding388plank_dock_theme_set_HorizPadding
382plank_dock_theme_set_IconShadowSize389plank_dock_theme_set_IconShadowSize
390plank_dock_theme_set_IndicatorColor
383plank_dock_theme_set_IndicatorSize391plank_dock_theme_set_IndicatorSize
392plank_dock_theme_set_IndicatorStyle
384plank_dock_theme_set_ItemMoveTime393plank_dock_theme_set_ItemMoveTime
385plank_dock_theme_set_ItemPadding394plank_dock_theme_set_ItemPadding
386plank_dock_theme_set_LaunchBounceHeight395plank_dock_theme_set_LaunchBounceHeight
@@ -462,6 +471,7 @@
462plank_hover_window_set_text471plank_hover_window_set_text
463plank_hover_window_show_at472plank_hover_window_show_at
464plank_indicator_state_get_type473plank_indicator_state_get_type
474plank_indicator_style_type_get_type
465plank_item_factory_construct475plank_item_factory_construct
466plank_item_factory_default_make_element476plank_item_factory_default_make_element
467plank_item_factory_get_item_for_dock477plank_item_factory_get_item_for_dock

Subscribers

People subscribed via source and target branches

to status/vote changes: