Awn

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

Proposed by Alberto Aldegheri
Status: Superseded
Proposed branch: lp:~albyrock87/awn/awn-lucido
Merge into: lp:awn/0.4
Diff against target: 3503 lines (+1499/-973)
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 (+21/-24)
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) Needs Fixing
Review via email: mp+27031@code.launchpad.net

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

This proposal has been superseded by a proposal from 2010-07-16.

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 :

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 :)

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

Minor code restyling

725. By Alberto <alby@CASA>

Bug fixes for separators in first position. Restyle of docklet-mode.

726. By Alberto <alby@CASA>

For simil-3D lovers: Now 3D angle acts on lucido too.

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

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

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

Fix to shape mask

728. By Alberto <alby@CASA>

Bug fixes to an old bug in cairo-utils: rounded_rect. Rect explode if radius is bigger than available space. Consecutive fix to highlights. Simplify and speedup to Edgy code. Bugfix to 3D style, not listening on corner-radius changes. Fix on Lucdio shape mask.

729. By Alberto <alby@CASA>

3D style rewritten. Now full customizable.

730. By Alberto <alby@CASA>

I hate when I forget things.

731. By Alberto <alby@CASA>

Add thickness to 3D style.

732. By Alberto <alby@CASA>

Better padding

733. By Alberto <alby@CASA>

Better painting

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

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)

:)

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

Other drawing adjust for glass looking

735. By Alberto <alby@CASA>

Cleanups

736. By Alberto <alby@CASA>

Thickness set to 7px

737. By Alberto <alby@CASA>

Better drawing. Thinner and more defined border. Improved padding.

738. By Alberto <alby@CASA>

s(e)(i)x is better :P

Revision history for this message
Michal Hruby (mhr3) wrote :

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 :

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

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

Thickness in 3D style, replacing floaty offset. Removed Lucido 3D style. Lucido now uses Curves Symmetry too.

740. By Alberto <alby@CASA>

Animation added to Lucido. There are some minor glitches sometime...

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

> 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 :)

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

A little speedup

742. By Alberto <alby@CASA>

Shit. I've forgot this.

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

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

Btw you can do code review :)

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

More consistent with other style engines

744. By Alberto <alby@CASA>

Huge speedup and cleanup. Fixed an old bug. Now listening on applets position change.

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

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.

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

Too much cleanup. Now works on expanded mode too.

746. By Alberto <alby@CASA>

Fix to 3D background padding

747. By Alberto <alby@CASA>

Rewrite of lucido path code. Bugs fixed and curves symmetry fully working.

748. By Alberto <alby@CASA>

Emit applets refreshed on docklet mode changed too.

749. By Alberto <alby@CASA>

Good looking start :)

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

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

Revision history for this message
Michal Hruby (mhr3) wrote :

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)
lp:~albyrock87/awn/awn-lucido updated
750. By Alberto <alby@CASA>

Little fixes

751. By Alberto <alby@CASA>

Merged from lp:awn

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

> 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);

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

Get and Set for separator new properties. Added awn_panel_get_docklet_mode to panel, removed the similar method in awn-applet-manager, because it returns -wrong- (updated too late) values.

753. By Alberto <alby@CASA>

I made an error while editing awn-panel.c, reverted that error.

754. By Alberto <alby@CASA>

Reverted changes on debian/changelog

755. By Alberto <alby@CASA>

Last fix to 3D edges when corner radius > height

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

> 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 :

NOooo stop!

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

ok, fixed :)

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

I had removed too much things :P

757. By Alberto <alby@CASA>

There was a drawing bug when corner radius = 0, fixed.

758. By Alberto <alby@CASA>

Merge with lp:awn rev 713

Revision history for this message
Michal Hruby (mhr3) wrote :

Please fix 3065.

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

> Please fix 3065.
Sorry Michal, fixed :)

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

Fixed 3065, sorry michal

Revision history for this message
Michal Hruby (mhr3) wrote :

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
lp:~albyrock87/awn/awn-lucido updated
760. By Alberto <alby@CASA>

Fixed Edgy. Auto invalidate bg on changed signal.

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

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

762. By Alberto <alby@CASA>

Better start animation. Fix to Criticals on lucido start. Pot Updated with make check.

763. By Alberto <alby@CASA>

Fixes to bug #608927

764. By Alberto <alby@CASA>

Avoid merge problems with gutted-core-icons branch

765. By Alberto <alby@CASA>

Patch for bug #608927

766. By Alberto <alby@CASA>

Remove unused refresh method from awnClass.py. A little fix to a translation string.

Unmerged revisions

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 10:54:57 +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 10:54:57 +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 10:54:57 +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 10:54:57 +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 10:54:57 +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 10:54:57 +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 10:54:57 +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 10:54:57 +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 10:54:57 +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 10:54:57 +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@@ -198,6 +190,9 @@
1659 cairo_set_line_width (cr, 1.0);
1660 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1661
1662+ gfloat x = 0.,
1663+ y = 0.;
1664+
1665 align = awn_background_get_panel_alignment (bg);
1666 g_object_get (bg->panel, "expand", &expand, NULL);
1667
1668@@ -223,8 +218,8 @@
1669 // performance as opposed to cairo_fill
1670 cairo_save (cr);
1671
1672- draw_rect (bg, cr, position, 1, 1, width-3, height-1, align, expand);
1673- cairo_clip (cr);
1674+ draw_rect (bg, cr, position, x, y, width, height, align, expand);
1675+ cairo_clip_preserve (cr);
1676 cairo_set_source (cr, pat);
1677 cairo_paint (cr);
1678
1679@@ -233,10 +228,12 @@
1680 cairo_pattern_destroy (pat);
1681
1682 /* Draw the hi-light */
1683- pat = cairo_pattern_create_linear (0, 0, 0, (height/3.0));
1684+ pat = cairo_pattern_create_linear (0, 0, 0, height);
1685 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_histep_1);
1686- awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_histep_2);
1687- draw_rect (bg, cr, position, 1, 1, width-3, height/3.0, align, expand);
1688+ awn_cairo_pattern_add_color_stop_color (pat, 0.3, bg->g_histep_2);
1689+ double red, green, blue, alpha;
1690+ desktop_agnostic_color_get_cairo_color (bg->g_histep_2, &red, &green, &blue, &alpha);
1691+ cairo_pattern_add_color_stop_rgba (pat, 0.36, red, green, blue, 0.);
1692
1693 cairo_set_source (cr, pat);
1694 cairo_fill (cr);
1695@@ -246,12 +243,12 @@
1696
1697 /* Internal border */
1698 awn_cairo_set_source_color (cr, bg->hilight_color);
1699- draw_rect (bg, cr, position, 1, 1, width-3, height+3, align, expand);
1700+ draw_rect (bg, cr, position, x + 1, y + 1, width-2, height-1, align, expand);
1701 cairo_stroke (cr);
1702
1703 /* External border */
1704 awn_cairo_set_source_color (cr, bg->border_color);
1705- draw_rect (bg, cr, position, 0, 0, width-1, height+3, align, expand);
1706+ draw_rect (bg, cr, position, x, y, width, height, align, expand);
1707 cairo_stroke (cr);
1708 }
1709
1710@@ -393,7 +390,7 @@
1711 break;
1712 }
1713
1714- draw_rect (bg, cr, position, 0, 0, width, height+3, align, expand);
1715+ draw_rect (bg, cr, position, 0, 0, width, height, align, expand);
1716 cairo_fill (cr);
1717
1718 cairo_restore (cr);
1719
1720=== modified file 'src/awn-background-floaty.c'
1721--- src/awn-background-floaty.c 2010-05-31 17:41:58 +0000
1722+++ src/awn-background-floaty.c 2010-07-16 10:54:57 +0000
1723@@ -181,7 +181,7 @@
1724 cairo_save (cr);
1725
1726 draw_rect (bg, cr, position, 1, 1, width-3, bg_size-2, TRUE);
1727- cairo_clip (cr);
1728+ cairo_clip_preserve (cr);
1729 cairo_set_source (cr, pat);
1730 cairo_paint (cr);
1731
1732@@ -190,10 +190,12 @@
1733 cairo_pattern_destroy (pat);
1734
1735 /* Draw the hi-light */
1736- pat = cairo_pattern_create_linear (0, 0, 0, (bg_size/3.0));
1737+ pat = cairo_pattern_create_linear (0., 0., 0., height);
1738 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_histep_1);
1739- awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_histep_2);
1740- draw_rect (bg, cr, position, 1, 1, width-3, bg_size/3.0, FALSE);
1741+ awn_cairo_pattern_add_color_stop_color (pat, 0.3, bg->g_histep_2);
1742+ double red, green, blue, alpha;
1743+ desktop_agnostic_color_get_cairo_color (bg->g_histep_2, &red, &green, &blue, &alpha);
1744+ cairo_pattern_add_color_stop_rgba (pat, 0.36, red, green, blue, 0.);
1745
1746 cairo_set_source (cr, pat);
1747 cairo_fill (cr);
1748
1749=== modified file 'src/awn-background-lucido.c'
1750--- src/awn-background-lucido.c 2010-05-31 22:40:18 +0000
1751+++ src/awn-background-lucido.c 2010-07-16 10:54:57 +0000
1752@@ -17,7 +17,7 @@
1753 *
1754 * Author : Alberto Aldegheri <albyrock87+dev@gmail.com>
1755 * Thanks to: Matt <sharkbaitbobby@gmail.com>
1756- * for the code section to analyze expanders
1757+ * for the code section to analyze separators
1758 *
1759 */
1760
1761@@ -39,11 +39,27 @@
1762
1763 struct _AwnBackgroundLucidoPrivate
1764 {
1765- gint expw;
1766- gint expn;
1767+ gint expw;
1768+ gfloat lastx;
1769+ gfloat lastxend;
1770+ GArray *pos;
1771+ gint pos_size;
1772+ guint tid;
1773+ gboolean needs_animation;
1774 };
1775
1776-#define TRANSFORM_RADIUS(x) sqrt(x/50.)*50.
1777+#define TOP_PADDING 2
1778+/* Timeout for animation -> 40 = 25fps*/
1779+#define ANIM_TIMEOUT 40
1780+/* ANIMATION SPEED needs to be greater than 0. - Lower values are faster */
1781+#define ANIMATION_SPEED 16.
1782+
1783+/* draw shape mask for debug */
1784+#define DEBUG_SHAPE_MASK FALSE
1785+
1786+#define TRANSFORM_RADIUS(x) MAX(sqrt(x/60.)*60.,1)
1787+
1788+#define IS_SPECIAL(x) AWN_IS_SEPARATOR(x)
1789
1790 static void awn_background_lucido_draw (AwnBackground *bg,
1791 cairo_t *cr,
1792@@ -61,18 +77,31 @@
1793 guint *padding_bottom,
1794 guint *padding_left,
1795 guint *padding_right);
1796-
1797+
1798 static gboolean
1799 awn_background_lucido_get_needs_redraw (AwnBackground *bg,
1800 GtkPositionType position,
1801 GdkRectangle *area);
1802-
1803+
1804+
1805+static void
1806+_set_special_widget_width_and_transparent (AwnBackground *bg,
1807+ gint width,
1808+ gboolean transp,
1809+ gboolean dispose);
1810+
1811 static void
1812 awn_background_lucido_corner_radius_changed (AwnBackground *bg)
1813 {
1814 gboolean expand = FALSE;
1815 g_object_get (bg->panel, "expand", &expand, NULL);
1816-
1817+
1818+ _set_special_widget_width_and_transparent (
1819+ bg,
1820+ TRANSFORM_RADIUS (bg->corner_radius),
1821+ TRUE,
1822+ FALSE);
1823+
1824 if (!expand)
1825 {
1826 awn_background_emit_padding_changed (bg);
1827@@ -92,19 +121,28 @@
1828 }
1829
1830 static void
1831+awn_background_lucido_applets_refreshed (AwnBackground *bg)
1832+{
1833+ _set_special_widget_width_and_transparent
1834+ (bg, TRANSFORM_RADIUS (bg->corner_radius), TRUE, FALSE);
1835+ awn_background_emit_changed (bg);
1836+}
1837+
1838+static void
1839 awn_background_lucido_constructed (GObject *object)
1840 {
1841 G_OBJECT_CLASS (awn_background_lucido_parent_class)->constructed (object);
1842-
1843+
1844 AwnBackground *bg = AWN_BACKGROUND (object);
1845 gpointer monitor = NULL;
1846-
1847+
1848 g_signal_connect_swapped (bg, "notify::corner-radius",
1849- G_CALLBACK (awn_background_lucido_corner_radius_changed),
1850+ G_CALLBACK (
1851+ awn_background_lucido_corner_radius_changed),
1852 object);
1853
1854 g_return_if_fail (bg->panel);
1855-
1856+
1857 g_signal_connect_swapped (bg->panel, "notify::expand",
1858 G_CALLBACK (awn_background_lucido_expand_changed),
1859 object);
1860@@ -116,11 +154,24 @@
1861 g_signal_connect_swapped (monitor, "notify::monitor-align",
1862 G_CALLBACK (awn_background_lucido_align_changed),
1863 object);
1864+
1865+ AwnAppletManager *manager = NULL;
1866+ g_object_get (bg->panel, "applet-manager", &manager, NULL);
1867+ g_return_if_fail (manager);
1868+ g_signal_connect_swapped (manager, "applets-refreshed",
1869+ G_CALLBACK (awn_background_lucido_applets_refreshed), bg);
1870 }
1871
1872 static void
1873 awn_background_lucido_dispose (GObject *object)
1874 {
1875+ _set_special_widget_width_and_transparent
1876+ (AWN_BACKGROUND (object), 10, FALSE, TRUE);
1877+
1878+ AwnBackgroundLucido *lbg = AWN_BACKGROUND_LUCIDO (object);
1879+ AwnBackgroundLucidoPrivate *priv = AWN_BACKGROUND_LUCIDO_GET_PRIVATE (lbg);
1880+ g_array_free (priv->pos, TRUE);
1881+
1882 gpointer monitor = NULL;
1883 if (AWN_BACKGROUND (object)->panel)
1884 {
1885@@ -139,6 +190,15 @@
1886 g_signal_handlers_disconnect_by_func (AWN_BACKGROUND (object),
1887 G_CALLBACK (awn_background_lucido_corner_radius_changed), object);
1888
1889+ AwnAppletManager *manager = NULL;
1890+ g_object_get (AWN_BACKGROUND (object)->panel,
1891+ "applet-manager", &manager, NULL);
1892+ if (manager)
1893+ {
1894+ g_signal_handlers_disconnect_by_func (manager,
1895+ G_CALLBACK (awn_background_lucido_applets_refreshed), object);
1896+ }
1897+
1898 G_OBJECT_CLASS (awn_background_lucido_parent_class)->dispose (object);
1899 }
1900
1901@@ -151,19 +211,30 @@
1902 obj_class->constructed = awn_background_lucido_constructed;
1903 obj_class->dispose = awn_background_lucido_dispose;
1904
1905+#if DEBUG_SHAPE_MASK
1906+ bg_class->draw = awn_background_lucido_get_shape_mask;
1907+#else
1908 bg_class->draw = awn_background_lucido_draw;
1909+#endif
1910 bg_class->padding_request = awn_background_lucido_padding_request;
1911 bg_class->get_shape_mask = awn_background_lucido_get_shape_mask;
1912 bg_class->get_input_shape_mask = awn_background_lucido_get_shape_mask;
1913 bg_class->get_needs_redraw = awn_background_lucido_get_needs_redraw;
1914-
1915+
1916 g_type_class_add_private (obj_class, sizeof (AwnBackgroundLucidoPrivate));
1917 }
1918
1919 static void
1920 awn_background_lucido_init (AwnBackgroundLucido *bg)
1921 {
1922-
1923+ AwnBackgroundLucidoPrivate *priv = AWN_BACKGROUND_LUCIDO_GET_PRIVATE (bg);
1924+ priv->lastx = 0;
1925+ priv->lastxend = INT_MAX;
1926+ priv->needs_animation = FALSE;
1927+ priv->tid = 0;
1928+ priv->pos = g_array_new (FALSE, TRUE, sizeof (gfloat));
1929+ priv->pos_size = 0;
1930+ awn_background_lucido_applets_refreshed (AWN_BACKGROUND (bg));
1931 }
1932
1933 AwnBackground *
1934@@ -179,6 +250,66 @@
1935 return bg;
1936 }
1937
1938+/* ANIMATION FUNCTIONS */
1939+
1940+/*
1941+ * _add_n_positions:
1942+ * adds n positions to position array that contains
1943+ * last positions of special applets
1944+ * Usually called when a special applet is added
1945+ */
1946+static void
1947+_add_n_positions (AwnBackgroundLucidoPrivate *priv, gint n, gfloat startpos)
1948+{
1949+ while (n-- > 0)
1950+ {
1951+ g_array_append_val (priv->pos, startpos);
1952+ ++priv->pos_size;
1953+ }
1954+}
1955+
1956+/*
1957+ * awn_background_lucido_redraw:
1958+ * @lbg: the lucido background ojbect
1959+ *
1960+ * Queue redraw of the panel and repeat itself if needed
1961+ */
1962+static gboolean
1963+awn_background_lucido_redraw (AwnBackgroundLucido *lbg)
1964+{
1965+ g_return_val_if_fail (AWN_IS_BACKGROUND_LUCIDO (lbg), FALSE);
1966+
1967+ AwnBackgroundLucidoPrivate *priv;
1968+ AwnBackground *bg = AWN_BACKGROUND (lbg);
1969+ priv = AWN_BACKGROUND_LUCIDO_GET_PRIVATE (lbg);
1970+
1971+ if (priv->needs_animation)
1972+ {
1973+ awn_background_invalidate (bg);
1974+ gtk_widget_queue_draw (GTK_WIDGET (bg->panel));
1975+ return TRUE;
1976+ }
1977+ else
1978+ {
1979+ priv->tid = 0;
1980+ return FALSE;
1981+ }
1982+}
1983+
1984+/*
1985+ * _restart_timeout:
1986+ * restarts animation's timer if needed
1987+ */
1988+static void _restart_timeout (AwnBackground *bg,
1989+ AwnBackgroundLucidoPrivate *priv)
1990+{
1991+ priv->needs_animation = TRUE;
1992+ if (!priv->tid)
1993+ {
1994+ priv->tid = g_timeout_add (ANIM_TIMEOUT, (GSourceFunc)awn_background_lucido_redraw, bg);
1995+ }
1996+}
1997+
1998 /*
1999 * Drawing functions
2000 */
2001@@ -202,6 +333,10 @@
2002 *ys = yf;
2003 }
2004
2005+/*
2006+ * Gets applet manager's childs.
2007+ * Sets docklet mode = TRUE if panel is in docklet mode
2008+ */
2009 static GList*
2010 _get_applet_widgets (AwnBackground* bg)
2011 {
2012@@ -211,6 +346,58 @@
2013 return gtk_container_get_children (GTK_CONTAINER (manager));
2014 }
2015
2016+/*
2017+ * Get applet manager size
2018+ * Get offset-left stored in "x" variable passed to method
2019+ *
2020+ */
2021+static gint
2022+_get_applet_manager_size (AwnBackground* bg, GtkPositionType position, float *x)
2023+{
2024+ AwnAppletManager *manager = NULL;
2025+ g_object_get (bg->panel, "applet-manager", &manager, NULL);
2026+ GtkWidget *widget = GTK_WIDGET (manager);
2027+ gint wx, wy;
2028+ gtk_widget_translate_coordinates(widget, gtk_widget_get_toplevel(widget),
2029+ 0, 0, &wx, &wy);
2030+ switch (position)
2031+ {
2032+ case GTK_POS_BOTTOM:
2033+ case GTK_POS_TOP:
2034+ if (x)
2035+ *x = wx;
2036+ return widget->allocation.width;
2037+ break;
2038+ default:
2039+ if (x)
2040+ *x = wy;
2041+ return widget->allocation.height;
2042+ break;
2043+ }
2044+}
2045+
2046+/*
2047+ * coord_get_near:
2048+ * @from: the current position
2049+ * @to: the target position
2050+ * @return: a position between "from" and "to", if distance = 1, returns "to"
2051+ */
2052+static float
2053+coord_get_near (const gfloat from, const gfloat to)
2054+{
2055+ float inc = abs (to - from);
2056+ float step = inc / ANIMATION_SPEED + 1.; // makes the resize shiny
2057+ inc = MIN (inc, step);
2058+ if (to > from)
2059+ {
2060+ return lroundf (from + inc);
2061+ }
2062+ else
2063+ {
2064+ return lroundf (from - inc);
2065+ }
2066+}
2067+
2068 /**
2069 * _create_path_lucido:
2070 * @bg: The background pointer
2071@@ -219,21 +406,23 @@
2072 * @y: The top left coordinate of the "bar rect" - default = 0
2073 * @w: The width of the bar
2074 * @h: The height of the bar
2075- * @stripe: The width of the stripe (0.0-1.0). Zero for auto-stripe.
2076 * @d: The width of each curve in the path
2077 * @dc: The width of the external curves in non-expanded&auto mode
2078- * @symmetry: The symmetry of the stripe when @stripe > 0
2079 * @internal: If Zero, creates the path for the stripe
2080 * @expanded: If Zero, the bar is not expanded
2081+ * @align: the monitor align
2082+ * @update_positions: if FALSE it uses positions stored in priv->pos,
2083+ * otherwise updates the position stored in priv->pos
2084 *
2085 * This function creates paths on which the bar will be drawn.
2086- * In atuo-stripe, it searchs for expanders applet, each expander
2087+ * In atuo-stripe, it searchs for separators applet, each separator
2088 * equals to one curve.
2089- * If the first widget is an expander, start from bottom-left,
2090+ * If the first widget is an separator, start from bottom-left,
2091 * otherwise start from top-left
2092+ *
2093+ * returns the calculated y coordinate to draw the gradient
2094 */
2095-
2096-static void
2097+static gfloat
2098 _create_path_lucido ( AwnBackground* bg,
2099 GtkPositionType position,
2100 cairo_t* cr,
2101@@ -241,371 +430,360 @@
2102 gfloat y,
2103 gfloat w,
2104 gfloat h,
2105- gfloat stripe,
2106 gfloat d,
2107 gfloat dc,
2108- gfloat symmetry,
2109 gboolean internal,
2110 gboolean expanded,
2111- gfloat align)
2112+ gfloat align,
2113+ gboolean update_positions)
2114 {
2115- cairo_new_path (cr);
2116+ AwnBackgroundLucido *lbg = AWN_BACKGROUND_LUCIDO (bg);
2117+ AwnBackgroundLucidoPrivate *priv = AWN_BACKGROUND_LUCIDO_GET_PRIVATE (lbg);
2118+ gfloat applet_manager_x = 0.;
2119+ _get_applet_manager_size (bg, position, &applet_manager_x);
2120+ gboolean needs_animation = FALSE;
2121
2122+ /****************************************************************************/
2123+ /******************** UPDATE STARTING POINT *************************/
2124+ /****************************************************************************/
2125+ /* x variable stores the starting x point for draw the panel */
2126+ if (update_positions)
2127+ {
2128+ if (!expanded)
2129+ {
2130+ x += applet_manager_x - dc;
2131+ }
2132+ x = lroundf (x);
2133+ if (x != priv->lastx)
2134+ {
2135+ needs_animation = TRUE;
2136+ }
2137+ x = coord_get_near (priv->lastx, x);
2138+ priv->lastx = x;
2139+ }
2140+ else
2141+ {
2142+ x = priv->lastx;
2143+ }
2144+ /****************************************************************************/
2145+ /******************** INIT GENERAL COORDINATES *************************/
2146+ /****************************************************************************/
2147+ gfloat sym = bg->curves_symmetry;
2148+ gfloat curx = x;
2149 gfloat lx = x;
2150 gfloat ly = y;
2151 gfloat y3 = y + h;
2152- gfloat y2 = y3 - 5;
2153-
2154- if (stripe > 0)
2155- {
2156- if (expanded)
2157- {
2158- stripe = (w * stripe); /* now stripe = non-stripe */
2159+ gfloat y2 = y3 - 8. * bg->thickness;
2160+ gfloat rdc = dc;
2161+
2162+ /****************************************************************************/
2163+ /******************** CURVES SYMMETRY HANDLER *************************/
2164+ /****************************************************************************/
2165+ sym = fabs (sym - 0.5);
2166+ gfloat exty = y + h * sym * 2.;
2167+ if (exty > y2)
2168+ {
2169+ y2 = exty;
2170+ }
2171+ if (internal && bg->curves_symmetry > 0.5)
2172+ {
2173+ y = exty;
2174+ }
2175+ else if (!internal && bg->curves_symmetry < 0.5)
2176+ {
2177+ y = exty;
2178+ }
2179+ /****************************************************************************/
2180+ /******************** OBTAIN LIST OF APPLETS *************************/
2181+ /****************************************************************************/
2182+ gboolean docklet_mode = awn_panel_get_docklet_mode (bg->panel);
2183+ GList *widgets = _get_applet_widgets (bg);
2184+ GList *i = widgets;
2185+ GtkWidget *widget = NULL;
2186+ /* j = index of last special widget found */
2187+ gint j = -1;
2188+ /* Check for docklet mode - In docklet mode first widget is the docklet */
2189+ if (i && docklet_mode)
2190+ {
2191+ i = i->next;
2192+ }
2193+ /* Check if the first widget is special */
2194+ gboolean first_widget_is_special = FALSE;
2195+ if (i && IS_SPECIAL (i->data))
2196+ {
2197+ first_widget_is_special = TRUE;
2198+ }
2199+ /****************************************************************************/
2200+ /******************** SETUP EXTERNAL CORNERS *************************/
2201+ /****************************************************************************/
2202+ if (expanded)
2203+ {
2204+ dc = rdc = 0.;
2205+ }
2206+ else if (align == 0.)
2207+ {
2208+ dc = 0.;
2209+ }
2210+ else if (align == 1.)
2211+ {
2212+ rdc = 0.;
2213+ }
2214+ /****************************************************************************/
2215+ /******************** START THE PATH *************************/
2216+ /****************************************************************************/
2217+ if (internal)
2218+ {
2219+ cairo_new_path (cr);
2220+ lx = lx + dc;
2221+ ly = y;
2222+ cairo_move_to (cr, lx, ly);
2223+ _line_from_to (cr, &lx, &ly, curx, y3);
2224+ }
2225+ else
2226+ {
2227+ cairo_new_path (cr);
2228+ lx = curx;
2229+ ly = y3;
2230+ cairo_move_to (cr, lx, ly);
2231+ }
2232+ /* check for special in first position */
2233+ if (first_widget_is_special)
2234+ {
2235+ i = i->next;
2236+ _line_from_to (cr, &lx, &ly, lx + dc, y2);
2237+ }
2238+ else if (!internal)
2239+ {
2240+ _line_from_to (cr, &lx, &ly, lx + dc, y);
2241+ }
2242+ else
2243+ {
2244+ _line_from_to (cr, &lx, &ly, lx + dc, exty);
2245+ }
2246+ /****************************************************************************/
2247+ /******************** UPDATE WIDTH FOR LAST X *************************/
2248+ /****************************************************************************/
2249+ /* w stores the "right corner", lastxend equals to last w */
2250+ if (update_positions)
2251+ {
2252+ w = lroundf (w);
2253+ if (w != priv->lastxend)
2254+ {
2255+ needs_animation = TRUE;
2256+ gfloat neww = coord_get_near (priv->lastxend, w);
2257+ w = MIN (w, neww);
2258+ priv->lastxend = w;
2259+ }
2260+ }
2261+ else
2262+ {
2263+ w = priv->lastxend;
2264+ }
2265+ /****************************************************************************/
2266+ /******************** LOOP ON APPLETS *************************/
2267+ /****************************************************************************/
2268+ gfloat saved_y = y;
2269+ if (bg->curves_symmetry < 0.5)
2270+ {
2271+ y = exty;
2272+ }
2273+ curx = lx;
2274+ gint wx, wy;
2275+ if (!docklet_mode)
2276+ {
2277+ for (; i; i = i->next)
2278+ {
2279+ widget = GTK_WIDGET (i->data);
2280+ if (!IS_SPECIAL (widget))
2281+ {
2282+ /* if not special continue */
2283+ continue;
2284+ }
2285+ /* special found, obtain coordinates */
2286+ ++j;
2287+ gtk_widget_translate_coordinates(widget, gtk_widget_get_toplevel(widget),
2288+ 0, 0, &wx, &wy);
2289+ switch (position)
2290+ {
2291+ case GTK_POS_BOTTOM:
2292+ case GTK_POS_TOP:
2293+ curx = wx;
2294+ break;
2295+ default:
2296+ curx = wy;
2297+ break;
2298+ }
2299+ if (priv->pos_size <= j)
2300+ {
2301+ /* New special applet found, resize the array */
2302+ _add_n_positions (priv, 1, lx);
2303+ }
2304+ /************************************************************************/
2305+ /***************** UPDATE SINGLE CURVE POSITION *********************/
2306+ /************************************************************************/
2307+ if (update_positions)
2308+ {
2309+ curx = lroundf (curx);
2310+ if (curx != g_array_index (priv->pos, gfloat, j))
2311+ {
2312+ needs_animation = TRUE;
2313+ }
2314+ curx = coord_get_near (g_array_index (priv->pos, gfloat, j), curx);
2315+ if (curx > (w - rdc - d))
2316+ {
2317+ curx = w - rdc - d;
2318+ }
2319+ g_array_index (priv->pos, gfloat, j) = curx;
2320+ }
2321+ else
2322+ {
2323+ curx = g_array_index (priv->pos, gfloat, j);
2324+ }
2325+ if (curx < 0)
2326+ {
2327+ continue;
2328+ }
2329+ _line_from_to (cr, &lx, &ly, curx, ly);
2330+ if (ly == y2)
2331+ {
2332+ _line_from_to (cr, &lx, &ly, lx + d, y);
2333+ }
2334+ else
2335+ {
2336+ _line_from_to (cr, &lx, &ly, lx + d, y2);
2337+ }
2338+ }
2339+ }
2340+ y = saved_y;
2341+ g_list_free (widgets);
2342+ /****************************************************************************/
2343+ /************************ CLOSE THE PATH ******************************/
2344+ /****************************************************************************/
2345+ if (expanded)
2346+ {
2347+ /* make sure that cairo close path in the right way */
2348+ _line_from_to (cr, &lx, &ly, w, ly);
2349+ if (internal)
2350+ {
2351+ _line_from_to (cr, &lx, &ly, lx, y);
2352+ }
2353+ else
2354+ {
2355+ _line_from_to (cr, &lx, &ly, lx, y3);
2356+ }
2357+ }
2358+ else
2359+ {
2360+ if (align == 1.)
2361+ {
2362 if (internal)
2363 {
2364- /* Manual-Stripe & Expanded & Internal */
2365- lx = stripe * symmetry;
2366- cairo_move_to (cr, lx, ly);
2367- _line_from_to (cr, &lx, &ly, lx+d, y2);
2368- _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - d, y2);
2369- _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry), y);
2370- cairo_close_path (cr);
2371- }
2372- else
2373- {
2374- /* Manual-Stripe & Expanded & External */
2375- ly = y3;
2376- cairo_move_to (cr, lx, ly);
2377+ _line_from_to (cr, &lx, &ly, w, ly);
2378 _line_from_to (cr, &lx, &ly, lx, y);
2379- _line_from_to (cr, &lx, &ly, stripe * symmetry, y);
2380- _line_from_to (cr, &lx, &ly, stripe * symmetry + d, y2);
2381- _line_from_to (cr, &lx, &ly, w - stripe * (1. - symmetry) - d, y2);
2382- _line_from_to (cr, &lx, &ly, w - stripe * (1. - symmetry), y);
2383- _line_from_to (cr, &lx, &ly, w, y);
2384- _line_from_to (cr, &lx, &ly, w, y3);
2385- cairo_close_path (cr);
2386- }
2387- }
2388- else
2389- {
2390- if (stripe == 1.)
2391- {
2392- _create_path_lucido (bg, position, cr, x, y, w, h, 0.,
2393- d, dc, 0., internal, expanded, align);
2394- return;
2395- }
2396- stripe = ((w - dc * 2) * stripe); /* now stripe = non-stripe */
2397- if (internal)
2398- {
2399- /* Manual-Stripe & Not-Expanded & Internal */
2400- lx = stripe * symmetry + dc;
2401- cairo_move_to (cr, lx, ly);
2402- _line_from_to (cr, &lx, &ly, lx + d, y2);
2403- _line_from_to (cr, &lx, &ly, w - stripe * (1.- symmetry) - dc - d, y2);
2404- _line_from_to (cr, &lx, &ly, w - stripe * (1.- symmetry) - dc, y);
2405- cairo_close_path (cr);
2406- }
2407- else
2408- {
2409- /* Manual-Stripe & Not-Expanded & External */
2410- ly = y3;
2411- cairo_move_to (cr, lx, ly);
2412- _line_from_to (cr, &lx, &ly, lx+dc, y);
2413- _line_from_to (cr, &lx, &ly, stripe * symmetry + dc, y);
2414- _line_from_to (cr, &lx, &ly, stripe * symmetry + d + dc, y2);
2415- _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - dc - d, y2);
2416- _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - dc, y);
2417- _line_from_to (cr, &lx, &ly, w-dc, y);
2418- _line_from_to (cr, &lx, &ly, w, y3);
2419- cairo_close_path(cr);
2420- }
2421- }
2422- }
2423- else
2424- {
2425- gint exps_found = 0;
2426- gfloat curx = x;
2427-
2428- if (expanded)
2429- {
2430- if (internal)
2431- {
2432- /* Auto-Stripe & Expanded & Internal */
2433- GList *widgets = _get_applet_widgets (bg);
2434- GList *i = widgets;
2435- GtkWidget *widget = NULL;
2436-
2437- /* analyze first widget*/
2438- if (i)
2439- {
2440- widget = GTK_WIDGET (i->data);
2441-
2442- /* if first widget is an expander or align==0 || 1*/
2443- if ( (widget && GTK_IS_IMAGE (widget) && !AWN_IS_SEPARATOR (widget) ) ||
2444- ( align == 0. || align == 1. ) )
2445- {
2446- /* start from bottom */
2447- lx = curx;
2448- ly = y;
2449- cairo_move_to (cr, lx, ly);
2450- _line_from_to (cr, &lx, &ly, lx, y2);
2451- ++exps_found;
2452- if (align != 0. && align != 1.)
2453- i = i->next;
2454- }
2455- }
2456- /* else start from top */
2457-
2458- for (; i; i = i->next)
2459- {
2460- widget = GTK_WIDGET (i->data);
2461-
2462- if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
2463- {
2464- /* if not expander continue */
2465- continue;
2466- }
2467- /* expander found */
2468- switch (position)
2469- {
2470- case GTK_POS_BOTTOM:
2471- case GTK_POS_TOP:
2472- curx = widget->allocation.x;
2473- if (exps_found % 2 != 0)
2474- {
2475- curx += widget->allocation.width;
2476- }
2477- break;
2478- default:
2479- curx = widget->allocation.y;
2480- if ( exps_found % 2 != 0)
2481- {
2482- curx += widget->allocation.height;
2483- }
2484- break;
2485- }
2486- if (curx < 0)
2487- {
2488- continue;
2489- }
2490-
2491- if (exps_found == 0)
2492- {
2493- /* this is the first expander */
2494- lx = curx;
2495- cairo_move_to (cr, lx, ly);
2496- _line_from_to (cr, &lx, &ly, curx + d, y2);
2497- }
2498- else
2499- {
2500- if (exps_found % 2 != 0)
2501- {
2502- /* odd expander - curve at the end of expander */
2503- _line_from_to (cr, &lx, &ly, curx - d, y2);
2504- if (i->next == NULL)
2505- _line_from_to (cr, &lx, &ly, curx, y2);
2506- _line_from_to (cr, &lx, &ly, curx, y);
2507- }
2508- else
2509- {
2510- /* even expander - curve at the start of expander */
2511- _line_from_to (cr, &lx, &ly, curx, y);
2512- _line_from_to (cr, &lx, &ly, curx + d, y2);
2513- /* else the last widget is an expander */
2514- }
2515- }
2516-
2517- ++exps_found;
2518- }
2519- g_list_free (widgets);
2520-
2521- _line_from_to (cr, &lx, &ly, w, ly);
2522-
2523- if (exps_found % 2 != 0)
2524- {
2525- _line_from_to (cr, &lx, &ly, lx, y);
2526- }
2527-
2528- cairo_close_path (cr);
2529- }
2530- else
2531- {
2532- /* Auto-Stripe & Expanded & External */
2533-
2534- GList *widgets = _get_applet_widgets (bg);
2535- GList *i = widgets;
2536- GtkWidget *widget = NULL;
2537-
2538- /* analyze first widget*/
2539- if (i)
2540- {
2541- widget = GTK_WIDGET (i->data);
2542-
2543- ly = y3;
2544- cairo_move_to (cr, lx, ly);
2545-
2546- /* if first widget is an expander or align==0 || 1*/
2547- if ( (widget && GTK_IS_IMAGE (widget) && !AWN_IS_SEPARATOR (widget) ) ||
2548- ( align == 0. || align == 1. ) )
2549- {
2550- /* start from bottom */
2551- _line_from_to (cr, &lx, &ly, lx, y2);
2552- ++exps_found;
2553- if (align != 0. && align != 1.)
2554- i = i->next;
2555- }
2556- else
2557- {
2558- /* start from top */
2559- _line_from_to (cr, &lx, &ly, lx, y);
2560- }
2561- }
2562-
2563- for (; i; i = i->next)
2564- {
2565- widget = GTK_WIDGET (i->data);
2566-
2567- if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
2568- {
2569- /* if not expander continue */
2570- continue;
2571- }
2572- /* expander found */
2573- switch (position)
2574- {
2575- case GTK_POS_BOTTOM:
2576- case GTK_POS_TOP:
2577- curx = widget->allocation.x;
2578- if (exps_found % 2 != 0)
2579- {
2580- curx += widget->allocation.width;
2581- }
2582- break;
2583- default:
2584- curx = widget->allocation.y;
2585- if (exps_found % 2 != 0)
2586- {
2587- curx += widget->allocation.height;
2588- }
2589- break;
2590- }
2591- if (curx < 0)
2592- {
2593- continue;
2594- }
2595-
2596- if (exps_found % 2 != 0)
2597- {
2598- _line_from_to (cr, &lx, &ly, curx - d, y2);
2599- if (i->next != NULL)
2600- _line_from_to (cr, &lx, &ly, curx, y);
2601- }
2602- else
2603- {
2604- _line_from_to (cr, &lx, &ly, curx, y);
2605- _line_from_to (cr, &lx, &ly, curx + d, y2);
2606- }
2607- ++exps_found;
2608- }
2609- g_list_free (widgets);
2610-
2611+ }
2612+ else
2613+ {
2614 _line_from_to (cr, &lx, &ly, w, ly);
2615 _line_from_to (cr, &lx, &ly, lx, y3);
2616-
2617- cairo_close_path (cr);
2618 }
2619 }
2620 else
2621 {
2622 if (internal)
2623 {
2624- /* Auto-Stripe & Not-Expanded & Internal */
2625- /* no-path */
2626+ _line_from_to (cr, &lx, &ly, w - rdc, y2);
2627+ _line_from_to (cr, &lx, &ly, w, y3);
2628+ _line_from_to (cr, &lx, &ly, w - rdc, y);
2629 }
2630 else
2631 {
2632- /* Auto-Stripe & Not-Expanded & External */
2633- ly = y3;
2634- cairo_move_to (cr, lx, ly);
2635-
2636- if (align == 0.)
2637- _line_from_to (cr, &lx, &ly, lx , y);
2638- else
2639- _line_from_to (cr, &lx, &ly, lx + dc, y);
2640-
2641- if (align == 1.)
2642- _line_from_to (cr, &lx, &ly, w, y);
2643- else
2644- _line_from_to (cr, &lx, &ly, w - dc, y);
2645-
2646+ _line_from_to (cr, &lx, &ly, w - rdc, ly);
2647 _line_from_to (cr, &lx, &ly, w, y3);
2648- cairo_close_path (cr);
2649 }
2650 }
2651 }
2652+ cairo_close_path (cr);
2653+ /****************************************************************************/
2654+ /******************** RESTART ANIMATION IF NEEDED **********************/
2655+ /****************************************************************************/
2656+ if (update_positions)
2657+ {
2658+ if (needs_animation)
2659+ {
2660+ _restart_timeout (bg, priv);
2661+ }
2662+ else
2663+ {
2664+ priv->needs_animation = FALSE;
2665+ }
2666+ }
2667+ return y;
2668 }
2669
2670 static void
2671 draw_top_bottom_background (AwnBackground* bg,
2672 GtkPositionType position,
2673 cairo_t* cr,
2674- gint width,
2675- gint height)
2676+ gfloat width,
2677+ gfloat height)
2678 {
2679 cairo_pattern_t *pat = NULL;
2680- cairo_pattern_t *pat_hi = NULL;
2681-
2682+
2683 /* Basic set-up */
2684 cairo_set_line_width (cr, 1.0);
2685 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
2686
2687 gboolean expand = FALSE;
2688 g_object_get (bg->panel, "expand", &expand, NULL);
2689-
2690+
2691 gfloat align = awn_background_get_panel_alignment (AWN_BACKGROUND (bg));
2692-
2693+
2694 /* Make sure the bar gets drawn on the 0.5 pixels (for sharp edges) */
2695- switch (position)
2696- {
2697- case GTK_POS_TOP:
2698- case GTK_POS_BOTTOM:
2699- cairo_translate (cr, 0., 0.5);
2700- break;
2701- default:
2702- cairo_translate (cr, 0.5, 0.);
2703- break;
2704- }
2705-
2706+ if (!expand)
2707+ {
2708+ cairo_translate (cr, 0.5, 0.5);
2709+ width -= 0.5;
2710+ }
2711+ else
2712+ {
2713+ cairo_translate (cr, -0.5, 0.5);
2714+ width += 1.;
2715+ }
2716+
2717 if (gtk_widget_is_composited (GTK_WIDGET (bg->panel)) == FALSE)
2718 {
2719 goto paint_lines;
2720 }
2721
2722+ gfloat x = 0.,
2723+ y = 0.;
2724+ gfloat y_pat;
2725+
2726 /* create internal path */
2727- _create_path_lucido (bg, position, cr, -1.0, 0., width, height,
2728- bg->stripe_width, TRANSFORM_RADIUS (bg->corner_radius),
2729- TRANSFORM_RADIUS (bg->corner_radius), bg->curves_symmetry,
2730- 1, expand, align);
2731+ y_pat = _create_path_lucido (bg, position, cr, x, y, width, height,
2732+ TRANSFORM_RADIUS (bg->corner_radius),
2733+ TRANSFORM_RADIUS (bg->corner_radius),
2734+ TRUE, expand, align, TRUE);
2735
2736 /* Draw internal pattern if needed */
2737- if ((expand || bg->stripe_width != 0.) && bg->enable_pattern && bg->pattern)
2738+ if (bg->enable_pattern && bg->pattern)
2739 {
2740 /* Prepare pattern */
2741- pat_hi = cairo_pattern_create_for_surface (bg->pattern);
2742- cairo_pattern_set_extend (pat_hi, CAIRO_EXTEND_REPEAT);
2743+ pat = cairo_pattern_create_for_surface (bg->pattern);
2744+ cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT);
2745 /* Draw */
2746 cairo_save (cr);
2747 cairo_clip_preserve (cr);
2748- cairo_set_source (cr, pat_hi);
2749+ cairo_set_source (cr, pat);
2750 cairo_paint (cr);
2751 cairo_restore (cr);
2752- cairo_pattern_destroy (pat_hi);
2753+ cairo_pattern_destroy (pat);
2754 }
2755
2756 /* Prepare the internal background */
2757- pat = cairo_pattern_create_linear (0, 0, 0, height);
2758- awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->border_color);
2759- awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->hilight_color);
2760+ pat = cairo_pattern_create_linear (x, y_pat, 0., height);
2761+ awn_cairo_pattern_add_color_stop_color (pat, 0., bg->g_histep_1);
2762+ awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_histep_2);
2763
2764 /* Draw the internal background gradient */
2765 cairo_save (cr);
2766@@ -613,37 +791,23 @@
2767 cairo_set_source (cr, pat);
2768 cairo_paint (cr);
2769 cairo_restore (cr);
2770+ awn_cairo_set_source_color (cr, bg->border_color);
2771+ cairo_stroke (cr);
2772+
2773+ /* create external path */
2774+ y_pat = _create_path_lucido (bg, position, cr, x, y, width, height,
2775+ TRANSFORM_RADIUS (bg->corner_radius),
2776+ TRANSFORM_RADIUS (bg->corner_radius),
2777+ FALSE, expand, align, FALSE);
2778
2779 /* Prepare external background gradient*/
2780- if (expand || bg->stripe_width != 0.)
2781- {
2782- cairo_pattern_destroy (pat);
2783- pat = cairo_pattern_create_linear (0, 0, 0, height);
2784- awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_step_1);
2785- awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);
2786- }
2787-
2788- /* create external path */
2789- _create_path_lucido (bg, position, cr, -1.0, 0., width, height,
2790- bg->stripe_width, TRANSFORM_RADIUS (bg->corner_radius),
2791- TRANSFORM_RADIUS (bg->corner_radius), bg->curves_symmetry,
2792- 0, expand, align);
2793+ cairo_pattern_destroy (pat);
2794+ pat = cairo_pattern_create_linear (x, y_pat, 0., height);
2795+ awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_step_1);
2796+ awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);
2797
2798- /* Draw external pattern if needed */
2799- if (!expand && bg->stripe_width == 0. && bg->enable_pattern && bg->pattern)
2800- {
2801- /* Prepare pattern */
2802- pat_hi = cairo_pattern_create_for_surface (bg->pattern);
2803- cairo_pattern_set_extend (pat_hi, CAIRO_EXTEND_REPEAT);
2804- /* Draw */
2805- cairo_save (cr);
2806- cairo_clip_preserve (cr);
2807- cairo_set_source (cr, pat_hi);
2808- cairo_paint (cr);
2809- cairo_restore (cr);
2810- cairo_pattern_destroy (pat_hi);
2811- }
2812-
2813+ /* Clean below external background */
2814+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
2815 /* Draw the external background */
2816 cairo_save (cr);
2817 cairo_clip_preserve (cr);
2818@@ -651,21 +815,12 @@
2819 cairo_paint (cr);
2820 cairo_restore (cr);
2821 cairo_pattern_destroy (pat);
2822-
2823- /* Draw the hi-light */
2824- pat_hi = cairo_pattern_create_linear (0, 0, 0, (height / 3.0));
2825- awn_cairo_pattern_add_color_stop_color (pat_hi, 0.0, bg->g_histep_1);
2826- awn_cairo_pattern_add_color_stop_color (pat_hi, 1.0, bg->g_histep_2);
2827-
2828- if (expand)
2829- {
2830- cairo_new_path (cr);
2831- cairo_rectangle (cr, 0, 0, width, (height / 3.0));
2832- }
2833-
2834- cairo_set_source (cr, pat_hi);
2835- cairo_fill (cr);
2836- cairo_pattern_destroy (pat_hi);
2837+ /* Restore operator */
2838+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
2839+
2840+ /* Draw border */
2841+ awn_cairo_set_source_color (cr, bg->hilight_color);
2842+ cairo_stroke (cr);
2843
2844 return;
2845 /* if not composited */
2846@@ -675,26 +830,26 @@
2847 {
2848 /* Internal border */
2849 awn_cairo_set_source_color (cr, bg->hilight_color);
2850- cairo_rectangle (cr, 1, 1, width - 3, height + 3);
2851+ cairo_rectangle (cr, 1., 1., width - 3., height + 3.);
2852 cairo_stroke (cr);
2853
2854 /* External border */
2855 awn_cairo_set_source_color (cr, bg->border_color);
2856- cairo_rectangle (cr, 1, 1, width - 1, height + 3);
2857+ cairo_rectangle (cr, 1., 1., width - 1., height + 3.);
2858 }
2859 else
2860 {
2861 awn_cairo_set_source_color (cr, bg->border_color);
2862 _create_path_lucido (bg, position, cr, 0., 0., width, height,
2863- bg->stripe_width, TRANSFORM_RADIUS (bg->corner_radius),
2864- TRANSFORM_RADIUS (bg->corner_radius), bg->curves_symmetry,
2865- 0, expand, align);
2866+ TRANSFORM_RADIUS (bg->corner_radius),
2867+ TRANSFORM_RADIUS (bg->corner_radius),
2868+ FALSE, expand, align, TRUE);
2869 cairo_stroke (cr);
2870 awn_cairo_set_source_color (cr, bg->hilight_color);
2871 _create_path_lucido (bg, position, cr, 1., 1., width-1., height-1.,
2872- bg->stripe_width, TRANSFORM_RADIUS (bg->corner_radius),
2873- TRANSFORM_RADIUS (bg->corner_radius), bg->curves_symmetry,
2874- 0, expand, align);
2875+ TRANSFORM_RADIUS (bg->corner_radius),
2876+ TRANSFORM_RADIUS (bg->corner_radius),
2877+ FALSE, expand, align, FALSE);
2878 }
2879 cairo_stroke (cr);
2880 }
2881@@ -708,7 +863,6 @@
2882 guint *padding_left,
2883 guint *padding_right)
2884 {
2885- #define TOP_PADDING 2
2886 gboolean expand = FALSE;
2887 g_object_get (bg->panel, "expand", &expand, NULL);
2888 gint side_padding = expand ? 0 : TRANSFORM_RADIUS (bg->corner_radius);
2889@@ -771,7 +925,8 @@
2890 switch (position)
2891 {
2892 case GTK_POS_RIGHT:
2893- cairo_translate (cr, 0., y + height);
2894+ height += y;
2895+ cairo_translate (cr, 0., height);
2896 cairo_scale (cr, 1., -1.);
2897 cairo_translate (cr, x, height);
2898 cairo_rotate (cr, M_PI * 1.5);
2899@@ -780,26 +935,130 @@
2900 height = temp;
2901 break;
2902 case GTK_POS_LEFT:
2903- cairo_translate (cr, x + width, y);
2904+ height += y;
2905+ cairo_translate (cr, x + width, 0.);
2906 cairo_rotate (cr, M_PI * 0.5);
2907 temp = width;
2908 width = height;
2909 height = temp;
2910 break;
2911 case GTK_POS_TOP:
2912- cairo_translate (cr, x, y + height);
2913+ width += x;
2914+ cairo_translate (cr, 0., y + height);
2915 cairo_scale (cr, 1., -1.);
2916 break;
2917 default:
2918- cairo_translate (cr, x, y);
2919+ width += x;
2920+ cairo_translate (cr, 0., y);
2921 break;
2922 }
2923-
2924+
2925 draw_top_bottom_background (bg, position, cr, width, height);
2926-
2927- cairo_restore (cr);
2928-}
2929-
2930+
2931+ cairo_restore (cr);
2932+}
2933+
2934+static void
2935+_set_special_widget_width_and_transparent (AwnBackground *bg,
2936+ gint width,
2937+ gboolean transp,
2938+ gboolean dispose)
2939+{
2940+ GList *widgets = _get_applet_widgets (bg);
2941+ GList *i = widgets;
2942+ GtkWidget *widget = NULL;
2943+
2944+ if (i && IS_SPECIAL (i->data) && !dispose)
2945+ {
2946+ widget = GTK_WIDGET (i->data);
2947+ awn_separator_set_separator_size (AWN_SEPARATOR (widget), 1);
2948+ awn_separator_set_transparent (AWN_SEPARATOR (widget), transp);
2949+ i = i->next;
2950+ }
2951+
2952+ for (; i; i = i->next)
2953+ {
2954+ widget = GTK_WIDGET (i->data);
2955+ if (!IS_SPECIAL (widget))
2956+ {
2957+ /* if not special continue */
2958+ continue;
2959+ }
2960+ awn_separator_set_separator_size (AWN_SEPARATOR (widget), width);
2961+ awn_separator_set_transparent (AWN_SEPARATOR (widget), transp);
2962+ }
2963+
2964+ g_list_free (widgets);
2965+}
2966+
2967+static void
2968+awn_background_lucido_get_shape_mask (AwnBackground *bg,
2969+ cairo_t *cr,
2970+ GtkPositionType position,
2971+ GdkRectangle *area)
2972+{
2973+ gint temp;
2974+ gint x = area->x, y = area->y;
2975+ gint width = area->width, height = area->height;
2976+ gfloat align = 0.5;
2977+ gboolean expand = FALSE;
2978+
2979+ cairo_save (cr);
2980+
2981+ align = awn_background_get_panel_alignment (bg);
2982+ g_object_get (bg->panel, "expand", &expand, NULL);
2983+
2984+ switch (position)
2985+ {
2986+ case GTK_POS_RIGHT:
2987+ height += y;
2988+ cairo_translate (cr, 0., height);
2989+ cairo_scale (cr, 1., -1.);
2990+ cairo_translate (cr, x, height);
2991+ cairo_rotate (cr, M_PI * 1.5);
2992+ temp = width;
2993+ width = height;
2994+ height = temp;
2995+ break;
2996+ case GTK_POS_LEFT:
2997+ height += y;
2998+ cairo_translate (cr, x + width, 0.);
2999+ cairo_rotate (cr, M_PI * 0.5);
3000+ temp = width;
3001+ width = height;
3002+ height = temp;
3003+ break;
3004+ case GTK_POS_TOP:
3005+ width += x;
3006+ cairo_translate (cr, 0., y + height);
3007+ cairo_scale (cr, 1., -1.);
3008+ break;
3009+ default:
3010+ width += x;
3011+ cairo_translate (cr, 0., y);
3012+ break;
3013+ }
3014+ if (expand)
3015+ {
3016+ cairo_rectangle (cr, 0., 0., width, height + 2.);
3017+ }
3018+ else
3019+ {
3020+ _create_path_lucido (bg, position, cr, 0., 0., width, height,
3021+ TRANSFORM_RADIUS (bg->corner_radius),
3022+ TRANSFORM_RADIUS (bg->corner_radius),
3023+ FALSE, expand, align, FALSE);
3024+ cairo_fill (cr);
3025+ _create_path_lucido (bg, position, cr, 0., 0., width, height,
3026+ TRANSFORM_RADIUS (bg->corner_radius),
3027+ TRANSFORM_RADIUS (bg->corner_radius),
3028+ TRUE, expand, align, FALSE);
3029+
3030+ }
3031+ cairo_fill (cr);
3032+
3033+ cairo_restore (cr);
3034+}
3035 static gboolean
3036 awn_background_lucido_get_needs_redraw (AwnBackground *bg,
3037 GtkPositionType position,
3038@@ -812,47 +1071,43 @@
3039 {
3040 return TRUE;
3041 }
3042-
3043- /* Check expanders positions & sizes changed */
3044+ gboolean expand = FALSE;
3045+ g_object_get (bg->panel, "expand", &expand, NULL);
3046+ if (!expand)
3047+ {
3048+ return FALSE;
3049+ }
3050+ /* Check separators positions,
3051+ * because bar's width doesn't change in expanded mode
3052+ */
3053 GList *widgets = _get_applet_widgets (bg);
3054 GList *i = widgets;
3055 GtkWidget *widget = NULL;
3056- gint wcheck = 0;
3057- gint ncheck = 0;
3058-
3059+ gint wcheck = 0, j = 0;
3060+
3061 for (; i; i = i->next)
3062 {
3063+ ++j;
3064 widget = GTK_WIDGET (i->data);
3065-
3066- if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
3067+ if (!IS_SPECIAL (widget))
3068 {
3069- /* if not expander continue */
3070+ /* if not special continue */
3071 continue;
3072 }
3073 switch (position)
3074 {
3075- case GTK_POS_BOTTOM:
3076- case GTK_POS_TOP:
3077- wcheck += (widget->allocation.x * 3) / 2 + widget->allocation.width;
3078+ case GTK_POS_LEFT:
3079+ case GTK_POS_RIGHT:
3080+ wcheck += widget->allocation.y * j;
3081 break;
3082 default:
3083- wcheck += (widget->allocation.y * 3 ) / 2 + widget->allocation.height;
3084+ wcheck += widget->allocation.x * j;
3085 break;
3086 }
3087- ++ncheck;
3088 }
3089 g_list_free (widgets);
3090-
3091- AwnBackgroundLucido *lbg = NULL;
3092- lbg = AWN_BACKGROUND_LUCIDO (bg);
3093- AwnBackgroundLucidoPrivate *priv;
3094- priv = AWN_BACKGROUND_LUCIDO_GET_PRIVATE (lbg);
3095- if (priv->expn != ncheck)
3096- {
3097- priv->expn = ncheck;
3098- /* used to refresh bar */
3099- awn_background_emit_padding_changed (bg);
3100- }
3101+ AwnBackgroundLucidoPrivate *priv =
3102+ AWN_BACKGROUND_LUCIDO_GET_PRIVATE (AWN_BACKGROUND_LUCIDO (bg));
3103 if (priv->expw != wcheck)
3104 {
3105 priv->expw = wcheck;
3106@@ -860,63 +1115,4 @@
3107 }
3108 return FALSE;
3109 }
3110-
3111-static void
3112-awn_background_lucido_get_shape_mask (AwnBackground *bg,
3113- cairo_t *cr,
3114- GtkPositionType position,
3115- GdkRectangle *area)
3116-{
3117- gint temp;
3118- gint x = area->x, y = area->y;
3119- gint width = area->width, height = area->height;
3120- gfloat align = 0.5;
3121- gboolean expand = FALSE;
3122-
3123- cairo_save (cr);
3124-
3125- align = awn_background_get_panel_alignment (bg);
3126- g_object_get (bg->panel, "expand", &expand, NULL);
3127-
3128- switch (position)
3129- {
3130- case GTK_POS_RIGHT:
3131- cairo_translate (cr, 0., y + height);
3132- cairo_scale (cr, 1., -1.);
3133- cairo_translate (cr, x, height);
3134- cairo_rotate (cr, M_PI * 1.5);
3135- temp = width;
3136- width = height;
3137- height = temp;
3138- break;
3139- case GTK_POS_LEFT:
3140- cairo_translate (cr, x + width, y);
3141- cairo_rotate (cr, M_PI * 0.5);
3142- temp = width;
3143- width = height;
3144- height = temp;
3145- break;
3146- case GTK_POS_TOP:
3147- cairo_translate (cr, x, y + height);
3148- cairo_scale (cr, 1., -1.);
3149- break;
3150- default:
3151- cairo_translate (cr, x, y);
3152- break;
3153- }
3154- if (expand)
3155- {
3156- cairo_rectangle (cr, 0, 0, width, height + 2);
3157- }
3158- else
3159- {
3160- _create_path_lucido (bg, position, cr, 0, 0., width, height,
3161- bg->stripe_width, TRANSFORM_RADIUS (bg->corner_radius),
3162- TRANSFORM_RADIUS (bg->corner_radius), bg->curves_symmetry,
3163- 0, expand, align);
3164- }
3165- cairo_fill (cr);
3166-
3167- cairo_restore (cr);
3168-}
3169 /* vim: set et ts=2 sts=2 sw=2 : */
3170
3171=== modified file 'src/awn-background.c'
3172--- src/awn-background.c 2010-06-02 09:54:30 +0000
3173+++ src/awn-background.c 2010-07-16 10:54:57 +0000
3174@@ -60,7 +60,7 @@
3175 PROP_CURVINESS,
3176 PROP_CURVES_SYMEMETRY,
3177 PROP_FLOATY_OFFSET,
3178- PROP_STRIPE_WIDTH
3179+ PROP_THICKNESS
3180 };
3181
3182 enum
3183@@ -198,8 +198,8 @@
3184 DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,
3185 NULL);
3186 desktop_agnostic_config_client_bind (bg->client,
3187- AWN_GROUP_THEME, AWN_THEME_STRIPE_WIDTH,
3188- object, "stripe-width", TRUE,
3189+ AWN_GROUP_THEME, AWN_THEME_THICKNESS,
3190+ object, "thickness", TRUE,
3191 DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,
3192 NULL);
3193 }
3194@@ -236,6 +236,9 @@
3195 case PROP_FLOATY_OFFSET:
3196 g_value_set_int (value, bg->floaty_offset);
3197 break;
3198+ case PROP_THICKNESS:
3199+ g_value_set_float (value, bg->thickness);
3200+ break;
3201 default:
3202 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3203 }
3204@@ -364,12 +367,12 @@
3205 case PROP_CURVES_SYMEMETRY:
3206 bg->curves_symmetry = g_value_get_float (value);
3207 break;
3208+ case PROP_THICKNESS:
3209+ bg->thickness = g_value_get_float (value);
3210+ break;
3211 case PROP_FLOATY_OFFSET:
3212 bg->floaty_offset = g_value_get_int (value);
3213 break;
3214- case PROP_STRIPE_WIDTH:
3215- bg->stripe_width = g_value_get_float (value);
3216- break;
3217
3218 default:
3219 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3220@@ -619,16 +622,15 @@
3221 0.0, 1.0, 0.5,
3222 G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
3223 G_PARAM_STATIC_STRINGS));
3224+ g_object_class_install_property (obj_class,
3225+ PROP_THICKNESS,
3226+ g_param_spec_float ("thickness",
3227+ "Thickness",
3228+ "The thickness in 3D mode",
3229+ 0.0, 1.0, 0.6,
3230+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
3231+ G_PARAM_STATIC_STRINGS));
3232
3233- g_object_class_install_property (obj_class,
3234- PROP_STRIPE_WIDTH,
3235- g_param_spec_float ("stripe-width",
3236- "Stripe Width",
3237- "The width of the stripe",
3238- 0.0, 1.0, 0.0,
3239- G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
3240- G_PARAM_STATIC_STRINGS));
3241-
3242 /* Add signals to the class */
3243 _bg_signals[CHANGED] =
3244 g_signal_new ("changed",
3245@@ -870,7 +872,7 @@
3246 awn_background_emit_padding_changed (AwnBackground *bg)
3247 {
3248 g_return_if_fail (AWN_IS_BACKGROUND (bg));
3249-
3250+ awn_background_invalidate (bg);
3251 g_signal_emit (bg, _bg_signals[PADDING_CHANGED], 0);
3252 }
3253
3254@@ -878,7 +880,7 @@
3255 awn_background_emit_changed (AwnBackground *bg)
3256 {
3257 g_return_if_fail (AWN_IS_BACKGROUND (bg));
3258-
3259+ awn_background_invalidate (bg);
3260 g_signal_emit (bg, _bg_signals[CHANGED], 0);
3261 }
3262
3263
3264=== modified file 'src/awn-background.h'
3265--- src/awn-background.h 2010-05-31 17:41:58 +0000
3266+++ src/awn-background.h 2010-07-16 10:54:57 +0000
3267@@ -76,7 +76,7 @@
3268 gfloat pattern_alpha;
3269 GdkPixbuf *pattern_original;
3270 cairo_surface_t *pattern;
3271-
3272+
3273 /* Speedup code.
3274 * We can save the bg and redraw only when properties changes
3275 */
3276@@ -91,7 +91,7 @@
3277 */
3278 gboolean dialog_gtk_mode;
3279 gboolean gtk_theme_mode;
3280-
3281+
3282 /* Appearance options -- (some are backend specific) */
3283 gboolean rounded_corners;
3284 gfloat corner_radius;
3285@@ -99,7 +99,7 @@
3286 gint floaty_offset;
3287 gfloat curviness;
3288 gfloat curves_symmetry;
3289- gfloat stripe_width;
3290+ gfloat thickness;
3291
3292 /* private */
3293 guint changed;
3294
3295=== modified file 'src/awn-defines.h'
3296--- src/awn-defines.h 2010-05-31 17:41:58 +0000
3297+++ src/awn-defines.h 2010-07-16 10:54:57 +0000
3298@@ -88,7 +88,7 @@
3299 #define AWN_THEME_CURVINESS "curviness"
3300 #define AWN_THEME_CURVES_SYMMETRY "curves_symmetry"
3301 #define AWN_THEME_FLOATY_OFFSET "floaty_offset"
3302-#define AWN_THEME_STRIPE_WIDTH "stripe_width"
3303+#define AWN_THEME_THICKNESS "thickness"
3304
3305 #endif /*_HAVE_AWN_DEFINES_H */
3306
3307
3308=== modified file 'src/awn-panel.c'
3309--- src/awn-panel.c 2010-05-31 16:49:07 +0000
3310+++ src/awn-panel.c 2010-07-16 10:54:57 +0000
3311@@ -3920,6 +3920,12 @@
3312 return FALSE;
3313 }
3314
3315+gboolean
3316+awn_panel_get_docklet_mode (AwnPanel *panel)
3317+{
3318+ return panel->priv->docklet != NULL;
3319+}
3320+
3321 static void
3322 awn_panel_docklet_destroy (AwnPanel *panel)
3323 {
3324
3325=== modified file 'src/awn-panel.h'
3326--- src/awn-panel.h 2010-05-30 22:48:59 +0000
3327+++ src/awn-panel.h 2010-07-16 10:54:57 +0000
3328@@ -111,6 +111,8 @@
3329 gboolean expand,
3330 DBusGMethodInvocation *context);
3331
3332+gboolean awn_panel_get_docklet_mode (AwnPanel *panel);
3333+
3334 gboolean awn_panel_get_snapshot (AwnPanel *panel,
3335 GValue *value,
3336 GError **error);
3337
3338=== modified file 'src/awn-separator.c'
3339--- src/awn-separator.c 2010-01-01 21:35:47 +0000
3340+++ src/awn-separator.c 2010-07-16 10:54:57 +0000
3341@@ -34,7 +34,9 @@
3342 GtkPositionType position;
3343 gint offset;
3344 gint size;
3345+ gint separator_size;
3346
3347+ gboolean transparent;
3348 DesktopAgnosticColor *sep_color;
3349 };
3350
3351@@ -47,7 +49,10 @@
3352 PROP_OFFSET,
3353 PROP_SIZE,
3354
3355- PROP_SEP_COLOR
3356+ PROP_SEP_COLOR,
3357+ PROP_SEP_TRANSPARENT,
3358+
3359+ PROP_SEP_SIZE
3360 };
3361
3362 static void
3363@@ -78,6 +83,12 @@
3364 case PROP_SEP_COLOR:
3365 g_value_set_object (value, priv->sep_color);
3366 break;
3367+ case PROP_SEP_SIZE:
3368+ g_value_set_int (value, priv->separator_size);
3369+ break;
3370+ case PROP_SEP_TRANSPARENT:
3371+ g_value_set_boolean (value, priv->transparent);
3372+ break;
3373 default:
3374 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3375 }
3376@@ -126,6 +137,14 @@
3377 priv->sep_color = g_value_dup_object (value);
3378 gtk_widget_queue_draw (GTK_WIDGET (object));
3379 break;
3380+ case PROP_SEP_SIZE:
3381+ awn_separator_set_separator_size (AWN_SEPARATOR (object),
3382+ g_value_get_int (value));
3383+ break;
3384+ case PROP_SEP_TRANSPARENT:
3385+ awn_separator_set_transparent (AWN_SEPARATOR (object),
3386+ g_value_get_boolean (value));
3387+ break;
3388 default:
3389 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3390 }
3391@@ -181,13 +200,13 @@
3392 {
3393 case GTK_POS_TOP:
3394 case GTK_POS_BOTTOM:
3395- req->width = 10;
3396+ req->width = priv->separator_size;
3397 req->height = priv->size + priv->offset;
3398 break;
3399 case GTK_POS_LEFT:
3400 case GTK_POS_RIGHT:
3401 req->width = priv->size + priv->offset;
3402- req->height = 10;
3403+ req->height = priv->separator_size;
3404 break;
3405 default:
3406 break;
3407@@ -198,6 +217,12 @@
3408 awn_separator_expose (GtkWidget *widget, GdkEventExpose *event)
3409 {
3410 AwnSeparatorPrivate *priv = AWN_SEPARATOR (widget)->priv;
3411+
3412+ if (priv->transparent)
3413+ {
3414+ return TRUE;
3415+ }
3416+
3417 cairo_t *cr;
3418 cairo_path_t *path;
3419 GtkOrientation orient;
3420@@ -366,6 +391,24 @@
3421 DESKTOP_AGNOSTIC_TYPE_COLOR,
3422 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
3423
3424+ g_object_class_install_property (object_class,
3425+ PROP_SEP_SIZE,
3426+ g_param_spec_int ("separator-size",
3427+ "Separator Size",
3428+ "The size of the separator",
3429+ 0, G_MAXINT, 10,
3430+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
3431+ G_PARAM_STATIC_STRINGS));
3432+
3433+ g_object_class_install_property (object_class,
3434+ PROP_SEP_TRANSPARENT,
3435+ g_param_spec_boolean ("transparent",
3436+ "Transparent",
3437+ "Is separator transparent?",
3438+ FALSE,
3439+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
3440+ G_PARAM_STATIC_STRINGS));
3441+
3442 g_type_class_add_private (klass, sizeof (AwnSeparatorPrivate));
3443 }
3444
3445@@ -405,3 +448,35 @@
3446 NULL);
3447 }
3448
3449+void
3450+awn_separator_set_transparent (AwnSeparator *sep, gboolean transp)
3451+{
3452+ if (sep->priv->transparent != transp)
3453+ {
3454+ sep->priv->transparent = transp;
3455+ gtk_widget_queue_draw (GTK_WIDGET (sep));
3456+ }
3457+}
3458+
3459+gboolean
3460+awn_separator_get_transparent (AwnSeparator *sep, gboolean transp)
3461+{
3462+ return sep->priv->transparent;
3463+}
3464+
3465+void
3466+awn_separator_set_separator_size (AwnSeparator *sep, gint size)
3467+{
3468+ if (sep->priv->separator_size != size)
3469+ {
3470+ sep->priv->separator_size = size;
3471+ gtk_widget_queue_resize (GTK_WIDGET (sep));
3472+ }
3473+}
3474+
3475+gint
3476+awn_separator_get_separator_size (AwnSeparator *sep, gint size)
3477+{
3478+ return sep->priv->separator_size;
3479+}
3480+
3481
3482=== modified file 'src/awn-separator.h'
3483--- src/awn-separator.h 2009-10-31 12:14:11 +0000
3484+++ src/awn-separator.h 2010-07-16 10:54:57 +0000
3485@@ -65,6 +65,18 @@
3486 GtkPositionType pos,
3487 gint size, gint offset);
3488
3489+void
3490+awn_separator_set_transparent (AwnSeparator *sep, gboolean transp);
3491+
3492+gboolean
3493+awn_separator_get_transparent (AwnSeparator *sep, gboolean transp);
3494+
3495+void
3496+awn_separator_set_separator_size (AwnSeparator *sep, gint size);
3497+
3498+gint
3499+awn_separator_get_separator_size (AwnSeparator *sep, gint size);
3500+
3501 G_END_DECLS
3502
3503 #endif /* _AWN_SEPARATOR_H_ */

Subscribers

People subscribed via source and target branches