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
=== modified file 'awn-settings/awn-settings.ui'
--- awn-settings/awn-settings.ui 2010-06-03 23:39:31 +0000
+++ awn-settings/awn-settings.ui 2010-07-16 10:54:57 +0000
@@ -899,22 +899,6 @@
899 </packing>899 </packing>
900 </child>900 </child>
901 <child>901 <child>
902 <object class="GtkSpinButton" id="theme_stripe_width">
903 <property name="visible">True</property>
904 <property name="can_focus">True</property>
905 <property name="invisible_char">&#x25CF;</property>
906 <property name="adjustment">adj_stripe_width</property>
907 <property name="digits">2</property>
908 </object>
909 <packing>
910 <property name="left_attach">2</property>
911 <property name="right_attach">3</property>
912 <property name="top_attach">11</property>
913 <property name="bottom_attach">12</property>
914 <property name="x_options"></property>
915 </packing>
916 </child>
917 <child>
918 <object class="GtkSpinButton" id="theme_angle">902 <object class="GtkSpinButton" id="theme_angle">
919 <property name="visible">True</property>903 <property name="visible">True</property>
920 <property name="can_focus">True</property>904 <property name="can_focus">True</property>
@@ -972,19 +956,6 @@
972 </packing>956 </packing>
973 </child>957 </child>
974 <child>958 <child>
975 <object class="GtkLabel" id="label_stripe">
976 <property name="visible">True</property>
977 <property name="xalign">0</property>
978 <property name="xpad">10</property>
979 <property name="label" translatable="yes">Stripe Width</property>
980 </object>
981 <packing>
982 <property name="right_attach">2</property>
983 <property name="top_attach">11</property>
984 <property name="bottom_attach">12</property>
985 </packing>
986 </child>
987 <child>
988 <object class="GtkLabel" id="label49">959 <object class="GtkLabel" id="label49">
989 <property name="visible">True</property>960 <property name="visible">True</property>
990 <property name="xalign">0</property>961 <property name="xalign">0</property>
@@ -1649,6 +1620,35 @@
1649 </packing>1620 </packing>
1650 </child>1621 </child>
1651 <child>1622 <child>
1623 <object class="GtkLabel" id="label_thickness">
1624 <property name="visible">True</property>
1625 <property name="xalign">0</property>
1626 <property name="xpad">10</property>
1627 <property name="label" translatable="yes">Thickness</property>
1628 </object>
1629 <packing>
1630 <property name="right_attach">2</property>
1631 <property name="top_attach">11</property>
1632 <property name="bottom_attach">12</property>
1633 </packing>
1634 </child>
1635 <child>
1636 <object class="GtkSpinButton" id="theme_thickness">
1637 <property name="visible">True</property>
1638 <property name="can_focus">True</property>
1639 <property name="invisible_char">&#x25CF;</property>
1640 <property name="adjustment">adj_thickness</property>
1641 <property name="digits">2</property>
1642 </object>
1643 <packing>
1644 <property name="left_attach">2</property>
1645 <property name="right_attach">3</property>
1646 <property name="top_attach">11</property>
1647 <property name="bottom_attach">12</property>
1648 <property name="x_options"></property>
1649 </packing>
1650 </child>
1651 <child>
1652 <placeholder/>1652 <placeholder/>
1653 </child>1653 </child>
1654 <child>1654 <child>
@@ -3439,10 +3439,6 @@
3439 <property name="upper">1</property>3439 <property name="upper">1</property>
3440 <property name="step_increment">0.01</property>3440 <property name="step_increment">0.01</property>
3441 </object>3441 </object>
3442 <object class="GtkAdjustment" id="adj_stripe_width">
3443 <property name="upper">1</property>
3444 <property name="step_increment">0.01</property>
3445 </object>
3446 <object class="GtkAdjustment" id="adj_radius">3442 <object class="GtkAdjustment" id="adj_radius">
3447 <property name="upper">100</property>3443 <property name="upper">100</property>
3448 <property name="step_increment">1</property>3444 <property name="step_increment">1</property>
@@ -3457,6 +3453,10 @@
3457 <property name="upper">100</property>3453 <property name="upper">100</property>
3458 <property name="step_increment">1</property>3454 <property name="step_increment">1</property>
3459 </object>3455 </object>
3456 <object class="GtkAdjustment" id="adj_thickness">
3457 <property name="upper">1</property>
3458 <property name="step_increment">0.05</property>
3459 </object>
3460 <object class="GtkAdjustment" id="adj_3d_angle">3460 <object class="GtkAdjustment" id="adj_3d_angle">
3461 <property name="upper">90</property>3461 <property name="upper">90</property>
3462 <property name="step_increment">1</property>3462 <property name="step_increment">1</property>
34633463
=== modified file 'awn-settings/awnDefs.py.in'
--- awn-settings/awnDefs.py.in 2010-05-31 17:41:58 +0000
+++ awn-settings/awnDefs.py.in 2010-07-16 10:54:57 +0000
@@ -86,8 +86,8 @@
86PANEL_ANGLE = "panel_angle" #float86PANEL_ANGLE = "panel_angle" #float
87CURVINESS = "curviness" #float87CURVINESS = "curviness" #float
88CURVES_SYMMETRY = "curves_symmetry" #float88CURVES_SYMMETRY = "curves_symmetry" #float
89STRIPE_WIDTH = "stripe_width" #float
90FLOATY_OFFSET = "floaty_offset" #int89FLOATY_OFFSET = "floaty_offset" #int
90THICKNESS = "thickness" #float
91TOOLTIP_FONT_NAME = "tooltip_font_name" #string91TOOLTIP_FONT_NAME = "tooltip_font_name" #string
92TOOLTIP_FONT_COLOR = "tooltip_font_color" #string92TOOLTIP_FONT_COLOR = "tooltip_font_color" #string
93TOOLTIP_BG_COLOR = "tooltip_bg_color" #string93TOOLTIP_BG_COLOR = "tooltip_bg_color" #string
9494
=== modified file 'awn-settings/awnSettings.py.in'
--- awn-settings/awnSettings.py.in 2010-05-31 17:41:58 +0000
+++ awn-settings/awnSettings.py.in 2010-07-16 10:54:57 +0000
@@ -579,8 +579,8 @@
579 579
580 curviness = gobject.property(type=float, default=1)580 curviness = gobject.property(type=float, default=1)
581 curves_symmetry = gobject.property(type=float, default=0)581 curves_symmetry = gobject.property(type=float, default=0)
582 stripe_width = gobject.property(type=float, default=0)
583 floaty_offset = gobject.property(type=int, default=10)582 floaty_offset = gobject.property(type=int, default=10)
583 thickness = gobject.property(type=float, default=0)
584 angle = gobject.property(type=int, default=45)584 angle = gobject.property(type=int, default=45)
585 radius = gobject.property(type=int, default=10)585 radius = gobject.property(type=int, default=10)
586 gtk_theme_mode = gobject.property(type=bool, default=False)586 gtk_theme_mode = gobject.property(type=bool, default=False)
@@ -730,7 +730,7 @@
730 (defs.THEME, defs.PANEL_ANGLE, 'float', sizes),730 (defs.THEME, defs.PANEL_ANGLE, 'float', sizes),
731 (defs.THEME, defs.CURVINESS, 'float', sizes),731 (defs.THEME, defs.CURVINESS, 'float', sizes),
732 (defs.THEME, defs.CURVES_SYMMETRY, 'float', sizes),732 (defs.THEME, defs.CURVES_SYMMETRY, 'float', sizes),
733 (defs.THEME, defs.STRIPE_WIDTH, 'float', sizes),733 (defs.THEME, defs.THICKNESS, 'float', sizes),
734 (defs.THEME, defs.FLOATY_OFFSET, 'int', sizes),734 (defs.THEME, defs.FLOATY_OFFSET, 'int', sizes),
735 (defs.THEME, defs.TOOLTIP_FONT_NAME, 'str', icon),735 (defs.THEME, defs.TOOLTIP_FONT_NAME, 'str', icon),
736 (defs.THEME, defs.TOOLTIP_FONT_COLOR, 'str', icon),736 (defs.THEME, defs.TOOLTIP_FONT_COLOR, 'str', icon),
@@ -828,12 +828,12 @@
828 "curviness", "theme_curviness"),828 "curviness", "theme_curviness"),
829 (self.client, defs.THEME, defs.CURVES_SYMMETRY,829 (self.client, defs.THEME, defs.CURVES_SYMMETRY,
830 "curves-symmetry", "theme_symmetry"),830 "curves-symmetry", "theme_symmetry"),
831 (self.client, defs.THEME, defs.STRIPE_WIDTH,
832 "stripe-width", "theme_stripe_width"),
833 (self.client, defs.THEME, defs.PANEL_ANGLE,831 (self.client, defs.THEME, defs.PANEL_ANGLE,
834 "angle", "theme_angle"),832 "angle", "theme_angle"),
835 (self.client, defs.THEME, defs.FLOATY_OFFSET,833 (self.client, defs.THEME, defs.FLOATY_OFFSET,
836 "floaty-offset", "theme_floaty_offset"),834 "floaty-offset", "theme_floaty_offset"),
835 (self.client, defs.THEME, defs.THICKNESS,
836 "thickness", "theme_thickness"),
837 (self.client, defs.THEME, defs.CORNER_RADIUS,837 (self.client, defs.THEME, defs.CORNER_RADIUS,
838 "radius", "theme_radius"),838 "radius", "theme_radius"),
839 (self.client, defs.THEME, defs.TOOLTIP_FONT_NAME,839 (self.client, defs.THEME, defs.TOOLTIP_FONT_NAME,
840840
=== modified file 'data/avant-window-navigator.schema-ini.in.in'
--- data/avant-window-navigator.schema-ini.in.in 2010-07-07 09:12:12 +0000
+++ data/avant-window-navigator.schema-ini.in.in 2010-07-16 10:54:57 +0000
@@ -233,10 +233,10 @@
233_description=The offset of the Floaty background.233_description=The offset of the Floaty background.
234per_instance = false234per_instance = false
235235
236[theme/stripe_width]236[theme/thickness]
237type = float237type = float
238default = 0.0238default = 0.6
239_description=The width of the stripe in Lucido mode.239_description=The thickness in 3D mode.
240per_instance = false240per_instance = false
241241
242[theme/dialog_gtk_mode]242[theme/dialog_gtk_mode]
243243
=== modified file 'libawn/awn-cairo-utils.c'
--- libawn/awn-cairo-utils.c 2010-01-10 14:43:43 +0000
+++ libawn/awn-cairo-utils.c 2010-07-16 10:54:57 +0000
@@ -16,6 +16,7 @@
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *17 *
18 * Author : Anthony Arobone <aarobone@gmail.com>18 * Author : Anthony Arobone <aarobone@gmail.com>
19 * Alberto Aldegheri <albyrock87+dev@gmail.com>
19 * (awn_cairo_rounded_rect)20 * (awn_cairo_rounded_rect)
20 * Author : Mark Lee <avant-wn@lazymalevolence.com>21 * Author : Mark Lee <avant-wn@lazymalevolence.com>
21 * (awn_cairo_set_source_color,22 * (awn_cairo_set_source_color,
@@ -42,16 +43,46 @@
42 /* arc with radius == 0.0 doesn't paint anything */43 /* arc with radius == 0.0 doesn't paint anything */
43 if (radius == 0.0) state = ROUND_NONE;44 if (radius == 0.0) state = ROUND_NONE;
4445
45 cairo_move_to (cr, rx0, ry1 - radius);46 /* fix to radius to avoid wrong draws */
47 if (radius > height / 2. && (
48 ((state & ROUND_TOP_LEFT) && (state & ROUND_BOTTOM_LEFT)) ||
49 ((state & ROUND_TOP_RIGHT) && (state & ROUND_BOTTOM_RIGHT))
50 ))
51 {
52 radius = height / 2.;
53 }
54 else if (radius > height)
55 {
56 radius = height;
57 }
58 if (radius > width / 2. && (
59 ((state & ROUND_TOP_LEFT) && (state & ROUND_TOP_RIGHT)) ||
60 ((state & ROUND_BOTTOM_LEFT) && (state & ROUND_BOTTOM_RIGHT))
61 ))
62 {
63 radius = width / 2.;
64 }
65 else if (radius > width)
66 {
67 radius = width;
68 }
4669
47 /* top left corner */70 /* top left corner */
48
49 if (state & ROUND_TOP_LEFT)71 if (state & ROUND_TOP_LEFT)
50 {72 {
73 if (state & ROUND_BOTTOM_LEFT)
74 {
75 cairo_move_to (cr, rx0, ry1 - radius);
76 }
77 else
78 {
79 cairo_move_to (cr, rx0, ry1);
80 }
51 cairo_arc (cr, rx0 + radius, ry0 + radius, radius, M_PI, M_PI * 1.5);81 cairo_arc (cr, rx0 + radius, ry0 + radius, radius, M_PI, M_PI * 1.5);
52 }82 }
53 else83 else
54 {84 {
85 cairo_move_to (cr, rx0, ry1 - radius);
55 cairo_line_to (cr, rx0, ry0);86 cairo_line_to (cr, rx0, ry0);
56 }87 }
5788
5889
=== modified file 'src/awn-applet-manager.c'
--- src/awn-applet-manager.c 2010-04-08 15:38:05 +0000
+++ src/awn-applet-manager.c 2010-07-16 10:54:57 +0000
@@ -88,6 +88,7 @@
88 APPLET_EMBEDDED,88 APPLET_EMBEDDED,
89 APPLET_REMOVED,89 APPLET_REMOVED,
90 SHAPE_MASK_CHANGED,90 SHAPE_MASK_CHANGED,
91 APPLETS_REFRESHED,
9192
92 LAST_SIGNAL93 LAST_SIGNAL
93};94};
@@ -402,7 +403,16 @@
402 NULL, NULL,403 NULL, NULL,
403 g_cclosure_marshal_VOID__VOID,404 g_cclosure_marshal_VOID__VOID,
404 G_TYPE_NONE, 0);405 G_TYPE_NONE, 0);
405 406
407 _applet_manager_signals[APPLETS_REFRESHED] =
408 g_signal_new("applets-refreshed",
409 G_OBJECT_CLASS_TYPE(obj_class),
410 G_SIGNAL_RUN_FIRST,
411 G_STRUCT_OFFSET(AwnAppletManagerClass, applets_refreshed),
412 NULL, NULL,
413 g_cclosure_marshal_VOID__VOID,
414 G_TYPE_NONE, 0);
415
406 g_type_class_add_private (obj_class, sizeof (AwnAppletManagerPrivate));416 g_type_class_add_private (obj_class, sizeof (AwnAppletManagerPrivate));
407}417}
408418
@@ -913,6 +923,7 @@
913 priv->expands = TRUE;923 priv->expands = TRUE;
914 g_object_notify (G_OBJECT (manager), "expands");924 g_object_notify (G_OBJECT (manager), "expands");
915 }925 }
926 g_signal_emit (manager, _applet_manager_signals[APPLETS_REFRESHED], 0);
916}927}
917928
918void929void
@@ -1170,6 +1181,8 @@
1170 g_object_notify (G_OBJECT (manager), "expands");1181 g_object_notify (G_OBJECT (manager), "expands");
11711182
1172 g_list_free (list);1183 g_list_free (list);
1184 /* Emit refresh signal for applets when swithcing docklet mode */
1185 g_signal_emit (manager, _applet_manager_signals[APPLETS_REFRESHED], 0);
1173}1186}
11741187
1175void1188void
@@ -1194,14 +1207,8 @@
1194 g_object_notify (G_OBJECT (manager), "expands");1207 g_object_notify (G_OBJECT (manager), "expands");
11951208
1196 g_list_free (list);1209 g_list_free (list);
1197}1210 /* Emit refresh signal for applets when swithcing docklet mode */
11981211 g_signal_emit (manager, _applet_manager_signals[APPLETS_REFRESHED], 0);
1199gboolean
1200awn_applet_manager_get_docklet_mode (AwnAppletManager *manager)
1201{
1202 g_return_val_if_fail (AWN_IS_APPLET_MANAGER (manager), FALSE);
1203
1204 return manager->priv->docklet_mode;
1205}1212}
12061213
1207void1214void
12081215
=== modified file 'src/awn-applet-manager.h'
--- src/awn-applet-manager.h 2009-11-28 22:33:39 +0000
+++ src/awn-applet-manager.h 2010-07-16 10:54:57 +0000
@@ -66,6 +66,7 @@
66 void (*applet_embedded) (AwnAppletManager *manager, GtkWidget *applet);66 void (*applet_embedded) (AwnAppletManager *manager, GtkWidget *applet);
67 void (*applet_removed) (AwnAppletManager *manager, GtkWidget *applet);67 void (*applet_removed) (AwnAppletManager *manager, GtkWidget *applet);
68 void (*shape_mask_changed) (AwnAppletManager *manager);68 void (*shape_mask_changed) (AwnAppletManager *manager);
69 void (*applets_refreshed) (AwnAppletManager *manager);
69};70};
7071
71GType awn_applet_manager_get_type (void) G_GNUC_CONST;72GType awn_applet_manager_get_type (void) G_GNUC_CONST;
@@ -93,7 +94,6 @@
9394
94void awn_applet_manager_add_docklet (AwnAppletManager *manager,95void awn_applet_manager_add_docklet (AwnAppletManager *manager,
95 GtkWidget *docklet);96 GtkWidget *docklet);
96gboolean awn_applet_manager_get_docklet_mode (AwnAppletManager *manager);
9797
98void awn_applet_manager_redraw_throbbers (AwnAppletManager *manager);98void awn_applet_manager_redraw_throbbers (AwnAppletManager *manager);
9999
100100
=== modified file 'src/awn-background-3d.c'
--- src/awn-background-3d.c 2009-12-22 21:09:43 +0000
+++ src/awn-background-3d.c 2010-07-16 10:54:57 +0000
@@ -15,7 +15,8 @@
15 * along with this program; if not, write to the Free Software15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *17 *
18 * Author : h4writer <hv1989@gmail.com>18 * Original Author : h4writer <hv1989@gmail.com>
19 * Rewrited by: Alberto Aldegheri <albyrock87+dev@gmail.com>
19 *20 *
20 */21 */
2122
@@ -27,22 +28,43 @@
27#include "awn-x.h"28#include "awn-x.h"
2829
29#include <math.h>30#include <math.h>
3031#include "awn-applet-manager.h"
31/* The pixels to draw the side of the panel*/32
32#define SIDE_SPACE 433#define MAX_THICKNESS 12.
34#define PADDING_BOTTOM 1
35#define PADDING_TOP 1
36#define BORDER_LINE_WIDTH 1
37
38/* There is a refresh bug when we are near the left border */
39#define DRAW_XPADDING 2
3340
34/* Some defines for debugging */41/* Some defines for debugging */
35#define DEBUG_DRAW_INTERNAL_BORDER_BOTTOM TRUE42#define DRAW_SIDE TRUE
36#define DEBUG_DRAW_EXTERNAL_BORDER_BOTTOM TRUE43#define DRAW_EXTERNAL_BORDER TRUE
37#define DEBUG_DRAW_SIDE TRUE44/* Internal border isn't good-looking for now */
38#define DEBUG_DRAW_INTERNAL_BORDER_TOP TRUE45/* We need another color, because Inner Border Color */
39#define DEBUG_DRAW_EXTERNAL_BORDER_TOP TRUE46/* is used for paint the side face of 3D */
40#define DEBUG_DRAW_HIGHLIGHT TRUE47#define DRAW_INTERNAL_BORDER FALSE
48#define DRAW_HIGHLIGHT TRUE
49#define CLEAR_TOP_BEFORE_PAINT FALSE
50#define FILL_BOTTOM_PLANE FALSE
4151
52/* Enable this for paint the shape mask */
42#define DEBUG_DRAW_INPUT_SHAPE_MASK FALSE53#define DEBUG_DRAW_INPUT_SHAPE_MASK FALSE
4354
55#define TRANSFORM_RADIUS(x) (x / 90. * 75)
56#define OBTAIN_THICKNESS(rad,thick) (floor(sin(TRANSFORM_RADIUS(rad)*\
57 M_PI/180.)*MAX_THICKNESS*thick))
58
44G_DEFINE_TYPE (AwnBackground3d, awn_background_3d, AWN_TYPE_BACKGROUND)59G_DEFINE_TYPE (AwnBackground3d, awn_background_3d, AWN_TYPE_BACKGROUND)
4560
61struct _Point3
62{
63 float x;
64 float y;
65 float z;
66};
67typedef struct _Point3 Point3;
46/* FORWARDS */68/* FORWARDS */
47static void awn_background_3d_padding_request (AwnBackground *bg,69static void awn_background_3d_padding_request (AwnBackground *bg,
48 GtkPositionType position,70 GtkPositionType position,
@@ -83,6 +105,14 @@
83 g_signal_connect (bg, "notify::panel-angle", 105 g_signal_connect (bg, "notify::panel-angle",
84 G_CALLBACK (awn_background_3d_update_padding), 106 G_CALLBACK (awn_background_3d_update_padding),
85 NULL);107 NULL);
108
109 g_signal_connect (bg, "notify::corner-radius",
110 G_CALLBACK (awn_background_3d_update_padding),
111 NULL);
112
113 g_signal_connect (bg, "notify::thickness",
114 G_CALLBACK (awn_background_3d_update_padding),
115 NULL);
86}116}
87117
88static void118static void
@@ -160,32 +190,18 @@
160 * @param x: the x pos in the flat dimension190 * @param x: the x pos in the flat dimension
161 * @param y: the y pos in the perspective191 * @param y: the y pos in the perspective
162 * 192 *
163 * Calculates the x position of the point (x,y) in the flat dimension brought back in the perspective193 * Calculates the x position of the point (x,y) in the flat dimension
194 * brought back in the perspective
164 * note: - the bottom left corner is (0,0)195 * note: - the bottom left corner is (0,0)
165 * - the bottom right corner should be (width, 0)196 * - the bottom right corner should be (width, 0)
166 *197 *
167 * Returns: gives the x position back of the point (x,y) in the flat dimension brought back in the perspective198 * Returns: gives the x position back of the point (x,y) in the flat dimension
199 * brought back in the perspective
168 */200 */
169static double201static double
170apply_perspective_x( double width, double angle, double x, double y )202apply_perspective_x( double width, double angle, double x, double y )
171{203{
172 return (width/2.0-x)/(width/2.0*tan((90-angle)*M_PI/180))*y+x;204 return (width/2.0-x)/(width/2.0*tan((90-angle)*M_PI/180)*1.5)*y+x;
173}
174
175/**
176 * get_width_on_height:
177 * @param width: the current width of the bar
178 * @param angle: the angle the bar will have
179 * @param y: the y pos in the perspective
180 *
181 * Calculates the width of the bar on a given y-pos (in the perspective)
182 *
183 * Returns: a double containing the width
184 */
185static double
186get_width_on_height( double width, double angle, double y )
187{
188 return width-2*y/tan((90-angle)*M_PI/180);
189}205}
190206
191/**207/**
@@ -194,100 +210,164 @@
194 * @param point2: control point 2210 * @param point2: control point 2
195 * @param point3: control point 3211 * @param point3: control point 3
196 * @param point4: control point 4212 * @param point4: control point 4
197 * @param t: the position between O and 1 (0 gives back point1, 1 gives back point4)213 * @param t: the position between O and 1
198 *214 * (0 gives back point1, 1 gives back point4)
199 * This function is used to get back the left most position of the rounded corner,215 *
200 * to let the side of the bar begin there.216 * This function is used to get back the left most position of the rounded
201 *217 * corner to let the side of the bar begin there.
202 * - Note: Not used atm. Can be I need it later on, but for now it's commented out.218 *
203 *219 * Note: Not used atm. Can be I need it later on, but for now it's commented out
204 * Returns: gives back the position of the cubic bezier curve constructed with these control points 220 *
221 * Returns: gives back the position of the cubic bezier curve constructed with
222 * these control points
205 */223 */
206/*static double cubic_bezier_curve(double point1, double point2, double point3, double point4, double t)224/*static double cubic_bezier_curve(double point1, double point2, double point3,
225 double point4, double t)
207{226{
208 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;227 return (1-t)*(1-t)*(1-t)*point1 + 3*t*(1-t)*(1-t)*point2 +
228 3*t*t*(1-t)*point3 + t*t*t*point4;
209}*/229}*/
210230
211231/**
212/*232 * calc_points
213 * Drawing functions233 * @param bg: AwnBackground
234 * @param x: the begin x position to draw
235 * @param y: the begin y position to draw
236 * @param width: the width for the drawing
237 * @param height: the height for the drawing
238 *
239 * Calculates vertices to draw the path
214 */240 */
215241static Point3*
242calc_points (AwnBackground *bg,
243 float x,
244 float y,
245 float width,
246 float height)
247{
248 float xp0, xp1, xp2, xp3, yp0, yp1, yp2, yp3;
249 float radius = bg->corner_radius;
250 /**
251 * rb = decrease the radius on bottom vertices
252 * ex = increase the x-radius on top vertices
253 */
254 float rb = 0., ex = 0.;
255 /* calc sin and cos for current angle */
256 float s = sin (TRANSFORM_RADIUS (bg->panel_angle) * M_PI / 180.);
257 float c = cos (TRANSFORM_RADIUS (bg->panel_angle) * M_PI / 180.);
258
259 /* Adjust radius */
260 if (radius > height)
261 {
262 ex = radius - height;
263 radius = height;
264 }
265 if (radius > height / 2.)
266 {
267 rb = 2. * radius - height;
268 }
269 if (radius == 0.)
270 {
271 /* for nice edges */
272 radius = 0.5;
273 }
274
275 /* Carefull: here (0,0) is in the top left corner of the screen
276 */
277 /* 0 1 2 3
278 * A x0 x1 x2 x3 B
279 * |___|___________________|___|__y0
280 * 11 | |__y1 4
281 * | |
282 * 10 | |__y2 5
283 * |___________________________|__y3 6
284 * D 9 8 7 C
285 *
286 * WARNING!! When draw the path, remember that ->
287 * A becomes D
288 * B becomes C
289 */
290 xp0 = 0.;
291 xp1 = radius;
292 xp2 = width - radius;
293 xp3 = width;
294
295 yp0 = 0.;
296 yp1 = radius;
297 yp2 = height - radius;
298 yp3 = height;
299
300 Point3 *vertices = (Point3 *) malloc (sizeof (Point3) * 12);
301 float z = 2;
302 vertices[0] = (Point3){xp0, yp0, z};
303 vertices[1] = (Point3){xp1 - rb, yp0, z};
304 vertices[2] = (Point3){xp2 + rb, yp0, z};
305 vertices[3] = (Point3){xp3, yp0, z};
306 vertices[4] = (Point3){xp3, yp1 - rb, z};
307 vertices[5] = (Point3){xp3, yp2, z};
308 vertices[6] = (Point3){xp3, yp3, z};
309 vertices[7] = (Point3){xp2 - ex, yp3, z};
310 vertices[8] = (Point3){xp1 + ex, yp3, z};
311 vertices[9] = (Point3){xp0, yp3, z};
312 vertices[10] = (Point3){xp0, yp2, z};
313 vertices[11] = (Point3){xp0, yp1 - rb, z};
314
315 int i = 0;
316
317 for (; i < 12; ++i)
318 {
319 /* 3D ROTATION OVER X AXIS */
320 vertices[i].y = c * vertices[i].y - s * vertices[i].z;
321 vertices[i].z = s * vertices[i].y + c * vertices[i].z;
322
323 /* 3D to 2D - For now, use apply_perspective_x
324 * maybe in the future we use projection matrix
325 */
326 vertices[i].x = apply_perspective_x (width,
327 TRANSFORM_RADIUS(bg->panel_angle),
328 vertices[i].x,
329 vertices[i].y ) + x;
330 /* Invert coordinates for our Y coordinate system cutted to int */
331 vertices[i].y = floor (height - vertices[i].y + y);
332 }
333 /* use vertices[8]->y to find the top coordinate of the panel */
334 return vertices;
335}
216/**336/**
217 * draw_rect_path:337 * draw_rect_path:
218 * @param bg: AwnBackground
219 * @param cr: a cairo context 338 * @param cr: a cairo context
220 * @param x: the begin x position to draw 339 * @param vertices: vertices to use for drawing
221 * @param y: the begin y position to draw340 * @param padding: padding from top
222 * @param width: the width for the drawing341 *
223 * @param height: the height for the drawing
224 * @param padding: makes the path X amount of pixels smaller on every side
225 *
226 * This function draws the path of the bar in perspective.342 * This function draws the path of the bar in perspective.
227 */343 */
228static void 344static void
229draw_rect_path (AwnBackground *bg,345draw_rect_path (cairo_t *cr, Point3 *vertices, float padding)
230 cairo_t *cr,
231 gdouble x,
232 gdouble y,
233 gint width,
234 gint height,
235 gint padding)
236{346{
237 double x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11,347
238 cy0, cy1, cy2, cy3;348 /* Let's make the path '*/
239 double radius = bg->corner_radius;349 cairo_new_path (cr);
240350 cairo_move_to (cr, vertices[1].x, vertices[1].y + padding);
241 /* Carefull: here (0,0) is in the top left corner of the screen351
242 * (x3,cy3) (x4,cy3) (x5,cy3) (x6,cy3)352 cairo_line_to (cr, vertices[2].x, vertices[2].y + padding);
243 * '-., | | ,.-'353 cairo_curve_to (cr, vertices[2].x, vertices[2].y + padding,
244 * (x2,cy2)___.-''''''''''''''''-.___(x7,cy2)354 vertices[3].x, vertices[3].y + padding,
245 * / \355 vertices[4].x, vertices[4].y + padding);
246 * (x1,cy1)___/ \___(x8,cy1)356
247 * '.____________________.'357 cairo_line_to (cr, vertices[5].x, vertices[5].y + padding);
248 * (x0,cy0)--'´| | `'--(x9,cy0)358 cairo_curve_to (cr, vertices[6].x, vertices[6].y + padding,
249 * (x11,cy0) (x10,cy0)359 vertices[7].x, vertices[7].y + padding,
250 */360 vertices[7].x, vertices[7].y + padding);
251361
252 x0 = x + apply_perspective_x(width, bg->panel_angle, padding, padding);362 cairo_line_to (cr, vertices[8].x, vertices[8].y + padding);
253 x1 = x + apply_perspective_x(width, bg->panel_angle, padding, radius+padding);363 cairo_curve_to (cr, vertices[8].x, vertices[8].y + padding,
254 x2 = x + apply_perspective_x(width, bg->panel_angle, padding, height/2.0-radius-padding);364 vertices[9].x, vertices[9].y + padding,
255 x3 = x + apply_perspective_x(width, bg->panel_angle, padding, height/2.0-padding);365 vertices[10].x, vertices[10].y + padding);
256 x4 = x + apply_perspective_x(width, bg->panel_angle, radius+padding, height/2.0-padding);366
257 x5 = x + apply_perspective_x(width, bg->panel_angle, width-radius-padding, height/2.0-padding);367 cairo_line_to (cr, vertices[11].x, vertices[11].y + padding);
258 x6 = x + apply_perspective_x(width, bg->panel_angle, width-padding, height/2.0-padding);368 cairo_curve_to (cr, vertices[0].x, vertices[0].y + padding,
259 x7 = x + apply_perspective_x(width, bg->panel_angle, width-padding, height/2.0-radius-padding);369 vertices[1].x, vertices[1].y + padding,
260 x8 = x + apply_perspective_x(width, bg->panel_angle, width-padding, radius+padding);370 vertices[1].x, vertices[1].y + padding);
261 x9 = x + apply_perspective_x(width, bg->panel_angle, width-padding, padding);
262 x10 = x + apply_perspective_x(width, bg->panel_angle, width-radius-padding, padding);
263 x11 = x + apply_perspective_x(width, bg->panel_angle, radius+padding, padding);
264
265 cy0 = y + height - padding;
266 cy1 = y + height - radius - padding;
267 cy2 = y + height/2.0 + radius + padding;
268 cy3 = y + height/2.0 + padding;
269
270 cairo_move_to(cr, x2, cy2);
271 cairo_curve_to(cr, x3, cy3, x3, cy3, x4, cy3);
272 cairo_line_to(cr, x5, cy3);
273 cairo_curve_to(cr, x6, cy3, x6, cy3, x7, cy2);
274 if( x8 > x7 )
275 {
276 /* draw the rounded corners on the bottom too */
277 cairo_line_to(cr, x8, cy1);
278 cairo_curve_to(cr, x9, cy0, x9, cy0, x10, cy0);
279 cairo_line_to(cr, x11, cy0);
280 cairo_curve_to(cr, x0, cy0, x0, cy0, x1, cy1);
281 cairo_line_to(cr, x2, cy2);
282 }
283 else
284 {
285 /* the radius is to big, so only draw the rounded corners on the top. On the bottom just ordinary corners. */
286 cairo_line_to(cr, x9, cy0);
287 cairo_line_to(cr, x0, cy0);
288 cairo_line_to(cr, x2, cy2);
289 }
290
291 cairo_close_path(cr);371 cairo_close_path(cr);
292}372}
293373
@@ -304,111 +384,214 @@
304static void384static void
305draw_top_bottom_background (AwnBackground *bg,385draw_top_bottom_background (AwnBackground *bg,
306 cairo_t *cr,386 cairo_t *cr,
307 gint width,387 gfloat width,
308 gint height)388 gfloat height)
309{389{
310#if DEBUG_DRAW_SIDE
311 int i;
312#endif
313 cairo_pattern_t *pat;390 cairo_pattern_t *pat;
391 float s = OBTAIN_THICKNESS (bg->panel_angle, bg->thickness);
314392
315 height -= SIDE_SPACE;393 height -= (s + PADDING_BOTTOM + 1.);
316394
317 /* Basic set-up */395 /* Basic set-up */
318 cairo_set_line_width (cr, 1.0);396 cairo_set_line_width (cr, 1.0);
319 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);397 /* Translate for sharp edges and for avoid drawing's glitches */
320 cairo_translate (cr, 0.5, 0.5);398 cairo_translate (cr, DRAW_XPADDING, 0.5);
321399 width -= DRAW_XPADDING * 2.;
322#if DEBUG_DRAW_INTERNAL_BORDER_BOTTOM400
323 /* Internal border (on the bottom) */401 /* calc vertices for draw the main path */
324 awn_cairo_set_source_color (cr, bg->hilight_color),402 Point3 *vertices = calc_points (bg, 0., 0., width, height);
325 draw_rect_path (bg, cr, 0, SIDE_SPACE, width, height, 1);403 /* calc the y coord of the top panel, used for pattern painting */
326 cairo_stroke (cr);404 float top_y = vertices[8].y;
327#endif405
328406 double red, green, blue, alpha;
329#if DEBUG_DRAW_EXTERNAL_BORDER_BOTTOM407 /* Save general context */
330 /* External border (on the bottom) */408 cairo_save (cr);
331 awn_cairo_set_source_color (cr, bg->border_color);409#if DRAW_SIDE
332 draw_rect_path (bg, cr, 0, SIDE_SPACE, width, height, 0.5);410 /* Internal border (The Side of the 3D panel) */
333 cairo_stroke (cr);411 /* Draw only if it will be visible */
334412 if (bg->panel_angle > 0)
335 /* Draw the background (on the bottom) */
336 //FIXME: I'm doubting if it is nicer with or without the bottom background drawn
337 /*pat = cairo_pattern_create_linear (0, 0, 0, height);
338 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_step_1);
339 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);
340
341 draw_rect_path (bg, cr, 0, 0, width, height, 0.5);
342 cairo_set_source (cr, pat);
343 cairo_fill (cr);
344
345 cairo_pattern_destroy (pat);*/
346
347 /* draw the side */
348 /* TODO: if a side has no rounded corners, the border should be drawn. */
349 pat = cairo_pattern_create_linear (0, 0, 0, height);
350 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_step_1);
351 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);
352 cairo_set_source (cr, pat);
353 for(i=SIDE_SPACE-1; i>0; i--)
354 {413 {
355 draw_rect_path (bg, cr, 0, i, width, height, 0.5);414 float i;
356 cairo_stroke (cr);415
416 /* Draw bottom plane (Inner Border Color) with
417 * its own border (Outer Border Color)
418 */
419 desktop_agnostic_color_get_cairo_color
420 (bg->hilight_color, &red, &green, &blue, &alpha);
421 /* if side is transparent (1. / 255.), don't draw bottom border */
422 if (alpha > 0.003)
423 {
424 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
425 draw_rect_path (cr, vertices, s);
426#if FILL_BOTTOM_PLANE
427 cairo_save (cr);
428 awn_cairo_set_source_color (cr, bg->hilight_color);
429 cairo_clip (cr);
430 cairo_paint (cr);
431 cairo_restore (cr);
432#endif
433 cairo_set_line_width (cr, BORDER_LINE_WIDTH);
434 awn_cairo_set_source_color (cr, bg->border_color);
435 cairo_stroke (cr);
436
437 /* Pixel per Pixel draw each plane only with border from bottom to top */
438 cairo_set_line_width (cr, 1.5);
439 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
440 for (i = s - 1.; i >= 0. ; i -= 1.)
441 {
442 draw_rect_path (cr, vertices, i);
443 awn_cairo_set_source_color (cr, bg->hilight_color);
444 cairo_stroke (cr);
445 }
446 /* draw edges lines if corner-radius is smaller then 3px */
447 if (bg->corner_radius < 4 || bg->corner_radius > (height - 3))
448 {
449 double alpha_coeff = bg->corner_radius;
450 cairo_move_to (cr, vertices[0].x, vertices[0].y);
451 cairo_line_to (cr, vertices[0].x, vertices[0].y + s);
452 cairo_move_to (cr, vertices[3].x, vertices[3].y);
453 cairo_line_to (cr, vertices[3].x, vertices[3].y + s);
454 if (bg->corner_radius < 4)
455 {
456 cairo_move_to (cr, vertices[6].x, vertices[6].y);
457 cairo_line_to (cr, vertices[6].x, vertices[6].y + s);
458 cairo_move_to (cr, vertices[9].x, vertices[9].y);
459 cairo_line_to (cr, vertices[9].x, vertices[9].y + s);
460 }
461 else
462 {
463 alpha_coeff = fabs (MIN (bg->corner_radius, height) - height);
464 }
465 alpha_coeff = (1.0 - alpha_coeff / 3.);
466 cairo_set_line_width (cr, BORDER_LINE_WIDTH);
467 desktop_agnostic_color_get_cairo_color
468 (bg->border_color, &red, &green, &blue, &alpha);
469 /* edges fade effect when increasing the corner radius from 0 to 3 */
470 cairo_set_source_rgba (cr, red, green, blue,
471 alpha * alpha_coeff);
472 cairo_stroke (cr);
473 }
474 }
475 /* Clear the area for the top plane
476 *-> hides "back border" when top is transparent
477 *-> disabled for now...
478 */
479#if CLEAR_TOP_BEFORE_PAINT
480 cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
481 draw_rect_path (cr, vertices, 0.);
482 cairo_save (cr);
483 cairo_set_source_rgba (cr, 0., 0., 0., 1.);
484 cairo_clip (cr);
485 cairo_paint (cr);
486 cairo_restore (cr);
487#endif
357 }488 }
489#endif
490 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
491 cairo_set_line_width (cr, 2.);
492 /* Draw the path of top plane */
493 draw_rect_path (cr, vertices, 0.);
494 /* obtain 0.0 - 1.0 relative height for pattern drawing */
495 top_y = top_y / height;
358496
497 /* Paint the top plane gradient */
498 pat = cairo_pattern_create_linear (0., 0., 0., height);
499 awn_cairo_pattern_add_color_stop_color (pat, top_y, bg->g_step_1);
500 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);
501 cairo_save (cr);
502 cairo_clip_preserve (cr);
503 cairo_set_source (cr, pat);
504 cairo_paint (cr);
359 cairo_pattern_destroy (pat);505 cairo_pattern_destroy (pat);
360#endif506 cairo_restore (cr);
361507
362 /* Draw the background (on the top) */
363 if (bg->enable_pattern && bg->pattern)508 if (bg->enable_pattern && bg->pattern)
364 {509 {
510 /* Paint the top plane pattern */
511 cairo_save (cr);
365 pat = cairo_pattern_create_for_surface (bg->pattern);512 pat = cairo_pattern_create_for_surface (bg->pattern);
366 cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT);513 cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT);
367 }514 cairo_clip_preserve (cr);
368 else515 cairo_set_source (cr, pat);
369 {516 cairo_paint (cr);
370 pat = cairo_pattern_create_linear (0, 0, 0, height);517 cairo_pattern_destroy (pat);
371 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_step_1);518 cairo_restore (cr);
372 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);519 }
373 }520
374521#if DRAW_HIGHLIGHT
522 /* Prepare the hi-light */
523 pat = cairo_pattern_create_linear (0., 0., 0., height);
524 awn_cairo_pattern_add_color_stop_color
525 (pat, top_y + 0.0, bg->g_histep_1);
526 awn_cairo_pattern_add_color_stop_color
527 (pat, top_y + (1. - top_y) * 0.3, bg->g_histep_2);
528
529 desktop_agnostic_color_get_cairo_color
530 (bg->g_histep_2, &red, &green, &blue, &alpha);
531 cairo_pattern_add_color_stop_rgba
532 (pat, top_y + (1. - top_y) * 0.4, red, green, blue, 0.);
533 /* Paint the hi-light gradient */
375 cairo_save (cr);534 cairo_save (cr);
376535 cairo_clip_preserve (cr);
377 draw_rect_path (bg, cr, 0, 0, width, height, 0.5);
378 cairo_clip (cr);
379 cairo_set_source (cr, pat);536 cairo_set_source (cr, pat);
380 cairo_paint (cr);537 cairo_paint (cr);
381
382 cairo_restore (cr);538 cairo_restore (cr);
383539 cairo_pattern_destroy (pat);
384 cairo_pattern_destroy (pat);540#endif
385541#if DRAW_INTERNAL_BORDER
386#if DEBUG_DRAW_HIGHLIGHT542 /* Internal border of the top surface */
387 /* Draw the hi-light (on the top) */543 desktop_agnostic_color_get_cairo_color
388 pat = cairo_pattern_create_linear (0, height/3.0, 0, height*2.0/3.0);544 (bg->border_color, &red, &green, &blue, &alpha);
389 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_histep_1);545 /* for glass-look don't draw internal border if there is no external border */
390 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_histep_2);546 if (alpha > 0.003)
391 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);547 {
392548 cairo_save (cr);
393 cairo_set_source (cr, pat);549 cairo_scale (cr, (width - 2.) / (width), (height - 2.) / (height));
394 cairo_fill (cr);550 cairo_translate (cr, 1., 1.);
395 cairo_pattern_destroy (pat);551 draw_rect_path (cr, vertices, 0.);
396#endif552 cairo_set_line_width (cr, BORDER_LINE_WIDTH + 0.5);
397553 awn_cairo_set_source_color (cr, bg->hilight_color);
398#if DEBUG_DRAW_INTERNAL_BORDER_TOP554 cairo_stroke (cr);
399 /* Internal border (on the top) */555 cairo_restore (cr);
400 awn_cairo_set_source_color (cr, bg->hilight_color);556 draw_rect_path (cr, vertices, 0.);
401 draw_rect_path (bg, cr, 0, 0, width, height, 1);557 }
558#endif
559#if DRAW_EXTERNAL_BORDER
560 /* External border */
561 cairo_set_line_width (cr, BORDER_LINE_WIDTH);
562 awn_cairo_set_source_color (cr, bg->border_color);
402 cairo_stroke (cr);563 cairo_stroke (cr);
403#endif564#endif
404565 /* restore genereal context */
405#if DEBUG_DRAW_EXTERNAL_BORDER_BOTTOM566 cairo_restore (cr);
406 /* External border (on the top) */567 /* free memory :) */
407 awn_cairo_set_source_color (cr, bg->border_color);568 free (vertices);
408 draw_rect_path (bg, cr, 0, 0, width, height, 0.5);569}
409 cairo_stroke (cr);570
410#endif571/**
411572 * _get_applet_manager_size
573 * Obtain width and height from applet manager
574 */
575static void
576_get_applet_manager_size (AwnBackground* bg, GtkPositionType position,
577 float *w, float *h)
578{
579 AwnAppletManager *manager = NULL;
580 g_object_get (bg->panel, "applet-manager", &manager, NULL);
581
582 switch (position)
583 {
584 case GTK_POS_BOTTOM:
585 case GTK_POS_TOP:
586 *w = GTK_WIDGET (manager)->allocation.width;
587 break;
588 default:
589 *w = GTK_WIDGET (manager)->allocation.height;
590 break;
591 }
592 gint size = 0;
593 g_object_get (manager, "size", &size, NULL);
594 *h = size;
412}595}
413596
414/**597/**
@@ -436,33 +619,54 @@
436 guint padding;619 guint padding;
437 g_object_get (bg->panel, "offset", &offset, "size", &size, NULL);620 g_object_get (bg->panel, "offset", &offset, "size", &size, NULL);
438621
439 if(offset > size)622 /* Find the coordinate of the (0;0) point in the prospective */
440 padding = (size+offset)/2.0/tan((90-bg->panel_angle)*M_PI/180);623 /* Its X coordinate is equal to the padding */
441 else624 float w,h;
442 {625 _get_applet_manager_size (bg, position, &w, &h);
443 double angle = 90 - CLAMP (bg->panel_angle, 0.0, 75.0);626 padding = apply_perspective_x
444 double y_pos = size / 2.0 + bg->corner_radius;627 ( w, TRANSFORM_RADIUS(bg->panel_angle), 0., h );
445 double x = y_pos / tan (angle * M_PI/180);628 /* Padding > h is not needed */
446 padding = MAX (x, offset);629 if (padding > h)
447 }630 {
631 padding = h;
632 }
633
634 /* Obtain the padding from corner radius */
635 float padding_from_rad = bg->corner_radius;
636
637 if (padding_from_rad > h)
638 {
639 padding_from_rad = h;
640 }
641 if (padding_from_rad > (h / 2.))
642 {
643 padding_from_rad = ( h - padding_from_rad );
644 }
645 /* Sum padding needed */
646 padding = MAX (padding, padding_from_rad) + DRAW_XPADDING;
647 float s = OBTAIN_THICKNESS (bg->panel_angle, bg->thickness);
448648
449 switch (position)649 switch (position)
450 {650 {
451 case GTK_POS_TOP:651 case GTK_POS_TOP:
452 *padding_top = SIDE_SPACE+2; *padding_bottom = 0;652 *padding_top = PADDING_BOTTOM + s;
653 *padding_bottom = PADDING_TOP;
453 *padding_left = padding; *padding_right = padding;654 *padding_left = padding; *padding_right = padding;
454 break;655 break;
455 case GTK_POS_BOTTOM:656 case GTK_POS_BOTTOM:
456 *padding_top = 0; *padding_bottom = SIDE_SPACE+2;657 *padding_top = PADDING_TOP;
658 *padding_bottom = PADDING_BOTTOM + s;
457 *padding_left = padding; *padding_right = padding;659 *padding_left = padding; *padding_right = padding;
458 break;660 break;
459 case GTK_POS_LEFT:661 case GTK_POS_LEFT:
460 *padding_top = padding; *padding_bottom = padding;662 *padding_top = padding; *padding_bottom = padding;
461 *padding_left = SIDE_SPACE+2; *padding_right = 0;663 *padding_left = PADDING_BOTTOM + s;
664 *padding_right = PADDING_TOP;
462 break;665 break;
463 case GTK_POS_RIGHT:666 case GTK_POS_RIGHT:
464 *padding_top = padding; *padding_bottom = padding;667 *padding_top = padding; *padding_bottom = padding;
465 *padding_left = 0; *padding_right = SIDE_SPACE+2;668 *padding_left = PADDING_TOP;
669 *padding_right = PADDING_BOTTOM + s;
466 break;670 break;
467 default:671 default:
468 break;672 break;
@@ -482,7 +686,8 @@
482 * Draws the bar in the in the cairo context &cr given the position &position,686 * Draws the bar in the in the cairo context &cr given the position &position,
483 * the &x and &y position and given &width and &height687 * the &x and &y position and given &width and &height
484 *688 *
485 * Important: every change to this function should get adjusted in input_shape_mask!!!689 * Important: every change to this function should get
690 * adjusted in input_shape_mask!!!
486 */691 */
487static void 692static void
488awn_background_3d_draw (AwnBackground *bg,693awn_background_3d_draw (AwnBackground *bg,
@@ -498,23 +703,27 @@
498 switch (position)703 switch (position)
499 {704 {
500 case GTK_POS_RIGHT:705 case GTK_POS_RIGHT:
501 cairo_translate (cr, x-1, y+height);706 cairo_translate (cr, 0., y + height);
707 cairo_scale (cr, 1., -1.);
708 cairo_translate (cr, x, height);
502 cairo_rotate (cr, M_PI * 1.5);709 cairo_rotate (cr, M_PI * 1.5);
503 temp = width;710 temp = width;
504 width = height; height = temp;711 width = height;
712 height = temp;
505 break;713 break;
506 case GTK_POS_LEFT:714 case GTK_POS_LEFT:
507 cairo_translate (cr, x+width+1, y);715 cairo_translate (cr, x + width, y);
508 cairo_rotate (cr, M_PI * 0.5);716 cairo_rotate (cr, M_PI * 0.5);
509 temp = width;717 temp = width;
510 width = height; height = temp;718 width = height;
719 height = temp;
511 break;720 break;
512 case GTK_POS_TOP:721 case GTK_POS_TOP:
513 cairo_translate (cr, x+width, y+height+1);722 cairo_translate (cr, x, y + height);
514 cairo_rotate (cr, M_PI);723 cairo_scale (cr, 1., -1.);
515 break;724 break;
516 default:725 default:
517 cairo_translate (cr, x, y-1);726 cairo_translate (cr, x, y);
518 break;727 break;
519 }728 }
520729
@@ -543,50 +752,55 @@
543 GtkPositionType position,752 GtkPositionType position,
544 GdkRectangle *area)753 GdkRectangle *area)
545{754{
546 int i;755 gfloat temp;
547 gint temp;756 gfloat x = area->x, y = area->y;
548 gint x = area->x, y = area->y;757 gfloat width = area->width, height = area->height;
549 gint width = area->width, height = area->height;
550 cairo_save (cr);758 cairo_save (cr);
551759
552 switch (position)760 switch (position)
553 {761 {
554 case GTK_POS_RIGHT:762 case GTK_POS_RIGHT:
555 cairo_translate (cr, x-1, y+height);763 cairo_translate (cr, 0., y + height);
764 cairo_scale (cr, 1., -1.);
765 cairo_translate (cr, x, height);
556 cairo_rotate (cr, M_PI * 1.5);766 cairo_rotate (cr, M_PI * 1.5);
557 temp = width;767 temp = width;
558 width = height; height = temp;768 width = height;
769 height = temp;
559 break;770 break;
560 case GTK_POS_LEFT:771 case GTK_POS_LEFT:
561 cairo_translate (cr, x+width+1, y);772 cairo_translate (cr, x + width, y);
562 cairo_rotate (cr, M_PI * 0.5);773 cairo_rotate (cr, M_PI * 0.5);
563 temp = width;774 temp = width;
564 width = height; height = temp;775 width = height;
776 height = temp;
565 break;777 break;
566 case GTK_POS_TOP:778 case GTK_POS_TOP:
567 cairo_translate (cr, x+width, y+height+1);779 cairo_translate (cr, x, y + height);
568 cairo_rotate (cr, M_PI);780 cairo_scale (cr, 1., -1.);
569 break;781 break;
570 default:782 default:
571 cairo_translate (cr, x, y-1);783 cairo_translate (cr, x, y);
572 break;784 break;
573 }785 }
574786 float s = OBTAIN_THICKNESS (bg->panel_angle, bg->thickness);
575 height -= SIDE_SPACE;787
576788 height -= (s + PADDING_BOTTOM + 1.);
577 /* Basic set-up */789 /* Basic set-up */
578 cairo_set_line_width (cr, 1.0);790 cairo_set_line_width (cr, 1.0);
579 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);791 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
580 cairo_translate (cr, 0.5, 0.5);792 cairo_translate (cr, DRAW_XPADDING, 0.5);
581793 width -= DRAW_XPADDING * 2.;
582 /* Draw the background (in black color*/794
583 cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0);795 /* Draw the background (in black color) */
584796 cairo_set_source_rgba(cr, 0., 0., 0., 1.);
585 for(i=SIDE_SPACE-1; i>-1; i--)797 /* for shape mask draw only top and bottom plane */
586 {798 Point3 *vertices = calc_points (bg, 0., 0., width, height);
587 draw_rect_path (bg, cr, 0, i, width, height, 0.5);799 draw_rect_path (cr, vertices, 0.);
588 cairo_fill (cr);800 cairo_fill (cr);
589 }801 draw_rect_path (cr, vertices, s);
802 cairo_fill (cr);
803 free (vertices);
590804
591 cairo_restore (cr);805 cairo_restore (cr);
592}806}
593807
=== modified file 'src/awn-background-edgy.c'
--- src/awn-background-edgy.c 2010-03-07 18:38:07 +0000
+++ src/awn-background-edgy.c 2010-07-16 10:54:57 +0000
@@ -16,6 +16,7 @@
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *17 *
18 * Author : Michal Hruby <michal.mhr@gmail.com>18 * Author : Michal Hruby <michal.mhr@gmail.com>
19 * Adjusted by: Alberto Aldegheri <albyrock87+dev@gmail.com>
19 *20 *
20 */21 */
2122
@@ -106,7 +107,8 @@
106static void107static void
107awn_background_edgy_align_changed (AwnBackgroundEdgy *bg) // has more params...108awn_background_edgy_align_changed (AwnBackgroundEdgy *bg) // has more params...
108{109{
109 gfloat align = awn_background_get_panel_alignment (AWN_BACKGROUND (bg));110 AwnBackground *abg = AWN_BACKGROUND (bg);
111 gfloat align = awn_background_get_panel_alignment (abg);
110 gboolean in_corner = align == 0.0 || align == 1.0;112 gboolean in_corner = align == 0.0 || align == 1.0;
111 if (bg->priv->in_corner != in_corner)113 if (bg->priv->in_corner != in_corner)
112 {114 {
@@ -120,21 +122,27 @@
120 else122 else
121 {123 {
122 gtk_widget_hide (bg->priv->separator);124 gtk_widget_hide (bg->priv->separator);
123 awn_background_emit_padding_changed (AWN_BACKGROUND (bg));125 awn_background_emit_padding_changed (abg);
124 }126 }
125 }127 }
126128
127 if (in_corner)129 if (in_corner)
128 {130 {
129 AwnAppletManager *manager;131 AwnAppletManager *manager;
130 g_object_get (AWN_BACKGROUND (bg)->panel, "applet-manager", &manager, NULL);132 g_object_get (abg->panel, "applet-manager", &manager, NULL);
131 awn_applet_manager_add_widget (manager, bg->priv->separator,133 awn_applet_manager_add_widget (manager, bg->priv->separator,
132 awn_background_edgy_separator_pos (bg, align));134 awn_background_edgy_separator_pos (bg, align));
133 awn_background_emit_padding_changed (AWN_BACKGROUND (bg));135 awn_background_emit_padding_changed (abg);
134 }136 }
135}137}
136138
137static void139static void
140awn_background_edgy_widgets_changed (AwnBackground *bg)
141{
142 awn_background_emit_padding_changed (bg);
143}
144
145static void
138awn_background_edgy_constructed (GObject *object)146awn_background_edgy_constructed (GObject *object)
139{147{
140 G_OBJECT_CLASS (awn_background_edgy_parent_class)->constructed (object);148 G_OBJECT_CLASS (awn_background_edgy_parent_class)->constructed (object);
@@ -152,7 +160,11 @@
152160
153 AwnAppletManager *manager;161 AwnAppletManager *manager;
154 g_object_get (panel, "applet-manager", &manager, NULL);162 g_object_get (panel, "applet-manager", &manager, NULL);
163 g_return_if_fail (manager);
155 awn_applet_manager_add_widget (manager, bg->priv->separator, 1);164 awn_applet_manager_add_widget (manager, bg->priv->separator, 1);
165 g_signal_connect_swapped (manager, "applets-refreshed",
166 G_CALLBACK (awn_background_edgy_widgets_changed), bg);
167
156168
157 gpointer monitor = NULL;169 gpointer monitor = NULL;
158 g_object_get (panel, "monitor", &monitor, NULL);170 g_object_get (panel, "monitor", &monitor, NULL);
@@ -196,6 +208,12 @@
196208
197 GtkWidget *widget = AWN_BACKGROUND_EDGY_GET_PRIVATE (object)->separator;209 GtkWidget *widget = AWN_BACKGROUND_EDGY_GET_PRIVATE (object)->separator;
198210
211 if (manager)
212 {
213 g_signal_handlers_disconnect_by_func (manager,
214 G_CALLBACK (awn_background_edgy_widgets_changed), object);
215 }
216
199 if (manager && widget)217 if (manager && widget)
200 {218 {
201 awn_applet_manager_remove_widget (manager, widget);219 awn_applet_manager_remove_widget (manager, widget);
@@ -276,7 +294,6 @@
276294
277 /* Basic set-up */295 /* Basic set-up */
278 cairo_set_line_width (cr, 1.0);296 cairo_set_line_width (cr, 1.0);
279 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
280297
281 if (gtk_widget_is_composited (GTK_WIDGET (bg->panel)) == FALSE)298 if (gtk_widget_is_composited (GTK_WIDGET (bg->panel)) == FALSE)
282 {299 {
@@ -313,6 +330,7 @@
313 draw_path(cr, height - 1.0, width, height, bottom_left);330 draw_path(cr, height - 1.0, width, height, bottom_left);
314 cairo_line_to (cr, bottom_left ? 0.0 : width, height);331 cairo_line_to (cr, bottom_left ? 0.0 : width, height);
315 cairo_clip (cr);332 cairo_clip (cr);
333 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
316 cairo_set_source (cr, pat);334 cairo_set_source (cr, pat);
317 cairo_paint (cr);335 cairo_paint (cr);
318336
@@ -320,12 +338,17 @@
320338
321 cairo_pattern_destroy (pat);339 cairo_pattern_destroy (pat);
322340
341 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
323 /* Draw the hi-light */342 /* Draw the hi-light */
343
324 pat = cairo_pattern_create_radial (bottom_left ? 0 : width, height,344 pat = cairo_pattern_create_radial (bottom_left ? 0 : width, height,
325 height * 3/4,345 height * 3/4,
326 bottom_left ? 0 : width, height,346 bottom_left ? 0 : width, height,
327 height);347 height);
328 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_histep_2);348 double red, green, blue, alpha;
349 desktop_agnostic_color_get_cairo_color (bg->g_histep_2, &red, &green, &blue, &alpha);
350 cairo_pattern_add_color_stop_rgba (pat, 0.0, red, green, blue, 0.);
351 awn_cairo_pattern_add_color_stop_color (pat, 0.2, bg->g_histep_2);
329 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_histep_1);352 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_histep_1);
330353
331 draw_path (cr, height * 3/4, width, height, bottom_left);354 draw_path (cr, height * 3/4, width, height, bottom_left);
@@ -359,50 +382,25 @@
359 guint *padding_left,382 guint *padding_left,
360 guint *padding_right)383 guint *padding_right)
361{384{
362 if (AWN_BACKGROUND_EDGY (bg)->priv->in_corner == FALSE)385 /* behave as standard flat bg */
363 {
364 /* if we're not in the corner behave as standard flat bg */
365 AWN_BACKGROUND_CLASS (awn_background_edgy_parent_class)->padding_request (
366 bg, position, padding_top, padding_bottom, padding_left, padding_right);
367 return;
368 }
369
370 gint base_side_pad, zero_pad = 0;
371 guint dummy, left, right;
372
373 AWN_BACKGROUND_CLASS (awn_background_edgy_parent_class)->padding_request (386 AWN_BACKGROUND_CLASS (awn_background_edgy_parent_class)->padding_request (
374 bg, GTK_POS_BOTTOM, &dummy, &dummy, &left, &right);387 bg, position, padding_top, padding_bottom, padding_left, padding_right);
375 base_side_pad = MAX (left, right);
376388
377 const gint req = AWN_BACKGROUND_EDGY (bg)->priv->top_pad;389 const gint req = AWN_BACKGROUND_EDGY (bg)->priv->top_pad;
378 gboolean bottom_left = awn_background_get_panel_alignment (bg) == 0.0;390
379391 /* set the top padding for background */
380 if (awn_background_do_rtl_swap (bg))
381 {
382 zero_pad = base_side_pad;
383 base_side_pad = 0;
384 }
385
386 switch (position)392 switch (position)
387 {393 {
388 case GTK_POS_TOP:394 case GTK_POS_TOP:
389 *padding_top = 0; *padding_bottom = req;395 *padding_top = 0; *padding_bottom = req;
390 *padding_left = bottom_left ? zero_pad : base_side_pad;
391 *padding_right = bottom_left ? base_side_pad : zero_pad;
392 break;396 break;
393 case GTK_POS_BOTTOM:397 case GTK_POS_BOTTOM:
394 *padding_top = req; *padding_bottom = 0;398 *padding_top = req; *padding_bottom = 0;
395 *padding_left = bottom_left ? zero_pad : base_side_pad;
396 *padding_right = bottom_left ? base_side_pad : zero_pad;
397 break;399 break;
398 case GTK_POS_LEFT:400 case GTK_POS_LEFT:
399 *padding_top = bottom_left ? zero_pad : base_side_pad;
400 *padding_bottom = bottom_left ? base_side_pad : zero_pad;
401 *padding_left = 0; *padding_right = req;401 *padding_left = 0; *padding_right = req;
402 break;402 break;
403 case GTK_POS_RIGHT:403 case GTK_POS_RIGHT:
404 *padding_top = bottom_left ? zero_pad : base_side_pad;
405 *padding_bottom = bottom_left ? base_side_pad : zero_pad;
406 *padding_left = req; *padding_right = 0;404 *padding_left = req; *padding_right = 0;
407 break;405 break;
408 default:406 default:
@@ -437,7 +435,7 @@
437 AWN_BACKGROUND_CLASS (awn_background_edgy_parent_class)->padding_request (435 AWN_BACKGROUND_CLASS (awn_background_edgy_parent_class)->padding_request (
438 bg, position, &top, &bot, &left, &right);436 bg, position, &top, &bot, &left, &right);
439 const gint modifier = AWN_BACKGROUND_EDGY (bg)->priv->top_pad;437 const gint modifier = AWN_BACKGROUND_EDGY (bg)->priv->top_pad;
440 438
441 switch (position)439 switch (position)
442 {440 {
443 case GTK_POS_RIGHT:441 case GTK_POS_RIGHT:
@@ -458,83 +456,84 @@
458 }456 }
459}457}
460458
461static void459static gboolean
462awn_background_edgy_prepare_context (AwnBackgroundEdgy *bg,460awn_background_edgy_flat_needed (AwnBackground *bg, gint width)
463 cairo_t *cr,461{
464 GtkPositionType position,462 gboolean expand = FALSE;
465 GdkRectangle *area,463 g_object_get (bg->panel, "expand", &expand, NULL);
466 gint *width_ptr, gint *height_ptr)464 if (expand || !AWN_BACKGROUND_EDGY (bg)->priv->in_corner)
465 {
466 return TRUE;
467 }
468 return width > AWN_BACKGROUND_EDGY (bg)->priv->radius * 4/3;
469}
470
471static void
472awn_background_edgy_get_shape_mask (AwnBackground *bg,
473 cairo_t *cr,
474 GtkPositionType position,
475 GdkRectangle *area)
467{476{
468 gint temp;477 gint temp;
469 gint x = area->x, y = area->y;478 gint x = area->x, y = area->y;
470 gint width = area->width, height = area->height;479 gint width = area->width, height = area->height;
480 const gboolean in_corner = AWN_BACKGROUND_EDGY (bg)->priv->in_corner;
481
482 if (awn_background_edgy_flat_needed (bg, width))
483 {
484 GdkRectangle areaf = {x, y, width, height};
485 cairo_save (cr);
486 awn_background_edgy_translate_for_flat (bg, position, &areaf);
487 AWN_BACKGROUND_CLASS (awn_background_edgy_parent_class)-> get_shape_mask (
488 bg, cr, position, &areaf);
489 cairo_restore (cr);
490 }
491 if (!in_corner)
492 {
493 return;
494 }
495 cairo_save (cr);
471496
472 switch (position)497 switch (position)
473 {498 {
474 case GTK_POS_RIGHT:499 case GTK_POS_RIGHT:
475 cairo_translate (cr, x, y);500 height += y;
476 cairo_rotate (cr, M_PI * 0.5);501 cairo_translate (cr, 0., height);
477 cairo_scale (cr, 1.0, -1.0);502 cairo_scale (cr, 1., -1.);
503 cairo_translate (cr, x, height);
504 cairo_rotate (cr, M_PI * 1.5);
478 temp = width;505 temp = width;
479 width = height; height = temp;506 width = height;
507 height = temp;
480 break;508 break;
481 case GTK_POS_LEFT:509 case GTK_POS_LEFT:
482 cairo_translate (cr, x+width, y);510 height += y;
511 cairo_translate (cr, x + width, 0.);
483 cairo_rotate (cr, M_PI * 0.5);512 cairo_rotate (cr, M_PI * 0.5);
484 temp = width;513 temp = width;
485 width = height; height = temp;514 width = height;
515 height = temp;
486 break;516 break;
487 case GTK_POS_TOP:517 case GTK_POS_TOP:
488 cairo_translate (cr, x, height - y);518 width += x;
489 cairo_scale (cr, 1.0, -1.0);519 cairo_translate (cr, 0., y + height);
520 cairo_scale (cr, 1., -1.);
490 break;521 break;
491 default:522 default:
492 cairo_translate (cr, x, y);523 width += x;
524 cairo_translate (cr, 0., y);
493 break;525 break;
494 }526 }
495527
496 if (width_ptr) *width_ptr = width;528 /* Basic set-up */
497 if (height_ptr) *height_ptr = height;529 cairo_set_line_width (cr, 1.0);
498}530 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
499531 gboolean bottom_left = awn_background_get_panel_alignment (bg) == 0.;
500static void 532 draw_path(cr, height - 1.0, width, height, bottom_left);
501chain_draw (AwnBackground *bg,533 cairo_line_to (cr, bottom_left ? 0.0 : width, height);
502 cairo_t *cr, 534 cairo_set_source_rgba (cr, 0., 0., 0., 1.);
503 GtkPositionType position,535 cairo_clip (cr);
504 GdkRectangle *area)536 cairo_paint (cr);
505{
506 cairo_save (cr);
507
508 if (AWN_BACKGROUND_EDGY (bg)->priv->in_corner)
509 {
510 /* we need to clip the drawing area of flat background */
511 gint width, height;
512
513 gfloat align = awn_background_get_panel_alignment (AWN_BACKGROUND (bg));
514 gboolean bottom_left = align == 0.0;
515
516 cairo_rectangle (cr, area->x, area->y, area->width, area->height);
517
518 /* init our context - translate, rotate.. */
519 awn_background_edgy_prepare_context (AWN_BACKGROUND_EDGY (bg), cr,
520 position, area, &width, &height);
521
522 cairo_move_to (cr, bottom_left ? 0.0 : width, height);
523 draw_path (cr, height - 1.0, width, height, bottom_left);
524 cairo_line_to (cr, bottom_left ? 0.0 : width, height);
525
526 cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
527 cairo_clip (cr);
528
529 /* prepare context for base class call */
530 cairo_identity_matrix (cr);
531 cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
532
533 awn_background_edgy_translate_for_flat (bg, position, area);
534 }
535
536 AWN_BACKGROUND_CLASS (awn_background_edgy_parent_class)-> draw (
537 bg, cr, position, area);
538537
539 cairo_restore (cr);538 cairo_restore (cr);
540}539}
@@ -545,73 +544,56 @@
545 GtkPositionType position,544 GtkPositionType position,
546 GdkRectangle *area)545 GdkRectangle *area)
547{546{
548 const gboolean in_corner = AWN_BACKGROUND_EDGY (bg)->priv->in_corner;547 gint temp;
549 gint base_size = area->width;548 gint x = area->x, y = area->y;
550549 gint width = area->width, height = area->height;
551 if (in_corner)550
552 {551 if (awn_background_edgy_flat_needed (bg, width))
553 gint width, height;552 {
554553 GdkRectangle areaf = {x, y, width, height};
555 cairo_save (cr);554 cairo_save (cr);
556555 awn_background_edgy_translate_for_flat (bg, position, &areaf);
557 /* init our context - translate, rotate.. */556 AWN_BACKGROUND_CLASS (awn_background_edgy_parent_class)-> draw (
558 awn_background_edgy_prepare_context (AWN_BACKGROUND_EDGY (bg),557 bg, cr, position, &areaf);
559 cr, position, area, &width, &height);558 cairo_restore (cr);
560559 }
561 draw_top_bottom_background (bg, cr, width, height);560
562561 cairo_save (cr);
563 cairo_restore (cr);562
564563 switch (position)
565 base_size = width;564 {
566 }565 case GTK_POS_RIGHT:
567566 height += y;
568 if (!in_corner || base_size > AWN_BACKGROUND_EDGY (bg)->priv->radius * 4/3)567 cairo_translate (cr, 0., height);
569 chain_draw (bg, cr, position, area);568 cairo_scale (cr, 1., -1.);
570}569 cairo_translate (cr, x, height);
571570 cairo_rotate (cr, M_PI * 1.5);
572static void 571 temp = width;
573awn_background_edgy_get_shape_mask (AwnBackground *bg,572 width = height;
574 cairo_t *cr, 573 height = temp;
575 GtkPositionType position,574 break;
576 GdkRectangle *area)575 case GTK_POS_LEFT:
577{576 height += y;
578 const gboolean in_corner = AWN_BACKGROUND_EDGY (bg)->priv->in_corner;577 cairo_translate (cr, x + width, 0.);
579 gint base_size = area->width;578 cairo_rotate (cr, M_PI * 0.5);
580579 temp = width;
581 if (in_corner)580 width = height;
582 {581 height = temp;
583 gint width, height;582 break;
584583 case GTK_POS_TOP:
585 cairo_save (cr);584 width += x;
586585 cairo_translate (cr, 0., y + height);
587 gfloat align = awn_background_get_panel_alignment (AWN_BACKGROUND (bg));586 cairo_scale (cr, 1., -1.);
588 gboolean bottom_left = align == 0.0;587 break;
589588 default:
590 /* init our context - translate, rotate.. */589 width += x;
591 awn_background_edgy_prepare_context (AWN_BACKGROUND_EDGY (bg),590 cairo_translate (cr, 0., y);
592 cr, position, area, &width, &height);591 break;
593592 }
594 draw_path (cr, height - 1.0, width, height, bottom_left);593
595 cairo_line_to (cr, bottom_left ? 0.0 : width, height);594 draw_top_bottom_background (bg, cr, width, height);
596595
597 cairo_fill_preserve (cr);596 cairo_restore (cr);
598 cairo_stroke (cr);
599
600 cairo_restore (cr);
601
602 base_size = width;
603
604 /* prepare context for base class call */
605 awn_background_edgy_translate_for_flat (bg, position, area);
606 }
607
608 if (!in_corner || base_size > AWN_BACKGROUND_EDGY (bg)->priv->radius * 4/3)
609 {
610 cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
611
612 AWN_BACKGROUND_CLASS (awn_background_edgy_parent_class)->get_shape_mask (
613 bg, cr, position, area);
614 }
615}597}
616598
617/* vim: set et ts=2 sts=2 sw=2 : */599/* vim: set et ts=2 sts=2 sw=2 : */
618600
=== modified file 'src/awn-background-flat.c'
--- src/awn-background-flat.c 2010-05-23 23:07:18 +0000
+++ src/awn-background-flat.c 2010-07-16 10:54:57 +0000
@@ -159,22 +159,14 @@
159 if (expand){ state = ROUND_NONE; x-=2; width+=4; }159 if (expand){ state = ROUND_NONE; x-=2; width+=4; }
160 else160 else
161 {161 {
162 switch (position)162 if (align == 0.0f)
163 {163 {
164 case GTK_POS_BOTTOM:164 state = ROUND_TOP_RIGHT; x-=2; width+=2;
165 case GTK_POS_LEFT:165 }
166 if (align == 0.0f){ state = ROUND_TOP_RIGHT; x-=2; width+=2; }166 else if(align == 1.0f)
167 else if(align == 1.0f){ state = ROUND_TOP_LEFT; width+=2; }167 {
168 break;168 state = ROUND_TOP_LEFT; width+=2;
169 case GTK_POS_TOP:169 }
170 case GTK_POS_RIGHT:
171 if (align == 0.0f){ state = ROUND_TOP_LEFT; width+=2; }
172 else if(align == 1.0f){ state = ROUND_TOP_RIGHT; x-=2; width+=2; }
173 break;
174 default:
175 break;
176 }
177
178 }170 }
179171
180 awn_cairo_rounded_rect (cr, x, y, width, height, bg->corner_radius, state);172 awn_cairo_rounded_rect (cr, x, y, width, height, bg->corner_radius, state);
@@ -198,6 +190,9 @@
198 cairo_set_line_width (cr, 1.0);190 cairo_set_line_width (cr, 1.0);
199 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);191 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
200192
193 gfloat x = 0.,
194 y = 0.;
195
201 align = awn_background_get_panel_alignment (bg);196 align = awn_background_get_panel_alignment (bg);
202 g_object_get (bg->panel, "expand", &expand, NULL);197 g_object_get (bg->panel, "expand", &expand, NULL);
203198
@@ -223,8 +218,8 @@
223 // performance as opposed to cairo_fill218 // performance as opposed to cairo_fill
224 cairo_save (cr);219 cairo_save (cr);
225220
226 draw_rect (bg, cr, position, 1, 1, width-3, height-1, align, expand);221 draw_rect (bg, cr, position, x, y, width, height, align, expand);
227 cairo_clip (cr);222 cairo_clip_preserve (cr);
228 cairo_set_source (cr, pat);223 cairo_set_source (cr, pat);
229 cairo_paint (cr);224 cairo_paint (cr);
230225
@@ -233,10 +228,12 @@
233 cairo_pattern_destroy (pat);228 cairo_pattern_destroy (pat);
234229
235 /* Draw the hi-light */230 /* Draw the hi-light */
236 pat = cairo_pattern_create_linear (0, 0, 0, (height/3.0));231 pat = cairo_pattern_create_linear (0, 0, 0, height);
237 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_histep_1);232 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_histep_1);
238 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_histep_2);233 awn_cairo_pattern_add_color_stop_color (pat, 0.3, bg->g_histep_2);
239 draw_rect (bg, cr, position, 1, 1, width-3, height/3.0, align, expand);234 double red, green, blue, alpha;
235 desktop_agnostic_color_get_cairo_color (bg->g_histep_2, &red, &green, &blue, &alpha);
236 cairo_pattern_add_color_stop_rgba (pat, 0.36, red, green, blue, 0.);
240237
241 cairo_set_source (cr, pat);238 cairo_set_source (cr, pat);
242 cairo_fill (cr);239 cairo_fill (cr);
@@ -246,12 +243,12 @@
246243
247 /* Internal border */244 /* Internal border */
248 awn_cairo_set_source_color (cr, bg->hilight_color);245 awn_cairo_set_source_color (cr, bg->hilight_color);
249 draw_rect (bg, cr, position, 1, 1, width-3, height+3, align, expand);246 draw_rect (bg, cr, position, x + 1, y + 1, width-2, height-1, align, expand);
250 cairo_stroke (cr);247 cairo_stroke (cr);
251248
252 /* External border */249 /* External border */
253 awn_cairo_set_source_color (cr, bg->border_color);250 awn_cairo_set_source_color (cr, bg->border_color);
254 draw_rect (bg, cr, position, 0, 0, width-1, height+3, align, expand);251 draw_rect (bg, cr, position, x, y, width, height, align, expand);
255 cairo_stroke (cr);252 cairo_stroke (cr);
256}253}
257254
@@ -393,7 +390,7 @@
393 break;390 break;
394 }391 }
395392
396 draw_rect (bg, cr, position, 0, 0, width, height+3, align, expand);393 draw_rect (bg, cr, position, 0, 0, width, height, align, expand);
397 cairo_fill (cr);394 cairo_fill (cr);
398395
399 cairo_restore (cr);396 cairo_restore (cr);
400397
=== modified file 'src/awn-background-floaty.c'
--- src/awn-background-floaty.c 2010-05-31 17:41:58 +0000
+++ src/awn-background-floaty.c 2010-07-16 10:54:57 +0000
@@ -181,7 +181,7 @@
181 cairo_save (cr);181 cairo_save (cr);
182182
183 draw_rect (bg, cr, position, 1, 1, width-3, bg_size-2, TRUE);183 draw_rect (bg, cr, position, 1, 1, width-3, bg_size-2, TRUE);
184 cairo_clip (cr);184 cairo_clip_preserve (cr);
185 cairo_set_source (cr, pat);185 cairo_set_source (cr, pat);
186 cairo_paint (cr);186 cairo_paint (cr);
187187
@@ -190,10 +190,12 @@
190 cairo_pattern_destroy (pat);190 cairo_pattern_destroy (pat);
191191
192 /* Draw the hi-light */192 /* Draw the hi-light */
193 pat = cairo_pattern_create_linear (0, 0, 0, (bg_size/3.0));193 pat = cairo_pattern_create_linear (0., 0., 0., height);
194 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_histep_1);194 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_histep_1);
195 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_histep_2);195 awn_cairo_pattern_add_color_stop_color (pat, 0.3, bg->g_histep_2);
196 draw_rect (bg, cr, position, 1, 1, width-3, bg_size/3.0, FALSE);196 double red, green, blue, alpha;
197 desktop_agnostic_color_get_cairo_color (bg->g_histep_2, &red, &green, &blue, &alpha);
198 cairo_pattern_add_color_stop_rgba (pat, 0.36, red, green, blue, 0.);
197199
198 cairo_set_source (cr, pat);200 cairo_set_source (cr, pat);
199 cairo_fill (cr);201 cairo_fill (cr);
200202
=== modified file 'src/awn-background-lucido.c'
--- src/awn-background-lucido.c 2010-05-31 22:40:18 +0000
+++ src/awn-background-lucido.c 2010-07-16 10:54:57 +0000
@@ -17,7 +17,7 @@
17 *17 *
18 * Author : Alberto Aldegheri <albyrock87+dev@gmail.com>18 * Author : Alberto Aldegheri <albyrock87+dev@gmail.com>
19 * Thanks to: Matt <sharkbaitbobby@gmail.com>19 * Thanks to: Matt <sharkbaitbobby@gmail.com>
20 * for the code section to analyze expanders20 * for the code section to analyze separators
21 *21 *
22 */22 */
2323
@@ -39,11 +39,27 @@
3939
40struct _AwnBackgroundLucidoPrivate40struct _AwnBackgroundLucidoPrivate
41{41{
42 gint expw;42 gint expw;
43 gint expn;43 gfloat lastx;
44 gfloat lastxend;
45 GArray *pos;
46 gint pos_size;
47 guint tid;
48 gboolean needs_animation;
44};49};
4550
46#define TRANSFORM_RADIUS(x) sqrt(x/50.)*50.51#define TOP_PADDING 2
52/* Timeout for animation -> 40 = 25fps*/
53#define ANIM_TIMEOUT 40
54/* ANIMATION SPEED needs to be greater than 0. - Lower values are faster */
55#define ANIMATION_SPEED 16.
56
57/* draw shape mask for debug */
58#define DEBUG_SHAPE_MASK FALSE
59
60#define TRANSFORM_RADIUS(x) MAX(sqrt(x/60.)*60.,1)
61
62#define IS_SPECIAL(x) AWN_IS_SEPARATOR(x)
4763
48static void awn_background_lucido_draw (AwnBackground *bg,64static void awn_background_lucido_draw (AwnBackground *bg,
49 cairo_t *cr,65 cairo_t *cr,
@@ -61,18 +77,31 @@
61 guint *padding_bottom,77 guint *padding_bottom,
62 guint *padding_left,78 guint *padding_left,
63 guint *padding_right);79 guint *padding_right);
64 80
65static gboolean81static gboolean
66awn_background_lucido_get_needs_redraw (AwnBackground *bg,82awn_background_lucido_get_needs_redraw (AwnBackground *bg,
67 GtkPositionType position,83 GtkPositionType position,
68 GdkRectangle *area);84 GdkRectangle *area);
69 85
86
87static void
88_set_special_widget_width_and_transparent (AwnBackground *bg,
89 gint width,
90 gboolean transp,
91 gboolean dispose);
92
70static void 93static void
71awn_background_lucido_corner_radius_changed (AwnBackground *bg)94awn_background_lucido_corner_radius_changed (AwnBackground *bg)
72{95{
73 gboolean expand = FALSE;96 gboolean expand = FALSE;
74 g_object_get (bg->panel, "expand", &expand, NULL);97 g_object_get (bg->panel, "expand", &expand, NULL);
75 98
99 _set_special_widget_width_and_transparent (
100 bg,
101 TRANSFORM_RADIUS (bg->corner_radius),
102 TRUE,
103 FALSE);
104
76 if (!expand)105 if (!expand)
77 {106 {
78 awn_background_emit_padding_changed (bg);107 awn_background_emit_padding_changed (bg);
@@ -92,19 +121,28 @@
92}121}
93122
94static void123static void
124awn_background_lucido_applets_refreshed (AwnBackground *bg)
125{
126 _set_special_widget_width_and_transparent
127 (bg, TRANSFORM_RADIUS (bg->corner_radius), TRUE, FALSE);
128 awn_background_emit_changed (bg);
129}
130
131static void
95awn_background_lucido_constructed (GObject *object)132awn_background_lucido_constructed (GObject *object)
96{133{
97 G_OBJECT_CLASS (awn_background_lucido_parent_class)->constructed (object);134 G_OBJECT_CLASS (awn_background_lucido_parent_class)->constructed (object);
98 135
99 AwnBackground *bg = AWN_BACKGROUND (object);136 AwnBackground *bg = AWN_BACKGROUND (object);
100 gpointer monitor = NULL;137 gpointer monitor = NULL;
101 138
102 g_signal_connect_swapped (bg, "notify::corner-radius",139 g_signal_connect_swapped (bg, "notify::corner-radius",
103 G_CALLBACK (awn_background_lucido_corner_radius_changed),140 G_CALLBACK (
141 awn_background_lucido_corner_radius_changed),
104 object);142 object);
105143
106 g_return_if_fail (bg->panel);144 g_return_if_fail (bg->panel);
107 145
108 g_signal_connect_swapped (bg->panel, "notify::expand",146 g_signal_connect_swapped (bg->panel, "notify::expand",
109 G_CALLBACK (awn_background_lucido_expand_changed),147 G_CALLBACK (awn_background_lucido_expand_changed),
110 object);148 object);
@@ -116,11 +154,24 @@
116 g_signal_connect_swapped (monitor, "notify::monitor-align",154 g_signal_connect_swapped (monitor, "notify::monitor-align",
117 G_CALLBACK (awn_background_lucido_align_changed),155 G_CALLBACK (awn_background_lucido_align_changed),
118 object);156 object);
157
158 AwnAppletManager *manager = NULL;
159 g_object_get (bg->panel, "applet-manager", &manager, NULL);
160 g_return_if_fail (manager);
161 g_signal_connect_swapped (manager, "applets-refreshed",
162 G_CALLBACK (awn_background_lucido_applets_refreshed), bg);
119}163}
120164
121static void165static void
122awn_background_lucido_dispose (GObject *object)166awn_background_lucido_dispose (GObject *object)
123{167{
168 _set_special_widget_width_and_transparent
169 (AWN_BACKGROUND (object), 10, FALSE, TRUE);
170
171 AwnBackgroundLucido *lbg = AWN_BACKGROUND_LUCIDO (object);
172 AwnBackgroundLucidoPrivate *priv = AWN_BACKGROUND_LUCIDO_GET_PRIVATE (lbg);
173 g_array_free (priv->pos, TRUE);
174
124 gpointer monitor = NULL;175 gpointer monitor = NULL;
125 if (AWN_BACKGROUND (object)->panel)176 if (AWN_BACKGROUND (object)->panel)
126 {177 {
@@ -139,6 +190,15 @@
139 g_signal_handlers_disconnect_by_func (AWN_BACKGROUND (object), 190 g_signal_handlers_disconnect_by_func (AWN_BACKGROUND (object),
140 G_CALLBACK (awn_background_lucido_corner_radius_changed), object);191 G_CALLBACK (awn_background_lucido_corner_radius_changed), object);
141192
193 AwnAppletManager *manager = NULL;
194 g_object_get (AWN_BACKGROUND (object)->panel,
195 "applet-manager", &manager, NULL);
196 if (manager)
197 {
198 g_signal_handlers_disconnect_by_func (manager,
199 G_CALLBACK (awn_background_lucido_applets_refreshed), object);
200 }
201
142 G_OBJECT_CLASS (awn_background_lucido_parent_class)->dispose (object);202 G_OBJECT_CLASS (awn_background_lucido_parent_class)->dispose (object);
143}203}
144204
@@ -151,19 +211,30 @@
151 obj_class->constructed = awn_background_lucido_constructed;211 obj_class->constructed = awn_background_lucido_constructed;
152 obj_class->dispose = awn_background_lucido_dispose;212 obj_class->dispose = awn_background_lucido_dispose;
153213
214#if DEBUG_SHAPE_MASK
215 bg_class->draw = awn_background_lucido_get_shape_mask;
216#else
154 bg_class->draw = awn_background_lucido_draw;217 bg_class->draw = awn_background_lucido_draw;
218#endif
155 bg_class->padding_request = awn_background_lucido_padding_request;219 bg_class->padding_request = awn_background_lucido_padding_request;
156 bg_class->get_shape_mask = awn_background_lucido_get_shape_mask;220 bg_class->get_shape_mask = awn_background_lucido_get_shape_mask;
157 bg_class->get_input_shape_mask = awn_background_lucido_get_shape_mask;221 bg_class->get_input_shape_mask = awn_background_lucido_get_shape_mask;
158 bg_class->get_needs_redraw = awn_background_lucido_get_needs_redraw;222 bg_class->get_needs_redraw = awn_background_lucido_get_needs_redraw;
159 223
160 g_type_class_add_private (obj_class, sizeof (AwnBackgroundLucidoPrivate));224 g_type_class_add_private (obj_class, sizeof (AwnBackgroundLucidoPrivate));
161}225}
162226
163static void227static void
164awn_background_lucido_init (AwnBackgroundLucido *bg)228awn_background_lucido_init (AwnBackgroundLucido *bg)
165{229{
166230 AwnBackgroundLucidoPrivate *priv = AWN_BACKGROUND_LUCIDO_GET_PRIVATE (bg);
231 priv->lastx = 0;
232 priv->lastxend = INT_MAX;
233 priv->needs_animation = FALSE;
234 priv->tid = 0;
235 priv->pos = g_array_new (FALSE, TRUE, sizeof (gfloat));
236 priv->pos_size = 0;
237 awn_background_lucido_applets_refreshed (AWN_BACKGROUND (bg));
167}238}
168239
169AwnBackground *240AwnBackground *
@@ -179,6 +250,66 @@
179 return bg;250 return bg;
180}251}
181252
253/* ANIMATION FUNCTIONS */
254
255/*
256 * _add_n_positions:
257 * adds n positions to position array that contains
258 * last positions of special applets
259 * Usually called when a special applet is added
260 */
261static void
262_add_n_positions (AwnBackgroundLucidoPrivate *priv, gint n, gfloat startpos)
263{
264 while (n-- > 0)
265 {
266 g_array_append_val (priv->pos, startpos);
267 ++priv->pos_size;
268 }
269}
270
271/*
272 * awn_background_lucido_redraw:
273 * @lbg: the lucido background ojbect
274 *
275 * Queue redraw of the panel and repeat itself if needed
276 */
277static gboolean
278awn_background_lucido_redraw (AwnBackgroundLucido *lbg)
279{
280 g_return_val_if_fail (AWN_IS_BACKGROUND_LUCIDO (lbg), FALSE);
281
282 AwnBackgroundLucidoPrivate *priv;
283 AwnBackground *bg = AWN_BACKGROUND (lbg);
284 priv = AWN_BACKGROUND_LUCIDO_GET_PRIVATE (lbg);
285
286 if (priv->needs_animation)
287 {
288 awn_background_invalidate (bg);
289 gtk_widget_queue_draw (GTK_WIDGET (bg->panel));
290 return TRUE;
291 }
292 else
293 {
294 priv->tid = 0;
295 return FALSE;
296 }
297}
298
299/*
300 * _restart_timeout:
301 * restarts animation's timer if needed
302 */
303static void _restart_timeout (AwnBackground *bg,
304 AwnBackgroundLucidoPrivate *priv)
305{
306 priv->needs_animation = TRUE;
307 if (!priv->tid)
308 {
309 priv->tid = g_timeout_add (ANIM_TIMEOUT, (GSourceFunc)awn_background_lucido_redraw, bg);
310 }
311}
312
182/*313/*
183 * Drawing functions314 * Drawing functions
184 */315 */
@@ -202,6 +333,10 @@
202 *ys = yf;333 *ys = yf;
203}334}
204335
336/*
337 * Gets applet manager's childs.
338 * Sets docklet mode = TRUE if panel is in docklet mode
339 */
205static GList*340static GList*
206_get_applet_widgets (AwnBackground* bg)341_get_applet_widgets (AwnBackground* bg)
207{342{
@@ -211,6 +346,58 @@
211 return gtk_container_get_children (GTK_CONTAINER (manager));346 return gtk_container_get_children (GTK_CONTAINER (manager));
212}347}
213348
349/*
350 * Get applet manager size
351 * Get offset-left stored in "x" variable passed to method
352 *
353 */
354static gint
355_get_applet_manager_size (AwnBackground* bg, GtkPositionType position, float *x)
356{
357 AwnAppletManager *manager = NULL;
358 g_object_get (bg->panel, "applet-manager", &manager, NULL);
359 GtkWidget *widget = GTK_WIDGET (manager);
360 gint wx, wy;
361 gtk_widget_translate_coordinates(widget, gtk_widget_get_toplevel(widget),
362 0, 0, &wx, &wy);
363 switch (position)
364 {
365 case GTK_POS_BOTTOM:
366 case GTK_POS_TOP:
367 if (x)
368 *x = wx;
369 return widget->allocation.width;
370 break;
371 default:
372 if (x)
373 *x = wy;
374 return widget->allocation.height;
375 break;
376 }
377}
378
379/*
380 * coord_get_near:
381 * @from: the current position
382 * @to: the target position
383 * @return: a position between "from" and "to", if distance = 1, returns "to"
384 */
385static float
386coord_get_near (const gfloat from, const gfloat to)
387{
388 float inc = abs (to - from);
389 float step = inc / ANIMATION_SPEED + 1.; // makes the resize shiny
390 inc = MIN (inc, step);
391 if (to > from)
392 {
393 return lroundf (from + inc);
394 }
395 else
396 {
397 return lroundf (from - inc);
398 }
399}
400
214/**401/**
215 * _create_path_lucido:402 * _create_path_lucido:
216 * @bg: The background pointer403 * @bg: The background pointer
@@ -219,21 +406,23 @@
219 * @y: The top left coordinate of the "bar rect" - default = 0406 * @y: The top left coordinate of the "bar rect" - default = 0
220 * @w: The width of the bar407 * @w: The width of the bar
221 * @h: The height of the bar408 * @h: The height of the bar
222 * @stripe: The width of the stripe (0.0-1.0). Zero for auto-stripe.
223 * @d: The width of each curve in the path409 * @d: The width of each curve in the path
224 * @dc: The width of the external curves in non-expanded&auto mode410 * @dc: The width of the external curves in non-expanded&auto mode
225 * @symmetry: The symmetry of the stripe when @stripe > 0
226 * @internal: If Zero, creates the path for the stripe411 * @internal: If Zero, creates the path for the stripe
227 * @expanded: If Zero, the bar is not expanded412 * @expanded: If Zero, the bar is not expanded
413 * @align: the monitor align
414 * @update_positions: if FALSE it uses positions stored in priv->pos,
415 * otherwise updates the position stored in priv->pos
228 *416 *
229 * This function creates paths on which the bar will be drawn.417 * This function creates paths on which the bar will be drawn.
230 * In atuo-stripe, it searchs for expanders applet, each expander418 * In atuo-stripe, it searchs for separators applet, each separator
231 * equals to one curve.419 * equals to one curve.
232 * If the first widget is an expander, start from bottom-left,420 * If the first widget is an separator, start from bottom-left,
233 * otherwise start from top-left421 * otherwise start from top-left
422 *
423 * returns the calculated y coordinate to draw the gradient
234 */424 */
235425static gfloat
236static void
237_create_path_lucido ( AwnBackground* bg,426_create_path_lucido ( AwnBackground* bg,
238 GtkPositionType position,427 GtkPositionType position,
239 cairo_t* cr,428 cairo_t* cr,
@@ -241,371 +430,360 @@
241 gfloat y,430 gfloat y,
242 gfloat w,431 gfloat w,
243 gfloat h,432 gfloat h,
244 gfloat stripe,
245 gfloat d,433 gfloat d,
246 gfloat dc,434 gfloat dc,
247 gfloat symmetry,
248 gboolean internal,435 gboolean internal,
249 gboolean expanded,436 gboolean expanded,
250 gfloat align)437 gfloat align,
438 gboolean update_positions)
251{439{
252 cairo_new_path (cr);440 AwnBackgroundLucido *lbg = AWN_BACKGROUND_LUCIDO (bg);
441 AwnBackgroundLucidoPrivate *priv = AWN_BACKGROUND_LUCIDO_GET_PRIVATE (lbg);
442 gfloat applet_manager_x = 0.;
443 _get_applet_manager_size (bg, position, &applet_manager_x);
444 gboolean needs_animation = FALSE;
253445
446 /****************************************************************************/
447 /******************** UPDATE STARTING POINT *************************/
448 /****************************************************************************/
449 /* x variable stores the starting x point for draw the panel */
450 if (update_positions)
451 {
452 if (!expanded)
453 {
454 x += applet_manager_x - dc;
455 }
456 x = lroundf (x);
457 if (x != priv->lastx)
458 {
459 needs_animation = TRUE;
460 }
461 x = coord_get_near (priv->lastx, x);
462 priv->lastx = x;
463 }
464 else
465 {
466 x = priv->lastx;
467 }
468 /****************************************************************************/
469 /******************** INIT GENERAL COORDINATES *************************/
470 /****************************************************************************/
471 gfloat sym = bg->curves_symmetry;
472 gfloat curx = x;
254 gfloat lx = x;473 gfloat lx = x;
255 gfloat ly = y;474 gfloat ly = y;
256 gfloat y3 = y + h;475 gfloat y3 = y + h;
257 gfloat y2 = y3 - 5;476 gfloat y2 = y3 - 8. * bg->thickness;
258 477 gfloat rdc = dc;
259 if (stripe > 0)478
260 {479 /****************************************************************************/
261 if (expanded)480 /******************** CURVES SYMMETRY HANDLER *************************/
262 {481 /****************************************************************************/
263 stripe = (w * stripe); /* now stripe = non-stripe */482 sym = fabs (sym - 0.5);
483 gfloat exty = y + h * sym * 2.;
484 if (exty > y2)
485 {
486 y2 = exty;
487 }
488 if (internal && bg->curves_symmetry > 0.5)
489 {
490 y = exty;
491 }
492 else if (!internal && bg->curves_symmetry < 0.5)
493 {
494 y = exty;
495 }
496 /****************************************************************************/
497 /******************** OBTAIN LIST OF APPLETS *************************/
498 /****************************************************************************/
499 gboolean docklet_mode = awn_panel_get_docklet_mode (bg->panel);
500 GList *widgets = _get_applet_widgets (bg);
501 GList *i = widgets;
502 GtkWidget *widget = NULL;
503 /* j = index of last special widget found */
504 gint j = -1;
505 /* Check for docklet mode - In docklet mode first widget is the docklet */
506 if (i && docklet_mode)
507 {
508 i = i->next;
509 }
510 /* Check if the first widget is special */
511 gboolean first_widget_is_special = FALSE;
512 if (i && IS_SPECIAL (i->data))
513 {
514 first_widget_is_special = TRUE;
515 }
516 /****************************************************************************/
517 /******************** SETUP EXTERNAL CORNERS *************************/
518 /****************************************************************************/
519 if (expanded)
520 {
521 dc = rdc = 0.;
522 }
523 else if (align == 0.)
524 {
525 dc = 0.;
526 }
527 else if (align == 1.)
528 {
529 rdc = 0.;
530 }
531 /****************************************************************************/
532 /******************** START THE PATH *************************/
533 /****************************************************************************/
534 if (internal)
535 {
536 cairo_new_path (cr);
537 lx = lx + dc;
538 ly = y;
539 cairo_move_to (cr, lx, ly);
540 _line_from_to (cr, &lx, &ly, curx, y3);
541 }
542 else
543 {
544 cairo_new_path (cr);
545 lx = curx;
546 ly = y3;
547 cairo_move_to (cr, lx, ly);
548 }
549 /* check for special in first position */
550 if (first_widget_is_special)
551 {
552 i = i->next;
553 _line_from_to (cr, &lx, &ly, lx + dc, y2);
554 }
555 else if (!internal)
556 {
557 _line_from_to (cr, &lx, &ly, lx + dc, y);
558 }
559 else
560 {
561 _line_from_to (cr, &lx, &ly, lx + dc, exty);
562 }
563 /****************************************************************************/
564 /******************** UPDATE WIDTH FOR LAST X *************************/
565 /****************************************************************************/
566 /* w stores the "right corner", lastxend equals to last w */
567 if (update_positions)
568 {
569 w = lroundf (w);
570 if (w != priv->lastxend)
571 {
572 needs_animation = TRUE;
573 gfloat neww = coord_get_near (priv->lastxend, w);
574 w = MIN (w, neww);
575 priv->lastxend = w;
576 }
577 }
578 else
579 {
580 w = priv->lastxend;
581 }
582 /****************************************************************************/
583 /******************** LOOP ON APPLETS *************************/
584 /****************************************************************************/
585 gfloat saved_y = y;
586 if (bg->curves_symmetry < 0.5)
587 {
588 y = exty;
589 }
590 curx = lx;
591 gint wx, wy;
592 if (!docklet_mode)
593 {
594 for (; i; i = i->next)
595 {
596 widget = GTK_WIDGET (i->data);
597 if (!IS_SPECIAL (widget))
598 {
599 /* if not special continue */
600 continue;
601 }
602 /* special found, obtain coordinates */
603 ++j;
604 gtk_widget_translate_coordinates(widget, gtk_widget_get_toplevel(widget),
605 0, 0, &wx, &wy);
606 switch (position)
607 {
608 case GTK_POS_BOTTOM:
609 case GTK_POS_TOP:
610 curx = wx;
611 break;
612 default:
613 curx = wy;
614 break;
615 }
616 if (priv->pos_size <= j)
617 {
618 /* New special applet found, resize the array */
619 _add_n_positions (priv, 1, lx);
620 }
621 /************************************************************************/
622 /***************** UPDATE SINGLE CURVE POSITION *********************/
623 /************************************************************************/
624 if (update_positions)
625 {
626 curx = lroundf (curx);
627 if (curx != g_array_index (priv->pos, gfloat, j))
628 {
629 needs_animation = TRUE;
630 }
631 curx = coord_get_near (g_array_index (priv->pos, gfloat, j), curx);
632 if (curx > (w - rdc - d))
633 {
634 curx = w - rdc - d;
635 }
636 g_array_index (priv->pos, gfloat, j) = curx;
637 }
638 else
639 {
640 curx = g_array_index (priv->pos, gfloat, j);
641 }
642 if (curx < 0)
643 {
644 continue;
645 }
646 _line_from_to (cr, &lx, &ly, curx, ly);
647 if (ly == y2)
648 {
649 _line_from_to (cr, &lx, &ly, lx + d, y);
650 }
651 else
652 {
653 _line_from_to (cr, &lx, &ly, lx + d, y2);
654 }
655 }
656 }
657 y = saved_y;
658 g_list_free (widgets);
659 /****************************************************************************/
660 /************************ CLOSE THE PATH ******************************/
661 /****************************************************************************/
662 if (expanded)
663 {
664 /* make sure that cairo close path in the right way */
665 _line_from_to (cr, &lx, &ly, w, ly);
666 if (internal)
667 {
668 _line_from_to (cr, &lx, &ly, lx, y);
669 }
670 else
671 {
672 _line_from_to (cr, &lx, &ly, lx, y3);
673 }
674 }
675 else
676 {
677 if (align == 1.)
678 {
264 if (internal)679 if (internal)
265 {680 {
266 /* Manual-Stripe & Expanded & Internal */681 _line_from_to (cr, &lx, &ly, w, ly);
267 lx = stripe * symmetry;
268 cairo_move_to (cr, lx, ly);
269 _line_from_to (cr, &lx, &ly, lx+d, y2);
270 _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - d, y2);
271 _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry), y);
272 cairo_close_path (cr);
273 }
274 else
275 {
276 /* Manual-Stripe & Expanded & External */
277 ly = y3;
278 cairo_move_to (cr, lx, ly);
279 _line_from_to (cr, &lx, &ly, lx, y);682 _line_from_to (cr, &lx, &ly, lx, y);
280 _line_from_to (cr, &lx, &ly, stripe * symmetry, y);683 }
281 _line_from_to (cr, &lx, &ly, stripe * symmetry + d, y2);684 else
282 _line_from_to (cr, &lx, &ly, w - stripe * (1. - symmetry) - d, y2);685 {
283 _line_from_to (cr, &lx, &ly, w - stripe * (1. - symmetry), y);
284 _line_from_to (cr, &lx, &ly, w, y);
285 _line_from_to (cr, &lx, &ly, w, y3);
286 cairo_close_path (cr);
287 }
288 }
289 else
290 {
291 if (stripe == 1.)
292 {
293 _create_path_lucido (bg, position, cr, x, y, w, h, 0.,
294 d, dc, 0., internal, expanded, align);
295 return;
296 }
297 stripe = ((w - dc * 2) * stripe); /* now stripe = non-stripe */
298 if (internal)
299 {
300 /* Manual-Stripe & Not-Expanded & Internal */
301 lx = stripe * symmetry + dc;
302 cairo_move_to (cr, lx, ly);
303 _line_from_to (cr, &lx, &ly, lx + d, y2);
304 _line_from_to (cr, &lx, &ly, w - stripe * (1.- symmetry) - dc - d, y2);
305 _line_from_to (cr, &lx, &ly, w - stripe * (1.- symmetry) - dc, y);
306 cairo_close_path (cr);
307 }
308 else
309 {
310 /* Manual-Stripe & Not-Expanded & External */
311 ly = y3;
312 cairo_move_to (cr, lx, ly);
313 _line_from_to (cr, &lx, &ly, lx+dc, y);
314 _line_from_to (cr, &lx, &ly, stripe * symmetry + dc, y);
315 _line_from_to (cr, &lx, &ly, stripe * symmetry + d + dc, y2);
316 _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - dc - d, y2);
317 _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - dc, y);
318 _line_from_to (cr, &lx, &ly, w-dc, y);
319 _line_from_to (cr, &lx, &ly, w, y3);
320 cairo_close_path(cr);
321 }
322 }
323 }
324 else
325 {
326 gint exps_found = 0;
327 gfloat curx = x;
328
329 if (expanded)
330 {
331 if (internal)
332 {
333 /* Auto-Stripe & Expanded & Internal */
334 GList *widgets = _get_applet_widgets (bg);
335 GList *i = widgets;
336 GtkWidget *widget = NULL;
337
338 /* analyze first widget*/
339 if (i)
340 {
341 widget = GTK_WIDGET (i->data);
342
343 /* if first widget is an expander or align==0 || 1*/
344 if ( (widget && GTK_IS_IMAGE (widget) && !AWN_IS_SEPARATOR (widget) ) ||
345 ( align == 0. || align == 1. ) )
346 {
347 /* start from bottom */
348 lx = curx;
349 ly = y;
350 cairo_move_to (cr, lx, ly);
351 _line_from_to (cr, &lx, &ly, lx, y2);
352 ++exps_found;
353 if (align != 0. && align != 1.)
354 i = i->next;
355 }
356 }
357 /* else start from top */
358
359 for (; i; i = i->next)
360 {
361 widget = GTK_WIDGET (i->data);
362
363 if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
364 {
365 /* if not expander continue */
366 continue;
367 }
368 /* expander found */
369 switch (position)
370 {
371 case GTK_POS_BOTTOM:
372 case GTK_POS_TOP:
373 curx = widget->allocation.x;
374 if (exps_found % 2 != 0)
375 {
376 curx += widget->allocation.width;
377 }
378 break;
379 default:
380 curx = widget->allocation.y;
381 if ( exps_found % 2 != 0)
382 {
383 curx += widget->allocation.height;
384 }
385 break;
386 }
387 if (curx < 0)
388 {
389 continue;
390 }
391
392 if (exps_found == 0)
393 {
394 /* this is the first expander */
395 lx = curx;
396 cairo_move_to (cr, lx, ly);
397 _line_from_to (cr, &lx, &ly, curx + d, y2);
398 }
399 else
400 {
401 if (exps_found % 2 != 0)
402 {
403 /* odd expander - curve at the end of expander */
404 _line_from_to (cr, &lx, &ly, curx - d, y2);
405 if (i->next == NULL)
406 _line_from_to (cr, &lx, &ly, curx, y2);
407 _line_from_to (cr, &lx, &ly, curx, y);
408 }
409 else
410 {
411 /* even expander - curve at the start of expander */
412 _line_from_to (cr, &lx, &ly, curx, y);
413 _line_from_to (cr, &lx, &ly, curx + d, y2);
414 /* else the last widget is an expander */
415 }
416 }
417
418 ++exps_found;
419 }
420 g_list_free (widgets);
421
422 _line_from_to (cr, &lx, &ly, w, ly);
423
424 if (exps_found % 2 != 0)
425 {
426 _line_from_to (cr, &lx, &ly, lx, y);
427 }
428
429 cairo_close_path (cr);
430 }
431 else
432 {
433 /* Auto-Stripe & Expanded & External */
434
435 GList *widgets = _get_applet_widgets (bg);
436 GList *i = widgets;
437 GtkWidget *widget = NULL;
438
439 /* analyze first widget*/
440 if (i)
441 {
442 widget = GTK_WIDGET (i->data);
443
444 ly = y3;
445 cairo_move_to (cr, lx, ly);
446
447 /* if first widget is an expander or align==0 || 1*/
448 if ( (widget && GTK_IS_IMAGE (widget) && !AWN_IS_SEPARATOR (widget) ) ||
449 ( align == 0. || align == 1. ) )
450 {
451 /* start from bottom */
452 _line_from_to (cr, &lx, &ly, lx, y2);
453 ++exps_found;
454 if (align != 0. && align != 1.)
455 i = i->next;
456 }
457 else
458 {
459 /* start from top */
460 _line_from_to (cr, &lx, &ly, lx, y);
461 }
462 }
463
464 for (; i; i = i->next)
465 {
466 widget = GTK_WIDGET (i->data);
467
468 if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
469 {
470 /* if not expander continue */
471 continue;
472 }
473 /* expander found */
474 switch (position)
475 {
476 case GTK_POS_BOTTOM:
477 case GTK_POS_TOP:
478 curx = widget->allocation.x;
479 if (exps_found % 2 != 0)
480 {
481 curx += widget->allocation.width;
482 }
483 break;
484 default:
485 curx = widget->allocation.y;
486 if (exps_found % 2 != 0)
487 {
488 curx += widget->allocation.height;
489 }
490 break;
491 }
492 if (curx < 0)
493 {
494 continue;
495 }
496
497 if (exps_found % 2 != 0)
498 {
499 _line_from_to (cr, &lx, &ly, curx - d, y2);
500 if (i->next != NULL)
501 _line_from_to (cr, &lx, &ly, curx, y);
502 }
503 else
504 {
505 _line_from_to (cr, &lx, &ly, curx, y);
506 _line_from_to (cr, &lx, &ly, curx + d, y2);
507 }
508 ++exps_found;
509 }
510 g_list_free (widgets);
511
512 _line_from_to (cr, &lx, &ly, w, ly);686 _line_from_to (cr, &lx, &ly, w, ly);
513 _line_from_to (cr, &lx, &ly, lx, y3);687 _line_from_to (cr, &lx, &ly, lx, y3);
514
515 cairo_close_path (cr);
516 }688 }
517 }689 }
518 else690 else
519 {691 {
520 if (internal)692 if (internal)
521 {693 {
522 /* Auto-Stripe & Not-Expanded & Internal */694 _line_from_to (cr, &lx, &ly, w - rdc, y2);
523 /* no-path */695 _line_from_to (cr, &lx, &ly, w, y3);
696 _line_from_to (cr, &lx, &ly, w - rdc, y);
524 }697 }
525 else698 else
526 {699 {
527 /* Auto-Stripe & Not-Expanded & External */700 _line_from_to (cr, &lx, &ly, w - rdc, ly);
528 ly = y3;
529 cairo_move_to (cr, lx, ly);
530
531 if (align == 0.)
532 _line_from_to (cr, &lx, &ly, lx , y);
533 else
534 _line_from_to (cr, &lx, &ly, lx + dc, y);
535
536 if (align == 1.)
537 _line_from_to (cr, &lx, &ly, w, y);
538 else
539 _line_from_to (cr, &lx, &ly, w - dc, y);
540
541 _line_from_to (cr, &lx, &ly, w, y3);701 _line_from_to (cr, &lx, &ly, w, y3);
542 cairo_close_path (cr);
543 }702 }
544 }703 }
545 }704 }
705 cairo_close_path (cr);
706 /****************************************************************************/
707 /******************** RESTART ANIMATION IF NEEDED **********************/
708 /****************************************************************************/
709 if (update_positions)
710 {
711 if (needs_animation)
712 {
713 _restart_timeout (bg, priv);
714 }
715 else
716 {
717 priv->needs_animation = FALSE;
718 }
719 }
720 return y;
546}721}
547722
548static void723static void
549draw_top_bottom_background (AwnBackground* bg,724draw_top_bottom_background (AwnBackground* bg,
550 GtkPositionType position,725 GtkPositionType position,
551 cairo_t* cr,726 cairo_t* cr,
552 gint width,727 gfloat width,
553 gint height)728 gfloat height)
554{729{
555 cairo_pattern_t *pat = NULL;730 cairo_pattern_t *pat = NULL;
556 cairo_pattern_t *pat_hi = NULL;731
557
558 /* Basic set-up */732 /* Basic set-up */
559 cairo_set_line_width (cr, 1.0);733 cairo_set_line_width (cr, 1.0);
560 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);734 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
561735
562 gboolean expand = FALSE;736 gboolean expand = FALSE;
563 g_object_get (bg->panel, "expand", &expand, NULL);737 g_object_get (bg->panel, "expand", &expand, NULL);
564 738
565 gfloat align = awn_background_get_panel_alignment (AWN_BACKGROUND (bg));739 gfloat align = awn_background_get_panel_alignment (AWN_BACKGROUND (bg));
566 740
567 /* Make sure the bar gets drawn on the 0.5 pixels (for sharp edges) */741 /* Make sure the bar gets drawn on the 0.5 pixels (for sharp edges) */
568 switch (position)742 if (!expand)
569 {743 {
570 case GTK_POS_TOP:744 cairo_translate (cr, 0.5, 0.5);
571 case GTK_POS_BOTTOM:745 width -= 0.5;
572 cairo_translate (cr, 0., 0.5);746 }
573 break;747 else
574 default:748 {
575 cairo_translate (cr, 0.5, 0.);749 cairo_translate (cr, -0.5, 0.5);
576 break;750 width += 1.;
577 }751 }
578 752
579 if (gtk_widget_is_composited (GTK_WIDGET (bg->panel)) == FALSE)753 if (gtk_widget_is_composited (GTK_WIDGET (bg->panel)) == FALSE)
580 {754 {
581 goto paint_lines;755 goto paint_lines;
582 }756 }
583757
758 gfloat x = 0.,
759 y = 0.;
760 gfloat y_pat;
761
584 /* create internal path */762 /* create internal path */
585 _create_path_lucido (bg, position, cr, -1.0, 0., width, height,763 y_pat = _create_path_lucido (bg, position, cr, x, y, width, height,
586 bg->stripe_width, TRANSFORM_RADIUS (bg->corner_radius),764 TRANSFORM_RADIUS (bg->corner_radius),
587 TRANSFORM_RADIUS (bg->corner_radius), bg->curves_symmetry,765 TRANSFORM_RADIUS (bg->corner_radius),
588 1, expand, align);766 TRUE, expand, align, TRUE);
589767
590 /* Draw internal pattern if needed */768 /* Draw internal pattern if needed */
591 if ((expand || bg->stripe_width != 0.) && bg->enable_pattern && bg->pattern)769 if (bg->enable_pattern && bg->pattern)
592 {770 {
593 /* Prepare pattern */771 /* Prepare pattern */
594 pat_hi = cairo_pattern_create_for_surface (bg->pattern);772 pat = cairo_pattern_create_for_surface (bg->pattern);
595 cairo_pattern_set_extend (pat_hi, CAIRO_EXTEND_REPEAT);773 cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT);
596 /* Draw */774 /* Draw */
597 cairo_save (cr);775 cairo_save (cr);
598 cairo_clip_preserve (cr);776 cairo_clip_preserve (cr);
599 cairo_set_source (cr, pat_hi);777 cairo_set_source (cr, pat);
600 cairo_paint (cr);778 cairo_paint (cr);
601 cairo_restore (cr);779 cairo_restore (cr);
602 cairo_pattern_destroy (pat_hi);780 cairo_pattern_destroy (pat);
603 }781 }
604782
605 /* Prepare the internal background */783 /* Prepare the internal background */
606 pat = cairo_pattern_create_linear (0, 0, 0, height);784 pat = cairo_pattern_create_linear (x, y_pat, 0., height);
607 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->border_color);785 awn_cairo_pattern_add_color_stop_color (pat, 0., bg->g_histep_1);
608 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->hilight_color);786 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_histep_2);
609787
610 /* Draw the internal background gradient */788 /* Draw the internal background gradient */
611 cairo_save (cr);789 cairo_save (cr);
@@ -613,37 +791,23 @@
613 cairo_set_source (cr, pat);791 cairo_set_source (cr, pat);
614 cairo_paint (cr);792 cairo_paint (cr);
615 cairo_restore (cr);793 cairo_restore (cr);
794 awn_cairo_set_source_color (cr, bg->border_color);
795 cairo_stroke (cr);
796
797 /* create external path */
798 y_pat = _create_path_lucido (bg, position, cr, x, y, width, height,
799 TRANSFORM_RADIUS (bg->corner_radius),
800 TRANSFORM_RADIUS (bg->corner_radius),
801 FALSE, expand, align, FALSE);
616802
617 /* Prepare external background gradient*/803 /* Prepare external background gradient*/
618 if (expand || bg->stripe_width != 0.)804 cairo_pattern_destroy (pat);
619 {805 pat = cairo_pattern_create_linear (x, y_pat, 0., height);
620 cairo_pattern_destroy (pat);806 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_step_1);
621 pat = cairo_pattern_create_linear (0, 0, 0, height);807 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);
622 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_step_1);
623 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);
624 }
625
626 /* create external path */
627 _create_path_lucido (bg, position, cr, -1.0, 0., width, height,
628 bg->stripe_width, TRANSFORM_RADIUS (bg->corner_radius),
629 TRANSFORM_RADIUS (bg->corner_radius), bg->curves_symmetry,
630 0, expand, align);
631808
632 /* Draw external pattern if needed */809 /* Clean below external background */
633 if (!expand && bg->stripe_width == 0. && bg->enable_pattern && bg->pattern)810 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
634 {
635 /* Prepare pattern */
636 pat_hi = cairo_pattern_create_for_surface (bg->pattern);
637 cairo_pattern_set_extend (pat_hi, CAIRO_EXTEND_REPEAT);
638 /* Draw */
639 cairo_save (cr);
640 cairo_clip_preserve (cr);
641 cairo_set_source (cr, pat_hi);
642 cairo_paint (cr);
643 cairo_restore (cr);
644 cairo_pattern_destroy (pat_hi);
645 }
646
647 /* Draw the external background */811 /* Draw the external background */
648 cairo_save (cr);812 cairo_save (cr);
649 cairo_clip_preserve (cr);813 cairo_clip_preserve (cr);
@@ -651,21 +815,12 @@
651 cairo_paint (cr);815 cairo_paint (cr);
652 cairo_restore (cr);816 cairo_restore (cr);
653 cairo_pattern_destroy (pat);817 cairo_pattern_destroy (pat);
654 818 /* Restore operator */
655 /* Draw the hi-light */819 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
656 pat_hi = cairo_pattern_create_linear (0, 0, 0, (height / 3.0));820
657 awn_cairo_pattern_add_color_stop_color (pat_hi, 0.0, bg->g_histep_1);821 /* Draw border */
658 awn_cairo_pattern_add_color_stop_color (pat_hi, 1.0, bg->g_histep_2);822 awn_cairo_set_source_color (cr, bg->hilight_color);
659 823 cairo_stroke (cr);
660 if (expand)
661 {
662 cairo_new_path (cr);
663 cairo_rectangle (cr, 0, 0, width, (height / 3.0));
664 }
665
666 cairo_set_source (cr, pat_hi);
667 cairo_fill (cr);
668 cairo_pattern_destroy (pat_hi);
669824
670 return;825 return;
671 /* if not composited */826 /* if not composited */
@@ -675,26 +830,26 @@
675 {830 {
676 /* Internal border */831 /* Internal border */
677 awn_cairo_set_source_color (cr, bg->hilight_color);832 awn_cairo_set_source_color (cr, bg->hilight_color);
678 cairo_rectangle (cr, 1, 1, width - 3, height + 3);833 cairo_rectangle (cr, 1., 1., width - 3., height + 3.);
679 cairo_stroke (cr);834 cairo_stroke (cr);
680835
681 /* External border */ 836 /* External border */
682 awn_cairo_set_source_color (cr, bg->border_color);837 awn_cairo_set_source_color (cr, bg->border_color);
683 cairo_rectangle (cr, 1, 1, width - 1, height + 3);838 cairo_rectangle (cr, 1., 1., width - 1., height + 3.);
684 }839 }
685 else840 else
686 {841 {
687 awn_cairo_set_source_color (cr, bg->border_color);842 awn_cairo_set_source_color (cr, bg->border_color);
688 _create_path_lucido (bg, position, cr, 0., 0., width, height,843 _create_path_lucido (bg, position, cr, 0., 0., width, height,
689 bg->stripe_width, TRANSFORM_RADIUS (bg->corner_radius),844 TRANSFORM_RADIUS (bg->corner_radius),
690 TRANSFORM_RADIUS (bg->corner_radius), bg->curves_symmetry,845 TRANSFORM_RADIUS (bg->corner_radius),
691 0, expand, align);846 FALSE, expand, align, TRUE);
692 cairo_stroke (cr);847 cairo_stroke (cr);
693 awn_cairo_set_source_color (cr, bg->hilight_color);848 awn_cairo_set_source_color (cr, bg->hilight_color);
694 _create_path_lucido (bg, position, cr, 1., 1., width-1., height-1.,849 _create_path_lucido (bg, position, cr, 1., 1., width-1., height-1.,
695 bg->stripe_width, TRANSFORM_RADIUS (bg->corner_radius),850 TRANSFORM_RADIUS (bg->corner_radius),
696 TRANSFORM_RADIUS (bg->corner_radius), bg->curves_symmetry,851 TRANSFORM_RADIUS (bg->corner_radius),
697 0, expand, align);852 FALSE, expand, align, FALSE);
698 }853 }
699 cairo_stroke (cr);854 cairo_stroke (cr);
700}855}
@@ -708,7 +863,6 @@
708 guint *padding_left,863 guint *padding_left,
709 guint *padding_right)864 guint *padding_right)
710{865{
711 #define TOP_PADDING 2
712 gboolean expand = FALSE;866 gboolean expand = FALSE;
713 g_object_get (bg->panel, "expand", &expand, NULL);867 g_object_get (bg->panel, "expand", &expand, NULL);
714 gint side_padding = expand ? 0 : TRANSFORM_RADIUS (bg->corner_radius);868 gint side_padding = expand ? 0 : TRANSFORM_RADIUS (bg->corner_radius);
@@ -771,7 +925,8 @@
771 switch (position)925 switch (position)
772 {926 {
773 case GTK_POS_RIGHT:927 case GTK_POS_RIGHT:
774 cairo_translate (cr, 0., y + height);928 height += y;
929 cairo_translate (cr, 0., height);
775 cairo_scale (cr, 1., -1.);930 cairo_scale (cr, 1., -1.);
776 cairo_translate (cr, x, height);931 cairo_translate (cr, x, height);
777 cairo_rotate (cr, M_PI * 1.5);932 cairo_rotate (cr, M_PI * 1.5);
@@ -780,26 +935,130 @@
780 height = temp;935 height = temp;
781 break;936 break;
782 case GTK_POS_LEFT:937 case GTK_POS_LEFT:
783 cairo_translate (cr, x + width, y);938 height += y;
939 cairo_translate (cr, x + width, 0.);
784 cairo_rotate (cr, M_PI * 0.5);940 cairo_rotate (cr, M_PI * 0.5);
785 temp = width;941 temp = width;
786 width = height;942 width = height;
787 height = temp;943 height = temp;
788 break;944 break;
789 case GTK_POS_TOP:945 case GTK_POS_TOP:
790 cairo_translate (cr, x, y + height);946 width += x;
947 cairo_translate (cr, 0., y + height);
791 cairo_scale (cr, 1., -1.);948 cairo_scale (cr, 1., -1.);
792 break;949 break;
793 default:950 default:
794 cairo_translate (cr, x, y);951 width += x;
952 cairo_translate (cr, 0., y);
795 break;953 break;
796 }954 }
797 955
798 draw_top_bottom_background (bg, position, cr, width, height);956 draw_top_bottom_background (bg, position, cr, width, height);
799 957
800 cairo_restore (cr);958 cairo_restore (cr);
801}959}
802960
961static void
962_set_special_widget_width_and_transparent (AwnBackground *bg,
963 gint width,
964 gboolean transp,
965 gboolean dispose)
966{
967 GList *widgets = _get_applet_widgets (bg);
968 GList *i = widgets;
969 GtkWidget *widget = NULL;
970
971 if (i && IS_SPECIAL (i->data) && !dispose)
972 {
973 widget = GTK_WIDGET (i->data);
974 awn_separator_set_separator_size (AWN_SEPARATOR (widget), 1);
975 awn_separator_set_transparent (AWN_SEPARATOR (widget), transp);
976 i = i->next;
977 }
978
979 for (; i; i = i->next)
980 {
981 widget = GTK_WIDGET (i->data);
982 if (!IS_SPECIAL (widget))
983 {
984 /* if not special continue */
985 continue;
986 }
987 awn_separator_set_separator_size (AWN_SEPARATOR (widget), width);
988 awn_separator_set_transparent (AWN_SEPARATOR (widget), transp);
989 }
990
991 g_list_free (widgets);
992}
993
994static void
995awn_background_lucido_get_shape_mask (AwnBackground *bg,
996 cairo_t *cr,
997 GtkPositionType position,
998 GdkRectangle *area)
999{
1000 gint temp;
1001 gint x = area->x, y = area->y;
1002 gint width = area->width, height = area->height;
1003 gfloat align = 0.5;
1004 gboolean expand = FALSE;
1005
1006 cairo_save (cr);
1007
1008 align = awn_background_get_panel_alignment (bg);
1009 g_object_get (bg->panel, "expand", &expand, NULL);
1010
1011 switch (position)
1012 {
1013 case GTK_POS_RIGHT:
1014 height += y;
1015 cairo_translate (cr, 0., height);
1016 cairo_scale (cr, 1., -1.);
1017 cairo_translate (cr, x, height);
1018 cairo_rotate (cr, M_PI * 1.5);
1019 temp = width;
1020 width = height;
1021 height = temp;
1022 break;
1023 case GTK_POS_LEFT:
1024 height += y;
1025 cairo_translate (cr, x + width, 0.);
1026 cairo_rotate (cr, M_PI * 0.5);
1027 temp = width;
1028 width = height;
1029 height = temp;
1030 break;
1031 case GTK_POS_TOP:
1032 width += x;
1033 cairo_translate (cr, 0., y + height);
1034 cairo_scale (cr, 1., -1.);
1035 break;
1036 default:
1037 width += x;
1038 cairo_translate (cr, 0., y);
1039 break;
1040 }
1041 if (expand)
1042 {
1043 cairo_rectangle (cr, 0., 0., width, height + 2.);
1044 }
1045 else
1046 {
1047 _create_path_lucido (bg, position, cr, 0., 0., width, height,
1048 TRANSFORM_RADIUS (bg->corner_radius),
1049 TRANSFORM_RADIUS (bg->corner_radius),
1050 FALSE, expand, align, FALSE);
1051 cairo_fill (cr);
1052 _create_path_lucido (bg, position, cr, 0., 0., width, height,
1053 TRANSFORM_RADIUS (bg->corner_radius),
1054 TRANSFORM_RADIUS (bg->corner_radius),
1055 TRUE, expand, align, FALSE);
1056
1057 }
1058 cairo_fill (cr);
1059
1060 cairo_restore (cr);
1061}
803static gboolean1062static gboolean
804awn_background_lucido_get_needs_redraw (AwnBackground *bg,1063awn_background_lucido_get_needs_redraw (AwnBackground *bg,
805 GtkPositionType position,1064 GtkPositionType position,
@@ -812,47 +1071,43 @@
812 {1071 {
813 return TRUE;1072 return TRUE;
814 }1073 }
815 1074 gboolean expand = FALSE;
816 /* Check expanders positions & sizes changed */1075 g_object_get (bg->panel, "expand", &expand, NULL);
1076 if (!expand)
1077 {
1078 return FALSE;
1079 }
1080 /* Check separators positions,
1081 * because bar's width doesn't change in expanded mode
1082 */
817 GList *widgets = _get_applet_widgets (bg);1083 GList *widgets = _get_applet_widgets (bg);
818 GList *i = widgets;1084 GList *i = widgets;
819 GtkWidget *widget = NULL;1085 GtkWidget *widget = NULL;
820 gint wcheck = 0;1086 gint wcheck = 0, j = 0;
821 gint ncheck = 0;1087
822
823 for (; i; i = i->next)1088 for (; i; i = i->next)
824 {1089 {
1090 ++j;
825 widget = GTK_WIDGET (i->data);1091 widget = GTK_WIDGET (i->data);
8261092 if (!IS_SPECIAL (widget))
827 if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
828 {1093 {
829 /* if not expander continue */1094 /* if not special continue */
830 continue;1095 continue;
831 }1096 }
832 switch (position)1097 switch (position)
833 {1098 {
834 case GTK_POS_BOTTOM:1099 case GTK_POS_LEFT:
835 case GTK_POS_TOP:1100 case GTK_POS_RIGHT:
836 wcheck += (widget->allocation.x * 3) / 2 + widget->allocation.width;1101 wcheck += widget->allocation.y * j;
837 break;1102 break;
838 default:1103 default:
839 wcheck += (widget->allocation.y * 3 ) / 2 + widget->allocation.height;1104 wcheck += widget->allocation.x * j;
840 break;1105 break;
841 }1106 }
842 ++ncheck;
843 }1107 }
844 g_list_free (widgets);1108 g_list_free (widgets);
845 1109 AwnBackgroundLucidoPrivate *priv =
846 AwnBackgroundLucido *lbg = NULL;1110 AWN_BACKGROUND_LUCIDO_GET_PRIVATE (AWN_BACKGROUND_LUCIDO (bg));
847 lbg = AWN_BACKGROUND_LUCIDO (bg);
848 AwnBackgroundLucidoPrivate *priv;
849 priv = AWN_BACKGROUND_LUCIDO_GET_PRIVATE (lbg);
850 if (priv->expn != ncheck)
851 {
852 priv->expn = ncheck;
853 /* used to refresh bar */
854 awn_background_emit_padding_changed (bg);
855 }
856 if (priv->expw != wcheck)1111 if (priv->expw != wcheck)
857 {1112 {
858 priv->expw = wcheck;1113 priv->expw = wcheck;
@@ -860,63 +1115,4 @@
860 }1115 }
861 return FALSE;1116 return FALSE;
862}1117}
863
864static void
865awn_background_lucido_get_shape_mask (AwnBackground *bg,
866 cairo_t *cr,
867 GtkPositionType position,
868 GdkRectangle *area)
869{
870 gint temp;
871 gint x = area->x, y = area->y;
872 gint width = area->width, height = area->height;
873 gfloat align = 0.5;
874 gboolean expand = FALSE;
875
876 cairo_save (cr);
877
878 align = awn_background_get_panel_alignment (bg);
879 g_object_get (bg->panel, "expand", &expand, NULL);
880
881 switch (position)
882 {
883 case GTK_POS_RIGHT:
884 cairo_translate (cr, 0., y + height);
885 cairo_scale (cr, 1., -1.);
886 cairo_translate (cr, x, height);
887 cairo_rotate (cr, M_PI * 1.5);
888 temp = width;
889 width = height;
890 height = temp;
891 break;
892 case GTK_POS_LEFT:
893 cairo_translate (cr, x + width, y);
894 cairo_rotate (cr, M_PI * 0.5);
895 temp = width;
896 width = height;
897 height = temp;
898 break;
899 case GTK_POS_TOP:
900 cairo_translate (cr, x, y + height);
901 cairo_scale (cr, 1., -1.);
902 break;
903 default:
904 cairo_translate (cr, x, y);
905 break;
906 }
907 if (expand)
908 {
909 cairo_rectangle (cr, 0, 0, width, height + 2);
910 }
911 else
912 {
913 _create_path_lucido (bg, position, cr, 0, 0., width, height,
914 bg->stripe_width, TRANSFORM_RADIUS (bg->corner_radius),
915 TRANSFORM_RADIUS (bg->corner_radius), bg->curves_symmetry,
916 0, expand, align);
917 }
918 cairo_fill (cr);
919
920 cairo_restore (cr);
921}
922/* vim: set et ts=2 sts=2 sw=2 : */1118/* vim: set et ts=2 sts=2 sw=2 : */
9231119
=== modified file 'src/awn-background.c'
--- src/awn-background.c 2010-06-02 09:54:30 +0000
+++ src/awn-background.c 2010-07-16 10:54:57 +0000
@@ -60,7 +60,7 @@
60 PROP_CURVINESS,60 PROP_CURVINESS,
61 PROP_CURVES_SYMEMETRY,61 PROP_CURVES_SYMEMETRY,
62 PROP_FLOATY_OFFSET,62 PROP_FLOATY_OFFSET,
63 PROP_STRIPE_WIDTH63 PROP_THICKNESS
64};64};
6565
66enum 66enum
@@ -198,8 +198,8 @@
198 DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,198 DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,
199 NULL);199 NULL);
200 desktop_agnostic_config_client_bind (bg->client,200 desktop_agnostic_config_client_bind (bg->client,
201 AWN_GROUP_THEME, AWN_THEME_STRIPE_WIDTH,201 AWN_GROUP_THEME, AWN_THEME_THICKNESS,
202 object, "stripe-width", TRUE,202 object, "thickness", TRUE,
203 DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,203 DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,
204 NULL);204 NULL);
205}205}
@@ -236,6 +236,9 @@
236 case PROP_FLOATY_OFFSET:236 case PROP_FLOATY_OFFSET:
237 g_value_set_int (value, bg->floaty_offset);237 g_value_set_int (value, bg->floaty_offset);
238 break;238 break;
239 case PROP_THICKNESS:
240 g_value_set_float (value, bg->thickness);
241 break;
239 default:242 default:
240 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);243 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
241 }244 }
@@ -364,12 +367,12 @@
364 case PROP_CURVES_SYMEMETRY:367 case PROP_CURVES_SYMEMETRY:
365 bg->curves_symmetry = g_value_get_float (value);368 bg->curves_symmetry = g_value_get_float (value);
366 break;369 break;
370 case PROP_THICKNESS:
371 bg->thickness = g_value_get_float (value);
372 break;
367 case PROP_FLOATY_OFFSET:373 case PROP_FLOATY_OFFSET:
368 bg->floaty_offset = g_value_get_int (value);374 bg->floaty_offset = g_value_get_int (value);
369 break;375 break;
370 case PROP_STRIPE_WIDTH:
371 bg->stripe_width = g_value_get_float (value);
372 break;
373376
374 default:377 default:
375 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);378 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -619,16 +622,15 @@
619 0.0, 1.0, 0.5,622 0.0, 1.0, 0.5,
620 G_PARAM_READWRITE | G_PARAM_CONSTRUCT |623 G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
621 G_PARAM_STATIC_STRINGS));624 G_PARAM_STATIC_STRINGS));
625 g_object_class_install_property (obj_class,
626 PROP_THICKNESS,
627 g_param_spec_float ("thickness",
628 "Thickness",
629 "The thickness in 3D mode",
630 0.0, 1.0, 0.6,
631 G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
632 G_PARAM_STATIC_STRINGS));
622 633
623 g_object_class_install_property (obj_class,
624 PROP_STRIPE_WIDTH,
625 g_param_spec_float ("stripe-width",
626 "Stripe Width",
627 "The width of the stripe",
628 0.0, 1.0, 0.0,
629 G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
630 G_PARAM_STATIC_STRINGS));
631
632 /* Add signals to the class */634 /* Add signals to the class */
633 _bg_signals[CHANGED] = 635 _bg_signals[CHANGED] =
634 g_signal_new ("changed",636 g_signal_new ("changed",
@@ -870,7 +872,7 @@
870awn_background_emit_padding_changed (AwnBackground *bg)872awn_background_emit_padding_changed (AwnBackground *bg)
871{873{
872 g_return_if_fail (AWN_IS_BACKGROUND (bg));874 g_return_if_fail (AWN_IS_BACKGROUND (bg));
873875 awn_background_invalidate (bg);
874 g_signal_emit (bg, _bg_signals[PADDING_CHANGED], 0);876 g_signal_emit (bg, _bg_signals[PADDING_CHANGED], 0);
875}877}
876878
@@ -878,7 +880,7 @@
878awn_background_emit_changed (AwnBackground *bg)880awn_background_emit_changed (AwnBackground *bg)
879{881{
880 g_return_if_fail (AWN_IS_BACKGROUND (bg));882 g_return_if_fail (AWN_IS_BACKGROUND (bg));
881883 awn_background_invalidate (bg);
882 g_signal_emit (bg, _bg_signals[CHANGED], 0);884 g_signal_emit (bg, _bg_signals[CHANGED], 0);
883}885}
884886
885887
=== modified file 'src/awn-background.h'
--- src/awn-background.h 2010-05-31 17:41:58 +0000
+++ src/awn-background.h 2010-07-16 10:54:57 +0000
@@ -76,7 +76,7 @@
76 gfloat pattern_alpha;76 gfloat pattern_alpha;
77 GdkPixbuf *pattern_original;77 GdkPixbuf *pattern_original;
78 cairo_surface_t *pattern;78 cairo_surface_t *pattern;
79 79
80 /* Speedup code.80 /* Speedup code.
81 * We can save the bg and redraw only when properties changes81 * We can save the bg and redraw only when properties changes
82 */82 */
@@ -91,7 +91,7 @@
91 */91 */
92 gboolean dialog_gtk_mode;92 gboolean dialog_gtk_mode;
93 gboolean gtk_theme_mode;93 gboolean gtk_theme_mode;
94 94
95 /* Appearance options -- (some are backend specific) */95 /* Appearance options -- (some are backend specific) */
96 gboolean rounded_corners;96 gboolean rounded_corners;
97 gfloat corner_radius;97 gfloat corner_radius;
@@ -99,7 +99,7 @@
99 gint floaty_offset;99 gint floaty_offset;
100 gfloat curviness;100 gfloat curviness;
101 gfloat curves_symmetry;101 gfloat curves_symmetry;
102 gfloat stripe_width;102 gfloat thickness;
103103
104 /* private */104 /* private */
105 guint changed;105 guint changed;
106106
=== modified file 'src/awn-defines.h'
--- src/awn-defines.h 2010-05-31 17:41:58 +0000
+++ src/awn-defines.h 2010-07-16 10:54:57 +0000
@@ -88,7 +88,7 @@
88#define AWN_THEME_CURVINESS "curviness"88#define AWN_THEME_CURVINESS "curviness"
89#define AWN_THEME_CURVES_SYMMETRY "curves_symmetry"89#define AWN_THEME_CURVES_SYMMETRY "curves_symmetry"
90#define AWN_THEME_FLOATY_OFFSET "floaty_offset"90#define AWN_THEME_FLOATY_OFFSET "floaty_offset"
91#define AWN_THEME_STRIPE_WIDTH "stripe_width"91#define AWN_THEME_THICKNESS "thickness"
9292
93#endif /*_HAVE_AWN_DEFINES_H */93#endif /*_HAVE_AWN_DEFINES_H */
9494
9595
=== modified file 'src/awn-panel.c'
--- src/awn-panel.c 2010-05-31 16:49:07 +0000
+++ src/awn-panel.c 2010-07-16 10:54:57 +0000
@@ -3920,6 +3920,12 @@
3920 return FALSE;3920 return FALSE;
3921}3921}
39223922
3923gboolean
3924awn_panel_get_docklet_mode (AwnPanel *panel)
3925{
3926 return panel->priv->docklet != NULL;
3927}
3928
3923static void3929static void
3924awn_panel_docklet_destroy (AwnPanel *panel)3930awn_panel_docklet_destroy (AwnPanel *panel)
3925{3931{
39263932
=== modified file 'src/awn-panel.h'
--- src/awn-panel.h 2010-05-30 22:48:59 +0000
+++ src/awn-panel.h 2010-07-16 10:54:57 +0000
@@ -111,6 +111,8 @@
111 gboolean expand,111 gboolean expand,
112 DBusGMethodInvocation *context);112 DBusGMethodInvocation *context);
113113
114gboolean awn_panel_get_docklet_mode (AwnPanel *panel);
115
114gboolean awn_panel_get_snapshot (AwnPanel *panel,116gboolean awn_panel_get_snapshot (AwnPanel *panel,
115 GValue *value,117 GValue *value,
116 GError **error);118 GError **error);
117119
=== modified file 'src/awn-separator.c'
--- src/awn-separator.c 2010-01-01 21:35:47 +0000
+++ src/awn-separator.c 2010-07-16 10:54:57 +0000
@@ -34,7 +34,9 @@
34 GtkPositionType position;34 GtkPositionType position;
35 gint offset;35 gint offset;
36 gint size;36 gint size;
37 gint separator_size;
3738
39 gboolean transparent;
38 DesktopAgnosticColor *sep_color;40 DesktopAgnosticColor *sep_color;
39};41};
4042
@@ -47,7 +49,10 @@
47 PROP_OFFSET,49 PROP_OFFSET,
48 PROP_SIZE,50 PROP_SIZE,
4951
50 PROP_SEP_COLOR52 PROP_SEP_COLOR,
53 PROP_SEP_TRANSPARENT,
54
55 PROP_SEP_SIZE
51};56};
5257
53static void58static void
@@ -78,6 +83,12 @@
78 case PROP_SEP_COLOR:83 case PROP_SEP_COLOR:
79 g_value_set_object (value, priv->sep_color);84 g_value_set_object (value, priv->sep_color);
80 break;85 break;
86 case PROP_SEP_SIZE:
87 g_value_set_int (value, priv->separator_size);
88 break;
89 case PROP_SEP_TRANSPARENT:
90 g_value_set_boolean (value, priv->transparent);
91 break;
81 default:92 default:
82 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);93 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
83 }94 }
@@ -126,6 +137,14 @@
126 priv->sep_color = g_value_dup_object (value);137 priv->sep_color = g_value_dup_object (value);
127 gtk_widget_queue_draw (GTK_WIDGET (object));138 gtk_widget_queue_draw (GTK_WIDGET (object));
128 break;139 break;
140 case PROP_SEP_SIZE:
141 awn_separator_set_separator_size (AWN_SEPARATOR (object),
142 g_value_get_int (value));
143 break;
144 case PROP_SEP_TRANSPARENT:
145 awn_separator_set_transparent (AWN_SEPARATOR (object),
146 g_value_get_boolean (value));
147 break;
129 default:148 default:
130 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);149 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
131 }150 }
@@ -181,13 +200,13 @@
181 {200 {
182 case GTK_POS_TOP:201 case GTK_POS_TOP:
183 case GTK_POS_BOTTOM:202 case GTK_POS_BOTTOM:
184 req->width = 10;203 req->width = priv->separator_size;
185 req->height = priv->size + priv->offset;204 req->height = priv->size + priv->offset;
186 break;205 break;
187 case GTK_POS_LEFT:206 case GTK_POS_LEFT:
188 case GTK_POS_RIGHT:207 case GTK_POS_RIGHT:
189 req->width = priv->size + priv->offset;208 req->width = priv->size + priv->offset;
190 req->height = 10;209 req->height = priv->separator_size;
191 break;210 break;
192 default:211 default:
193 break;212 break;
@@ -198,6 +217,12 @@
198awn_separator_expose (GtkWidget *widget, GdkEventExpose *event)217awn_separator_expose (GtkWidget *widget, GdkEventExpose *event)
199{218{
200 AwnSeparatorPrivate *priv = AWN_SEPARATOR (widget)->priv;219 AwnSeparatorPrivate *priv = AWN_SEPARATOR (widget)->priv;
220
221 if (priv->transparent)
222 {
223 return TRUE;
224 }
225
201 cairo_t *cr;226 cairo_t *cr;
202 cairo_path_t *path;227 cairo_path_t *path;
203 GtkOrientation orient;228 GtkOrientation orient;
@@ -366,6 +391,24 @@
366 DESKTOP_AGNOSTIC_TYPE_COLOR,391 DESKTOP_AGNOSTIC_TYPE_COLOR,
367 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));392 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
368393
394 g_object_class_install_property (object_class,
395 PROP_SEP_SIZE,
396 g_param_spec_int ("separator-size",
397 "Separator Size",
398 "The size of the separator",
399 0, G_MAXINT, 10,
400 G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
401 G_PARAM_STATIC_STRINGS));
402
403 g_object_class_install_property (object_class,
404 PROP_SEP_TRANSPARENT,
405 g_param_spec_boolean ("transparent",
406 "Transparent",
407 "Is separator transparent?",
408 FALSE,
409 G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
410 G_PARAM_STATIC_STRINGS));
411
369 g_type_class_add_private (klass, sizeof (AwnSeparatorPrivate));412 g_type_class_add_private (klass, sizeof (AwnSeparatorPrivate));
370}413}
371414
@@ -405,3 +448,35 @@
405 NULL);448 NULL);
406}449}
407450
451void
452awn_separator_set_transparent (AwnSeparator *sep, gboolean transp)
453{
454 if (sep->priv->transparent != transp)
455 {
456 sep->priv->transparent = transp;
457 gtk_widget_queue_draw (GTK_WIDGET (sep));
458 }
459}
460
461gboolean
462awn_separator_get_transparent (AwnSeparator *sep, gboolean transp)
463{
464 return sep->priv->transparent;
465}
466
467void
468awn_separator_set_separator_size (AwnSeparator *sep, gint size)
469{
470 if (sep->priv->separator_size != size)
471 {
472 sep->priv->separator_size = size;
473 gtk_widget_queue_resize (GTK_WIDGET (sep));
474 }
475}
476
477gint
478awn_separator_get_separator_size (AwnSeparator *sep, gint size)
479{
480 return sep->priv->separator_size;
481}
482
408483
=== modified file 'src/awn-separator.h'
--- src/awn-separator.h 2009-10-31 12:14:11 +0000
+++ src/awn-separator.h 2010-07-16 10:54:57 +0000
@@ -65,6 +65,18 @@
65 GtkPositionType pos,65 GtkPositionType pos,
66 gint size, gint offset);66 gint size, gint offset);
6767
68void
69awn_separator_set_transparent (AwnSeparator *sep, gboolean transp);
70
71gboolean
72awn_separator_get_transparent (AwnSeparator *sep, gboolean transp);
73
74void
75awn_separator_set_separator_size (AwnSeparator *sep, gint size);
76
77gint
78awn_separator_get_separator_size (AwnSeparator *sep, gint size);
79
68G_END_DECLS80G_END_DECLS
6981
70#endif /* _AWN_SEPARATOR_H_ */82#endif /* _AWN_SEPARATOR_H_ */

Subscribers

People subscribed via source and target branches