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: 1235 lines (+946/-12)
12 files modified
awn-settings/awn-settings.ui (+34/-0)
awn-settings/awnDefs.py.in (+1/-0)
awn-settings/awnSettings.py.in (+6/-1)
data/avant-window-navigator.schema-ini.in.in (+7/-1)
src/Makefile.am (+2/-0)
src/awn-background-flat.c (+10/-6)
src/awn-background-lucido.c (+700/-0)
src/awn-background-lucido.h (+70/-0)
src/awn-background.c (+91/-4)
src/awn-background.h (+16/-0)
src/awn-defines.h (+1/-0)
src/awn-panel.c (+8/-0)
To merge this branch: bzr merge lp:~albyrock87/awn/awn-lucido
Reviewer Review Type Date Requested Status
Michal Hruby (community) Needs Fixing
Alberto Aldegheri Needs Resubmitting
Review via email: mp+25444@code.launchpad.net

This proposal has been superseded by a proposal from 2010-05-27.

Description of the change

This is a rewrite of awn-style-lucido.

Implemented a new style, features:
- Stripe-style
- The number of stripes changes dynamically depends on "expanders"
- If you set stripe-width>0, you can manually set the stripe position and width
- Fixed all-orientation cairo "translate"
- custom curved style if panel is not expanded
- speedup code for draw background only when need (otherwise repaint last surface)

:)

To post a comment you must log in.
Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

WTF!!!

Why BZR removes 'po/avant-window-navigator.pot' if i've never touched that file?????

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

> WTF!!!
>
> Why BZR removes 'po/avant-window-navigator.pot' if i've never touched that
> file?????

There's a bug in the build system, make clean removes it, please revert the change.
Also there are a lot of lines which break our coding conventions, I know it might sound trivial, but for the review process it makes it easier to read the code. Fix please.

review: Needs Fixing (coding-conventions)
Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

> > WTF!!!
> >
> > Why BZR removes 'po/avant-window-navigator.pot' if i've never touched that
> > file?????
>
> There's a bug in the build system, make clean removes it, please revert the
> change.
> Also there are a lot of lines which break our coding conventions, I know it
> might sound trivial, but for the review process it makes it easier to read the
> code. Fix please.

'po/avant-window-navigator.pot' -> restored from rev 699
Conding style fixes :)
Default Stripe-Width = 0 (enables auto-stripe)

review: Needs Resubmitting
Revision history for this message
moonbeam (rcryderman) wrote :

Seems to be leaking:

revision: 707.

After leaving it running 12-24 hours.

mapped: 1539380K writeable/private: 1297488K shared: 816K

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

> Seems to be leaking:
>
> revision: 707.
>
> After leaving it running 12-24 hours.
>
> mapped: 1539380K writeable/private: 1297488K shared: 816K

I'm very sorry for that :'(

Now it's fixed (rev 710) :)

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

Thanks for the style fixes. Here are my comments:

1) When using cairo methods, please use doubles directly, don't have the compiler do it ( cairo_scale (cr, 1, -1) => cairo_scale (cr, 1., -1.) )
2) You're using the expander detection quite often, move it to a function (at least the g_object_get() + gtk_container_get_children() )
3) Get rid of "g_list_free (i)", it could cause problems.
4) Since you introduced the helper surface, it'd be nice to integrate it properly into the background base class and have a "cached-drawing" property that will control whether the surface is used (default TRUE). (you'll get an extra point if you provide some statistics on how often is helps)
5) The stripe-width spin is put on a strange place in awn-settings, please try to rearrange it, so that it fits nicely.

review: Needs Fixing (code review)
Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

> Thanks for the style fixes. Here are my comments:
>
> 1) When using cairo methods, please use doubles directly, don't have the
> compiler do it ( cairo_scale (cr, 1, -1) => cairo_scale (cr, 1., -1.) )
> 2) You're using the expander detection quite often, move it to a function (at
> least the g_object_get() + gtk_container_get_children() )
> 3) Get rid of "g_list_free (i)", it could cause problems.
> 4) Since you introduced the helper surface, it'd be nice to integrate it
> properly into the background base class and have a "cached-drawing" property
> that will control whether the surface is used (default TRUE). (you'll get an
> extra point if you provide some statistics on how often is helps)
> 5) The stripe-width spin is put on a strange place in awn-settings, please try
> to rearrange it, so that it fits nicely.

I'm working on this.

For now I can tell you that (in lucido style), times are:
- use helper surface: ~0ms
- redraw surface: ~10ms

If you hover an icon and then run away with your mouse with bounce effect, you get about 20 redraw (during animation):
- using helper surface: ~1ms
- not using helper surface: 20*10 = 200ms

Time calculated with:
#include <time.h>

clock_t start, end;
double elapsed;

start = clock();
... /* Do the work. */
end = clock();
elapsed = ((double) (end - start)) / (((double)CLOCKS_PER_SEC) / 1000.0 );

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

> Thanks for the style fixes. Here are my comments:
>
> 1) When using cairo methods, please use doubles directly, don't have the
> compiler do it ( cairo_scale (cr, 1, -1) => cairo_scale (cr, 1., -1.) )
> 2) You're using the expander detection quite often, move it to a function (at
> least the g_object_get() + gtk_container_get_children() )
> 3) Get rid of "g_list_free (i)", it could cause problems.
> 4) Since you introduced the helper surface, it'd be nice to integrate it
> properly into the background base class and have a "cached-drawing" property
> that will control whether the surface is used (default TRUE). (you'll get an
> extra point if you provide some statistics on how often is helps)
> 5) The stripe-width spin is put on a strange place in awn-settings, please try
> to rearrange it, so that it fits nicely.

Ok, What do you think about?

Some statistic? mh..
On any animation's step on every icon, you get background refreshed. (with cache in O(1) time)
The same for any expose event.

However, if you want to see how often is the redraw, you can put a:
fprintf (stderr, "I'm redrawing the bg \n");
on awn-background.c row 701

You will see that the redraw is rare, then the performance gain is very often :)

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

Resubmitting :)

PS: i've checked for mem-leaks this time, and I have not found any mem-leak.

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

As a side note, the "Resubmit" is for reviewers when they want you to resubmit the proposal, when you want to resubmit it, there's the "Resubmit proposal" link on top of this page.

1) Please revert the 1210-1220, this should go into background's finalize method.
2) It seems that awn_background_get_needs_redraw (and also the lucido variant) is not necessary to be exposed in the .h files. Please make it a static method and use the virtual klass->get_needs_redraw to call it.
3) Also why is 1190-1192 necessary?

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

> As a side note, the "Resubmit" is for reviewers when they want you to resubmit
> the proposal, when you want to resubmit it, there's the "Resubmit proposal"
> link on top of this page.
I'm sorry, but I'm new in Lauchpad&Bzr :P

> 1) Please revert the 1210-1220, this should go into background's finalize
> method.
Done :)

> 2) It seems that awn_background_get_needs_redraw (and also the lucido variant)
> is not necessary to be exposed in the .h files. Please make it a static method
> and use the virtual klass->get_needs_redraw to call it.
awn_background_get_needs_redraw needs to be in awn-background.h because it is used in awn-background-lucido.c @ awn_background_lucido_get_needs_redraw.

Moved awn_background_lucido_get_needs_redraw into .c

> 3) Also why is 1190-1192 necessary?
Because when you move panel position from bottom to top, or left to right, width&height doesn't change. So we need to notify background to redraw itself.

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

> > 2) It seems that awn_background_get_needs_redraw (and also the lucido
> variant)
> > is not necessary to be exposed in the .h files. Please make it a static
> method
> > and use the virtual klass->get_needs_redraw to call it.
> awn_background_get_needs_redraw needs to be in awn-background.h because it is
> used in awn-background-lucido.c @ awn_background_lucido_get_needs_redraw.

It still doesn't have to be in the .h, you can use >>>
AWN_BACKGROUND_CLASS (awn_background_lucido_parent_class)-> get_needs_redraw ()

> > 3) Also why is 1190-1192 necessary?
> Because when you move panel position from bottom to top, or left to right,
> width&height doesn't change. So we need to notify background to redraw itself.

Ok, but please make a method for it (awn_background_invalidate), the usage of public variables is really unfortunate in the background class.

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

> > > 2) It seems that awn_background_get_needs_redraw (and also the lucido
> > variant)
> > > is not necessary to be exposed in the .h files. Please make it a static
> > method
> > > and use the virtual klass->get_needs_redraw to call it.
> > awn_background_get_needs_redraw needs to be in awn-background.h because it
> is
> > used in awn-background-lucido.c @ awn_background_lucido_get_needs_redraw.
>
> It still doesn't have to be in the .h, you can use >>>
> AWN_BACKGROUND_CLASS (awn_background_lucido_parent_class)-> get_needs_redraw
> ()

Done, thank you :)

> > > 3) Also why is 1190-1192 necessary?
> > Because when you move panel position from bottom to top, or left to right,
> > width&height doesn't change. So we need to notify background to redraw
> itself.
>
> Ok, but please make a method for it (awn_background_invalidate), the usage of
> public variables is really unfortunate in the background class.

You're right, done

lp:~albyrock87/awn/awn-lucido updated
700. By Michal Hruby

 * awn-settings/awnSettings.py.in:
 * po/avant-window-navigator.pot:
 Fix LP bug #586670.

701. By Michal Hruby

 * applets/quick-prefs/applet.vala:
 Use async DBus calls in quick-prefs applet.

702. By Michal Hruby

 * src/awn-monitor.c:
 * src/awn-monitor.h:
 * src/awn-panel.c:
 Possible fix for LP bug #562453.

703. By Michal Hruby

Merge Lucido style from <lp:~albyrock87/awn/awn-lucido>

704. By Michal Hruby

 * awn-settings/awn-settings.ui:
 * awn-settings/awnDefs.py.in:
 * awn-settings/awnSettings.py.in:
 * data/avant-window-navigator.schema-ini.in.in:
 * src/awn-background-floaty.c:
 * src/awn-background-lucido.c:
 * src/awn-background.c:
 * src/awn-background.h:
 * src/awn-defines.h:
 Stop misusing curviness in Floaty, don't use it in Lucido either.

705. By Michal Hruby

Merge Lucido changes from <lp:~albyrock87/awn/awn-lucido>

706. By Alberto <alby@CASA>

FixTo:(0.5 pixel line not colored)

707. By Alberto <alby@CASA>

Merge from trunk

708. By Alberto <alby@CASA>

First version of separator-lucido

709. By Alberto <alby@CASA>

Stripe Width deleted

710. By Alberto <alby@CASA>

Draw bugfix

711. By Alberto <alby@CASA>

Draw bugfix number 2

712. By Alberto <alby@CASA>

Ops, removing test code

713. By Alberto <alby@CASA>

Better hi-light pattern

714. By Alberto <alby@CASA>

SEP_WIDTH to SEP_SIZE

715. By Alberto <alby@CASA>

Fix to expanded+align background position

716. By Alberto <alby@CASA>

Ops, fix mem leak

717. By Alberto <alby@CASA>

Fix: Refresh bug in expanded+align+no-expanders

718. By Alberto <alby@CASA>

Test version on separators.

719. By Alberto <alby@CASA>

ops

720. By Alberto <alby@CASA>

Fix to a bug when changing corner radius

721. By Alberto <alby@alby-laptop>

Some fixes and code restyle

722. By Alberto <alby@CASA>

Revert all animation changes for getting back stability. Animation -for now and for me- cant work. Feel free to fork rev 721.

723. By Alberto <alby@CASA>

Merge with lp:awn

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.

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

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

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

741. By Alberto <alby@CASA>

A little speedup

742. By Alberto <alby@CASA>

Shit. I've forgot this.

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.

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

750. By Alberto <alby@CASA>

Little fixes

751. By Alberto <alby@CASA>

Merged from lp:awn

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

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

759. By Alberto <alby@CASA>

Fixed 3065, sorry michal

760. By Alberto <alby@CASA>

Fixed Edgy. Auto invalidate bg on changed signal.

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-03-08 12:50:07 +0000
+++ awn-settings/awn-settings.ui 2010-05-24 12:32:29 +0000
@@ -908,6 +908,22 @@
908 </packing>908 </packing>
909 </child>909 </child>
910 <child>910 <child>
911 <object class="GtkSpinButton" id="theme_stripe_width">
912 <property name="visible">True</property>
913 <property name="can_focus">True</property>
914 <property name="invisible_char">&#x25CF;</property>
915 <property name="adjustment">adj_stripe_width</property>
916 <property name="digits">2</property>
917 </object>
918 <packing>
919 <property name="left_attach">5</property>
920 <property name="right_attach">6</property>
921 <property name="top_attach">8</property>
922 <property name="bottom_attach">9</property>
923 <property name="x_options"></property>
924 </packing>
925 </child>
926 <child>
911 <object class="GtkSpinButton" id="theme_angle">927 <object class="GtkSpinButton" id="theme_angle">
912 <property name="visible">True</property>928 <property name="visible">True</property>
913 <property name="can_focus">True</property>929 <property name="can_focus">True</property>
@@ -964,6 +980,20 @@
964 </packing>980 </packing>
965 </child>981 </child>
966 <child>982 <child>
983 <object class="GtkLabel" id="label_stripe">
984 <property name="visible">True</property>
985 <property name="xalign">0</property>
986 <property name="xpad">0</property>
987 <property name="label" translatable="yes">Stripe Width</property>
988 </object>
989 <packing>
990 <property name="left_attach">3</property>
991 <property name="right_attach">5</property>
992 <property name="top_attach">8</property>
993 <property name="bottom_attach">9</property>
994 </packing>
995 </child>
996 <child>
967 <object class="GtkLabel" id="label49">997 <object class="GtkLabel" id="label49">
968 <property name="visible">True</property>998 <property name="visible">True</property>
969 <property name="xalign">0</property>999 <property name="xalign">0</property>
@@ -3406,6 +3436,10 @@
3406 <property name="upper">1</property>3436 <property name="upper">1</property>
3407 <property name="step_increment">0.01</property>3437 <property name="step_increment">0.01</property>
3408 </object>3438 </object>
3439 <object class="GtkAdjustment" id="adj_stripe_width">
3440 <property name="upper">1</property>
3441 <property name="step_increment">0.01</property>
3442 </object>
3409 <object class="GtkAdjustment" id="adj_radius">3443 <object class="GtkAdjustment" id="adj_radius">
3410 <property name="upper">100</property>3444 <property name="upper">100</property>
3411 <property name="step_increment">1</property>3445 <property name="step_increment">1</property>
34123446
=== modified file 'awn-settings/awnDefs.py.in'
--- awn-settings/awnDefs.py.in 2010-04-29 14:58:51 +0000
+++ awn-settings/awnDefs.py.in 2010-05-24 12:32:29 +0000
@@ -86,6 +86,7 @@
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
89TOOLTIP_FONT_NAME = "tooltip_font_name" #string90TOOLTIP_FONT_NAME = "tooltip_font_name" #string
90TOOLTIP_FONT_COLOR = "tooltip_font_color" #string91TOOLTIP_FONT_COLOR = "tooltip_font_color" #string
91TOOLTIP_BG_COLOR = "tooltip_bg_color" #string92TOOLTIP_BG_COLOR = "tooltip_bg_color" #string
9293
=== modified file 'awn-settings/awnSettings.py.in'
--- awn-settings/awnSettings.py.in 2010-04-11 00:22:25 +0000
+++ awn-settings/awnSettings.py.in 2010-05-24 12:32:29 +0000
@@ -141,7 +141,8 @@
141 #setup style mode141 #setup style mode
142 dropdown = self.wTree.get_object("stylecombo")142 dropdown = self.wTree.get_object("stylecombo")
143 self.create_dropdown(dropdown, [_("None"), _("Flat"), _("3d"),143 self.create_dropdown(dropdown, [_("None"), _("Flat"), _("3d"),
144 _("Curved"), _("Edgy"), _("Floaty")])144 _("Curved"), _("Edgy"), _("Floaty"),
145 _("Lucido")])
145146
146 #setup behaviour combo147 #setup behaviour combo
147 dropdown = self.wTree.get_object("behaviorcombo")148 dropdown = self.wTree.get_object("behaviorcombo")
@@ -578,6 +579,7 @@
578 579
579 curviness = gobject.property(type=int, default=10)580 curviness = gobject.property(type=int, default=10)
580 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)
581 angle = gobject.property(type=int, default=45)583 angle = gobject.property(type=int, default=45)
582 radius = gobject.property(type=int, default=10)584 radius = gobject.property(type=int, default=10)
583 gtk_theme_mode = gobject.property(type=bool, default=False)585 gtk_theme_mode = gobject.property(type=bool, default=False)
@@ -727,6 +729,7 @@
727 (defs.THEME, defs.PANEL_ANGLE, 'float', sizes),729 (defs.THEME, defs.PANEL_ANGLE, 'float', sizes),
728 (defs.THEME, defs.CURVINESS, 'float', sizes),730 (defs.THEME, defs.CURVINESS, 'float', sizes),
729 (defs.THEME, defs.CURVES_SYMMETRY, 'float', sizes),731 (defs.THEME, defs.CURVES_SYMMETRY, 'float', sizes),
732 (defs.THEME, defs.STRIPE_WIDTH, 'float', sizes),
730 (defs.THEME, defs.TOOLTIP_FONT_NAME, 'str', icon),733 (defs.THEME, defs.TOOLTIP_FONT_NAME, 'str', icon),
731 (defs.THEME, defs.TOOLTIP_FONT_COLOR, 'str', icon),734 (defs.THEME, defs.TOOLTIP_FONT_COLOR, 'str', icon),
732 (defs.THEME, defs.TOOLTIP_BG_COLOR, 'str', icon),735 (defs.THEME, defs.TOOLTIP_BG_COLOR, 'str', icon),
@@ -823,6 +826,8 @@
823 "curviness", "theme_curviness"),826 "curviness", "theme_curviness"),
824 (self.client, defs.THEME, defs.CURVES_SYMMETRY,827 (self.client, defs.THEME, defs.CURVES_SYMMETRY,
825 "curves-symmetry", "theme_symmetry"),828 "curves-symmetry", "theme_symmetry"),
829 (self.client, defs.THEME, defs.STRIPE_WIDTH,
830 "stripe-width", "theme_stripe_width"),
826 (self.client, defs.THEME, defs.PANEL_ANGLE,831 (self.client, defs.THEME, defs.PANEL_ANGLE,
827 "angle", "theme_angle"),832 "angle", "theme_angle"),
828 (self.client, defs.THEME, defs.CORNER_RADIUS,833 (self.client, defs.THEME, defs.CORNER_RADIUS,
829834
=== modified file 'data/avant-window-navigator.schema-ini.in.in'
--- data/avant-window-navigator.schema-ini.in.in 2010-03-09 20:20:25 +0000
+++ data/avant-window-navigator.schema-ini.in.in 2010-05-24 12:32:29 +0000
@@ -159,7 +159,7 @@
159[panel/style]159[panel/style]
160type = integer160type = integer
161default = 1161default = 1
162_description=The style of the bar. (none=0, flat bar=1, 3d bar=2, curved bar=3, edgy=4, floaty=5)162_description=The style of the bar. (none=0, flat bar=1, 3d bar=2, curved bar=3, edgy=4, floaty=5,lucido=6)
163163
164[panels/panel_list]164[panels/panel_list]
165type = list-integer165type = list-integer
@@ -227,6 +227,12 @@
227_description=The curviness of the panel in Curves mode.227_description=The curviness of the panel in Curves mode.
228per_instance = false228per_instance = false
229229
230[theme/stripe_width]
231type = float
232default = 0.0
233_description=The width of the stripe in Lucido mode.
234per_instance = false
235
230[theme/dialog_gtk_mode]236[theme/dialog_gtk_mode]
231type = boolean237type = boolean
232default = true238default = true
233239
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2010-03-24 23:24:19 +0000
+++ src/Makefile.am 2010-05-24 12:32:29 +0000
@@ -41,6 +41,8 @@
41 awn-background-edgy.h \41 awn-background-edgy.h \
42 awn-background-floaty.c \42 awn-background-floaty.c \
43 awn-background-floaty.h \43 awn-background-floaty.h \
44 awn-background-lucido.c \
45 awn-background-lucido.h \
44 awn-defines.h \46 awn-defines.h \
45 $(builddir)/awn-marshal.c \47 $(builddir)/awn-marshal.c \
46 $(builddir)/awn-marshal.h \48 $(builddir)/awn-marshal.h \
4749
=== modified file 'src/awn-background-flat.c'
--- src/awn-background-flat.c 2010-03-07 18:38:07 +0000
+++ src/awn-background-flat.c 2010-05-24 12:32:29 +0000
@@ -324,20 +324,24 @@
324 switch (position)324 switch (position)
325 {325 {
326 case GTK_POS_RIGHT:326 case GTK_POS_RIGHT:
327 cairo_translate (cr, x, y+height);327 cairo_translate (cr, 0., y + height);
328 cairo_scale (cr, 1., -1.);
329 cairo_translate (cr, x, height);
328 cairo_rotate (cr, M_PI * 1.5);330 cairo_rotate (cr, M_PI * 1.5);
329 temp = width;331 temp = width;
330 width = height; height = temp;332 width = height;
333 height = temp;
331 break;334 break;
332 case GTK_POS_LEFT:335 case GTK_POS_LEFT:
333 cairo_translate (cr, x+width, y);336 cairo_translate (cr, x + width, y);
334 cairo_rotate (cr, M_PI * 0.5);337 cairo_rotate (cr, M_PI * 0.5);
335 temp = width;338 temp = width;
336 width = height; height = temp;339 width = height;
340 height = temp;
337 break;341 break;
338 case GTK_POS_TOP:342 case GTK_POS_TOP:
339 cairo_translate (cr, x+width, y+height);343 cairo_translate (cr, x, y + height);
340 cairo_rotate (cr, M_PI);344 cairo_scale (cr, 1., -1.);
341 break;345 break;
342 default:346 default:
343 cairo_translate (cr, x, y);347 cairo_translate (cr, x, y);
344348
=== added file 'src/awn-background-lucido.c'
--- src/awn-background-lucido.c 1970-01-01 00:00:00 +0000
+++ src/awn-background-lucido.c 2010-05-24 12:32:29 +0000
@@ -0,0 +1,700 @@
1/*
2 * Copyright (C) 2009 Michal Hruby <michal.mhr@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Author : Alberto Aldegheri <albyrock87+dev@gmail.com>
19 * Thanks to: Matt <sharkbaitbobby@gmail.com>
20 * for the code section to analyze expanders
21 *
22 */
23
24#include "config.h"
25
26#include <gdk/gdk.h>
27#include <libawn/awn-cairo-utils.h>
28#include <math.h>
29
30#include "awn-applet-manager.h"
31#include "awn-background-lucido.h"
32#include "awn-separator.h"
33
34G_DEFINE_TYPE (AwnBackgroundLucido, awn_background_lucido, AWN_TYPE_BACKGROUND_FLAT)
35
36#define AWN_BACKGROUND_LUCIDO_GET_PRIVATE(obj) ( \
37 G_TYPE_INSTANCE_GET_PRIVATE (obj, AWN_TYPE_BACKGROUND_LUCIDO, \
38 AwnBackgroundLucidoPrivate))
39
40static void awn_background_lucido_draw (AwnBackground *bg,
41 cairo_t *cr,
42 GtkPositionType position,
43 GdkRectangle *area);
44
45static void awn_background_lucido_get_shape_mask (AwnBackground *bg,
46 cairo_t *cr,
47 GtkPositionType position,
48 GdkRectangle *area);
49
50static void awn_background_lucido_padding_request (AwnBackground *bg,
51 GtkPositionType position,
52 guint *padding_top,
53 guint *padding_bottom,
54 guint *padding_left,
55 guint *padding_right);
56
57static gboolean
58awn_background_lucido_get_needs_redraw (AwnBackground *bg,
59 GtkPositionType position,
60 GdkRectangle *area);
61
62static void
63awn_background_lucido_constructed (GObject *object)
64{
65 G_OBJECT_CLASS (awn_background_lucido_parent_class)->constructed (object);
66}
67
68static void
69awn_background_lucido_dispose (GObject *object)
70{
71 G_OBJECT_CLASS (awn_background_lucido_parent_class)->dispose (object);
72}
73
74static void
75awn_background_lucido_class_init (AwnBackgroundLucidoClass *klass)
76{
77 AwnBackgroundClass *bg_class = AWN_BACKGROUND_CLASS (klass);
78
79 GObjectClass *obj_class = G_OBJECT_CLASS (klass);
80 obj_class->constructed = awn_background_lucido_constructed;
81 obj_class->dispose = awn_background_lucido_dispose;
82
83 bg_class->draw = awn_background_lucido_draw;
84 bg_class->padding_request = awn_background_lucido_padding_request;
85 bg_class->get_shape_mask = awn_background_lucido_get_shape_mask;
86 bg_class->get_input_shape_mask = awn_background_lucido_get_shape_mask;
87 bg_class->get_needs_redraw = awn_background_lucido_get_needs_redraw;
88}
89
90static void
91awn_background_lucido_init (AwnBackgroundLucido *bg)
92{
93
94}
95
96AwnBackground *
97awn_background_lucido_new (DesktopAgnosticConfigClient *client,
98 AwnPanel *panel)
99{
100 AwnBackground *bg;
101
102 bg = g_object_new (AWN_TYPE_BACKGROUND_LUCIDO,
103 "client", client,
104 "panel", panel,
105 NULL);
106 return bg;
107}
108
109/*
110 * Drawing functions
111 */
112static void
113_line_from_to ( cairo_t *cr,
114 gfloat *xs,
115 gfloat *ys,
116 gfloat xf,
117 gfloat yf)
118{
119 if ( *xs==xf || *ys==yf ) /* Vertical/Horizontal line */
120 cairo_line_to (cr, xf, yf);
121 else
122 { /* Oblique */
123 gfloat xm = ( *xs + xf ) / 2.0;
124 cairo_curve_to (cr, xm, *ys, xm, yf, xf, yf);
125 }
126 *xs = xf;
127 *ys = yf;
128}
129
130static GList*
131_get_applet_widgets (AwnBackground* bg)
132{
133 AwnAppletManager *manager = NULL;
134 g_object_get (bg->panel, "applet-manager", &manager, NULL);
135
136 return gtk_container_get_children (GTK_CONTAINER (manager));
137}
138
139/**
140 * _create_path_lucido:
141 * @bg: The background pointer
142 * @position: The position of the bar
143 * @cairo_t: The cairo context
144 * @y: The top left coordinate of the "bar rect" - default = 0
145 * @w: The width of the bar
146 * @h: The height of the bar
147 * @stripe: The width of the stripe (0.0-1.0). Zero for auto-stripe.
148 * @d: The width of each curve in the path
149 * @dc: The width of the external curves in non-expanded&auto mode
150 * @symmetry: The symmetry of the stripe when @stripe > 0
151 * @internal: If Zero, creates the path for the stripe
152 * @expanded: If Zero, the bar is not expanded
153 *
154 * This function creates paths on which the bar will be drawn.
155 * In atuo-stripe, it searchs for expanders applet, each expander
156 * equals to one curve.
157 * If the first widget is an expander, start from bottom-left,
158 * otherwise start from top-left
159 */
160
161static void
162_create_path_lucido ( AwnBackground* bg,
163 GtkPositionType position,
164 cairo_t* cr,
165 gfloat y,
166 gfloat w,
167 gfloat h,
168 gfloat stripe,
169 gfloat d,
170 gfloat dc,
171 gfloat symmetry,
172 gboolean internal,
173 gboolean expanded)
174{
175 cairo_new_path (cr);
176
177 gfloat lx = 0.0;
178 gfloat ly = y;
179 gfloat y3 = y + h;
180 gfloat y2 = y3 - 5;
181
182 if (stripe > 0)
183 {
184 if (expanded)
185 {
186 stripe = (w * stripe); /* now stripe = non-stripe */
187 if (internal)
188 {
189 /* Manual-Stripe & Expanded & Internal */
190 lx = stripe * symmetry;
191 cairo_move_to (cr, lx, ly);
192 _line_from_to (cr, &lx, &ly, lx+d, y2);
193 _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - d, y2);
194 _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry), y);
195 cairo_close_path (cr);
196 }
197 else
198 {
199 /* Manual-Stripe & Expanded & External */
200 ly = y3;
201 cairo_move_to (cr, lx, ly);
202 _line_from_to (cr, &lx, &ly, lx, y);
203 _line_from_to (cr, &lx, &ly, stripe * symmetry, y);
204 _line_from_to (cr, &lx, &ly, stripe * symmetry + d, y2);
205 _line_from_to (cr, &lx, &ly, w - stripe * (1. - symmetry) - d, y2);
206 _line_from_to (cr, &lx, &ly, w - stripe * (1. - symmetry), y);
207 _line_from_to (cr, &lx, &ly, w, y);
208 _line_from_to (cr, &lx, &ly, w, y3);
209 cairo_close_path (cr);
210 }
211 }
212 else
213 {
214 if (stripe == 1.)
215 {
216 _create_path_lucido (bg, position, cr, y, w, h, 0.,
217 d, dc, 0., internal, expanded);
218 return;
219 }
220 stripe = ((w - dc * 2) * stripe); /* now stripe = non-stripe */
221 if (internal)
222 {
223 /* Manual-Stripe & Not-Expanded & Internal */
224 lx = stripe * symmetry + dc;
225 cairo_move_to (cr, lx, ly);
226 _line_from_to (cr, &lx, &ly, lx + d, y2);
227 _line_from_to (cr, &lx, &ly, w - stripe * (1.- symmetry) - dc - d, y2);
228 _line_from_to (cr, &lx, &ly, w - stripe * (1.- symmetry) - dc, y);
229 cairo_close_path (cr);
230 }
231 else
232 {
233 /* Manual-Stripe & Not-Expanded & External */
234 ly = y3;
235 cairo_move_to (cr, lx, ly);
236 _line_from_to (cr, &lx, &ly, lx+dc, y);
237 _line_from_to (cr, &lx, &ly, stripe * symmetry + dc, y);
238 _line_from_to (cr, &lx, &ly, stripe * symmetry + d + dc, y2);
239 _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - dc - d, y2);
240 _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - dc, y);
241 _line_from_to (cr, &lx, &ly, w-dc, y);
242 _line_from_to (cr, &lx, &ly, w, y3);
243 cairo_close_path(cr);
244 }
245 }
246 }
247 else
248 {
249 gint exps_found = 0;
250 gfloat curx = 0.0;
251
252 if (expanded)
253 {
254 if (internal)
255 {
256 /* Auto-Stripe & Expanded & Internal */
257 GList *widgets = _get_applet_widgets (bg);
258 GList *i = widgets;
259 GtkWidget *widget = NULL;
260
261 /* analyze first widget*/
262 widget = GTK_WIDGET (i->data);
263
264 /* if first widget is an expander */
265 if (widget && GTK_IS_IMAGE (widget) && !AWN_IS_SEPARATOR (widget))
266 {
267 /* start from bottom */
268 lx = curx;
269 ly = y;
270 cairo_move_to (cr, lx, ly);
271 _line_from_to (cr, &lx, &ly, lx, y2);
272 ++exps_found;
273 }
274 /* else start from top */
275
276 for (; i; i = i->next)
277 {
278 widget = GTK_WIDGET (i->data);
279
280 if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
281 {
282 /* if not expander continue */
283 continue;
284 }
285 /* expander found */
286 switch (position)
287 {
288 case GTK_POS_BOTTOM:
289 case GTK_POS_TOP:
290 curx = widget->allocation.x;
291 if (exps_found % 2 != 0)
292 curx += widget->allocation.width;
293 break;
294 default:
295 curx = widget->allocation.y;
296 if ( exps_found % 2 != 0)
297 curx += widget->allocation.height;
298 break;
299 }
300 if (curx < 0)
301 continue;
302
303 if (exps_found == 0)
304 {
305 /* this is the first expander */
306 lx = curx;
307 cairo_move_to (cr, lx, ly);
308 _line_from_to (cr, &lx, &ly, curx + d, y2);
309 }
310 else
311 {
312 if (exps_found % 2 != 0)
313 {
314 /* odd expander - curve at the end of expander */
315 _line_from_to (cr, &lx, &ly, curx - d, y2);
316 _line_from_to (cr, &lx, &ly, curx, y);
317 }
318 else
319 {
320 /* even expander - curve at the start of expander */
321 _line_from_to (cr, &lx, &ly, curx, y);
322 _line_from_to (cr, &lx, &ly, curx + d, y2);
323 }
324 }
325
326 ++exps_found;
327 }
328 g_list_free (widgets);
329
330 _line_from_to (cr, &lx, &ly, w, ly);
331
332 if (exps_found % 2 != 0)
333 _line_from_to (cr, &lx, &ly, lx, y);
334
335 cairo_close_path (cr);
336 }
337 else
338 {
339 /* Auto-Stripe & Expanded & External */
340
341 GList *widgets = _get_applet_widgets (bg);
342 GList *i = widgets;
343 GtkWidget *widget = NULL;
344
345 /* analyze first widget*/
346 widget = GTK_WIDGET (i->data);
347
348 ly = y3;
349 cairo_move_to (cr, lx, ly);
350
351 /* if first widget is an expander */
352 if (widget && GTK_IS_IMAGE (widget) && !AWN_IS_SEPARATOR (widget))
353 {
354 /* start from bottom */
355 _line_from_to (cr, &lx, &ly, lx, y2);
356 ++exps_found;
357 }
358 else
359 {
360 /* start from top */
361 _line_from_to (cr, &lx, &ly, lx, y);
362 }
363
364 for (; i; i = i->next)
365 {
366 widget = GTK_WIDGET (i->data);
367
368 if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
369 {
370 /* if not expander continue */
371 continue;
372 }
373 /* expander found */
374 switch (position)
375 {
376 case GTK_POS_BOTTOM:
377 case GTK_POS_TOP:
378 curx = widget->allocation.x;
379 if (exps_found % 2 != 0)
380 curx += widget->allocation.width;
381 break;
382 default:
383 curx = widget->allocation.y;
384 if (exps_found % 2 != 0)
385 curx += widget->allocation.height;
386 break;
387 }
388 if (curx < 0)
389 continue;
390
391 if (exps_found % 2 != 0)
392 {
393 _line_from_to (cr, &lx, &ly, curx - d, y2);
394 _line_from_to (cr, &lx, &ly, curx, y);
395 }
396 else
397 {
398 _line_from_to (cr, &lx, &ly, curx, y);
399 _line_from_to (cr, &lx, &ly, curx + d, y2);
400 }
401 ++exps_found;
402 }
403 g_list_free (widgets);
404
405 _line_from_to (cr, &lx, &ly, w, ly);
406 _line_from_to (cr, &lx, &ly, lx, y3);
407
408 cairo_close_path (cr);
409 }
410 }
411 else
412 {
413 if (internal)
414 {
415 /* Auto-Stripe & Not-Expanded & Internal */
416 /* no-path */
417 }
418 else
419 {
420 /* Auto-Stripe & Not-Expanded & External */
421 ly = y3;
422 cairo_move_to (cr, lx, ly);
423 _line_from_to (cr, &lx, &ly, lx + dc, y);
424 _line_from_to (cr, &lx, &ly, w - dc, y);
425 _line_from_to (cr, &lx, &ly, w, y3);
426 cairo_close_path (cr);
427 }
428 }
429 }
430}
431
432static void
433draw_top_bottom_background (AwnBackground* bg,
434 GtkPositionType position,
435 cairo_t* cr,
436 gint width,
437 gint height)
438{
439 cairo_pattern_t *pat = NULL;
440 cairo_pattern_t *pat_hi = NULL;
441
442 /* Make sure the bar gets drawn on the 0.5 pixels (for sharp edges) */
443 cairo_translate (cr, 0.5, 0.5);
444
445 /* Basic set-up */
446 cairo_set_line_width (cr, 1.0);
447 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
448
449 if(gtk_widget_is_composited (GTK_WIDGET (bg->panel) ) == FALSE)
450 {
451 goto paint_lines;
452 }
453
454 gboolean expand = FALSE;
455 g_object_get (bg->panel, "expand", &expand, NULL);
456
457 /* create internal path */
458 _create_path_lucido (bg, position, cr, 0, width, height,
459 bg->stripe_width, bg->curviness,
460 bg->curviness, bg->curves_symmetry,
461 1, expand);
462
463 /* Draw internal pattern if needed */
464 if (bg->enable_pattern && bg->pattern)
465 {
466 /* Prepare pattern */
467 pat = cairo_pattern_create_for_surface (bg->pattern);
468 cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT);
469 /* Draw */
470 cairo_save (cr);
471 cairo_clip_preserve (cr);
472 cairo_set_source (cr, pat);
473 cairo_paint (cr);
474 cairo_restore (cr);
475 cairo_pattern_destroy (pat);
476 }
477
478 /* Prepare the internal background */
479 pat = cairo_pattern_create_linear (0, 0, 0, height);
480 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->border_color);
481 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->hilight_color);
482
483 /* Draw the internal background gradient */
484 cairo_save (cr);
485 cairo_clip_preserve (cr);
486 cairo_set_source (cr, pat);
487 cairo_paint (cr);
488 cairo_restore (cr);
489 cairo_pattern_destroy (pat);
490
491 /* Prepare external background gradient*/
492 pat = cairo_pattern_create_linear (0, 0, 0, height);
493 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_step_1);
494 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);
495
496 /* create external path */
497 _create_path_lucido (bg, position, cr, 0, width, height,
498 bg->stripe_width, bg->curviness,
499 bg->curviness, bg->curves_symmetry,
500 0, expand);
501
502 /* Draw the external background */
503 cairo_save (cr);
504 cairo_clip_preserve (cr);
505 cairo_set_source (cr, pat);
506 cairo_paint (cr);
507 cairo_restore (cr);
508 cairo_pattern_destroy (pat);
509
510 /* Draw the hi-light */
511 pat_hi = cairo_pattern_create_linear (0, 0, 0, (height / 3.0));
512 awn_cairo_pattern_add_color_stop_color (pat_hi, 0.0, bg->g_histep_1);
513 awn_cairo_pattern_add_color_stop_color (pat_hi, 1.0, bg->g_histep_2);
514
515 if (expand)
516 {
517 cairo_new_path (cr);
518 cairo_rectangle (cr, 0, 0, width, (height / 3.0));
519 }
520
521 cairo_set_source (cr, pat_hi);
522 cairo_fill (cr);
523 cairo_pattern_destroy (pat_hi);
524
525 return;
526 /* if not composited */
527paint_lines:
528
529 /* Internal border */
530 awn_cairo_set_source_color (cr, bg->hilight_color);
531 cairo_rectangle (cr, 1, 1, width - 3, height + 3);
532 cairo_stroke (cr);
533
534 /* External border */
535 awn_cairo_set_source_color (cr, bg->border_color);
536 cairo_rectangle (cr, 1, 1, width - 1, height + 3);
537 cairo_stroke (cr);
538}
539
540
541static
542void awn_background_lucido_padding_request (AwnBackground *bg,
543 GtkPositionType position,
544 guint *padding_top,
545 guint *padding_bottom,
546 guint *padding_left,
547 guint *padding_right)
548{
549 #define TOP_PADDING 2
550 gboolean expand = FALSE;
551 g_object_get (bg->panel, "expand", &expand, NULL);
552 gint side_padding = expand ? 0 : bg->curviness;
553 gint zero_padding = 0;
554
555 gfloat align = awn_background_get_panel_alignment (bg);
556 if (awn_background_do_rtl_swap (bg))
557 {
558 if (align <= 0.0 || align >= 1.0)
559 {
560 zero_padding = side_padding;
561 side_padding = 0;
562 }
563 }
564
565 switch (position)
566 {
567 case GTK_POS_TOP:
568 *padding_top = 0;
569 *padding_bottom = TOP_PADDING;
570 *padding_left = align == 0.0 ? zero_padding : side_padding;
571 *padding_right = align == 1.0 ? zero_padding : side_padding;
572 break;
573 case GTK_POS_BOTTOM:
574 *padding_top = TOP_PADDING;
575 *padding_bottom = 0;
576 *padding_left = align == 0.0 ? zero_padding : side_padding;
577 *padding_right = align == 1.0 ? zero_padding : side_padding;
578 break;
579 case GTK_POS_LEFT:
580 *padding_top = align == 0.0 ? zero_padding : side_padding;
581 *padding_bottom = align == 1.0 ? zero_padding : side_padding;
582 *padding_left = 0;
583 *padding_right = TOP_PADDING;
584 break;
585 case GTK_POS_RIGHT:
586 *padding_top = align == 0.0 ? zero_padding : side_padding;
587 *padding_bottom = align == 1.0 ? zero_padding : side_padding;
588 *padding_left = TOP_PADDING;
589 *padding_right = 0;
590 break;
591 default:
592 break;
593 }
594}
595
596
597
598static void
599awn_background_lucido_draw (AwnBackground *bg,
600 cairo_t *cr,
601 GtkPositionType position,
602 GdkRectangle *area)
603{
604 gint temp;
605 gint x = area->x, y = area->y;
606 gint width = area->width, height = area->height;
607 cairo_save (cr);
608
609 switch (position)
610 {
611 case GTK_POS_RIGHT:
612 cairo_translate (cr, 0., y + height);
613 cairo_scale (cr, 1., -1.);
614 cairo_translate (cr, x, height);
615 cairo_rotate (cr, M_PI * 1.5);
616 temp = width;
617 width = height;
618 height = temp;
619 break;
620 case GTK_POS_LEFT:
621 cairo_translate (cr, x + width, y);
622 cairo_rotate (cr, M_PI * 0.5);
623 temp = width;
624 width = height;
625 height = temp;
626 break;
627 case GTK_POS_TOP:
628 cairo_translate (cr, x, y + height);
629 cairo_scale (cr, 1., -1.);
630 break;
631 default:
632 cairo_translate (cr, x, y);
633 break;
634 }
635
636 draw_top_bottom_background (bg, position, cr, width, height);
637
638 cairo_restore (cr);
639}
640
641static gboolean
642awn_background_lucido_get_needs_redraw (AwnBackground *bg,
643 GtkPositionType position,
644 GdkRectangle *area)
645{
646 /* Check default needs redraw */
647 gboolean nr = AWN_BACKGROUND_CLASS (awn_background_lucido_parent_class)->
648 get_needs_redraw (bg, position, area);
649 if (nr)
650 return TRUE;
651
652 /* Check expanders positions & sizes changed */
653 GList *widgets = _get_applet_widgets (bg);
654 GList *i = widgets;
655 GtkWidget *widget = NULL;
656 gint wcheck = 0;
657
658 for (; i; i = i->next)
659 {
660 widget = GTK_WIDGET (i->data);
661
662 if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
663 {
664 /* if not expander continue */
665 continue;
666 }
667 switch (position)
668 {
669 case GTK_POS_BOTTOM:
670 case GTK_POS_TOP:
671 wcheck += widget->allocation.x + widget->allocation.width;
672 break;
673 default:
674 wcheck += widget->allocation.y + widget->allocation.height;
675 break;
676 }
677 }
678 g_list_free (widgets);
679
680 AwnBackgroundLucido *lbg = NULL;
681 lbg = AWN_BACKGROUND_LUCIDO (bg);
682 if (lbg->expw != wcheck)
683 {
684 lbg->expw = wcheck;
685 return TRUE;
686 }
687 return FALSE;
688}
689
690static void
691awn_background_lucido_get_shape_mask (AwnBackground *bg,
692 cairo_t *cr,
693 GtkPositionType position,
694 GdkRectangle *area)
695{
696 AWN_BACKGROUND_CLASS (awn_background_lucido_parent_class)->get_shape_mask (
697 bg, cr, position, area);
698}
699
700/* vim: set et ts=2 sts=2 sw=2 : */
0701
=== added file 'src/awn-background-lucido.h'
--- src/awn-background-lucido.h 1970-01-01 00:00:00 +0000
+++ src/awn-background-lucido.h 2010-05-24 12:32:29 +0000
@@ -0,0 +1,70 @@
1/*
2 * Copyright (C) 2009 Michal Hruby <michal.mhr@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Author : Alberto Aldegheri <albyrock87+dev@gmail.com>
19*/
20
21#ifndef _AWN_BACKGROUND_LUCIDO_H
22#define _AWN_BACKGROUND_LUCIDO_H
23
24#include <glib.h>
25#include <glib-object.h>
26#include <gtk/gtk.h>
27
28#include "awn-background-flat.h"
29
30G_BEGIN_DECLS
31
32#define AWN_TYPE_BACKGROUND_LUCIDO (awn_background_lucido_get_type())
33
34#define AWN_BACKGROUND_LUCIDO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AWN_TYPE_BACKGROUND_LUCIDO, \
35 AwnBackgroundLucido))
36
37#define AWN_BACKGROUND_LUCIDO_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), AWN_BACKGROUND_LUCIDO, \
38 AwnBackgroundLucidoClass))
39
40#define AWN_IS_BACKGROUND_LUCIDO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AWN_TYPE_BACKGROUND_LUCIDO))
41
42#define AWN_IS_BACKGROUND_LUCIDO_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), \
43 AWN_TYPE_BACKGROUND_LUCIDO))
44
45#define AWN_BACKGROUND_LUCIDO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
46 AWN_TYPE_BACKGROUND_LUCIDO, AwnBackgroundLucidoClass))
47
48typedef struct _AwnBackgroundLucido AwnBackgroundLucido;
49typedef struct _AwnBackgroundLucidoClass AwnBackgroundLucidoClass;
50
51struct _AwnBackgroundLucido
52{
53 AwnBackgroundFlat parent;
54 gint expw;
55};
56
57struct _AwnBackgroundLucidoClass
58{
59 AwnBackgroundFlatClass parent_class;
60};
61
62GType awn_background_lucido_get_type (void) G_GNUC_CONST;
63
64AwnBackground * awn_background_lucido_new (DesktopAgnosticConfigClient *client,
65 AwnPanel *panel);
66
67G_END_DECLS
68
69#endif /* _AWN_BACKGROUND_LUCIDO_H */
70
071
=== modified file 'src/awn-background.c'
--- src/awn-background.c 2010-04-08 15:38:05 +0000
+++ src/awn-background.c 2010-05-24 12:32:29 +0000
@@ -58,7 +58,8 @@
58 PROP_CORNER_RADIUS,58 PROP_CORNER_RADIUS,
59 PROP_PANEL_ANGLE,59 PROP_PANEL_ANGLE,
60 PROP_CURVINESS,60 PROP_CURVINESS,
61 PROP_CURVES_SYMEMETRY61 PROP_CURVES_SYMEMETRY,
62 PROP_STRIPE_WIDTH
62};63};
6364
64enum 65enum
@@ -90,6 +91,10 @@
90 GtkPositionType position,91 GtkPositionType position,
91 GdkRectangle *area);92 GdkRectangle *area);
9293
94static gboolean awn_background_get_needs_redraw (AwnBackground *bg,
95 GtkPositionType position,
96 GdkRectangle *area);
97
93static AwnPathType awn_background_path_default (AwnBackground *bg,98static AwnPathType awn_background_path_default (AwnBackground *bg,
94 gfloat *offset_mod);99 gfloat *offset_mod);
95100
@@ -186,6 +191,11 @@
186 object, "curves-symmetry", TRUE,191 object, "curves-symmetry", TRUE,
187 DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,192 DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,
188 NULL);193 NULL);
194 desktop_agnostic_config_client_bind (bg->client,
195 AWN_GROUP_THEME, AWN_THEME_STRIPE_WIDTH,
196 object, "stripe-width", TRUE,
197 DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,
198 NULL);
189}199}
190200
191static void201static void
@@ -342,12 +352,15 @@
342 case PROP_CURVES_SYMEMETRY:352 case PROP_CURVES_SYMEMETRY:
343 bg->curves_symmetry = g_value_get_float (value);353 bg->curves_symmetry = g_value_get_float (value);
344 break;354 break;
355 case PROP_STRIPE_WIDTH:
356 bg->stripe_width = g_value_get_float (value);
357 break;
345358
346 default:359 default:
347 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);360 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
348 return;361 return;
349 }362 }
350363 awn_background_invalidate (bg);
351 g_signal_emit (object, _bg_signals[CHANGED], 0);364 g_signal_emit (object, _bg_signals[CHANGED], 0);
352}365}
353366
@@ -380,6 +393,12 @@
380 if (bg->hilight_color) g_object_unref (bg->hilight_color);393 if (bg->hilight_color) g_object_unref (bg->hilight_color);
381 if (bg->sep_color) g_object_unref (bg->sep_color);394 if (bg->sep_color) g_object_unref (bg->sep_color);
382395
396 if (bg->helper_surface != NULL)
397 {
398 cairo_surface_finish (bg->helper_surface);
399 cairo_surface_destroy (bg->helper_surface);
400 }
401
383 G_OBJECT_CLASS (awn_background_parent_class)->finalize (object);402 G_OBJECT_CLASS (awn_background_parent_class)->finalize (object);
384}403}
385404
@@ -398,6 +417,7 @@
398 klass->get_input_shape_mask = awn_background_mask_none;417 klass->get_input_shape_mask = awn_background_mask_none;
399 klass->get_path_type = awn_background_path_default;418 klass->get_path_type = awn_background_path_default;
400 klass->get_strut_offsets = NULL;419 klass->get_strut_offsets = NULL;
420 klass->get_needs_redraw = awn_background_get_needs_redraw;
401421
402 /* Object properties */422 /* Object properties */
403 g_object_class_install_property (obj_class,423 g_object_class_install_property (obj_class,
@@ -575,6 +595,15 @@
575 0.0, 1.0, 0.5,595 0.0, 1.0, 0.5,
576 G_PARAM_READWRITE | G_PARAM_CONSTRUCT |596 G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
577 G_PARAM_STATIC_STRINGS));597 G_PARAM_STATIC_STRINGS));
598
599 g_object_class_install_property (obj_class,
600 PROP_STRIPE_WIDTH,
601 g_param_spec_float ("stripe-width",
602 "Stripe Width",
603 "The width of the stripe",
604 0.0, 1.0, 0.0,
605 G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
606 G_PARAM_STATIC_STRINGS));
578607
579 /* Add signals to the class */608 /* Add signals to the class */
580 _bg_signals[CHANGED] = 609 _bg_signals[CHANGED] =
@@ -650,6 +679,11 @@
650 bg->border_color = NULL;679 bg->border_color = NULL;
651 bg->hilight_color = NULL;680 bg->hilight_color = NULL;
652 bg->sep_color = NULL;681 bg->sep_color = NULL;
682 bg->needs_redraw = TRUE;
683 bg->helper_surface = NULL;
684 bg->cache_enabled = TRUE;
685 bg->last_height = 0;
686 bg->last_width = 0;
653}687}
654688
655void 689void
@@ -664,8 +698,40 @@
664 698
665 klass = AWN_BACKGROUND_GET_CLASS (bg);699 klass = AWN_BACKGROUND_GET_CLASS (bg);
666 g_return_if_fail (klass->draw != NULL);700 g_return_if_fail (klass->draw != NULL);
667701
668 klass->draw (bg, cr, position, area);702 /* Check if background caching is enabled - TRUE by default */
703 if (bg->cache_enabled)
704 {
705 g_return_if_fail (klass->get_needs_redraw != NULL);
706 cairo_save (cr);
707
708 /* Check if background needs to be redrawn */
709 if (klass->get_needs_redraw (bg, position, area))
710 {
711 /* Free last surface */
712 if (bg->helper_surface != NULL)
713 {
714 cairo_surface_finish (bg->helper_surface);
715 cairo_surface_destroy (bg->helper_surface);
716 }
717 /* Create new surface */
718 bg->helper_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
719 area->x + area->width,
720 area->y + area->height);
721 cairo_t* temp_cr = cairo_create (bg->helper_surface);
722 /* Draw background on temp cairo_t */
723 klass->draw (bg, temp_cr, position, area);
724 cairo_destroy (temp_cr);
725 }
726 /* Paint saved surface */
727 cairo_set_source_surface (cr, bg->helper_surface, 0., 0.);
728 cairo_paint(cr);
729 cairo_restore (cr);
730 }
731 else
732 {
733 klass->draw (bg, cr, position, area);
734 }
669}735}
670736
671void 737void
@@ -1009,4 +1075,25 @@
1009 return AWN_PATH_LINEAR;1075 return AWN_PATH_LINEAR;
1010}1076}
10111077
1078static gboolean awn_background_get_needs_redraw (AwnBackground *bg,
1079 GtkPositionType position,
1080 GdkRectangle *area)
1081{
1082 if (bg->needs_redraw == 1 ||
1083 bg->last_height != area->height ||
1084 bg->last_width != area->width)
1085 {
1086 bg->needs_redraw = 0;
1087 bg->last_height = area->height;
1088 bg->last_width = area->width;
1089 return TRUE;
1090 }
1091 return FALSE;
1092}
1093
1094void awn_background_invalidate (AwnBackground *bg)
1095{
1096 bg->needs_redraw = 1;
1097}
1098
1012/* vim: set et ts=2 sts=2 sw=2 : */1099/* vim: set et ts=2 sts=2 sw=2 : */
10131100
=== modified file 'src/awn-background.h'
--- src/awn-background.h 2010-03-07 18:38:07 +0000
+++ src/awn-background.h 2010-05-24 12:32:29 +0000
@@ -76,6 +76,15 @@
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
80 /* Speedup code.
81 * We can save the bg and redraw only when properties changes
82 */
83 gboolean cache_enabled;
84 gboolean needs_redraw;
85 cairo_surface_t* helper_surface;
86 gint last_height;
87 gint last_width;
7988
80 /* FIXME:89 /* FIXME:
81 * These two should ultimately go somewhere else (once we do multiple panels)90 * These two should ultimately go somewhere else (once we do multiple panels)
@@ -89,6 +98,7 @@
89 gint panel_angle;98 gint panel_angle;
90 gfloat curviness;99 gfloat curviness;
91 gfloat curves_symmetry;100 gfloat curves_symmetry;
101 gfloat stripe_width;
92102
93 /* private */103 /* private */
94 guint changed;104 guint changed;
@@ -129,6 +139,10 @@
129 GdkRectangle *area,139 GdkRectangle *area,
130 gint *strut,140 gint *strut,
131 gint *strut_start, gint *strut_end);141 gint *strut_start, gint *strut_end);
142
143 gboolean (*get_needs_redraw) (AwnBackground *bg,
144 GtkPositionType position,
145 GdkRectangle *area);
132146
133 /*< signals >*/147 /*< signals >*/
134 void (*changed) (AwnBackground *bg);148 void (*changed) (AwnBackground *bg);
@@ -142,6 +156,8 @@
142 GtkPositionType position,156 GtkPositionType position,
143 GdkRectangle *area);157 GdkRectangle *area);
144158
159void awn_background_invalidate (AwnBackground *bg);
160
145void awn_background_padding_request (AwnBackground *bg,161void awn_background_padding_request (AwnBackground *bg,
146 GtkPositionType position,162 GtkPositionType position,
147 guint *padding_top,163 guint *padding_top,
148164
=== modified file 'src/awn-defines.h'
--- src/awn-defines.h 2010-02-06 13:34:02 +0000
+++ src/awn-defines.h 2010-05-24 12:32:29 +0000
@@ -87,6 +87,7 @@
87#define AWN_THEME_PANEL_ANGLE "panel_angle"87#define AWN_THEME_PANEL_ANGLE "panel_angle"
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_STRIPE_WIDTH "stripe_width"
9091
91#endif /*_HAVE_AWN_DEFINES_H */92#endif /*_HAVE_AWN_DEFINES_H */
9293
9394
=== modified file 'src/awn-panel.c'
--- src/awn-panel.c 2010-04-10 21:24:01 +0000
+++ src/awn-panel.c 2010-05-24 12:32:29 +0000
@@ -43,6 +43,7 @@
43#include "awn-background-3d.h"43#include "awn-background-3d.h"
44#include "awn-background-curves.h"44#include "awn-background-curves.h"
45#include "awn-background-edgy.h"45#include "awn-background-edgy.h"
46#include "awn-background-lucido.h"
46#include "awn-background-floaty.h"47#include "awn-background-floaty.h"
47#include "awn-defines.h"48#include "awn-defines.h"
48#include "awn-marshal.h"49#include "awn-marshal.h"
@@ -222,6 +223,7 @@
222 STYLE_EDGY,223 STYLE_EDGY,
223 STYLE_FLOATY,224 STYLE_FLOATY,
224225
226 STYLE_LUCIDO,
225 STYLE_LAST227 STYLE_LAST
226};228};
227229
@@ -2973,6 +2975,9 @@
2973 position_window (panel);2975 position_window (panel);
2974 2976
2975 gtk_widget_queue_resize (GTK_WIDGET (panel));2977 gtk_widget_queue_resize (GTK_WIDGET (panel));
2978
2979 if (priv->bg)
2980 awn_background_invalidate (priv->bg);
2976}2981}
29772982
2978static void2983static void
@@ -3168,6 +3173,9 @@
3168 case STYLE_EDGY:3173 case STYLE_EDGY:
3169 priv->bg = awn_background_edgy_new (priv->client, panel);3174 priv->bg = awn_background_edgy_new (priv->client, panel);
3170 break;3175 break;
3176 case STYLE_LUCIDO:
3177 priv->bg = awn_background_lucido_new (priv->client, panel);
3178 break;
3171 case STYLE_FLOATY:3179 case STYLE_FLOATY:
3172 priv->bg = awn_background_floaty_new (priv->client, panel);3180 priv->bg = awn_background_floaty_new (priv->client, panel);
3173 break;3181 break;

Subscribers

People subscribed via source and target branches