Awn

Merge lp:~albyrock87/awn/awn-lucido into lp:awn/0.4

Proposed by Alberto Aldegheri
Status: Merged
Merged at revision: 714
Proposed branch: lp:~albyrock87/awn/awn-lucido
Merge into: lp:awn/0.4
Diff against target: 3467 lines (+1492/-969)
19 files modified
awn-settings/awn-settings.ui (+33/-33)
awn-settings/awnDefs.py.in (+1/-1)
awn-settings/awnSettings.py.in (+4/-4)
data/avant-window-navigator.schema-ini.in.in (+3/-3)
libawn/awn-cairo-utils.c (+33/-2)
src/awn-applet-manager.c (+16/-9)
src/awn-applet-manager.h (+1/-1)
src/awn-background-3d.c (+454/-240)
src/awn-background-edgy.c (+143/-161)
src/awn-background-flat.c (+14/-20)
src/awn-background-floaty.c (+6/-4)
src/awn-background-lucido.c (+663/-467)
src/awn-background.c (+19/-17)
src/awn-background.h (+3/-3)
src/awn-defines.h (+1/-1)
src/awn-panel.c (+6/-0)
src/awn-panel.h (+2/-0)
src/awn-separator.c (+78/-3)
src/awn-separator.h (+12/-0)
To merge this branch: bzr merge lp:~albyrock87/awn/awn-lucido
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+30089@code.launchpad.net

This proposal supersedes a proposal from 2010-06-08.

Description of the change

Thank's to mhr3's idea: "use separators tho style Lucido"

A video to explain all features [OLD]:
http://www.youtube.com/watch?v=5PD9WFDPcmk

New version:
http://www.youtube.com/watch?v=8EFIILJJufo

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal

Ok, there'll be many points here, but here we go:

1) Please add curly brackets to all ifs (& elses) per code guidelines (the one-liners).
2) awn_background_lucido_redraw - please add variables for AwnBackgroundLucidoPrivate and AwnBackground, everything caps looks just strange...
3) _init_positions - remove 239-240 - it's init, so the assumption that you need to free something is wrong (otherwise it's not really init)
4) 315: starting a timer in init method is suspicious, ideally it should be started only once you know that you need to animate.
5) 1082: shouldn't the value be 10?
6) 1224: What's the 10000?
7) I still don't like the "transparent" property, I suggest connecting to expose event instead of setting this property, since you mentioned you don't want to add panel-style switch in Separator's expose.
8) Revert 1436 & 1442.

review: Needs Fixing (code-review)
Revision history for this message
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal

Oh, and 1477 is unnecessary.

Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

> Ok, there'll be many points here, but here we go:
>
> 1) Please add curly brackets to all ifs (& elses) per code guidelines (the
> one-liners).
> 2) awn_background_lucido_redraw - please add variables for
> AwnBackgroundLucidoPrivate and AwnBackground, everything caps looks just
> strange...
Ok..

> 3) _init_positions - remove 239-240 - it's init, so the assumption that you
> need to free something is wrong (otherwise it's not really init)
> 4) 315: starting a timer in init method is suspicious, ideally it should be
> started only once you know that you need to animate.
You're right..

> 5) 1082: shouldn't the value be 10?
Not in that case: if the first applet is a separator, that separator acts like a "background changer". If you put a separator in first position, the curve starts from bottom, otherwise from top.
> 6) 1224: What's the 10000?
It can be changed to : if (expand) w = -w; it's just for give "expand" a great importance in the "w" calculation.

> 7) I still don't like the "transparent" property, I suggest connecting to
> expose event instead of setting this property, since you mentioned you don't
> want to add panel-style switch in Separator's expose.
I mentioned I do want to add style switches to Separator :)
So.. what to do now?

> 8) Revert 1436 & 1442.
Ok

Revision history for this message
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal

> I mentioned I do want to add style switches to Separator :)
> So.. what to do now?

Add panel-style property to Separators and have AppletManager update it.

review: Needs Fixing
Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

Lucido in lp:awn needs to be improved with separator version.
Animation (for now) remains in my dreams.
Feel free to fork rev 721 and try to fix it as you wish :)

Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

>> Add panel-style property to Separators and have AppletManager update it.
My answer is no, for the following reasons:

- Lucido, needs to set the aspect of each single separator,
  because (for example) if there is a separator in the first position,
  that separator needs to be 1 pixel (non-visible-like).
  But if we talk generally, Curve Style, needs to set the height of each separator
  depending on the position of the separator in the background.
- When some config-values change, separator needs to change too.
  For real 3d effect (in 3d style - 3d angle property) separator needs to be inclined
  based on the position an height of the bar.
  But for example, in Lucido, speparator needs to change when corner radius changes.

So, if we have Applet Manager update each separator, it means that Applet Manager knows exactly how to do that-> it means code duplication, and extra listener, for what? To move a "loop on separators" and bg specifications into AppletManager?
Don't take it personally, but for me that has no sense.

Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

In two words:
- fix on awn_round_rect to avoid glitches
- fix and simplify edgy code
- rewrite of 3D style (now using floaty_offset too)
- Lucido with separators and a "fake 3D" style (with no thickness)

:)

Revision history for this message
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal

I didn't do code review yet, but from playing around with it:
1) The new 3D style is awesome, but something has to be done with the floaty offset, as I mentioned on IRC, it's not a good idea to support it in other than "Floaty" styles. If you want to control the "thickness" add a new key for it.
2) I don't even remember now how did our old 3d style looked like, but is it still possible to have it with a combination of the config keys?
3) Lucido - I don't like that it also listens to 3d angle, there's not much "3d" on it, and personally I find the addition forceful - I'd recommend to remove it completely or at least use some other key and not 3d angle, as the default for angle isn't suitable (perhaps curviness? the old 3d code used it to change the size of the panel, and default there is 1.0, so it'd be fine).
4) Lucido is much better with separators as opposed to expanders, but the jumping when opening / closing new tasks is a deal breaker, this needs to be fixed!

review: Needs Fixing (behaviour)
Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

> 1) The new 3D style is awesome, but something has to be done with the floaty
> offset, as I mentioned on IRC, it's not a good idea to support it in other
> than "Floaty" styles. If you want to control the "thickness" add a new key for
> it.
Solved with new "Thickness" key -> 0.0 < thickness < 1.0 default = 0.6
Thickness in pixel = thickness * MAX_THICKNESS.
MAX_THICKNESS = 10px

> 2) I don't even remember now how did our old 3d style looked like, but is it
> still possible to have it with a combination of the config keys?
It is possible with one limitation : the inner border
You can see it enabling DRAW_INTERNAL_BORDER define on top of awn-background-3d.c
It is disabled because it doesn't look good with some combination of color.

> 3) Lucido - I don't like that it also listens to 3d angle, there's not much
> "3d" on it, and personally I find the addition forceful - I'd recommend to
> remove it completely or at least use some other key and not 3d angle, as the
> default for angle isn't suitable (perhaps curviness? the old 3d code used it
> to change the size of the panel, and default there is 1.0, so it'd be fine).
Removed 3d on Lucido.
Added curves symmetry to control the stripe part height :)
> 4) Lucido is much better with separators as opposed to expanders, but the
> jumping when opening / closing new tasks is a deal breaker, this needs to be
> fixed!
I need to work on this.

Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

> 4) Lucido is much better with separators as opposed to expanders, but the
> jumping when opening / closing new tasks is a deal breaker, this needs to be
> fixed!
Done :)

Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

Wait before merge, there is a bug that I need to fix when moving separators..

Btw you can do code review :)

Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

Now Lucido is more consistent with other styles.

Borders are now borders :)
Stripe gradient is now controlled by highlight colors :)

Curves Symmetry now controls both parts.

Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

mhr3, I think that now this is ready for a new review and code review :)

Revision history for this message
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal

I'm not going to do a detailed code review of the drawing code (as I didn't write most of that code anyway), the rest looks quite good, though there are a few issues:
Changes to Edgy you introduced bring a bug on the circle when you're using semi-transparent colors. Also if the code is about to be kept, get rid of the craziness with memcpy of GdkRectangle - it's a simple struct, allocating it on stack and assigning to it will work just fine.
Also it'd be nice to add public getter/setter methods for the new properties in AwnSeparator.

review: Needs Fixing (code-review)
Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

> Changes to Edgy you introduced bring a bug on the circle when you're using
> semi-transparent colors. Also if the code is about to be kept, get rid of the
> craziness with memcpy of GdkRectangle - it's a simple struct, allocating it on
> stack and assigning to it will work just fine.
Done :)
> Also it'd be nice to add public getter/setter methods for the new properties
> in AwnSeparator.
I don't understand... new properties are accessible through:
g_object_set (G_OBJECT (widget_separator), "transparent", TRUE, NULL);

Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

> Also it'd be nice to add public getter/setter methods for the new properties
> in AwnSeparator.

All done.
I've made a little change in awn-applet-manager, and awn-panel (rev 752).

I think that now it's all fixed, and we can move on :)

For me it's ready to merge :)

Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

NOooo stop!

Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

ok, fixed :)

Revision history for this message
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal

Please fix 3065.

Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

> Please fix 3065.
Sorry Michal, fixed :)

Revision history for this message
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal

There's still a problem with the changes to Edgy - if there's only one icon, it doesn't display only the circle. Other than that I don't see any problems...

Please resubmit once fixed.

review: Needs Fixing
Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

Here we are! :)
I've changed Edgy code a bit to make it simplier and faster (during aling change).

Resubmitting proposal now :)

lp:~albyrock87/awn/awn-lucido updated
761. By Alberto <alby@CASA>

Revert changes to flat

Revision history for this message
Michal Hruby (mhr3) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'awn-settings/awn-settings.ui'
2--- awn-settings/awn-settings.ui 2010-06-03 23:39:31 +0000
3+++ awn-settings/awn-settings.ui 2010-07-16 11:56:43 +0000
4@@ -899,22 +899,6 @@
5 </packing>
6 </child>
7 <child>
8- <object class="GtkSpinButton" id="theme_stripe_width">
9- <property name="visible">True</property>
10- <property name="can_focus">True</property>
11- <property name="invisible_char">&#x25CF;</property>
12- <property name="adjustment">adj_stripe_width</property>
13- <property name="digits">2</property>
14- </object>
15- <packing>
16- <property name="left_attach">2</property>
17- <property name="right_attach">3</property>
18- <property name="top_attach">11</property>
19- <property name="bottom_attach">12</property>
20- <property name="x_options"></property>
21- </packing>
22- </child>
23- <child>
24 <object class="GtkSpinButton" id="theme_angle">
25 <property name="visible">True</property>
26 <property name="can_focus">True</property>
27@@ -972,19 +956,6 @@
28 </packing>
29 </child>
30 <child>
31- <object class="GtkLabel" id="label_stripe">
32- <property name="visible">True</property>
33- <property name="xalign">0</property>
34- <property name="xpad">10</property>
35- <property name="label" translatable="yes">Stripe Width</property>
36- </object>
37- <packing>
38- <property name="right_attach">2</property>
39- <property name="top_attach">11</property>
40- <property name="bottom_attach">12</property>
41- </packing>
42- </child>
43- <child>
44 <object class="GtkLabel" id="label49">
45 <property name="visible">True</property>
46 <property name="xalign">0</property>
47@@ -1649,6 +1620,35 @@
48 </packing>
49 </child>
50 <child>
51+ <object class="GtkLabel" id="label_thickness">
52+ <property name="visible">True</property>
53+ <property name="xalign">0</property>
54+ <property name="xpad">10</property>
55+ <property name="label" translatable="yes">Thickness</property>
56+ </object>
57+ <packing>
58+ <property name="right_attach">2</property>
59+ <property name="top_attach">11</property>
60+ <property name="bottom_attach">12</property>
61+ </packing>
62+ </child>
63+ <child>
64+ <object class="GtkSpinButton" id="theme_thickness">
65+ <property name="visible">True</property>
66+ <property name="can_focus">True</property>
67+ <property name="invisible_char">&#x25CF;</property>
68+ <property name="adjustment">adj_thickness</property>
69+ <property name="digits">2</property>
70+ </object>
71+ <packing>
72+ <property name="left_attach">2</property>
73+ <property name="right_attach">3</property>
74+ <property name="top_attach">11</property>
75+ <property name="bottom_attach">12</property>
76+ <property name="x_options"></property>
77+ </packing>
78+ </child>
79+ <child>
80 <placeholder/>
81 </child>
82 <child>
83@@ -3439,10 +3439,6 @@
84 <property name="upper">1</property>
85 <property name="step_increment">0.01</property>
86 </object>
87- <object class="GtkAdjustment" id="adj_stripe_width">
88- <property name="upper">1</property>
89- <property name="step_increment">0.01</property>
90- </object>
91 <object class="GtkAdjustment" id="adj_radius">
92 <property name="upper">100</property>
93 <property name="step_increment">1</property>
94@@ -3457,6 +3453,10 @@
95 <property name="upper">100</property>
96 <property name="step_increment">1</property>
97 </object>
98+ <object class="GtkAdjustment" id="adj_thickness">
99+ <property name="upper">1</property>
100+ <property name="step_increment">0.05</property>
101+ </object>
102 <object class="GtkAdjustment" id="adj_3d_angle">
103 <property name="upper">90</property>
104 <property name="step_increment">1</property>
105
106=== modified file 'awn-settings/awnDefs.py.in'
107--- awn-settings/awnDefs.py.in 2010-05-31 17:41:58 +0000
108+++ awn-settings/awnDefs.py.in 2010-07-16 11:56:43 +0000
109@@ -86,8 +86,8 @@
110 PANEL_ANGLE = "panel_angle" #float
111 CURVINESS = "curviness" #float
112 CURVES_SYMMETRY = "curves_symmetry" #float
113-STRIPE_WIDTH = "stripe_width" #float
114 FLOATY_OFFSET = "floaty_offset" #int
115+THICKNESS = "thickness" #float
116 TOOLTIP_FONT_NAME = "tooltip_font_name" #string
117 TOOLTIP_FONT_COLOR = "tooltip_font_color" #string
118 TOOLTIP_BG_COLOR = "tooltip_bg_color" #string
119
120=== modified file 'awn-settings/awnSettings.py.in'
121--- awn-settings/awnSettings.py.in 2010-05-31 17:41:58 +0000
122+++ awn-settings/awnSettings.py.in 2010-07-16 11:56:43 +0000
123@@ -579,8 +579,8 @@
124
125 curviness = gobject.property(type=float, default=1)
126 curves_symmetry = gobject.property(type=float, default=0)
127- stripe_width = gobject.property(type=float, default=0)
128 floaty_offset = gobject.property(type=int, default=10)
129+ thickness = gobject.property(type=float, default=0)
130 angle = gobject.property(type=int, default=45)
131 radius = gobject.property(type=int, default=10)
132 gtk_theme_mode = gobject.property(type=bool, default=False)
133@@ -730,7 +730,7 @@
134 (defs.THEME, defs.PANEL_ANGLE, 'float', sizes),
135 (defs.THEME, defs.CURVINESS, 'float', sizes),
136 (defs.THEME, defs.CURVES_SYMMETRY, 'float', sizes),
137- (defs.THEME, defs.STRIPE_WIDTH, 'float', sizes),
138+ (defs.THEME, defs.THICKNESS, 'float', sizes),
139 (defs.THEME, defs.FLOATY_OFFSET, 'int', sizes),
140 (defs.THEME, defs.TOOLTIP_FONT_NAME, 'str', icon),
141 (defs.THEME, defs.TOOLTIP_FONT_COLOR, 'str', icon),
142@@ -828,12 +828,12 @@
143 "curviness", "theme_curviness"),
144 (self.client, defs.THEME, defs.CURVES_SYMMETRY,
145 "curves-symmetry", "theme_symmetry"),
146- (self.client, defs.THEME, defs.STRIPE_WIDTH,
147- "stripe-width", "theme_stripe_width"),
148 (self.client, defs.THEME, defs.PANEL_ANGLE,
149 "angle", "theme_angle"),
150 (self.client, defs.THEME, defs.FLOATY_OFFSET,
151 "floaty-offset", "theme_floaty_offset"),
152+ (self.client, defs.THEME, defs.THICKNESS,
153+ "thickness", "theme_thickness"),
154 (self.client, defs.THEME, defs.CORNER_RADIUS,
155 "radius", "theme_radius"),
156 (self.client, defs.THEME, defs.TOOLTIP_FONT_NAME,
157
158=== modified file 'data/avant-window-navigator.schema-ini.in.in'
159--- data/avant-window-navigator.schema-ini.in.in 2010-07-07 09:12:12 +0000
160+++ data/avant-window-navigator.schema-ini.in.in 2010-07-16 11:56:43 +0000
161@@ -233,10 +233,10 @@
162 _description=The offset of the Floaty background.
163 per_instance = false
164
165-[theme/stripe_width]
166+[theme/thickness]
167 type = float
168-default = 0.0
169-_description=The width of the stripe in Lucido mode.
170+default = 0.6
171+_description=The thickness in 3D mode.
172 per_instance = false
173
174 [theme/dialog_gtk_mode]
175
176=== modified file 'libawn/awn-cairo-utils.c'
177--- libawn/awn-cairo-utils.c 2010-01-10 14:43:43 +0000
178+++ libawn/awn-cairo-utils.c 2010-07-16 11:56:43 +0000
179@@ -16,6 +16,7 @@
180 * along with this program. If not, see <http://www.gnu.org/licenses/>.
181 *
182 * Author : Anthony Arobone <aarobone@gmail.com>
183+ * Alberto Aldegheri <albyrock87+dev@gmail.com>
184 * (awn_cairo_rounded_rect)
185 * Author : Mark Lee <avant-wn@lazymalevolence.com>
186 * (awn_cairo_set_source_color,
187@@ -42,16 +43,46 @@
188 /* arc with radius == 0.0 doesn't paint anything */
189 if (radius == 0.0) state = ROUND_NONE;
190
191- cairo_move_to (cr, rx0, ry1 - radius);
192+ /* fix to radius to avoid wrong draws */
193+ if (radius > height / 2. && (
194+ ((state & ROUND_TOP_LEFT) && (state & ROUND_BOTTOM_LEFT)) ||
195+ ((state & ROUND_TOP_RIGHT) && (state & ROUND_BOTTOM_RIGHT))
196+ ))
197+ {
198+ radius = height / 2.;
199+ }
200+ else if (radius > height)
201+ {
202+ radius = height;
203+ }
204+ if (radius > width / 2. && (
205+ ((state & ROUND_TOP_LEFT) && (state & ROUND_TOP_RIGHT)) ||
206+ ((state & ROUND_BOTTOM_LEFT) && (state & ROUND_BOTTOM_RIGHT))
207+ ))
208+ {
209+ radius = width / 2.;
210+ }
211+ else if (radius > width)
212+ {
213+ radius = width;
214+ }
215
216 /* top left corner */
217-
218 if (state & ROUND_TOP_LEFT)
219 {
220+ if (state & ROUND_BOTTOM_LEFT)
221+ {
222+ cairo_move_to (cr, rx0, ry1 - radius);
223+ }
224+ else
225+ {
226+ cairo_move_to (cr, rx0, ry1);
227+ }
228 cairo_arc (cr, rx0 + radius, ry0 + radius, radius, M_PI, M_PI * 1.5);
229 }
230 else
231 {
232+ cairo_move_to (cr, rx0, ry1 - radius);
233 cairo_line_to (cr, rx0, ry0);
234 }
235
236
237=== modified file 'src/awn-applet-manager.c'
238--- src/awn-applet-manager.c 2010-04-08 15:38:05 +0000
239+++ src/awn-applet-manager.c 2010-07-16 11:56:43 +0000
240@@ -88,6 +88,7 @@
241 APPLET_EMBEDDED,
242 APPLET_REMOVED,
243 SHAPE_MASK_CHANGED,
244+ APPLETS_REFRESHED,
245
246 LAST_SIGNAL
247 };
248@@ -402,7 +403,16 @@
249 NULL, NULL,
250 g_cclosure_marshal_VOID__VOID,
251 G_TYPE_NONE, 0);
252-
253+
254+ _applet_manager_signals[APPLETS_REFRESHED] =
255+ g_signal_new("applets-refreshed",
256+ G_OBJECT_CLASS_TYPE(obj_class),
257+ G_SIGNAL_RUN_FIRST,
258+ G_STRUCT_OFFSET(AwnAppletManagerClass, applets_refreshed),
259+ NULL, NULL,
260+ g_cclosure_marshal_VOID__VOID,
261+ G_TYPE_NONE, 0);
262+
263 g_type_class_add_private (obj_class, sizeof (AwnAppletManagerPrivate));
264 }
265
266@@ -913,6 +923,7 @@
267 priv->expands = TRUE;
268 g_object_notify (G_OBJECT (manager), "expands");
269 }
270+ g_signal_emit (manager, _applet_manager_signals[APPLETS_REFRESHED], 0);
271 }
272
273 void
274@@ -1170,6 +1181,8 @@
275 g_object_notify (G_OBJECT (manager), "expands");
276
277 g_list_free (list);
278+ /* Emit refresh signal for applets when swithcing docklet mode */
279+ g_signal_emit (manager, _applet_manager_signals[APPLETS_REFRESHED], 0);
280 }
281
282 void
283@@ -1194,14 +1207,8 @@
284 g_object_notify (G_OBJECT (manager), "expands");
285
286 g_list_free (list);
287-}
288-
289-gboolean
290-awn_applet_manager_get_docklet_mode (AwnAppletManager *manager)
291-{
292- g_return_val_if_fail (AWN_IS_APPLET_MANAGER (manager), FALSE);
293-
294- return manager->priv->docklet_mode;
295+ /* Emit refresh signal for applets when swithcing docklet mode */
296+ g_signal_emit (manager, _applet_manager_signals[APPLETS_REFRESHED], 0);
297 }
298
299 void
300
301=== modified file 'src/awn-applet-manager.h'
302--- src/awn-applet-manager.h 2009-11-28 22:33:39 +0000
303+++ src/awn-applet-manager.h 2010-07-16 11:56:43 +0000
304@@ -66,6 +66,7 @@
305 void (*applet_embedded) (AwnAppletManager *manager, GtkWidget *applet);
306 void (*applet_removed) (AwnAppletManager *manager, GtkWidget *applet);
307 void (*shape_mask_changed) (AwnAppletManager *manager);
308+ void (*applets_refreshed) (AwnAppletManager *manager);
309 };
310
311 GType awn_applet_manager_get_type (void) G_GNUC_CONST;
312@@ -93,7 +94,6 @@
313
314 void awn_applet_manager_add_docklet (AwnAppletManager *manager,
315 GtkWidget *docklet);
316-gboolean awn_applet_manager_get_docklet_mode (AwnAppletManager *manager);
317
318 void awn_applet_manager_redraw_throbbers (AwnAppletManager *manager);
319
320
321=== modified file 'src/awn-background-3d.c'
322--- src/awn-background-3d.c 2009-12-22 21:09:43 +0000
323+++ src/awn-background-3d.c 2010-07-16 11:56:43 +0000
324@@ -15,7 +15,8 @@
325 * along with this program; if not, write to the Free Software
326 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
327 *
328- * Author : h4writer <hv1989@gmail.com>
329+ * Original Author : h4writer <hv1989@gmail.com>
330+ * Rewrited by: Alberto Aldegheri <albyrock87+dev@gmail.com>
331 *
332 */
333
334@@ -27,22 +28,43 @@
335 #include "awn-x.h"
336
337 #include <math.h>
338-
339-/* The pixels to draw the side of the panel*/
340-#define SIDE_SPACE 4
341+#include "awn-applet-manager.h"
342+
343+#define MAX_THICKNESS 12.
344+#define PADDING_BOTTOM 1
345+#define PADDING_TOP 1
346+#define BORDER_LINE_WIDTH 1
347+
348+/* There is a refresh bug when we are near the left border */
349+#define DRAW_XPADDING 2
350
351 /* Some defines for debugging */
352-#define DEBUG_DRAW_INTERNAL_BORDER_BOTTOM TRUE
353-#define DEBUG_DRAW_EXTERNAL_BORDER_BOTTOM TRUE
354-#define DEBUG_DRAW_SIDE TRUE
355-#define DEBUG_DRAW_INTERNAL_BORDER_TOP TRUE
356-#define DEBUG_DRAW_EXTERNAL_BORDER_TOP TRUE
357-#define DEBUG_DRAW_HIGHLIGHT TRUE
358+#define DRAW_SIDE TRUE
359+#define DRAW_EXTERNAL_BORDER TRUE
360+/* Internal border isn't good-looking for now */
361+/* We need another color, because Inner Border Color */
362+/* is used for paint the side face of 3D */
363+#define DRAW_INTERNAL_BORDER FALSE
364+#define DRAW_HIGHLIGHT TRUE
365+#define CLEAR_TOP_BEFORE_PAINT FALSE
366+#define FILL_BOTTOM_PLANE FALSE
367
368+/* Enable this for paint the shape mask */
369 #define DEBUG_DRAW_INPUT_SHAPE_MASK FALSE
370
371+#define TRANSFORM_RADIUS(x) (x / 90. * 75)
372+#define OBTAIN_THICKNESS(rad,thick) (floor(sin(TRANSFORM_RADIUS(rad)*\
373+ M_PI/180.)*MAX_THICKNESS*thick))
374+
375 G_DEFINE_TYPE (AwnBackground3d, awn_background_3d, AWN_TYPE_BACKGROUND)
376
377+struct _Point3
378+{
379+ float x;
380+ float y;
381+ float z;
382+};
383+typedef struct _Point3 Point3;
384 /* FORWARDS */
385 static void awn_background_3d_padding_request (AwnBackground *bg,
386 GtkPositionType position,
387@@ -83,6 +105,14 @@
388 g_signal_connect (bg, "notify::panel-angle",
389 G_CALLBACK (awn_background_3d_update_padding),
390 NULL);
391+
392+ g_signal_connect (bg, "notify::corner-radius",
393+ G_CALLBACK (awn_background_3d_update_padding),
394+ NULL);
395+
396+ g_signal_connect (bg, "notify::thickness",
397+ G_CALLBACK (awn_background_3d_update_padding),
398+ NULL);
399 }
400
401 static void
402@@ -160,32 +190,18 @@
403 * @param x: the x pos in the flat dimension
404 * @param y: the y pos in the perspective
405 *
406- * Calculates the x position of the point (x,y) in the flat dimension brought back in the perspective
407+ * Calculates the x position of the point (x,y) in the flat dimension
408+ * brought back in the perspective
409 * note: - the bottom left corner is (0,0)
410 * - the bottom right corner should be (width, 0)
411 *
412- * Returns: gives the x position back of the point (x,y) in the flat dimension brought back in the perspective
413+ * Returns: gives the x position back of the point (x,y) in the flat dimension
414+ * brought back in the perspective
415 */
416 static double
417 apply_perspective_x( double width, double angle, double x, double y )
418 {
419- return (width/2.0-x)/(width/2.0*tan((90-angle)*M_PI/180))*y+x;
420-}
421-
422-/**
423- * get_width_on_height:
424- * @param width: the current width of the bar
425- * @param angle: the angle the bar will have
426- * @param y: the y pos in the perspective
427- *
428- * Calculates the width of the bar on a given y-pos (in the perspective)
429- *
430- * Returns: a double containing the width
431- */
432-static double
433-get_width_on_height( double width, double angle, double y )
434-{
435- return width-2*y/tan((90-angle)*M_PI/180);
436+ return (width/2.0-x)/(width/2.0*tan((90-angle)*M_PI/180)*1.5)*y+x;
437 }
438
439 /**
440@@ -194,100 +210,164 @@
441 * @param point2: control point 2
442 * @param point3: control point 3
443 * @param point4: control point 4
444- * @param t: the position between O and 1 (0 gives back point1, 1 gives back point4)
445- *
446- * This function is used to get back the left most position of the rounded corner,
447- * to let the side of the bar begin there.
448- *
449- * - Note: Not used atm. Can be I need it later on, but for now it's commented out.
450- *
451- * Returns: gives back the position of the cubic bezier curve constructed with these control points
452+ * @param t: the position between O and 1
453+ * (0 gives back point1, 1 gives back point4)
454+ *
455+ * This function is used to get back the left most position of the rounded
456+ * corner to let the side of the bar begin there.
457+ *
458+ * Note: Not used atm. Can be I need it later on, but for now it's commented out
459+ *
460+ * Returns: gives back the position of the cubic bezier curve constructed with
461+ * these control points
462 */
463-/*static double cubic_bezier_curve(double point1, double point2, double point3, double point4, double t)
464+/*static double cubic_bezier_curve(double point1, double point2, double point3,
465+ double point4, double t)
466 {
467- return (1-t)*(1-t)*(1-t)*point1 + 3*t*(1-t)*(1-t)*point2 + 3*t*t*(1-t)*point3 + t*t*t*point4;
468+ return (1-t)*(1-t)*(1-t)*point1 + 3*t*(1-t)*(1-t)*point2 +
469+ 3*t*t*(1-t)*point3 + t*t*t*point4;
470 }*/
471
472-
473-/*
474- * Drawing functions
475+/**
476+ * calc_points
477+ * @param bg: AwnBackground
478+ * @param x: the begin x position to draw
479+ * @param y: the begin y position to draw
480+ * @param width: the width for the drawing
481+ * @param height: the height for the drawing
482+ *
483+ * Calculates vertices to draw the path
484 */
485-
486+static Point3*
487+calc_points (AwnBackground *bg,
488+ float x,
489+ float y,
490+ float width,
491+ float height)
492+{
493+ float xp0, xp1, xp2, xp3, yp0, yp1, yp2, yp3;
494+ float radius = bg->corner_radius;
495+ /**
496+ * rb = decrease the radius on bottom vertices
497+ * ex = increase the x-radius on top vertices
498+ */
499+ float rb = 0., ex = 0.;
500+ /* calc sin and cos for current angle */
501+ float s = sin (TRANSFORM_RADIUS (bg->panel_angle) * M_PI / 180.);
502+ float c = cos (TRANSFORM_RADIUS (bg->panel_angle) * M_PI / 180.);
503+
504+ /* Adjust radius */
505+ if (radius > height)
506+ {
507+ ex = radius - height;
508+ radius = height;
509+ }
510+ if (radius > height / 2.)
511+ {
512+ rb = 2. * radius - height;
513+ }
514+ if (radius == 0.)
515+ {
516+ /* for nice edges */
517+ radius = 0.5;
518+ }
519+
520+ /* Carefull: here (0,0) is in the top left corner of the screen
521+ */
522+ /* 0 1 2 3
523+ * A x0 x1 x2 x3 B
524+ * |___|___________________|___|__y0
525+ * 11 | |__y1 4
526+ * | |
527+ * 10 | |__y2 5
528+ * |___________________________|__y3 6
529+ * D 9 8 7 C
530+ *
531+ * WARNING!! When draw the path, remember that ->
532+ * A becomes D
533+ * B becomes C
534+ */
535+ xp0 = 0.;
536+ xp1 = radius;
537+ xp2 = width - radius;
538+ xp3 = width;
539+
540+ yp0 = 0.;
541+ yp1 = radius;
542+ yp2 = height - radius;
543+ yp3 = height;
544+
545+ Point3 *vertices = (Point3 *) malloc (sizeof (Point3) * 12);
546+ float z = 2;
547+ vertices[0] = (Point3){xp0, yp0, z};
548+ vertices[1] = (Point3){xp1 - rb, yp0, z};
549+ vertices[2] = (Point3){xp2 + rb, yp0, z};
550+ vertices[3] = (Point3){xp3, yp0, z};
551+ vertices[4] = (Point3){xp3, yp1 - rb, z};
552+ vertices[5] = (Point3){xp3, yp2, z};
553+ vertices[6] = (Point3){xp3, yp3, z};
554+ vertices[7] = (Point3){xp2 - ex, yp3, z};
555+ vertices[8] = (Point3){xp1 + ex, yp3, z};
556+ vertices[9] = (Point3){xp0, yp3, z};
557+ vertices[10] = (Point3){xp0, yp2, z};
558+ vertices[11] = (Point3){xp0, yp1 - rb, z};
559+
560+ int i = 0;
561+
562+ for (; i < 12; ++i)
563+ {
564+ /* 3D ROTATION OVER X AXIS */
565+ vertices[i].y = c * vertices[i].y - s * vertices[i].z;
566+ vertices[i].z = s * vertices[i].y + c * vertices[i].z;
567+
568+ /* 3D to 2D - For now, use apply_perspective_x
569+ * maybe in the future we use projection matrix
570+ */
571+ vertices[i].x = apply_perspective_x (width,
572+ TRANSFORM_RADIUS(bg->panel_angle),
573+ vertices[i].x,
574+ vertices[i].y ) + x;
575+ /* Invert coordinates for our Y coordinate system cutted to int */
576+ vertices[i].y = floor (height - vertices[i].y + y);
577+ }
578+ /* use vertices[8]->y to find the top coordinate of the panel */
579+ return vertices;
580+}
581 /**
582 * draw_rect_path:
583- * @param bg: AwnBackground
584 * @param cr: a cairo context
585- * @param x: the begin x position to draw
586- * @param y: the begin y position to draw
587- * @param width: the width for the drawing
588- * @param height: the height for the drawing
589- * @param padding: makes the path X amount of pixels smaller on every side
590- *
591+ * @param vertices: vertices to use for drawing
592+ * @param padding: padding from top
593+ *
594 * This function draws the path of the bar in perspective.
595 */
596 static void
597-draw_rect_path (AwnBackground *bg,
598- cairo_t *cr,
599- gdouble x,
600- gdouble y,
601- gint width,
602- gint height,
603- gint padding)
604+draw_rect_path (cairo_t *cr, Point3 *vertices, float padding)
605 {
606- double x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11,
607- cy0, cy1, cy2, cy3;
608- double radius = bg->corner_radius;
609-
610- /* Carefull: here (0,0) is in the top left corner of the screen
611- * (x3,cy3) (x4,cy3) (x5,cy3) (x6,cy3)
612- * '-., | | ,.-'
613- * (x2,cy2)___.-''''''''''''''''-.___(x7,cy2)
614- * / \
615- * (x1,cy1)___/ \___(x8,cy1)
616- * '.____________________.'
617- * (x0,cy0)--'´| | `'--(x9,cy0)
618- * (x11,cy0) (x10,cy0)
619- */
620-
621- x0 = x + apply_perspective_x(width, bg->panel_angle, padding, padding);
622- x1 = x + apply_perspective_x(width, bg->panel_angle, padding, radius+padding);
623- x2 = x + apply_perspective_x(width, bg->panel_angle, padding, height/2.0-radius-padding);
624- x3 = x + apply_perspective_x(width, bg->panel_angle, padding, height/2.0-padding);
625- x4 = x + apply_perspective_x(width, bg->panel_angle, radius+padding, height/2.0-padding);
626- x5 = x + apply_perspective_x(width, bg->panel_angle, width-radius-padding, height/2.0-padding);
627- x6 = x + apply_perspective_x(width, bg->panel_angle, width-padding, height/2.0-padding);
628- x7 = x + apply_perspective_x(width, bg->panel_angle, width-padding, height/2.0-radius-padding);
629- x8 = x + apply_perspective_x(width, bg->panel_angle, width-padding, radius+padding);
630- x9 = x + apply_perspective_x(width, bg->panel_angle, width-padding, padding);
631- x10 = x + apply_perspective_x(width, bg->panel_angle, width-radius-padding, padding);
632- x11 = x + apply_perspective_x(width, bg->panel_angle, radius+padding, padding);
633-
634- cy0 = y + height - padding;
635- cy1 = y + height - radius - padding;
636- cy2 = y + height/2.0 + radius + padding;
637- cy3 = y + height/2.0 + padding;
638-
639- cairo_move_to(cr, x2, cy2);
640- cairo_curve_to(cr, x3, cy3, x3, cy3, x4, cy3);
641- cairo_line_to(cr, x5, cy3);
642- cairo_curve_to(cr, x6, cy3, x6, cy3, x7, cy2);
643- if( x8 > x7 )
644- {
645- /* draw the rounded corners on the bottom too */
646- cairo_line_to(cr, x8, cy1);
647- cairo_curve_to(cr, x9, cy0, x9, cy0, x10, cy0);
648- cairo_line_to(cr, x11, cy0);
649- cairo_curve_to(cr, x0, cy0, x0, cy0, x1, cy1);
650- cairo_line_to(cr, x2, cy2);
651- }
652- else
653- {
654- /* the radius is to big, so only draw the rounded corners on the top. On the bottom just ordinary corners. */
655- cairo_line_to(cr, x9, cy0);
656- cairo_line_to(cr, x0, cy0);
657- cairo_line_to(cr, x2, cy2);
658- }
659-
660+
661+ /* Let's make the path '*/
662+ cairo_new_path (cr);
663+ cairo_move_to (cr, vertices[1].x, vertices[1].y + padding);
664+
665+ cairo_line_to (cr, vertices[2].x, vertices[2].y + padding);
666+ cairo_curve_to (cr, vertices[2].x, vertices[2].y + padding,
667+ vertices[3].x, vertices[3].y + padding,
668+ vertices[4].x, vertices[4].y + padding);
669+
670+ cairo_line_to (cr, vertices[5].x, vertices[5].y + padding);
671+ cairo_curve_to (cr, vertices[6].x, vertices[6].y + padding,
672+ vertices[7].x, vertices[7].y + padding,
673+ vertices[7].x, vertices[7].y + padding);
674+
675+ cairo_line_to (cr, vertices[8].x, vertices[8].y + padding);
676+ cairo_curve_to (cr, vertices[8].x, vertices[8].y + padding,
677+ vertices[9].x, vertices[9].y + padding,
678+ vertices[10].x, vertices[10].y + padding);
679+
680+ cairo_line_to (cr, vertices[11].x, vertices[11].y + padding);
681+ cairo_curve_to (cr, vertices[0].x, vertices[0].y + padding,
682+ vertices[1].x, vertices[1].y + padding,
683+ vertices[1].x, vertices[1].y + padding);
684 cairo_close_path(cr);
685 }
686
687@@ -304,111 +384,214 @@
688 static void
689 draw_top_bottom_background (AwnBackground *bg,
690 cairo_t *cr,
691- gint width,
692- gint height)
693+ gfloat width,
694+ gfloat height)
695 {
696-#if DEBUG_DRAW_SIDE
697- int i;
698-#endif
699 cairo_pattern_t *pat;
700+ float s = OBTAIN_THICKNESS (bg->panel_angle, bg->thickness);
701
702- height -= SIDE_SPACE;
703+ height -= (s + PADDING_BOTTOM + 1.);
704
705 /* Basic set-up */
706 cairo_set_line_width (cr, 1.0);
707- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
708- cairo_translate (cr, 0.5, 0.5);
709-
710-#if DEBUG_DRAW_INTERNAL_BORDER_BOTTOM
711- /* Internal border (on the bottom) */
712- awn_cairo_set_source_color (cr, bg->hilight_color),
713- draw_rect_path (bg, cr, 0, SIDE_SPACE, width, height, 1);
714- cairo_stroke (cr);
715-#endif
716-
717-#if DEBUG_DRAW_EXTERNAL_BORDER_BOTTOM
718- /* External border (on the bottom) */
719- awn_cairo_set_source_color (cr, bg->border_color);
720- draw_rect_path (bg, cr, 0, SIDE_SPACE, width, height, 0.5);
721- cairo_stroke (cr);
722-
723- /* Draw the background (on the bottom) */
724- //FIXME: I'm doubting if it is nicer with or without the bottom background drawn
725- /*pat = cairo_pattern_create_linear (0, 0, 0, height);
726- awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_step_1);
727- awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);
728-
729- draw_rect_path (bg, cr, 0, 0, width, height, 0.5);
730- cairo_set_source (cr, pat);
731- cairo_fill (cr);
732-
733- cairo_pattern_destroy (pat);*/
734-
735- /* draw the side */
736- /* TODO: if a side has no rounded corners, the border should be drawn. */
737- pat = cairo_pattern_create_linear (0, 0, 0, height);
738- awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_step_1);
739- awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);
740- cairo_set_source (cr, pat);
741- for(i=SIDE_SPACE-1; i>0; i--)
742+ /* Translate for sharp edges and for avoid drawing's glitches */
743+ cairo_translate (cr, DRAW_XPADDING, 0.5);
744+ width -= DRAW_XPADDING * 2.;
745+
746+ /* calc vertices for draw the main path */
747+ Point3 *vertices = calc_points (bg, 0., 0., width, height);
748+ /* calc the y coord of the top panel, used for pattern painting */
749+ float top_y = vertices[8].y;
750+
751+ double red, green, blue, alpha;
752+ /* Save general context */
753+ cairo_save (cr);
754+#if DRAW_SIDE
755+ /* Internal border (The Side of the 3D panel) */
756+ /* Draw only if it will be visible */
757+ if (bg->panel_angle > 0)
758 {
759- draw_rect_path (bg, cr, 0, i, width, height, 0.5);
760- cairo_stroke (cr);
761+ float i;
762+
763+ /* Draw bottom plane (Inner Border Color) with
764+ * its own border (Outer Border Color)
765+ */
766+ desktop_agnostic_color_get_cairo_color
767+ (bg->hilight_color, &red, &green, &blue, &alpha);
768+ /* if side is transparent (1. / 255.), don't draw bottom border */
769+ if (alpha > 0.003)
770+ {
771+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
772+ draw_rect_path (cr, vertices, s);
773+#if FILL_BOTTOM_PLANE
774+ cairo_save (cr);
775+ awn_cairo_set_source_color (cr, bg->hilight_color);
776+ cairo_clip (cr);
777+ cairo_paint (cr);
778+ cairo_restore (cr);
779+#endif
780+ cairo_set_line_width (cr, BORDER_LINE_WIDTH);
781+ awn_cairo_set_source_color (cr, bg->border_color);
782+ cairo_stroke (cr);
783+
784+ /* Pixel per Pixel draw each plane only with border from bottom to top */
785+ cairo_set_line_width (cr, 1.5);
786+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
787+ for (i = s - 1.; i >= 0. ; i -= 1.)
788+ {
789+ draw_rect_path (cr, vertices, i);
790+ awn_cairo_set_source_color (cr, bg->hilight_color);
791+ cairo_stroke (cr);
792+ }
793+ /* draw edges lines if corner-radius is smaller then 3px */
794+ if (bg->corner_radius < 4 || bg->corner_radius > (height - 3))
795+ {
796+ double alpha_coeff = bg->corner_radius;
797+ cairo_move_to (cr, vertices[0].x, vertices[0].y);
798+ cairo_line_to (cr, vertices[0].x, vertices[0].y + s);
799+ cairo_move_to (cr, vertices[3].x, vertices[3].y);
800+ cairo_line_to (cr, vertices[3].x, vertices[3].y + s);
801+ if (bg->corner_radius < 4)
802+ {
803+ cairo_move_to (cr, vertices[6].x, vertices[6].y);
804+ cairo_line_to (cr, vertices[6].x, vertices[6].y + s);
805+ cairo_move_to (cr, vertices[9].x, vertices[9].y);
806+ cairo_line_to (cr, vertices[9].x, vertices[9].y + s);
807+ }
808+ else
809+ {
810+ alpha_coeff = fabs (MIN (bg->corner_radius, height) - height);
811+ }
812+ alpha_coeff = (1.0 - alpha_coeff / 3.);
813+ cairo_set_line_width (cr, BORDER_LINE_WIDTH);
814+ desktop_agnostic_color_get_cairo_color
815+ (bg->border_color, &red, &green, &blue, &alpha);
816+ /* edges fade effect when increasing the corner radius from 0 to 3 */
817+ cairo_set_source_rgba (cr, red, green, blue,
818+ alpha * alpha_coeff);
819+ cairo_stroke (cr);
820+ }
821+ }
822+ /* Clear the area for the top plane
823+ *-> hides "back border" when top is transparent
824+ *-> disabled for now...
825+ */
826+#if CLEAR_TOP_BEFORE_PAINT
827+ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
828+ draw_rect_path (cr, vertices, 0.);
829+ cairo_save (cr);
830+ cairo_set_source_rgba (cr, 0., 0., 0., 1.);
831+ cairo_clip (cr);
832+ cairo_paint (cr);
833+ cairo_restore (cr);
834+#endif
835 }
836+#endif
837+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
838+ cairo_set_line_width (cr, 2.);
839+ /* Draw the path of top plane */
840+ draw_rect_path (cr, vertices, 0.);
841+ /* obtain 0.0 - 1.0 relative height for pattern drawing */
842+ top_y = top_y / height;
843
844+ /* Paint the top plane gradient */
845+ pat = cairo_pattern_create_linear (0., 0., 0., height);
846+ awn_cairo_pattern_add_color_stop_color (pat, top_y, bg->g_step_1);
847+ awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);
848+ cairo_save (cr);
849+ cairo_clip_preserve (cr);
850+ cairo_set_source (cr, pat);
851+ cairo_paint (cr);
852 cairo_pattern_destroy (pat);
853-#endif
854+ cairo_restore (cr);
855
856- /* Draw the background (on the top) */
857 if (bg->enable_pattern && bg->pattern)
858 {
859+ /* Paint the top plane pattern */
860+ cairo_save (cr);
861 pat = cairo_pattern_create_for_surface (bg->pattern);
862 cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT);
863- }
864- else
865- {
866- pat = cairo_pattern_create_linear (0, 0, 0, height);
867- awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_step_1);
868- awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);
869- }
870-
871+ cairo_clip_preserve (cr);
872+ cairo_set_source (cr, pat);
873+ cairo_paint (cr);
874+ cairo_pattern_destroy (pat);
875+ cairo_restore (cr);
876+ }
877+
878+#if DRAW_HIGHLIGHT
879+ /* Prepare the hi-light */
880+ pat = cairo_pattern_create_linear (0., 0., 0., height);
881+ awn_cairo_pattern_add_color_stop_color
882+ (pat, top_y + 0.0, bg->g_histep_1);
883+ awn_cairo_pattern_add_color_stop_color
884+ (pat, top_y + (1. - top_y) * 0.3, bg->g_histep_2);
885+
886+ desktop_agnostic_color_get_cairo_color
887+ (bg->g_histep_2, &red, &green, &blue, &alpha);
888+ cairo_pattern_add_color_stop_rgba
889+ (pat, top_y + (1. - top_y) * 0.4, red, green, blue, 0.);
890+ /* Paint the hi-light gradient */
891 cairo_save (cr);
892-
893- draw_rect_path (bg, cr, 0, 0, width, height, 0.5);
894- cairo_clip (cr);
895+ cairo_clip_preserve (cr);
896 cairo_set_source (cr, pat);
897 cairo_paint (cr);
898-
899 cairo_restore (cr);
900-
901- cairo_pattern_destroy (pat);
902-
903-#if DEBUG_DRAW_HIGHLIGHT
904- /* Draw the hi-light (on the top) */
905- pat = cairo_pattern_create_linear (0, height/3.0, 0, height*2.0/3.0);
906- awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_histep_1);
907- awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_histep_2);
908- draw_rect_path (bg, cr, apply_perspective_x(width, bg->panel_angle, 0, height/3.0), height/3.0, get_width_on_height(width, bg->panel_angle, height/3.0), height/3.0, 1.5);
909-
910- cairo_set_source (cr, pat);
911- cairo_fill (cr);
912- cairo_pattern_destroy (pat);
913-#endif
914-
915-#if DEBUG_DRAW_INTERNAL_BORDER_TOP
916- /* Internal border (on the top) */
917- awn_cairo_set_source_color (cr, bg->hilight_color);
918- draw_rect_path (bg, cr, 0, 0, width, height, 1);
919+ cairo_pattern_destroy (pat);
920+#endif
921+#if DRAW_INTERNAL_BORDER
922+ /* Internal border of the top surface */
923+ desktop_agnostic_color_get_cairo_color
924+ (bg->border_color, &red, &green, &blue, &alpha);
925+ /* for glass-look don't draw internal border if there is no external border */
926+ if (alpha > 0.003)
927+ {
928+ cairo_save (cr);
929+ cairo_scale (cr, (width - 2.) / (width), (height - 2.) / (height));
930+ cairo_translate (cr, 1., 1.);
931+ draw_rect_path (cr, vertices, 0.);
932+ cairo_set_line_width (cr, BORDER_LINE_WIDTH + 0.5);
933+ awn_cairo_set_source_color (cr, bg->hilight_color);
934+ cairo_stroke (cr);
935+ cairo_restore (cr);
936+ draw_rect_path (cr, vertices, 0.);
937+ }
938+#endif
939+#if DRAW_EXTERNAL_BORDER
940+ /* External border */
941+ cairo_set_line_width (cr, BORDER_LINE_WIDTH);
942+ awn_cairo_set_source_color (cr, bg->border_color);
943 cairo_stroke (cr);
944 #endif
945-
946-#if DEBUG_DRAW_EXTERNAL_BORDER_BOTTOM
947- /* External border (on the top) */
948- awn_cairo_set_source_color (cr, bg->border_color);
949- draw_rect_path (bg, cr, 0, 0, width, height, 0.5);
950- cairo_stroke (cr);
951-#endif
952-
953+ /* restore genereal context */
954+ cairo_restore (cr);
955+ /* free memory :) */
956+ free (vertices);
957+}
958+
959+/**
960+ * _get_applet_manager_size
961+ * Obtain width and height from applet manager
962+ */
963+static void
964+_get_applet_manager_size (AwnBackground* bg, GtkPositionType position,
965+ float *w, float *h)
966+{
967+ AwnAppletManager *manager = NULL;
968+ g_object_get (bg->panel, "applet-manager", &manager, NULL);
969+
970+ switch (position)
971+ {
972+ case GTK_POS_BOTTOM:
973+ case GTK_POS_TOP:
974+ *w = GTK_WIDGET (manager)->allocation.width;
975+ break;
976+ default:
977+ *w = GTK_WIDGET (manager)->allocation.height;
978+ break;
979+ }
980+ gint size = 0;
981+ g_object_get (manager, "size", &size, NULL);
982+ *h = size;
983 }
984
985 /**
986@@ -436,33 +619,54 @@
987 guint padding;
988 g_object_get (bg->panel, "offset", &offset, "size", &size, NULL);
989
990- if(offset > size)
991- padding = (size+offset)/2.0/tan((90-bg->panel_angle)*M_PI/180);
992- else
993- {
994- double angle = 90 - CLAMP (bg->panel_angle, 0.0, 75.0);
995- double y_pos = size / 2.0 + bg->corner_radius;
996- double x = y_pos / tan (angle * M_PI/180);
997- padding = MAX (x, offset);
998- }
999+ /* Find the coordinate of the (0;0) point in the prospective */
1000+ /* Its X coordinate is equal to the padding */
1001+ float w,h;
1002+ _get_applet_manager_size (bg, position, &w, &h);
1003+ padding = apply_perspective_x
1004+ ( w, TRANSFORM_RADIUS(bg->panel_angle), 0., h );
1005+ /* Padding > h is not needed */
1006+ if (padding > h)
1007+ {
1008+ padding = h;
1009+ }
1010+
1011+ /* Obtain the padding from corner radius */
1012+ float padding_from_rad = bg->corner_radius;
1013+
1014+ if (padding_from_rad > h)
1015+ {
1016+ padding_from_rad = h;
1017+ }
1018+ if (padding_from_rad > (h / 2.))
1019+ {
1020+ padding_from_rad = ( h - padding_from_rad );
1021+ }
1022+ /* Sum padding needed */
1023+ padding = MAX (padding, padding_from_rad) + DRAW_XPADDING;
1024+ float s = OBTAIN_THICKNESS (bg->panel_angle, bg->thickness);
1025
1026 switch (position)
1027 {
1028 case GTK_POS_TOP:
1029- *padding_top = SIDE_SPACE+2; *padding_bottom = 0;
1030+ *padding_top = PADDING_BOTTOM + s;
1031+ *padding_bottom = PADDING_TOP;
1032 *padding_left = padding; *padding_right = padding;
1033 break;
1034 case GTK_POS_BOTTOM:
1035- *padding_top = 0; *padding_bottom = SIDE_SPACE+2;
1036+ *padding_top = PADDING_TOP;
1037+ *padding_bottom = PADDING_BOTTOM + s;
1038 *padding_left = padding; *padding_right = padding;
1039 break;
1040 case GTK_POS_LEFT:
1041 *padding_top = padding; *padding_bottom = padding;
1042- *padding_left = SIDE_SPACE+2; *padding_right = 0;
1043+ *padding_left = PADDING_BOTTOM + s;
1044+ *padding_right = PADDING_TOP;
1045 break;
1046 case GTK_POS_RIGHT:
1047 *padding_top = padding; *padding_bottom = padding;
1048- *padding_left = 0; *padding_right = SIDE_SPACE+2;
1049+ *padding_left = PADDING_TOP;
1050+ *padding_right = PADDING_BOTTOM + s;
1051 break;
1052 default:
1053 break;
1054@@ -482,7 +686,8 @@
1055 * Draws the bar in the in the cairo context &cr given the position &position,
1056 * the &x and &y position and given &width and &height
1057 *
1058- * Important: every change to this function should get adjusted in input_shape_mask!!!
1059+ * Important: every change to this function should get
1060+ * adjusted in input_shape_mask!!!
1061 */
1062 static void
1063 awn_background_3d_draw (AwnBackground *bg,
1064@@ -498,23 +703,27 @@
1065 switch (position)
1066 {
1067 case GTK_POS_RIGHT:
1068- cairo_translate (cr, x-1, y+height);
1069+ cairo_translate (cr, 0., y + height);
1070+ cairo_scale (cr, 1., -1.);
1071+ cairo_translate (cr, x, height);
1072 cairo_rotate (cr, M_PI * 1.5);
1073 temp = width;
1074- width = height; height = temp;
1075+ width = height;
1076+ height = temp;
1077 break;
1078 case GTK_POS_LEFT:
1079- cairo_translate (cr, x+width+1, y);
1080+ cairo_translate (cr, x + width, y);
1081 cairo_rotate (cr, M_PI * 0.5);
1082 temp = width;
1083- width = height; height = temp;
1084+ width = height;
1085+ height = temp;
1086 break;
1087 case GTK_POS_TOP:
1088- cairo_translate (cr, x+width, y+height+1);
1089- cairo_rotate (cr, M_PI);
1090+ cairo_translate (cr, x, y + height);
1091+ cairo_scale (cr, 1., -1.);
1092 break;
1093 default:
1094- cairo_translate (cr, x, y-1);
1095+ cairo_translate (cr, x, y);
1096 break;
1097 }
1098
1099@@ -543,50 +752,55 @@
1100 GtkPositionType position,
1101 GdkRectangle *area)
1102 {
1103- int i;
1104- gint temp;
1105- gint x = area->x, y = area->y;
1106- gint width = area->width, height = area->height;
1107+ gfloat temp;
1108+ gfloat x = area->x, y = area->y;
1109+ gfloat width = area->width, height = area->height;
1110 cairo_save (cr);
1111
1112 switch (position)
1113 {
1114 case GTK_POS_RIGHT:
1115- cairo_translate (cr, x-1, y+height);
1116+ cairo_translate (cr, 0., y + height);
1117+ cairo_scale (cr, 1., -1.);
1118+ cairo_translate (cr, x, height);
1119 cairo_rotate (cr, M_PI * 1.5);
1120 temp = width;
1121- width = height; height = temp;
1122+ width = height;
1123+ height = temp;
1124 break;
1125 case GTK_POS_LEFT:
1126- cairo_translate (cr, x+width+1, y);
1127+ cairo_translate (cr, x + width, y);
1128 cairo_rotate (cr, M_PI * 0.5);
1129 temp = width;
1130- width = height; height = temp;
1131+ width = height;
1132+ height = temp;
1133 break;
1134 case GTK_POS_TOP:
1135- cairo_translate (cr, x+width, y+height+1);
1136- cairo_rotate (cr, M_PI);
1137+ cairo_translate (cr, x, y + height);
1138+ cairo_scale (cr, 1., -1.);
1139 break;
1140 default:
1141- cairo_translate (cr, x, y-1);
1142+ cairo_translate (cr, x, y);
1143 break;
1144 }
1145-
1146- height -= SIDE_SPACE;
1147-
1148+ float s = OBTAIN_THICKNESS (bg->panel_angle, bg->thickness);
1149+
1150+ height -= (s + PADDING_BOTTOM + 1.);
1151 /* Basic set-up */
1152 cairo_set_line_width (cr, 1.0);
1153 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1154- cairo_translate (cr, 0.5, 0.5);
1155-
1156- /* Draw the background (in black color*/
1157- cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0);
1158-
1159- for(i=SIDE_SPACE-1; i>-1; i--)
1160- {
1161- draw_rect_path (bg, cr, 0, i, width, height, 0.5);
1162- cairo_fill (cr);
1163- }
1164+ cairo_translate (cr, DRAW_XPADDING, 0.5);
1165+ width -= DRAW_XPADDING * 2.;
1166+
1167+ /* Draw the background (in black color) */
1168+ cairo_set_source_rgba(cr, 0., 0., 0., 1.);
1169+ /* for shape mask draw only top and bottom plane */
1170+ Point3 *vertices = calc_points (bg, 0., 0., width, height);
1171+ draw_rect_path (cr, vertices, 0.);
1172+ cairo_fill (cr);
1173+ draw_rect_path (cr, vertices, s);
1174+ cairo_fill (cr);
1175+ free (vertices);
1176
1177 cairo_restore (cr);
1178 }
1179
1180=== modified file 'src/awn-background-edgy.c'
1181--- src/awn-background-edgy.c 2010-03-07 18:38:07 +0000
1182+++ src/awn-background-edgy.c 2010-07-16 11:56:43 +0000
1183@@ -16,6 +16,7 @@
1184 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1185 *
1186 * Author : Michal Hruby <michal.mhr@gmail.com>
1187+ * Adjusted by: Alberto Aldegheri <albyrock87+dev@gmail.com>
1188 *
1189 */
1190
1191@@ -106,7 +107,8 @@
1192 static void
1193 awn_background_edgy_align_changed (AwnBackgroundEdgy *bg) // has more params...
1194 {
1195- gfloat align = awn_background_get_panel_alignment (AWN_BACKGROUND (bg));
1196+ AwnBackground *abg = AWN_BACKGROUND (bg);
1197+ gfloat align = awn_background_get_panel_alignment (abg);
1198 gboolean in_corner = align == 0.0 || align == 1.0;
1199 if (bg->priv->in_corner != in_corner)
1200 {
1201@@ -120,21 +122,27 @@
1202 else
1203 {
1204 gtk_widget_hide (bg->priv->separator);
1205- awn_background_emit_padding_changed (AWN_BACKGROUND (bg));
1206+ awn_background_emit_padding_changed (abg);
1207 }
1208 }
1209
1210 if (in_corner)
1211 {
1212 AwnAppletManager *manager;
1213- g_object_get (AWN_BACKGROUND (bg)->panel, "applet-manager", &manager, NULL);
1214+ g_object_get (abg->panel, "applet-manager", &manager, NULL);
1215 awn_applet_manager_add_widget (manager, bg->priv->separator,
1216 awn_background_edgy_separator_pos (bg, align));
1217- awn_background_emit_padding_changed (AWN_BACKGROUND (bg));
1218+ awn_background_emit_padding_changed (abg);
1219 }
1220 }
1221
1222 static void
1223+awn_background_edgy_widgets_changed (AwnBackground *bg)
1224+{
1225+ awn_background_emit_padding_changed (bg);
1226+}
1227+
1228+static void
1229 awn_background_edgy_constructed (GObject *object)
1230 {
1231 G_OBJECT_CLASS (awn_background_edgy_parent_class)->constructed (object);
1232@@ -152,7 +160,11 @@
1233
1234 AwnAppletManager *manager;
1235 g_object_get (panel, "applet-manager", &manager, NULL);
1236+ g_return_if_fail (manager);
1237 awn_applet_manager_add_widget (manager, bg->priv->separator, 1);
1238+ g_signal_connect_swapped (manager, "applets-refreshed",
1239+ G_CALLBACK (awn_background_edgy_widgets_changed), bg);
1240+
1241
1242 gpointer monitor = NULL;
1243 g_object_get (panel, "monitor", &monitor, NULL);
1244@@ -196,6 +208,12 @@
1245
1246 GtkWidget *widget = AWN_BACKGROUND_EDGY_GET_PRIVATE (object)->separator;
1247
1248+ if (manager)
1249+ {
1250+ g_signal_handlers_disconnect_by_func (manager,
1251+ G_CALLBACK (awn_background_edgy_widgets_changed), object);
1252+ }
1253+
1254 if (manager && widget)
1255 {
1256 awn_applet_manager_remove_widget (manager, widget);
1257@@ -276,7 +294,6 @@
1258
1259 /* Basic set-up */
1260 cairo_set_line_width (cr, 1.0);
1261- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1262
1263 if (gtk_widget_is_composited (GTK_WIDGET (bg->panel)) == FALSE)
1264 {
1265@@ -313,6 +330,7 @@
1266 draw_path(cr, height - 1.0, width, height, bottom_left);
1267 cairo_line_to (cr, bottom_left ? 0.0 : width, height);
1268 cairo_clip (cr);
1269+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
1270 cairo_set_source (cr, pat);
1271 cairo_paint (cr);
1272
1273@@ -320,12 +338,17 @@
1274
1275 cairo_pattern_destroy (pat);
1276
1277+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1278 /* Draw the hi-light */
1279+
1280 pat = cairo_pattern_create_radial (bottom_left ? 0 : width, height,
1281 height * 3/4,
1282 bottom_left ? 0 : width, height,
1283 height);
1284- awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_histep_2);
1285+ double red, green, blue, alpha;
1286+ desktop_agnostic_color_get_cairo_color (bg->g_histep_2, &red, &green, &blue, &alpha);
1287+ cairo_pattern_add_color_stop_rgba (pat, 0.0, red, green, blue, 0.);
1288+ awn_cairo_pattern_add_color_stop_color (pat, 0.2, bg->g_histep_2);
1289 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_histep_1);
1290
1291 draw_path (cr, height * 3/4, width, height, bottom_left);
1292@@ -359,50 +382,25 @@
1293 guint *padding_left,
1294 guint *padding_right)
1295 {
1296- if (AWN_BACKGROUND_EDGY (bg)->priv->in_corner == FALSE)
1297- {
1298- /* if we're not in the corner behave as standard flat bg */
1299- AWN_BACKGROUND_CLASS (awn_background_edgy_parent_class)->padding_request (
1300- bg, position, padding_top, padding_bottom, padding_left, padding_right);
1301- return;
1302- }
1303-
1304- gint base_side_pad, zero_pad = 0;
1305- guint dummy, left, right;
1306-
1307+ /* behave as standard flat bg */
1308 AWN_BACKGROUND_CLASS (awn_background_edgy_parent_class)->padding_request (
1309- bg, GTK_POS_BOTTOM, &dummy, &dummy, &left, &right);
1310- base_side_pad = MAX (left, right);
1311+ bg, position, padding_top, padding_bottom, padding_left, padding_right);
1312
1313 const gint req = AWN_BACKGROUND_EDGY (bg)->priv->top_pad;
1314- gboolean bottom_left = awn_background_get_panel_alignment (bg) == 0.0;
1315-
1316- if (awn_background_do_rtl_swap (bg))
1317- {
1318- zero_pad = base_side_pad;
1319- base_side_pad = 0;
1320- }
1321-
1322+
1323+ /* set the top padding for background */
1324 switch (position)
1325 {
1326 case GTK_POS_TOP:
1327 *padding_top = 0; *padding_bottom = req;
1328- *padding_left = bottom_left ? zero_pad : base_side_pad;
1329- *padding_right = bottom_left ? base_side_pad : zero_pad;
1330 break;
1331 case GTK_POS_BOTTOM:
1332 *padding_top = req; *padding_bottom = 0;
1333- *padding_left = bottom_left ? zero_pad : base_side_pad;
1334- *padding_right = bottom_left ? base_side_pad : zero_pad;
1335 break;
1336 case GTK_POS_LEFT:
1337- *padding_top = bottom_left ? zero_pad : base_side_pad;
1338- *padding_bottom = bottom_left ? base_side_pad : zero_pad;
1339 *padding_left = 0; *padding_right = req;
1340 break;
1341 case GTK_POS_RIGHT:
1342- *padding_top = bottom_left ? zero_pad : base_side_pad;
1343- *padding_bottom = bottom_left ? base_side_pad : zero_pad;
1344 *padding_left = req; *padding_right = 0;
1345 break;
1346 default:
1347@@ -437,7 +435,7 @@
1348 AWN_BACKGROUND_CLASS (awn_background_edgy_parent_class)->padding_request (
1349 bg, position, &top, &bot, &left, &right);
1350 const gint modifier = AWN_BACKGROUND_EDGY (bg)->priv->top_pad;
1351-
1352+
1353 switch (position)
1354 {
1355 case GTK_POS_RIGHT:
1356@@ -458,83 +456,84 @@
1357 }
1358 }
1359
1360-static void
1361-awn_background_edgy_prepare_context (AwnBackgroundEdgy *bg,
1362- cairo_t *cr,
1363- GtkPositionType position,
1364- GdkRectangle *area,
1365- gint *width_ptr, gint *height_ptr)
1366+static gboolean
1367+awn_background_edgy_flat_needed (AwnBackground *bg, gint width)
1368+{
1369+ gboolean expand = FALSE;
1370+ g_object_get (bg->panel, "expand", &expand, NULL);
1371+ if (expand || !AWN_BACKGROUND_EDGY (bg)->priv->in_corner)
1372+ {
1373+ return TRUE;
1374+ }
1375+ return width > AWN_BACKGROUND_EDGY (bg)->priv->radius * 4/3;
1376+}
1377+
1378+static void
1379+awn_background_edgy_get_shape_mask (AwnBackground *bg,
1380+ cairo_t *cr,
1381+ GtkPositionType position,
1382+ GdkRectangle *area)
1383 {
1384 gint temp;
1385 gint x = area->x, y = area->y;
1386 gint width = area->width, height = area->height;
1387+ const gboolean in_corner = AWN_BACKGROUND_EDGY (bg)->priv->in_corner;
1388+
1389+ if (awn_background_edgy_flat_needed (bg, width))
1390+ {
1391+ GdkRectangle areaf = {x, y, width, height};
1392+ cairo_save (cr);
1393+ awn_background_edgy_translate_for_flat (bg, position, &areaf);
1394+ AWN_BACKGROUND_CLASS (awn_background_edgy_parent_class)-> get_shape_mask (
1395+ bg, cr, position, &areaf);
1396+ cairo_restore (cr);
1397+ }
1398+ if (!in_corner)
1399+ {
1400+ return;
1401+ }
1402+ cairo_save (cr);
1403
1404 switch (position)
1405 {
1406 case GTK_POS_RIGHT:
1407- cairo_translate (cr, x, y);
1408- cairo_rotate (cr, M_PI * 0.5);
1409- cairo_scale (cr, 1.0, -1.0);
1410+ height += y;
1411+ cairo_translate (cr, 0., height);
1412+ cairo_scale (cr, 1., -1.);
1413+ cairo_translate (cr, x, height);
1414+ cairo_rotate (cr, M_PI * 1.5);
1415 temp = width;
1416- width = height; height = temp;
1417+ width = height;
1418+ height = temp;
1419 break;
1420 case GTK_POS_LEFT:
1421- cairo_translate (cr, x+width, y);
1422+ height += y;
1423+ cairo_translate (cr, x + width, 0.);
1424 cairo_rotate (cr, M_PI * 0.5);
1425 temp = width;
1426- width = height; height = temp;
1427+ width = height;
1428+ height = temp;
1429 break;
1430 case GTK_POS_TOP:
1431- cairo_translate (cr, x, height - y);
1432- cairo_scale (cr, 1.0, -1.0);
1433+ width += x;
1434+ cairo_translate (cr, 0., y + height);
1435+ cairo_scale (cr, 1., -1.);
1436 break;
1437 default:
1438- cairo_translate (cr, x, y);
1439+ width += x;
1440+ cairo_translate (cr, 0., y);
1441 break;
1442 }
1443-
1444- if (width_ptr) *width_ptr = width;
1445- if (height_ptr) *height_ptr = height;
1446-}
1447-
1448-static void
1449-chain_draw (AwnBackground *bg,
1450- cairo_t *cr,
1451- GtkPositionType position,
1452- GdkRectangle *area)
1453-{
1454- cairo_save (cr);
1455-
1456- if (AWN_BACKGROUND_EDGY (bg)->priv->in_corner)
1457- {
1458- /* we need to clip the drawing area of flat background */
1459- gint width, height;
1460-
1461- gfloat align = awn_background_get_panel_alignment (AWN_BACKGROUND (bg));
1462- gboolean bottom_left = align == 0.0;
1463-
1464- cairo_rectangle (cr, area->x, area->y, area->width, area->height);
1465-
1466- /* init our context - translate, rotate.. */
1467- awn_background_edgy_prepare_context (AWN_BACKGROUND_EDGY (bg), cr,
1468- position, area, &width, &height);
1469-
1470- cairo_move_to (cr, bottom_left ? 0.0 : width, height);
1471- draw_path (cr, height - 1.0, width, height, bottom_left);
1472- cairo_line_to (cr, bottom_left ? 0.0 : width, height);
1473-
1474- cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
1475- cairo_clip (cr);
1476-
1477- /* prepare context for base class call */
1478- cairo_identity_matrix (cr);
1479- cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
1480-
1481- awn_background_edgy_translate_for_flat (bg, position, area);
1482- }
1483-
1484- AWN_BACKGROUND_CLASS (awn_background_edgy_parent_class)-> draw (
1485- bg, cr, position, area);
1486+
1487+ /* Basic set-up */
1488+ cairo_set_line_width (cr, 1.0);
1489+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1490+ gboolean bottom_left = awn_background_get_panel_alignment (bg) == 0.;
1491+ draw_path(cr, height - 1.0, width, height, bottom_left);
1492+ cairo_line_to (cr, bottom_left ? 0.0 : width, height);
1493+ cairo_set_source_rgba (cr, 0., 0., 0., 1.);
1494+ cairo_clip (cr);
1495+ cairo_paint (cr);
1496
1497 cairo_restore (cr);
1498 }
1499@@ -545,73 +544,56 @@
1500 GtkPositionType position,
1501 GdkRectangle *area)
1502 {
1503- const gboolean in_corner = AWN_BACKGROUND_EDGY (bg)->priv->in_corner;
1504- gint base_size = area->width;
1505-
1506- if (in_corner)
1507- {
1508- gint width, height;
1509-
1510- cairo_save (cr);
1511-
1512- /* init our context - translate, rotate.. */
1513- awn_background_edgy_prepare_context (AWN_BACKGROUND_EDGY (bg),
1514- cr, position, area, &width, &height);
1515-
1516- draw_top_bottom_background (bg, cr, width, height);
1517-
1518- cairo_restore (cr);
1519-
1520- base_size = width;
1521- }
1522-
1523- if (!in_corner || base_size > AWN_BACKGROUND_EDGY (bg)->priv->radius * 4/3)
1524- chain_draw (bg, cr, position, area);
1525-}
1526-
1527-static void
1528-awn_background_edgy_get_shape_mask (AwnBackground *bg,
1529- cairo_t *cr,
1530- GtkPositionType position,
1531- GdkRectangle *area)
1532-{
1533- const gboolean in_corner = AWN_BACKGROUND_EDGY (bg)->priv->in_corner;
1534- gint base_size = area->width;
1535-
1536- if (in_corner)
1537- {
1538- gint width, height;
1539-
1540- cairo_save (cr);
1541-
1542- gfloat align = awn_background_get_panel_alignment (AWN_BACKGROUND (bg));
1543- gboolean bottom_left = align == 0.0;
1544-
1545- /* init our context - translate, rotate.. */
1546- awn_background_edgy_prepare_context (AWN_BACKGROUND_EDGY (bg),
1547- cr, position, area, &width, &height);
1548-
1549- draw_path (cr, height - 1.0, width, height, bottom_left);
1550- cairo_line_to (cr, bottom_left ? 0.0 : width, height);
1551-
1552- cairo_fill_preserve (cr);
1553- cairo_stroke (cr);
1554-
1555- cairo_restore (cr);
1556-
1557- base_size = width;
1558-
1559- /* prepare context for base class call */
1560- awn_background_edgy_translate_for_flat (bg, position, area);
1561- }
1562-
1563- if (!in_corner || base_size > AWN_BACKGROUND_EDGY (bg)->priv->radius * 4/3)
1564- {
1565- cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
1566-
1567- AWN_BACKGROUND_CLASS (awn_background_edgy_parent_class)->get_shape_mask (
1568- bg, cr, position, area);
1569- }
1570+ gint temp;
1571+ gint x = area->x, y = area->y;
1572+ gint width = area->width, height = area->height;
1573+
1574+ if (awn_background_edgy_flat_needed (bg, width))
1575+ {
1576+ GdkRectangle areaf = {x, y, width, height};
1577+ cairo_save (cr);
1578+ awn_background_edgy_translate_for_flat (bg, position, &areaf);
1579+ AWN_BACKGROUND_CLASS (awn_background_edgy_parent_class)-> draw (
1580+ bg, cr, position, &areaf);
1581+ cairo_restore (cr);
1582+ }
1583+
1584+ cairo_save (cr);
1585+
1586+ switch (position)
1587+ {
1588+ case GTK_POS_RIGHT:
1589+ height += y;
1590+ cairo_translate (cr, 0., height);
1591+ cairo_scale (cr, 1., -1.);
1592+ cairo_translate (cr, x, height);
1593+ cairo_rotate (cr, M_PI * 1.5);
1594+ temp = width;
1595+ width = height;
1596+ height = temp;
1597+ break;
1598+ case GTK_POS_LEFT:
1599+ height += y;
1600+ cairo_translate (cr, x + width, 0.);
1601+ cairo_rotate (cr, M_PI * 0.5);
1602+ temp = width;
1603+ width = height;
1604+ height = temp;
1605+ break;
1606+ case GTK_POS_TOP:
1607+ width += x;
1608+ cairo_translate (cr, 0., y + height);
1609+ cairo_scale (cr, 1., -1.);
1610+ break;
1611+ default:
1612+ width += x;
1613+ cairo_translate (cr, 0., y);
1614+ break;
1615+ }
1616+
1617+ draw_top_bottom_background (bg, cr, width, height);
1618+
1619+ cairo_restore (cr);
1620 }
1621
1622 /* vim: set et ts=2 sts=2 sw=2 : */
1623
1624=== modified file 'src/awn-background-flat.c'
1625--- src/awn-background-flat.c 2010-05-23 23:07:18 +0000
1626+++ src/awn-background-flat.c 2010-07-16 11:56:43 +0000
1627@@ -159,22 +159,14 @@
1628 if (expand){ state = ROUND_NONE; x-=2; width+=4; }
1629 else
1630 {
1631- switch (position)
1632- {
1633- case GTK_POS_BOTTOM:
1634- case GTK_POS_LEFT:
1635- if (align == 0.0f){ state = ROUND_TOP_RIGHT; x-=2; width+=2; }
1636- else if(align == 1.0f){ state = ROUND_TOP_LEFT; width+=2; }
1637- break;
1638- case GTK_POS_TOP:
1639- case GTK_POS_RIGHT:
1640- if (align == 0.0f){ state = ROUND_TOP_LEFT; width+=2; }
1641- else if(align == 1.0f){ state = ROUND_TOP_RIGHT; x-=2; width+=2; }
1642- break;
1643- default:
1644- break;
1645- }
1646-
1647+ if (align == 0.0f)
1648+ {
1649+ state = ROUND_TOP_RIGHT; x-=2; width+=2;
1650+ }
1651+ else if(align == 1.0f)
1652+ {
1653+ state = ROUND_TOP_LEFT; width+=2;
1654+ }
1655 }
1656
1657 awn_cairo_rounded_rect (cr, x, y, width, height, bg->corner_radius, state);
1658@@ -224,7 +216,7 @@
1659 cairo_save (cr);
1660
1661 draw_rect (bg, cr, position, 1, 1, width-3, height-1, align, expand);
1662- cairo_clip (cr);
1663+ cairo_clip_preserve (cr);
1664 cairo_set_source (cr, pat);
1665 cairo_paint (cr);
1666
1667@@ -233,10 +225,12 @@
1668 cairo_pattern_destroy (pat);
1669
1670 /* Draw the hi-light */
1671- pat = cairo_pattern_create_linear (0, 0, 0, (height/3.0));
1672+ pat = cairo_pattern_create_linear (0, 0, 0, height);
1673 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_histep_1);
1674- awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_histep_2);
1675- draw_rect (bg, cr, position, 1, 1, width-3, height/3.0, align, expand);
1676+ awn_cairo_pattern_add_color_stop_color (pat, 0.3, bg->g_histep_2);
1677+ double red, green, blue, alpha;
1678+ desktop_agnostic_color_get_cairo_color (bg->g_histep_2, &red, &green, &blue, &alpha);
1679+ cairo_pattern_add_color_stop_rgba (pat, 0.36, red, green, blue, 0.);
1680
1681 cairo_set_source (cr, pat);
1682 cairo_fill (cr);
1683
1684=== modified file 'src/awn-background-floaty.c'
1685--- src/awn-background-floaty.c 2010-05-31 17:41:58 +0000
1686+++ src/awn-background-floaty.c 2010-07-16 11:56:43 +0000
1687@@ -181,7 +181,7 @@
1688 cairo_save (cr);
1689
1690 draw_rect (bg, cr, position, 1, 1, width-3, bg_size-2, TRUE);
1691- cairo_clip (cr);
1692+ cairo_clip_preserve (cr);
1693 cairo_set_source (cr, pat);
1694 cairo_paint (cr);
1695
1696@@ -190,10 +190,12 @@
1697 cairo_pattern_destroy (pat);
1698
1699 /* Draw the hi-light */
1700- pat = cairo_pattern_create_linear (0, 0, 0, (bg_size/3.0));
1701+ pat = cairo_pattern_create_linear (0., 0., 0., height);
1702 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_histep_1);
1703- awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_histep_2);
1704- draw_rect (bg, cr, position, 1, 1, width-3, bg_size/3.0, FALSE);
1705+ awn_cairo_pattern_add_color_stop_color (pat, 0.3, bg->g_histep_2);
1706+ double red, green, blue, alpha;
1707+ desktop_agnostic_color_get_cairo_color (bg->g_histep_2, &red, &green, &blue, &alpha);
1708+ cairo_pattern_add_color_stop_rgba (pat, 0.36, red, green, blue, 0.);
1709
1710 cairo_set_source (cr, pat);
1711 cairo_fill (cr);
1712
1713=== modified file 'src/awn-background-lucido.c'
1714--- src/awn-background-lucido.c 2010-05-31 22:40:18 +0000
1715+++ src/awn-background-lucido.c 2010-07-16 11:56:43 +0000
1716@@ -17,7 +17,7 @@
1717 *
1718 * Author : Alberto Aldegheri <albyrock87+dev@gmail.com>
1719 * Thanks to: Matt <sharkbaitbobby@gmail.com>
1720- * for the code section to analyze expanders
1721+ * for the code section to analyze separators
1722 *
1723 */
1724
1725@@ -39,11 +39,27 @@
1726
1727 struct _AwnBackgroundLucidoPrivate
1728 {
1729- gint expw;
1730- gint expn;
1731+ gint expw;
1732+ gfloat lastx;
1733+ gfloat lastxend;
1734+ GArray *pos;
1735+ gint pos_size;
1736+ guint tid;
1737+ gboolean needs_animation;
1738 };
1739
1740-#define TRANSFORM_RADIUS(x) sqrt(x/50.)*50.
1741+#define TOP_PADDING 2
1742+/* Timeout for animation -> 40 = 25fps*/
1743+#define ANIM_TIMEOUT 40
1744+/* ANIMATION SPEED needs to be greater than 0. - Lower values are faster */
1745+#define ANIMATION_SPEED 16.
1746+
1747+/* draw shape mask for debug */
1748+#define DEBUG_SHAPE_MASK FALSE
1749+
1750+#define TRANSFORM_RADIUS(x) MAX(sqrt(x/60.)*60.,1)
1751+
1752+#define IS_SPECIAL(x) AWN_IS_SEPARATOR(x)
1753
1754 static void awn_background_lucido_draw (AwnBackground *bg,
1755 cairo_t *cr,
1756@@ -61,18 +77,31 @@
1757 guint *padding_bottom,
1758 guint *padding_left,
1759 guint *padding_right);
1760-
1761+
1762 static gboolean
1763 awn_background_lucido_get_needs_redraw (AwnBackground *bg,
1764 GtkPositionType position,
1765 GdkRectangle *area);
1766-
1767+
1768+
1769+static void
1770+_set_special_widget_width_and_transparent (AwnBackground *bg,
1771+ gint width,
1772+ gboolean transp,
1773+ gboolean dispose);
1774+
1775 static void
1776 awn_background_lucido_corner_radius_changed (AwnBackground *bg)
1777 {
1778 gboolean expand = FALSE;
1779 g_object_get (bg->panel, "expand", &expand, NULL);
1780-
1781+
1782+ _set_special_widget_width_and_transparent (
1783+ bg,
1784+ TRANSFORM_RADIUS (bg->corner_radius),
1785+ TRUE,
1786+ FALSE);
1787+
1788 if (!expand)
1789 {
1790 awn_background_emit_padding_changed (bg);
1791@@ -92,19 +121,28 @@
1792 }
1793
1794 static void
1795+awn_background_lucido_applets_refreshed (AwnBackground *bg)
1796+{
1797+ _set_special_widget_width_and_transparent
1798+ (bg, TRANSFORM_RADIUS (bg->corner_radius), TRUE, FALSE);
1799+ awn_background_emit_changed (bg);
1800+}
1801+
1802+static void
1803 awn_background_lucido_constructed (GObject *object)
1804 {
1805 G_OBJECT_CLASS (awn_background_lucido_parent_class)->constructed (object);
1806-
1807+
1808 AwnBackground *bg = AWN_BACKGROUND (object);
1809 gpointer monitor = NULL;
1810-
1811+
1812 g_signal_connect_swapped (bg, "notify::corner-radius",
1813- G_CALLBACK (awn_background_lucido_corner_radius_changed),
1814+ G_CALLBACK (
1815+ awn_background_lucido_corner_radius_changed),
1816 object);
1817
1818 g_return_if_fail (bg->panel);
1819-
1820+
1821 g_signal_connect_swapped (bg->panel, "notify::expand",
1822 G_CALLBACK (awn_background_lucido_expand_changed),
1823 object);
1824@@ -116,11 +154,24 @@
1825 g_signal_connect_swapped (monitor, "notify::monitor-align",
1826 G_CALLBACK (awn_background_lucido_align_changed),
1827 object);
1828+
1829+ AwnAppletManager *manager = NULL;
1830+ g_object_get (bg->panel, "applet-manager", &manager, NULL);
1831+ g_return_if_fail (manager);
1832+ g_signal_connect_swapped (manager, "applets-refreshed",
1833+ G_CALLBACK (awn_background_lucido_applets_refreshed), bg);
1834 }
1835
1836 static void
1837 awn_background_lucido_dispose (GObject *object)
1838 {
1839+ _set_special_widget_width_and_transparent
1840+ (AWN_BACKGROUND (object), 10, FALSE, TRUE);
1841+
1842+ AwnBackgroundLucido *lbg = AWN_BACKGROUND_LUCIDO (object);
1843+ AwnBackgroundLucidoPrivate *priv = AWN_BACKGROUND_LUCIDO_GET_PRIVATE (lbg);
1844+ g_array_free (priv->pos, TRUE);
1845+
1846 gpointer monitor = NULL;
1847 if (AWN_BACKGROUND (object)->panel)
1848 {
1849@@ -139,6 +190,15 @@
1850 g_signal_handlers_disconnect_by_func (AWN_BACKGROUND (object),
1851 G_CALLBACK (awn_background_lucido_corner_radius_changed), object);
1852
1853+ AwnAppletManager *manager = NULL;
1854+ g_object_get (AWN_BACKGROUND (object)->panel,
1855+ "applet-manager", &manager, NULL);
1856+ if (manager)
1857+ {
1858+ g_signal_handlers_disconnect_by_func (manager,
1859+ G_CALLBACK (awn_background_lucido_applets_refreshed), object);
1860+ }
1861+
1862 G_OBJECT_CLASS (awn_background_lucido_parent_class)->dispose (object);
1863 }
1864
1865@@ -151,19 +211,30 @@
1866 obj_class->constructed = awn_background_lucido_constructed;
1867 obj_class->dispose = awn_background_lucido_dispose;
1868
1869+#if DEBUG_SHAPE_MASK
1870+ bg_class->draw = awn_background_lucido_get_shape_mask;
1871+#else
1872 bg_class->draw = awn_background_lucido_draw;
1873+#endif
1874 bg_class->padding_request = awn_background_lucido_padding_request;
1875 bg_class->get_shape_mask = awn_background_lucido_get_shape_mask;
1876 bg_class->get_input_shape_mask = awn_background_lucido_get_shape_mask;
1877 bg_class->get_needs_redraw = awn_background_lucido_get_needs_redraw;
1878-
1879+
1880 g_type_class_add_private (obj_class, sizeof (AwnBackgroundLucidoPrivate));
1881 }
1882
1883 static void
1884 awn_background_lucido_init (AwnBackgroundLucido *bg)
1885 {
1886-
1887+ AwnBackgroundLucidoPrivate *priv = AWN_BACKGROUND_LUCIDO_GET_PRIVATE (bg);
1888+ priv->lastx = 0;
1889+ priv->lastxend = INT_MAX;
1890+ priv->needs_animation = FALSE;
1891+ priv->tid = 0;
1892+ priv->pos = g_array_new (FALSE, TRUE, sizeof (gfloat));
1893+ priv->pos_size = 0;
1894+ awn_background_lucido_applets_refreshed (AWN_BACKGROUND (bg));
1895 }
1896
1897 AwnBackground *
1898@@ -179,6 +250,66 @@
1899 return bg;
1900 }
1901
1902+/* ANIMATION FUNCTIONS */
1903+
1904+/*
1905+ * _add_n_positions:
1906+ * adds n positions to position array that contains
1907+ * last positions of special applets
1908+ * Usually called when a special applet is added
1909+ */
1910+static void
1911+_add_n_positions (AwnBackgroundLucidoPrivate *priv, gint n, gfloat startpos)
1912+{
1913+ while (n-- > 0)
1914+ {
1915+ g_array_append_val (priv->pos, startpos);
1916+ ++priv->pos_size;
1917+ }
1918+}
1919+
1920+/*
1921+ * awn_background_lucido_redraw:
1922+ * @lbg: the lucido background ojbect
1923+ *
1924+ * Queue redraw of the panel and repeat itself if needed
1925+ */
1926+static gboolean
1927+awn_background_lucido_redraw (AwnBackgroundLucido *lbg)
1928+{
1929+ g_return_val_if_fail (AWN_IS_BACKGROUND_LUCIDO (lbg), FALSE);
1930+
1931+ AwnBackgroundLucidoPrivate *priv;
1932+ AwnBackground *bg = AWN_BACKGROUND (lbg);
1933+ priv = AWN_BACKGROUND_LUCIDO_GET_PRIVATE (lbg);
1934+
1935+ if (priv->needs_animation)
1936+ {
1937+ awn_background_invalidate (bg);
1938+ gtk_widget_queue_draw (GTK_WIDGET (bg->panel));
1939+ return TRUE;
1940+ }
1941+ else
1942+ {
1943+ priv->tid = 0;
1944+ return FALSE;
1945+ }
1946+}
1947+
1948+/*
1949+ * _restart_timeout:
1950+ * restarts animation's timer if needed
1951+ */
1952+static void _restart_timeout (AwnBackground *bg,
1953+ AwnBackgroundLucidoPrivate *priv)
1954+{
1955+ priv->needs_animation = TRUE;
1956+ if (!priv->tid)
1957+ {
1958+ priv->tid = g_timeout_add (ANIM_TIMEOUT, (GSourceFunc)awn_background_lucido_redraw, bg);
1959+ }
1960+}
1961+
1962 /*
1963 * Drawing functions
1964 */
1965@@ -202,6 +333,10 @@
1966 *ys = yf;
1967 }
1968
1969+/*
1970+ * Gets applet manager's childs.
1971+ * Sets docklet mode = TRUE if panel is in docklet mode
1972+ */
1973 static GList*
1974 _get_applet_widgets (AwnBackground* bg)
1975 {
1976@@ -211,6 +346,58 @@
1977 return gtk_container_get_children (GTK_CONTAINER (manager));
1978 }
1979
1980+/*
1981+ * Get applet manager size
1982+ * Get offset-left stored in "x" variable passed to method
1983+ *
1984+ */
1985+static gint
1986+_get_applet_manager_size (AwnBackground* bg, GtkPositionType position, float *x)
1987+{
1988+ AwnAppletManager *manager = NULL;
1989+ g_object_get (bg->panel, "applet-manager", &manager, NULL);
1990+ GtkWidget *widget = GTK_WIDGET (manager);
1991+ gint wx, wy;
1992+ gtk_widget_translate_coordinates(widget, gtk_widget_get_toplevel(widget),
1993+ 0, 0, &wx, &wy);
1994+ switch (position)
1995+ {
1996+ case GTK_POS_BOTTOM:
1997+ case GTK_POS_TOP:
1998+ if (x)
1999+ *x = wx;
2000+ return widget->allocation.width;
2001+ break;
2002+ default:
2003+ if (x)
2004+ *x = wy;
2005+ return widget->allocation.height;
2006+ break;
2007+ }
2008+}
2009+
2010+/*
2011+ * coord_get_near:
2012+ * @from: the current position
2013+ * @to: the target position
2014+ * @return: a position between "from" and "to", if distance = 1, returns "to"
2015+ */
2016+static float
2017+coord_get_near (const gfloat from, const gfloat to)
2018+{
2019+ float inc = abs (to - from);
2020+ float step = inc / ANIMATION_SPEED + 1.; // makes the resize shiny
2021+ inc = MIN (inc, step);
2022+ if (to > from)
2023+ {
2024+ return lroundf (from + inc);
2025+ }
2026+ else
2027+ {
2028+ return lroundf (from - inc);
2029+ }
2030+}
2031+
2032 /**
2033 * _create_path_lucido:
2034 * @bg: The background pointer
2035@@ -219,21 +406,23 @@
2036 * @y: The top left coordinate of the "bar rect" - default = 0
2037 * @w: The width of the bar
2038 * @h: The height of the bar
2039- * @stripe: The width of the stripe (0.0-1.0). Zero for auto-stripe.
2040 * @d: The width of each curve in the path
2041 * @dc: The width of the external curves in non-expanded&auto mode
2042- * @symmetry: The symmetry of the stripe when @stripe > 0
2043 * @internal: If Zero, creates the path for the stripe
2044 * @expanded: If Zero, the bar is not expanded
2045+ * @align: the monitor align
2046+ * @update_positions: if FALSE it uses positions stored in priv->pos,
2047+ * otherwise updates the position stored in priv->pos
2048 *
2049 * This function creates paths on which the bar will be drawn.
2050- * In atuo-stripe, it searchs for expanders applet, each expander
2051+ * In atuo-stripe, it searchs for separators applet, each separator
2052 * equals to one curve.
2053- * If the first widget is an expander, start from bottom-left,
2054+ * If the first widget is an separator, start from bottom-left,
2055 * otherwise start from top-left
2056+ *
2057+ * returns the calculated y coordinate to draw the gradient
2058 */
2059-
2060-static void
2061+static gfloat
2062 _create_path_lucido ( AwnBackground* bg,
2063 GtkPositionType position,
2064 cairo_t* cr,
2065@@ -241,371 +430,360 @@
2066 gfloat y,
2067 gfloat w,
2068 gfloat h,
2069- gfloat stripe,
2070 gfloat d,
2071 gfloat dc,
2072- gfloat symmetry,
2073 gboolean internal,
2074 gboolean expanded,
2075- gfloat align)
2076+ gfloat align,
2077+ gboolean update_positions)
2078 {
2079- cairo_new_path (cr);
2080+ AwnBackgroundLucido *lbg = AWN_BACKGROUND_LUCIDO (bg);
2081+ AwnBackgroundLucidoPrivate *priv = AWN_BACKGROUND_LUCIDO_GET_PRIVATE (lbg);
2082+ gfloat applet_manager_x = 0.;
2083+ _get_applet_manager_size (bg, position, &applet_manager_x);
2084+ gboolean needs_animation = FALSE;
2085
2086+ /****************************************************************************/
2087+ /******************** UPDATE STARTING POINT *************************/
2088+ /****************************************************************************/
2089+ /* x variable stores the starting x point for draw the panel */
2090+ if (update_positions)
2091+ {
2092+ if (!expanded)
2093+ {
2094+ x += applet_manager_x - dc;
2095+ }
2096+ x = lroundf (x);
2097+ if (x != priv->lastx)
2098+ {
2099+ needs_animation = TRUE;
2100+ }
2101+ x = coord_get_near (priv->lastx, x);
2102+ priv->lastx = x;
2103+ }
2104+ else
2105+ {
2106+ x = priv->lastx;
2107+ }
2108+ /****************************************************************************/
2109+ /******************** INIT GENERAL COORDINATES *************************/
2110+ /****************************************************************************/
2111+ gfloat sym = bg->curves_symmetry;
2112+ gfloat curx = x;
2113 gfloat lx = x;
2114 gfloat ly = y;
2115 gfloat y3 = y + h;
2116- gfloat y2 = y3 - 5;
2117-
2118- if (stripe > 0)
2119- {
2120- if (expanded)
2121- {
2122- stripe = (w * stripe); /* now stripe = non-stripe */
2123+ gfloat y2 = y3 - 8. * bg->thickness;
2124+ gfloat rdc = dc;
2125+
2126+ /****************************************************************************/
2127+ /******************** CURVES SYMMETRY HANDLER *************************/
2128+ /****************************************************************************/
2129+ sym = fabs (sym - 0.5);
2130+ gfloat exty = y + h * sym * 2.;
2131+ if (exty > y2)
2132+ {
2133+ y2 = exty;
2134+ }
2135+ if (internal && bg->curves_symmetry > 0.5)
2136+ {
2137+ y = exty;
2138+ }
2139+ else if (!internal && bg->curves_symmetry < 0.5)
2140+ {
2141+ y = exty;
2142+ }
2143+ /****************************************************************************/
2144+ /******************** OBTAIN LIST OF APPLETS *************************/
2145+ /****************************************************************************/
2146+ gboolean docklet_mode = awn_panel_get_docklet_mode (bg->panel);
2147+ GList *widgets = _get_applet_widgets (bg);
2148+ GList *i = widgets;
2149+ GtkWidget *widget = NULL;
2150+ /* j = index of last special widget found */
2151+ gint j = -1;
2152+ /* Check for docklet mode - In docklet mode first widget is the docklet */
2153+ if (i && docklet_mode)
2154+ {
2155+ i = i->next;
2156+ }
2157+ /* Check if the first widget is special */
2158+ gboolean first_widget_is_special = FALSE;
2159+ if (i && IS_SPECIAL (i->data))
2160+ {
2161+ first_widget_is_special = TRUE;
2162+ }
2163+ /****************************************************************************/
2164+ /******************** SETUP EXTERNAL CORNERS *************************/
2165+ /****************************************************************************/
2166+ if (expanded)
2167+ {
2168+ dc = rdc = 0.;
2169+ }
2170+ else if (align == 0.)
2171+ {
2172+ dc = 0.;
2173+ }
2174+ else if (align == 1.)
2175+ {
2176+ rdc = 0.;
2177+ }
2178+ /****************************************************************************/
2179+ /******************** START THE PATH *************************/
2180+ /****************************************************************************/
2181+ if (internal)
2182+ {
2183+ cairo_new_path (cr);
2184+ lx = lx + dc;
2185+ ly = y;
2186+ cairo_move_to (cr, lx, ly);
2187+ _line_from_to (cr, &lx, &ly, curx, y3);
2188+ }
2189+ else
2190+ {
2191+ cairo_new_path (cr);
2192+ lx = curx;
2193+ ly = y3;
2194+ cairo_move_to (cr, lx, ly);
2195+ }
2196+ /* check for special in first position */
2197+ if (first_widget_is_special)
2198+ {
2199+ i = i->next;
2200+ _line_from_to (cr, &lx, &ly, lx + dc, y2);
2201+ }
2202+ else if (!internal)
2203+ {
2204+ _line_from_to (cr, &lx, &ly, lx + dc, y);
2205+ }
2206+ else
2207+ {
2208+ _line_from_to (cr, &lx, &ly, lx + dc, exty);
2209+ }
2210+ /****************************************************************************/
2211+ /******************** UPDATE WIDTH FOR LAST X *************************/
2212+ /****************************************************************************/
2213+ /* w stores the "right corner", lastxend equals to last w */
2214+ if (update_positions)
2215+ {
2216+ w = lroundf (w);
2217+ if (w != priv->lastxend)
2218+ {
2219+ needs_animation = TRUE;
2220+ gfloat neww = coord_get_near (priv->lastxend, w);
2221+ w = MIN (w, neww);
2222+ priv->lastxend = w;
2223+ }
2224+ }
2225+ else
2226+ {
2227+ w = priv->lastxend;
2228+ }
2229+ /****************************************************************************/
2230+ /******************** LOOP ON APPLETS *************************/
2231+ /****************************************************************************/
2232+ gfloat saved_y = y;
2233+ if (bg->curves_symmetry < 0.5)
2234+ {
2235+ y = exty;
2236+ }
2237+ curx = lx;
2238+ gint wx, wy;
2239+ if (!docklet_mode)
2240+ {
2241+ for (; i; i = i->next)
2242+ {
2243+ widget = GTK_WIDGET (i->data);
2244+ if (!IS_SPECIAL (widget))
2245+ {
2246+ /* if not special continue */
2247+ continue;
2248+ }
2249+ /* special found, obtain coordinates */
2250+ ++j;
2251+ gtk_widget_translate_coordinates(widget, gtk_widget_get_toplevel(widget),
2252+ 0, 0, &wx, &wy);
2253+ switch (position)
2254+ {
2255+ case GTK_POS_BOTTOM:
2256+ case GTK_POS_TOP:
2257+ curx = wx;
2258+ break;
2259+ default:
2260+ curx = wy;
2261+ break;
2262+ }
2263+ if (priv->pos_size <= j)
2264+ {
2265+ /* New special applet found, resize the array */
2266+ _add_n_positions (priv, 1, lx);
2267+ }
2268+ /************************************************************************/
2269+ /***************** UPDATE SINGLE CURVE POSITION *********************/
2270+ /************************************************************************/
2271+ if (update_positions)
2272+ {
2273+ curx = lroundf (curx);
2274+ if (curx != g_array_index (priv->pos, gfloat, j))
2275+ {
2276+ needs_animation = TRUE;
2277+ }
2278+ curx = coord_get_near (g_array_index (priv->pos, gfloat, j), curx);
2279+ if (curx > (w - rdc - d))
2280+ {
2281+ curx = w - rdc - d;
2282+ }
2283+ g_array_index (priv->pos, gfloat, j) = curx;
2284+ }
2285+ else
2286+ {
2287+ curx = g_array_index (priv->pos, gfloat, j);
2288+ }
2289+ if (curx < 0)
2290+ {
2291+ continue;
2292+ }
2293+ _line_from_to (cr, &lx, &ly, curx, ly);
2294+ if (ly == y2)
2295+ {
2296+ _line_from_to (cr, &lx, &ly, lx + d, y);
2297+ }
2298+ else
2299+ {
2300+ _line_from_to (cr, &lx, &ly, lx + d, y2);
2301+ }
2302+ }
2303+ }
2304+ y = saved_y;
2305+ g_list_free (widgets);
2306+ /****************************************************************************/
2307+ /************************ CLOSE THE PATH ******************************/
2308+ /****************************************************************************/
2309+ if (expanded)
2310+ {
2311+ /* make sure that cairo close path in the right way */
2312+ _line_from_to (cr, &lx, &ly, w, ly);
2313+ if (internal)
2314+ {
2315+ _line_from_to (cr, &lx, &ly, lx, y);
2316+ }
2317+ else
2318+ {
2319+ _line_from_to (cr, &lx, &ly, lx, y3);
2320+ }
2321+ }
2322+ else
2323+ {
2324+ if (align == 1.)
2325+ {
2326 if (internal)
2327 {
2328- /* Manual-Stripe & Expanded & Internal */
2329- lx = stripe * symmetry;
2330- cairo_move_to (cr, lx, ly);
2331- _line_from_to (cr, &lx, &ly, lx+d, y2);
2332- _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - d, y2);
2333- _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry), y);
2334- cairo_close_path (cr);
2335- }
2336- else
2337- {
2338- /* Manual-Stripe & Expanded & External */
2339- ly = y3;
2340- cairo_move_to (cr, lx, ly);
2341+ _line_from_to (cr, &lx, &ly, w, ly);
2342 _line_from_to (cr, &lx, &ly, lx, y);
2343- _line_from_to (cr, &lx, &ly, stripe * symmetry, y);
2344- _line_from_to (cr, &lx, &ly, stripe * symmetry + d, y2);
2345- _line_from_to (cr, &lx, &ly, w - stripe * (1. - symmetry) - d, y2);
2346- _line_from_to (cr, &lx, &ly, w - stripe * (1. - symmetry), y);
2347- _line_from_to (cr, &lx, &ly, w, y);
2348- _line_from_to (cr, &lx, &ly, w, y3);
2349- cairo_close_path (cr);
2350- }
2351- }
2352- else
2353- {
2354- if (stripe == 1.)
2355- {
2356- _create_path_lucido (bg, position, cr, x, y, w, h, 0.,
2357- d, dc, 0., internal, expanded, align);
2358- return;
2359- }
2360- stripe = ((w - dc * 2) * stripe); /* now stripe = non-stripe */
2361- if (internal)
2362- {
2363- /* Manual-Stripe & Not-Expanded & Internal */
2364- lx = stripe * symmetry + dc;
2365- cairo_move_to (cr, lx, ly);
2366- _line_from_to (cr, &lx, &ly, lx + d, y2);
2367- _line_from_to (cr, &lx, &ly, w - stripe * (1.- symmetry) - dc - d, y2);
2368- _line_from_to (cr, &lx, &ly, w - stripe * (1.- symmetry) - dc, y);
2369- cairo_close_path (cr);
2370- }
2371- else
2372- {
2373- /* Manual-Stripe & Not-Expanded & External */
2374- ly = y3;
2375- cairo_move_to (cr, lx, ly);
2376- _line_from_to (cr, &lx, &ly, lx+dc, y);
2377- _line_from_to (cr, &lx, &ly, stripe * symmetry + dc, y);
2378- _line_from_to (cr, &lx, &ly, stripe * symmetry + d + dc, y2);
2379- _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - dc - d, y2);
2380- _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - dc, y);
2381- _line_from_to (cr, &lx, &ly, w-dc, y);
2382- _line_from_to (cr, &lx, &ly, w, y3);
2383- cairo_close_path(cr);
2384- }
2385- }
2386- }
2387- else
2388- {
2389- gint exps_found = 0;
2390- gfloat curx = x;
2391-
2392- if (expanded)
2393- {
2394- if (internal)
2395- {
2396- /* Auto-Stripe & Expanded & Internal */
2397- GList *widgets = _get_applet_widgets (bg);
2398- GList *i = widgets;
2399- GtkWidget *widget = NULL;
2400-
2401- /* analyze first widget*/
2402- if (i)
2403- {
2404- widget = GTK_WIDGET (i->data);
2405-
2406- /* if first widget is an expander or align==0 || 1*/
2407- if ( (widget && GTK_IS_IMAGE (widget) && !AWN_IS_SEPARATOR (widget) ) ||
2408- ( align == 0. || align == 1. ) )
2409- {
2410- /* start from bottom */
2411- lx = curx;
2412- ly = y;
2413- cairo_move_to (cr, lx, ly);
2414- _line_from_to (cr, &lx, &ly, lx, y2);
2415- ++exps_found;
2416- if (align != 0. && align != 1.)
2417- i = i->next;
2418- }
2419- }
2420- /* else start from top */
2421-
2422- for (; i; i = i->next)
2423- {
2424- widget = GTK_WIDGET (i->data);
2425-
2426- if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
2427- {
2428- /* if not expander continue */
2429- continue;
2430- }
2431- /* expander found */
2432- switch (position)
2433- {
2434- case GTK_POS_BOTTOM:
2435- case GTK_POS_TOP:
2436- curx = widget->allocation.x;
2437- if (exps_found % 2 != 0)
2438- {
2439- curx += widget->allocation.width;
2440- }
2441- break;
2442- default:
2443- curx = widget->allocation.y;
2444- if ( exps_found % 2 != 0)
2445- {
2446- curx += widget->allocation.height;
2447- }
2448- break;
2449- }
2450- if (curx < 0)
2451- {
2452- continue;
2453- }
2454-
2455- if (exps_found == 0)
2456- {
2457- /* this is the first expander */
2458- lx = curx;
2459- cairo_move_to (cr, lx, ly);
2460- _line_from_to (cr, &lx, &ly, curx + d, y2);
2461- }
2462- else
2463- {
2464- if (exps_found % 2 != 0)
2465- {
2466- /* odd expander - curve at the end of expander */
2467- _line_from_to (cr, &lx, &ly, curx - d, y2);
2468- if (i->next == NULL)
2469- _line_from_to (cr, &lx, &ly, curx, y2);
2470- _line_from_to (cr, &lx, &ly, curx, y);
2471- }
2472- else
2473- {
2474- /* even expander - curve at the start of expander */
2475- _line_from_to (cr, &lx, &ly, curx, y);
2476- _line_from_to (cr, &lx, &ly, curx + d, y2);
2477- /* else the last widget is an expander */
2478- }
2479- }
2480-
2481- ++exps_found;
2482- }
2483- g_list_free (widgets);
2484-
2485- _line_from_to (cr, &lx, &ly, w, ly);
2486-
2487- if (exps_found % 2 != 0)
2488- {
2489- _line_from_to (cr, &lx, &ly, lx, y);
2490- }
2491-
2492- cairo_close_path (cr);
2493- }
2494- else
2495- {
2496- /* Auto-Stripe & Expanded & External */
2497-
2498- GList *widgets = _get_applet_widgets (bg);
2499- GList *i = widgets;
2500- GtkWidget *widget = NULL;
2501-
2502- /* analyze first widget*/
2503- if (i)
2504- {
2505- widget = GTK_WIDGET (i->data);
2506-
2507- ly = y3;
2508- cairo_move_to (cr, lx, ly);
2509-
2510- /* if first widget is an expander or align==0 || 1*/
2511- if ( (widget && GTK_IS_IMAGE (widget) && !AWN_IS_SEPARATOR (widget) ) ||
2512- ( align == 0. || align == 1. ) )
2513- {
2514- /* start from bottom */
2515- _line_from_to (cr, &lx, &ly, lx, y2);
2516- ++exps_found;
2517- if (align != 0. && align != 1.)
2518- i = i->next;
2519- }
2520- else
2521- {
2522- /* start from top */
2523- _line_from_to (cr, &lx, &ly, lx, y);
2524- }
2525- }
2526-
2527- for (; i; i = i->next)
2528- {
2529- widget = GTK_WIDGET (i->data);
2530-
2531- if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
2532- {
2533- /* if not expander continue */
2534- continue;
2535- }
2536- /* expander found */
2537- switch (position)
2538- {
2539- case GTK_POS_BOTTOM:
2540- case GTK_POS_TOP:
2541- curx = widget->allocation.x;
2542- if (exps_found % 2 != 0)
2543- {
2544- curx += widget->allocation.width;
2545- }
2546- break;
2547- default:
2548- curx = widget->allocation.y;
2549- if (exps_found % 2 != 0)
2550- {
2551- curx += widget->allocation.height;
2552- }
2553- break;
2554- }
2555- if (curx < 0)
2556- {
2557- continue;
2558- }
2559-
2560- if (exps_found % 2 != 0)
2561- {
2562- _line_from_to (cr, &lx, &ly, curx - d, y2);
2563- if (i->next != NULL)
2564- _line_from_to (cr, &lx, &ly, curx, y);
2565- }
2566- else
2567- {
2568- _line_from_to (cr, &lx, &ly, curx, y);
2569- _line_from_to (cr, &lx, &ly, curx + d, y2);
2570- }
2571- ++exps_found;
2572- }
2573- g_list_free (widgets);
2574-
2575+ }
2576+ else
2577+ {
2578 _line_from_to (cr, &lx, &ly, w, ly);
2579 _line_from_to (cr, &lx, &ly, lx, y3);
2580-
2581- cairo_close_path (cr);
2582 }
2583 }
2584 else
2585 {
2586 if (internal)
2587 {
2588- /* Auto-Stripe & Not-Expanded & Internal */
2589- /* no-path */
2590+ _line_from_to (cr, &lx, &ly, w - rdc, y2);
2591+ _line_from_to (cr, &lx, &ly, w, y3);
2592+ _line_from_to (cr, &lx, &ly, w - rdc, y);
2593 }
2594 else
2595 {
2596- /* Auto-Stripe & Not-Expanded & External */
2597- ly = y3;
2598- cairo_move_to (cr, lx, ly);
2599-
2600- if (align == 0.)
2601- _line_from_to (cr, &lx, &ly, lx , y);
2602- else
2603- _line_from_to (cr, &lx, &ly, lx + dc, y);
2604-
2605- if (align == 1.)
2606- _line_from_to (cr, &lx, &ly, w, y);
2607- else
2608- _line_from_to (cr, &lx, &ly, w - dc, y);
2609-
2610+ _line_from_to (cr, &lx, &ly, w - rdc, ly);
2611 _line_from_to (cr, &lx, &ly, w, y3);
2612- cairo_close_path (cr);
2613 }
2614 }
2615 }
2616+ cairo_close_path (cr);
2617+ /****************************************************************************/
2618+ /******************** RESTART ANIMATION IF NEEDED **********************/
2619+ /****************************************************************************/
2620+ if (update_positions)
2621+ {
2622+ if (needs_animation)
2623+ {
2624+ _restart_timeout (bg, priv);
2625+ }
2626+ else
2627+ {
2628+ priv->needs_animation = FALSE;
2629+ }
2630+ }
2631+ return y;
2632 }
2633
2634 static void
2635 draw_top_bottom_background (AwnBackground* bg,
2636 GtkPositionType position,
2637 cairo_t* cr,
2638- gint width,
2639- gint height)
2640+ gfloat width,
2641+ gfloat height)
2642 {
2643 cairo_pattern_t *pat = NULL;
2644- cairo_pattern_t *pat_hi = NULL;
2645-
2646+
2647 /* Basic set-up */
2648 cairo_set_line_width (cr, 1.0);
2649 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
2650
2651 gboolean expand = FALSE;
2652 g_object_get (bg->panel, "expand", &expand, NULL);
2653-
2654+
2655 gfloat align = awn_background_get_panel_alignment (AWN_BACKGROUND (bg));
2656-
2657+
2658 /* Make sure the bar gets drawn on the 0.5 pixels (for sharp edges) */
2659- switch (position)
2660- {
2661- case GTK_POS_TOP:
2662- case GTK_POS_BOTTOM:
2663- cairo_translate (cr, 0., 0.5);
2664- break;
2665- default:
2666- cairo_translate (cr, 0.5, 0.);
2667- break;
2668- }
2669-
2670+ if (!expand)
2671+ {
2672+ cairo_translate (cr, 0.5, 0.5);
2673+ width -= 0.5;
2674+ }
2675+ else
2676+ {
2677+ cairo_translate (cr, -0.5, 0.5);
2678+ width += 1.;
2679+ }
2680+
2681 if (gtk_widget_is_composited (GTK_WIDGET (bg->panel)) == FALSE)
2682 {
2683 goto paint_lines;
2684 }
2685
2686+ gfloat x = 0.,
2687+ y = 0.;
2688+ gfloat y_pat;
2689+
2690 /* create internal path */
2691- _create_path_lucido (bg, position, cr, -1.0, 0., width, height,
2692- bg->stripe_width, TRANSFORM_RADIUS (bg->corner_radius),
2693- TRANSFORM_RADIUS (bg->corner_radius), bg->curves_symmetry,
2694- 1, expand, align);
2695+ y_pat = _create_path_lucido (bg, position, cr, x, y, width, height,
2696+ TRANSFORM_RADIUS (bg->corner_radius),
2697+ TRANSFORM_RADIUS (bg->corner_radius),
2698+ TRUE, expand, align, TRUE);
2699
2700 /* Draw internal pattern if needed */
2701- if ((expand || bg->stripe_width != 0.) && bg->enable_pattern && bg->pattern)
2702+ if (bg->enable_pattern && bg->pattern)
2703 {
2704 /* Prepare pattern */
2705- pat_hi = cairo_pattern_create_for_surface (bg->pattern);
2706- cairo_pattern_set_extend (pat_hi, CAIRO_EXTEND_REPEAT);
2707+ pat = cairo_pattern_create_for_surface (bg->pattern);
2708+ cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT);
2709 /* Draw */
2710 cairo_save (cr);
2711 cairo_clip_preserve (cr);
2712- cairo_set_source (cr, pat_hi);
2713+ cairo_set_source (cr, pat);
2714 cairo_paint (cr);
2715 cairo_restore (cr);
2716- cairo_pattern_destroy (pat_hi);
2717+ cairo_pattern_destroy (pat);
2718 }
2719
2720 /* Prepare the internal background */
2721- pat = cairo_pattern_create_linear (0, 0, 0, height);
2722- awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->border_color);
2723- awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->hilight_color);
2724+ pat = cairo_pattern_create_linear (x, y_pat, 0., height);
2725+ awn_cairo_pattern_add_color_stop_color (pat, 0., bg->g_histep_1);
2726+ awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_histep_2);
2727
2728 /* Draw the internal background gradient */
2729 cairo_save (cr);
2730@@ -613,37 +791,23 @@
2731 cairo_set_source (cr, pat);
2732 cairo_paint (cr);
2733 cairo_restore (cr);
2734+ awn_cairo_set_source_color (cr, bg->border_color);
2735+ cairo_stroke (cr);
2736+
2737+ /* create external path */
2738+ y_pat = _create_path_lucido (bg, position, cr, x, y, width, height,
2739+ TRANSFORM_RADIUS (bg->corner_radius),
2740+ TRANSFORM_RADIUS (bg->corner_radius),
2741+ FALSE, expand, align, FALSE);
2742
2743 /* Prepare external background gradient*/
2744- if (expand || bg->stripe_width != 0.)
2745- {
2746- cairo_pattern_destroy (pat);
2747- pat = cairo_pattern_create_linear (0, 0, 0, height);
2748- awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_step_1);
2749- awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);
2750- }
2751-
2752- /* create external path */
2753- _create_path_lucido (bg, position, cr, -1.0, 0., width, height,
2754- bg->stripe_width, TRANSFORM_RADIUS (bg->corner_radius),
2755- TRANSFORM_RADIUS (bg->corner_radius), bg->curves_symmetry,
2756- 0, expand, align);
2757+ cairo_pattern_destroy (pat);
2758+ pat = cairo_pattern_create_linear (x, y_pat, 0., height);
2759+ awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_step_1);
2760+ awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);
2761
2762- /* Draw external pattern if needed */
2763- if (!expand && bg->stripe_width == 0. && bg->enable_pattern && bg->pattern)
2764- {
2765- /* Prepare pattern */
2766- pat_hi = cairo_pattern_create_for_surface (bg->pattern);
2767- cairo_pattern_set_extend (pat_hi, CAIRO_EXTEND_REPEAT);
2768- /* Draw */
2769- cairo_save (cr);
2770- cairo_clip_preserve (cr);
2771- cairo_set_source (cr, pat_hi);
2772- cairo_paint (cr);
2773- cairo_restore (cr);
2774- cairo_pattern_destroy (pat_hi);
2775- }
2776-
2777+ /* Clean below external background */
2778+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
2779 /* Draw the external background */
2780 cairo_save (cr);
2781 cairo_clip_preserve (cr);
2782@@ -651,21 +815,12 @@
2783 cairo_paint (cr);
2784 cairo_restore (cr);
2785 cairo_pattern_destroy (pat);
2786-
2787- /* Draw the hi-light */
2788- pat_hi = cairo_pattern_create_linear (0, 0, 0, (height / 3.0));
2789- awn_cairo_pattern_add_color_stop_color (pat_hi, 0.0, bg->g_histep_1);
2790- awn_cairo_pattern_add_color_stop_color (pat_hi, 1.0, bg->g_histep_2);
2791-
2792- if (expand)
2793- {
2794- cairo_new_path (cr);
2795- cairo_rectangle (cr, 0, 0, width, (height / 3.0));
2796- }
2797-
2798- cairo_set_source (cr, pat_hi);
2799- cairo_fill (cr);
2800- cairo_pattern_destroy (pat_hi);
2801+ /* Restore operator */
2802+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
2803+
2804+ /* Draw border */
2805+ awn_cairo_set_source_color (cr, bg->hilight_color);
2806+ cairo_stroke (cr);
2807
2808 return;
2809 /* if not composited */
2810@@ -675,26 +830,26 @@
2811 {
2812 /* Internal border */
2813 awn_cairo_set_source_color (cr, bg->hilight_color);
2814- cairo_rectangle (cr, 1, 1, width - 3, height + 3);
2815+ cairo_rectangle (cr, 1., 1., width - 3., height + 3.);
2816 cairo_stroke (cr);
2817
2818 /* External border */
2819 awn_cairo_set_source_color (cr, bg->border_color);
2820- cairo_rectangle (cr, 1, 1, width - 1, height + 3);
2821+ cairo_rectangle (cr, 1., 1., width - 1., height + 3.);
2822 }
2823 else
2824 {
2825 awn_cairo_set_source_color (cr, bg->border_color);
2826 _create_path_lucido (bg, position, cr, 0., 0., width, height,
2827- bg->stripe_width, TRANSFORM_RADIUS (bg->corner_radius),
2828- TRANSFORM_RADIUS (bg->corner_radius), bg->curves_symmetry,
2829- 0, expand, align);
2830+ TRANSFORM_RADIUS (bg->corner_radius),
2831+ TRANSFORM_RADIUS (bg->corner_radius),
2832+ FALSE, expand, align, TRUE);
2833 cairo_stroke (cr);
2834 awn_cairo_set_source_color (cr, bg->hilight_color);
2835 _create_path_lucido (bg, position, cr, 1., 1., width-1., height-1.,
2836- bg->stripe_width, TRANSFORM_RADIUS (bg->corner_radius),
2837- TRANSFORM_RADIUS (bg->corner_radius), bg->curves_symmetry,
2838- 0, expand, align);
2839+ TRANSFORM_RADIUS (bg->corner_radius),
2840+ TRANSFORM_RADIUS (bg->corner_radius),
2841+ FALSE, expand, align, FALSE);
2842 }
2843 cairo_stroke (cr);
2844 }
2845@@ -708,7 +863,6 @@
2846 guint *padding_left,
2847 guint *padding_right)
2848 {
2849- #define TOP_PADDING 2
2850 gboolean expand = FALSE;
2851 g_object_get (bg->panel, "expand", &expand, NULL);
2852 gint side_padding = expand ? 0 : TRANSFORM_RADIUS (bg->corner_radius);
2853@@ -771,7 +925,8 @@
2854 switch (position)
2855 {
2856 case GTK_POS_RIGHT:
2857- cairo_translate (cr, 0., y + height);
2858+ height += y;
2859+ cairo_translate (cr, 0., height);
2860 cairo_scale (cr, 1., -1.);
2861 cairo_translate (cr, x, height);
2862 cairo_rotate (cr, M_PI * 1.5);
2863@@ -780,26 +935,130 @@
2864 height = temp;
2865 break;
2866 case GTK_POS_LEFT:
2867- cairo_translate (cr, x + width, y);
2868+ height += y;
2869+ cairo_translate (cr, x + width, 0.);
2870 cairo_rotate (cr, M_PI * 0.5);
2871 temp = width;
2872 width = height;
2873 height = temp;
2874 break;
2875 case GTK_POS_TOP:
2876- cairo_translate (cr, x, y + height);
2877+ width += x;
2878+ cairo_translate (cr, 0., y + height);
2879 cairo_scale (cr, 1., -1.);
2880 break;
2881 default:
2882- cairo_translate (cr, x, y);
2883+ width += x;
2884+ cairo_translate (cr, 0., y);
2885 break;
2886 }
2887-
2888+
2889 draw_top_bottom_background (bg, position, cr, width, height);
2890-
2891- cairo_restore (cr);
2892-}
2893-
2894+
2895+ cairo_restore (cr);
2896+}
2897+
2898+static void
2899+_set_special_widget_width_and_transparent (AwnBackground *bg,
2900+ gint width,
2901+ gboolean transp,
2902+ gboolean dispose)
2903+{
2904+ GList *widgets = _get_applet_widgets (bg);
2905+ GList *i = widgets;
2906+ GtkWidget *widget = NULL;
2907+
2908+ if (i && IS_SPECIAL (i->data) && !dispose)
2909+ {
2910+ widget = GTK_WIDGET (i->data);
2911+ awn_separator_set_separator_size (AWN_SEPARATOR (widget), 1);
2912+ awn_separator_set_transparent (AWN_SEPARATOR (widget), transp);
2913+ i = i->next;
2914+ }
2915+
2916+ for (; i; i = i->next)
2917+ {
2918+ widget = GTK_WIDGET (i->data);
2919+ if (!IS_SPECIAL (widget))
2920+ {
2921+ /* if not special continue */
2922+ continue;
2923+ }
2924+ awn_separator_set_separator_size (AWN_SEPARATOR (widget), width);
2925+ awn_separator_set_transparent (AWN_SEPARATOR (widget), transp);
2926+ }
2927+
2928+ g_list_free (widgets);
2929+}
2930+
2931+static void
2932+awn_background_lucido_get_shape_mask (AwnBackground *bg,
2933+ cairo_t *cr,
2934+ GtkPositionType position,
2935+ GdkRectangle *area)
2936+{
2937+ gint temp;
2938+ gint x = area->x, y = area->y;
2939+ gint width = area->width, height = area->height;
2940+ gfloat align = 0.5;
2941+ gboolean expand = FALSE;
2942+
2943+ cairo_save (cr);
2944+
2945+ align = awn_background_get_panel_alignment (bg);
2946+ g_object_get (bg->panel, "expand", &expand, NULL);
2947+
2948+ switch (position)
2949+ {
2950+ case GTK_POS_RIGHT:
2951+ height += y;
2952+ cairo_translate (cr, 0., height);
2953+ cairo_scale (cr, 1., -1.);
2954+ cairo_translate (cr, x, height);
2955+ cairo_rotate (cr, M_PI * 1.5);
2956+ temp = width;
2957+ width = height;
2958+ height = temp;
2959+ break;
2960+ case GTK_POS_LEFT:
2961+ height += y;
2962+ cairo_translate (cr, x + width, 0.);
2963+ cairo_rotate (cr, M_PI * 0.5);
2964+ temp = width;
2965+ width = height;
2966+ height = temp;
2967+ break;
2968+ case GTK_POS_TOP:
2969+ width += x;
2970+ cairo_translate (cr, 0., y + height);
2971+ cairo_scale (cr, 1., -1.);
2972+ break;
2973+ default:
2974+ width += x;
2975+ cairo_translate (cr, 0., y);
2976+ break;
2977+ }
2978+ if (expand)
2979+ {
2980+ cairo_rectangle (cr, 0., 0., width, height + 2.);
2981+ }
2982+ else
2983+ {
2984+ _create_path_lucido (bg, position, cr, 0., 0., width, height,
2985+ TRANSFORM_RADIUS (bg->corner_radius),
2986+ TRANSFORM_RADIUS (bg->corner_radius),
2987+ FALSE, expand, align, FALSE);
2988+ cairo_fill (cr);
2989+ _create_path_lucido (bg, position, cr, 0., 0., width, height,
2990+ TRANSFORM_RADIUS (bg->corner_radius),
2991+ TRANSFORM_RADIUS (bg->corner_radius),
2992+ TRUE, expand, align, FALSE);
2993+
2994+ }
2995+ cairo_fill (cr);
2996+
2997+ cairo_restore (cr);
2998+}
2999 static gboolean
3000 awn_background_lucido_get_needs_redraw (AwnBackground *bg,
3001 GtkPositionType position,
3002@@ -812,47 +1071,43 @@
3003 {
3004 return TRUE;
3005 }
3006-
3007- /* Check expanders positions & sizes changed */
3008+ gboolean expand = FALSE;
3009+ g_object_get (bg->panel, "expand", &expand, NULL);
3010+ if (!expand)
3011+ {
3012+ return FALSE;
3013+ }
3014+ /* Check separators positions,
3015+ * because bar's width doesn't change in expanded mode
3016+ */
3017 GList *widgets = _get_applet_widgets (bg);
3018 GList *i = widgets;
3019 GtkWidget *widget = NULL;
3020- gint wcheck = 0;
3021- gint ncheck = 0;
3022-
3023+ gint wcheck = 0, j = 0;
3024+
3025 for (; i; i = i->next)
3026 {
3027+ ++j;
3028 widget = GTK_WIDGET (i->data);
3029-
3030- if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
3031+ if (!IS_SPECIAL (widget))
3032 {
3033- /* if not expander continue */
3034+ /* if not special continue */
3035 continue;
3036 }
3037 switch (position)
3038 {
3039- case GTK_POS_BOTTOM:
3040- case GTK_POS_TOP:
3041- wcheck += (widget->allocation.x * 3) / 2 + widget->allocation.width;
3042+ case GTK_POS_LEFT:
3043+ case GTK_POS_RIGHT:
3044+ wcheck += widget->allocation.y * j;
3045 break;
3046 default:
3047- wcheck += (widget->allocation.y * 3 ) / 2 + widget->allocation.height;
3048+ wcheck += widget->allocation.x * j;
3049 break;
3050 }
3051- ++ncheck;
3052 }
3053 g_list_free (widgets);
3054-
3055- AwnBackgroundLucido *lbg = NULL;
3056- lbg = AWN_BACKGROUND_LUCIDO (bg);
3057- AwnBackgroundLucidoPrivate *priv;
3058- priv = AWN_BACKGROUND_LUCIDO_GET_PRIVATE (lbg);
3059- if (priv->expn != ncheck)
3060- {
3061- priv->expn = ncheck;
3062- /* used to refresh bar */
3063- awn_background_emit_padding_changed (bg);
3064- }
3065+ AwnBackgroundLucidoPrivate *priv =
3066+ AWN_BACKGROUND_LUCIDO_GET_PRIVATE (AWN_BACKGROUND_LUCIDO (bg));
3067 if (priv->expw != wcheck)
3068 {
3069 priv->expw = wcheck;
3070@@ -860,63 +1115,4 @@
3071 }
3072 return FALSE;
3073 }
3074-
3075-static void
3076-awn_background_lucido_get_shape_mask (AwnBackground *bg,
3077- cairo_t *cr,
3078- GtkPositionType position,
3079- GdkRectangle *area)
3080-{
3081- gint temp;
3082- gint x = area->x, y = area->y;
3083- gint width = area->width, height = area->height;
3084- gfloat align = 0.5;
3085- gboolean expand = FALSE;
3086-
3087- cairo_save (cr);
3088-
3089- align = awn_background_get_panel_alignment (bg);
3090- g_object_get (bg->panel, "expand", &expand, NULL);
3091-
3092- switch (position)
3093- {
3094- case GTK_POS_RIGHT:
3095- cairo_translate (cr, 0., y + height);
3096- cairo_scale (cr, 1., -1.);
3097- cairo_translate (cr, x, height);
3098- cairo_rotate (cr, M_PI * 1.5);
3099- temp = width;
3100- width = height;
3101- height = temp;
3102- break;
3103- case GTK_POS_LEFT:
3104- cairo_translate (cr, x + width, y);
3105- cairo_rotate (cr, M_PI * 0.5);
3106- temp = width;
3107- width = height;
3108- height = temp;
3109- break;
3110- case GTK_POS_TOP:
3111- cairo_translate (cr, x, y + height);
3112- cairo_scale (cr, 1., -1.);
3113- break;
3114- default:
3115- cairo_translate (cr, x, y);
3116- break;
3117- }
3118- if (expand)
3119- {
3120- cairo_rectangle (cr, 0, 0, width, height + 2);
3121- }
3122- else
3123- {
3124- _create_path_lucido (bg, position, cr, 0, 0., width, height,
3125- bg->stripe_width, TRANSFORM_RADIUS (bg->corner_radius),
3126- TRANSFORM_RADIUS (bg->corner_radius), bg->curves_symmetry,
3127- 0, expand, align);
3128- }
3129- cairo_fill (cr);
3130-
3131- cairo_restore (cr);
3132-}
3133 /* vim: set et ts=2 sts=2 sw=2 : */
3134
3135=== modified file 'src/awn-background.c'
3136--- src/awn-background.c 2010-06-02 09:54:30 +0000
3137+++ src/awn-background.c 2010-07-16 11:56:43 +0000
3138@@ -60,7 +60,7 @@
3139 PROP_CURVINESS,
3140 PROP_CURVES_SYMEMETRY,
3141 PROP_FLOATY_OFFSET,
3142- PROP_STRIPE_WIDTH
3143+ PROP_THICKNESS
3144 };
3145
3146 enum
3147@@ -198,8 +198,8 @@
3148 DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,
3149 NULL);
3150 desktop_agnostic_config_client_bind (bg->client,
3151- AWN_GROUP_THEME, AWN_THEME_STRIPE_WIDTH,
3152- object, "stripe-width", TRUE,
3153+ AWN_GROUP_THEME, AWN_THEME_THICKNESS,
3154+ object, "thickness", TRUE,
3155 DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,
3156 NULL);
3157 }
3158@@ -236,6 +236,9 @@
3159 case PROP_FLOATY_OFFSET:
3160 g_value_set_int (value, bg->floaty_offset);
3161 break;
3162+ case PROP_THICKNESS:
3163+ g_value_set_float (value, bg->thickness);
3164+ break;
3165 default:
3166 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3167 }
3168@@ -364,12 +367,12 @@
3169 case PROP_CURVES_SYMEMETRY:
3170 bg->curves_symmetry = g_value_get_float (value);
3171 break;
3172+ case PROP_THICKNESS:
3173+ bg->thickness = g_value_get_float (value);
3174+ break;
3175 case PROP_FLOATY_OFFSET:
3176 bg->floaty_offset = g_value_get_int (value);
3177 break;
3178- case PROP_STRIPE_WIDTH:
3179- bg->stripe_width = g_value_get_float (value);
3180- break;
3181
3182 default:
3183 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3184@@ -619,16 +622,15 @@
3185 0.0, 1.0, 0.5,
3186 G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
3187 G_PARAM_STATIC_STRINGS));
3188+ g_object_class_install_property (obj_class,
3189+ PROP_THICKNESS,
3190+ g_param_spec_float ("thickness",
3191+ "Thickness",
3192+ "The thickness in 3D mode",
3193+ 0.0, 1.0, 0.6,
3194+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
3195+ G_PARAM_STATIC_STRINGS));
3196
3197- g_object_class_install_property (obj_class,
3198- PROP_STRIPE_WIDTH,
3199- g_param_spec_float ("stripe-width",
3200- "Stripe Width",
3201- "The width of the stripe",
3202- 0.0, 1.0, 0.0,
3203- G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
3204- G_PARAM_STATIC_STRINGS));
3205-
3206 /* Add signals to the class */
3207 _bg_signals[CHANGED] =
3208 g_signal_new ("changed",
3209@@ -870,7 +872,7 @@
3210 awn_background_emit_padding_changed (AwnBackground *bg)
3211 {
3212 g_return_if_fail (AWN_IS_BACKGROUND (bg));
3213-
3214+ awn_background_invalidate (bg);
3215 g_signal_emit (bg, _bg_signals[PADDING_CHANGED], 0);
3216 }
3217
3218@@ -878,7 +880,7 @@
3219 awn_background_emit_changed (AwnBackground *bg)
3220 {
3221 g_return_if_fail (AWN_IS_BACKGROUND (bg));
3222-
3223+ awn_background_invalidate (bg);
3224 g_signal_emit (bg, _bg_signals[CHANGED], 0);
3225 }
3226
3227
3228=== modified file 'src/awn-background.h'
3229--- src/awn-background.h 2010-05-31 17:41:58 +0000
3230+++ src/awn-background.h 2010-07-16 11:56:43 +0000
3231@@ -76,7 +76,7 @@
3232 gfloat pattern_alpha;
3233 GdkPixbuf *pattern_original;
3234 cairo_surface_t *pattern;
3235-
3236+
3237 /* Speedup code.
3238 * We can save the bg and redraw only when properties changes
3239 */
3240@@ -91,7 +91,7 @@
3241 */
3242 gboolean dialog_gtk_mode;
3243 gboolean gtk_theme_mode;
3244-
3245+
3246 /* Appearance options -- (some are backend specific) */
3247 gboolean rounded_corners;
3248 gfloat corner_radius;
3249@@ -99,7 +99,7 @@
3250 gint floaty_offset;
3251 gfloat curviness;
3252 gfloat curves_symmetry;
3253- gfloat stripe_width;
3254+ gfloat thickness;
3255
3256 /* private */
3257 guint changed;
3258
3259=== modified file 'src/awn-defines.h'
3260--- src/awn-defines.h 2010-05-31 17:41:58 +0000
3261+++ src/awn-defines.h 2010-07-16 11:56:43 +0000
3262@@ -88,7 +88,7 @@
3263 #define AWN_THEME_CURVINESS "curviness"
3264 #define AWN_THEME_CURVES_SYMMETRY "curves_symmetry"
3265 #define AWN_THEME_FLOATY_OFFSET "floaty_offset"
3266-#define AWN_THEME_STRIPE_WIDTH "stripe_width"
3267+#define AWN_THEME_THICKNESS "thickness"
3268
3269 #endif /*_HAVE_AWN_DEFINES_H */
3270
3271
3272=== modified file 'src/awn-panel.c'
3273--- src/awn-panel.c 2010-05-31 16:49:07 +0000
3274+++ src/awn-panel.c 2010-07-16 11:56:43 +0000
3275@@ -3920,6 +3920,12 @@
3276 return FALSE;
3277 }
3278
3279+gboolean
3280+awn_panel_get_docklet_mode (AwnPanel *panel)
3281+{
3282+ return panel->priv->docklet != NULL;
3283+}
3284+
3285 static void
3286 awn_panel_docklet_destroy (AwnPanel *panel)
3287 {
3288
3289=== modified file 'src/awn-panel.h'
3290--- src/awn-panel.h 2010-05-30 22:48:59 +0000
3291+++ src/awn-panel.h 2010-07-16 11:56:43 +0000
3292@@ -111,6 +111,8 @@
3293 gboolean expand,
3294 DBusGMethodInvocation *context);
3295
3296+gboolean awn_panel_get_docklet_mode (AwnPanel *panel);
3297+
3298 gboolean awn_panel_get_snapshot (AwnPanel *panel,
3299 GValue *value,
3300 GError **error);
3301
3302=== modified file 'src/awn-separator.c'
3303--- src/awn-separator.c 2010-01-01 21:35:47 +0000
3304+++ src/awn-separator.c 2010-07-16 11:56:43 +0000
3305@@ -34,7 +34,9 @@
3306 GtkPositionType position;
3307 gint offset;
3308 gint size;
3309+ gint separator_size;
3310
3311+ gboolean transparent;
3312 DesktopAgnosticColor *sep_color;
3313 };
3314
3315@@ -47,7 +49,10 @@
3316 PROP_OFFSET,
3317 PROP_SIZE,
3318
3319- PROP_SEP_COLOR
3320+ PROP_SEP_COLOR,
3321+ PROP_SEP_TRANSPARENT,
3322+
3323+ PROP_SEP_SIZE
3324 };
3325
3326 static void
3327@@ -78,6 +83,12 @@
3328 case PROP_SEP_COLOR:
3329 g_value_set_object (value, priv->sep_color);
3330 break;
3331+ case PROP_SEP_SIZE:
3332+ g_value_set_int (value, priv->separator_size);
3333+ break;
3334+ case PROP_SEP_TRANSPARENT:
3335+ g_value_set_boolean (value, priv->transparent);
3336+ break;
3337 default:
3338 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3339 }
3340@@ -126,6 +137,14 @@
3341 priv->sep_color = g_value_dup_object (value);
3342 gtk_widget_queue_draw (GTK_WIDGET (object));
3343 break;
3344+ case PROP_SEP_SIZE:
3345+ awn_separator_set_separator_size (AWN_SEPARATOR (object),
3346+ g_value_get_int (value));
3347+ break;
3348+ case PROP_SEP_TRANSPARENT:
3349+ awn_separator_set_transparent (AWN_SEPARATOR (object),
3350+ g_value_get_boolean (value));
3351+ break;
3352 default:
3353 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3354 }
3355@@ -181,13 +200,13 @@
3356 {
3357 case GTK_POS_TOP:
3358 case GTK_POS_BOTTOM:
3359- req->width = 10;
3360+ req->width = priv->separator_size;
3361 req->height = priv->size + priv->offset;
3362 break;
3363 case GTK_POS_LEFT:
3364 case GTK_POS_RIGHT:
3365 req->width = priv->size + priv->offset;
3366- req->height = 10;
3367+ req->height = priv->separator_size;
3368 break;
3369 default:
3370 break;
3371@@ -198,6 +217,12 @@
3372 awn_separator_expose (GtkWidget *widget, GdkEventExpose *event)
3373 {
3374 AwnSeparatorPrivate *priv = AWN_SEPARATOR (widget)->priv;
3375+
3376+ if (priv->transparent)
3377+ {
3378+ return TRUE;
3379+ }
3380+
3381 cairo_t *cr;
3382 cairo_path_t *path;
3383 GtkOrientation orient;
3384@@ -366,6 +391,24 @@
3385 DESKTOP_AGNOSTIC_TYPE_COLOR,
3386 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
3387
3388+ g_object_class_install_property (object_class,
3389+ PROP_SEP_SIZE,
3390+ g_param_spec_int ("separator-size",
3391+ "Separator Size",
3392+ "The size of the separator",
3393+ 0, G_MAXINT, 10,
3394+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
3395+ G_PARAM_STATIC_STRINGS));
3396+
3397+ g_object_class_install_property (object_class,
3398+ PROP_SEP_TRANSPARENT,
3399+ g_param_spec_boolean ("transparent",
3400+ "Transparent",
3401+ "Is separator transparent?",
3402+ FALSE,
3403+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
3404+ G_PARAM_STATIC_STRINGS));
3405+
3406 g_type_class_add_private (klass, sizeof (AwnSeparatorPrivate));
3407 }
3408
3409@@ -405,3 +448,35 @@
3410 NULL);
3411 }
3412
3413+void
3414+awn_separator_set_transparent (AwnSeparator *sep, gboolean transp)
3415+{
3416+ if (sep->priv->transparent != transp)
3417+ {
3418+ sep->priv->transparent = transp;
3419+ gtk_widget_queue_draw (GTK_WIDGET (sep));
3420+ }
3421+}
3422+
3423+gboolean
3424+awn_separator_get_transparent (AwnSeparator *sep, gboolean transp)
3425+{
3426+ return sep->priv->transparent;
3427+}
3428+
3429+void
3430+awn_separator_set_separator_size (AwnSeparator *sep, gint size)
3431+{
3432+ if (sep->priv->separator_size != size)
3433+ {
3434+ sep->priv->separator_size = size;
3435+ gtk_widget_queue_resize (GTK_WIDGET (sep));
3436+ }
3437+}
3438+
3439+gint
3440+awn_separator_get_separator_size (AwnSeparator *sep, gint size)
3441+{
3442+ return sep->priv->separator_size;
3443+}
3444+
3445
3446=== modified file 'src/awn-separator.h'
3447--- src/awn-separator.h 2009-10-31 12:14:11 +0000
3448+++ src/awn-separator.h 2010-07-16 11:56:43 +0000
3449@@ -65,6 +65,18 @@
3450 GtkPositionType pos,
3451 gint size, gint offset);
3452
3453+void
3454+awn_separator_set_transparent (AwnSeparator *sep, gboolean transp);
3455+
3456+gboolean
3457+awn_separator_get_transparent (AwnSeparator *sep, gboolean transp);
3458+
3459+void
3460+awn_separator_set_separator_size (AwnSeparator *sep, gint size);
3461+
3462+gint
3463+awn_separator_get_separator_size (AwnSeparator *sep, gint size);
3464+
3465 G_END_DECLS
3466
3467 #endif /* _AWN_SEPARATOR_H_ */

Subscribers

People subscribed via source and target branches