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
1=== modified file 'awn-settings/awn-settings.ui'
2--- awn-settings/awn-settings.ui 2010-03-08 12:50:07 +0000
3+++ awn-settings/awn-settings.ui 2010-05-24 12:32:29 +0000
4@@ -908,6 +908,22 @@
5 </packing>
6 </child>
7 <child>
8+ <object class="GtkSpinButton" id="theme_stripe_width">
9+ <property name="visible">True</property>
10+ <property name="can_focus">True</property>
11+ <property name="invisible_char">&#x25CF;</property>
12+ <property name="adjustment">adj_stripe_width</property>
13+ <property name="digits">2</property>
14+ </object>
15+ <packing>
16+ <property name="left_attach">5</property>
17+ <property name="right_attach">6</property>
18+ <property name="top_attach">8</property>
19+ <property name="bottom_attach">9</property>
20+ <property name="x_options"></property>
21+ </packing>
22+ </child>
23+ <child>
24 <object class="GtkSpinButton" id="theme_angle">
25 <property name="visible">True</property>
26 <property name="can_focus">True</property>
27@@ -964,6 +980,20 @@
28 </packing>
29 </child>
30 <child>
31+ <object class="GtkLabel" id="label_stripe">
32+ <property name="visible">True</property>
33+ <property name="xalign">0</property>
34+ <property name="xpad">0</property>
35+ <property name="label" translatable="yes">Stripe Width</property>
36+ </object>
37+ <packing>
38+ <property name="left_attach">3</property>
39+ <property name="right_attach">5</property>
40+ <property name="top_attach">8</property>
41+ <property name="bottom_attach">9</property>
42+ </packing>
43+ </child>
44+ <child>
45 <object class="GtkLabel" id="label49">
46 <property name="visible">True</property>
47 <property name="xalign">0</property>
48@@ -3406,6 +3436,10 @@
49 <property name="upper">1</property>
50 <property name="step_increment">0.01</property>
51 </object>
52+ <object class="GtkAdjustment" id="adj_stripe_width">
53+ <property name="upper">1</property>
54+ <property name="step_increment">0.01</property>
55+ </object>
56 <object class="GtkAdjustment" id="adj_radius">
57 <property name="upper">100</property>
58 <property name="step_increment">1</property>
59
60=== modified file 'awn-settings/awnDefs.py.in'
61--- awn-settings/awnDefs.py.in 2010-04-29 14:58:51 +0000
62+++ awn-settings/awnDefs.py.in 2010-05-24 12:32:29 +0000
63@@ -86,6 +86,7 @@
64 PANEL_ANGLE = "panel_angle" #float
65 CURVINESS = "curviness" #float
66 CURVES_SYMMETRY = "curves_symmetry" #float
67+STRIPE_WIDTH = "stripe_width" #float
68 TOOLTIP_FONT_NAME = "tooltip_font_name" #string
69 TOOLTIP_FONT_COLOR = "tooltip_font_color" #string
70 TOOLTIP_BG_COLOR = "tooltip_bg_color" #string
71
72=== modified file 'awn-settings/awnSettings.py.in'
73--- awn-settings/awnSettings.py.in 2010-04-11 00:22:25 +0000
74+++ awn-settings/awnSettings.py.in 2010-05-24 12:32:29 +0000
75@@ -141,7 +141,8 @@
76 #setup style mode
77 dropdown = self.wTree.get_object("stylecombo")
78 self.create_dropdown(dropdown, [_("None"), _("Flat"), _("3d"),
79- _("Curved"), _("Edgy"), _("Floaty")])
80+ _("Curved"), _("Edgy"), _("Floaty"),
81+ _("Lucido")])
82
83 #setup behaviour combo
84 dropdown = self.wTree.get_object("behaviorcombo")
85@@ -578,6 +579,7 @@
86
87 curviness = gobject.property(type=int, default=10)
88 curves_symmetry = gobject.property(type=float, default=0)
89+ stripe_width = gobject.property(type=float, default=0)
90 angle = gobject.property(type=int, default=45)
91 radius = gobject.property(type=int, default=10)
92 gtk_theme_mode = gobject.property(type=bool, default=False)
93@@ -727,6 +729,7 @@
94 (defs.THEME, defs.PANEL_ANGLE, 'float', sizes),
95 (defs.THEME, defs.CURVINESS, 'float', sizes),
96 (defs.THEME, defs.CURVES_SYMMETRY, 'float', sizes),
97+ (defs.THEME, defs.STRIPE_WIDTH, 'float', sizes),
98 (defs.THEME, defs.TOOLTIP_FONT_NAME, 'str', icon),
99 (defs.THEME, defs.TOOLTIP_FONT_COLOR, 'str', icon),
100 (defs.THEME, defs.TOOLTIP_BG_COLOR, 'str', icon),
101@@ -823,6 +826,8 @@
102 "curviness", "theme_curviness"),
103 (self.client, defs.THEME, defs.CURVES_SYMMETRY,
104 "curves-symmetry", "theme_symmetry"),
105+ (self.client, defs.THEME, defs.STRIPE_WIDTH,
106+ "stripe-width", "theme_stripe_width"),
107 (self.client, defs.THEME, defs.PANEL_ANGLE,
108 "angle", "theme_angle"),
109 (self.client, defs.THEME, defs.CORNER_RADIUS,
110
111=== modified file 'data/avant-window-navigator.schema-ini.in.in'
112--- data/avant-window-navigator.schema-ini.in.in 2010-03-09 20:20:25 +0000
113+++ data/avant-window-navigator.schema-ini.in.in 2010-05-24 12:32:29 +0000
114@@ -159,7 +159,7 @@
115 [panel/style]
116 type = integer
117 default = 1
118-_description=The style of the bar. (none=0, flat bar=1, 3d bar=2, curved bar=3, edgy=4, floaty=5)
119+_description=The style of the bar. (none=0, flat bar=1, 3d bar=2, curved bar=3, edgy=4, floaty=5,lucido=6)
120
121 [panels/panel_list]
122 type = list-integer
123@@ -227,6 +227,12 @@
124 _description=The curviness of the panel in Curves mode.
125 per_instance = false
126
127+[theme/stripe_width]
128+type = float
129+default = 0.0
130+_description=The width of the stripe in Lucido mode.
131+per_instance = false
132+
133 [theme/dialog_gtk_mode]
134 type = boolean
135 default = true
136
137=== modified file 'src/Makefile.am'
138--- src/Makefile.am 2010-03-24 23:24:19 +0000
139+++ src/Makefile.am 2010-05-24 12:32:29 +0000
140@@ -41,6 +41,8 @@
141 awn-background-edgy.h \
142 awn-background-floaty.c \
143 awn-background-floaty.h \
144+ awn-background-lucido.c \
145+ awn-background-lucido.h \
146 awn-defines.h \
147 $(builddir)/awn-marshal.c \
148 $(builddir)/awn-marshal.h \
149
150=== modified file 'src/awn-background-flat.c'
151--- src/awn-background-flat.c 2010-03-07 18:38:07 +0000
152+++ src/awn-background-flat.c 2010-05-24 12:32:29 +0000
153@@ -324,20 +324,24 @@
154 switch (position)
155 {
156 case GTK_POS_RIGHT:
157- cairo_translate (cr, x, y+height);
158+ cairo_translate (cr, 0., y + height);
159+ cairo_scale (cr, 1., -1.);
160+ cairo_translate (cr, x, height);
161 cairo_rotate (cr, M_PI * 1.5);
162 temp = width;
163- width = height; height = temp;
164+ width = height;
165+ height = temp;
166 break;
167 case GTK_POS_LEFT:
168- cairo_translate (cr, x+width, y);
169+ cairo_translate (cr, x + width, y);
170 cairo_rotate (cr, M_PI * 0.5);
171 temp = width;
172- width = height; height = temp;
173+ width = height;
174+ height = temp;
175 break;
176 case GTK_POS_TOP:
177- cairo_translate (cr, x+width, y+height);
178- cairo_rotate (cr, M_PI);
179+ cairo_translate (cr, x, y + height);
180+ cairo_scale (cr, 1., -1.);
181 break;
182 default:
183 cairo_translate (cr, x, y);
184
185=== added file 'src/awn-background-lucido.c'
186--- src/awn-background-lucido.c 1970-01-01 00:00:00 +0000
187+++ src/awn-background-lucido.c 2010-05-24 12:32:29 +0000
188@@ -0,0 +1,700 @@
189+/*
190+ * Copyright (C) 2009 Michal Hruby <michal.mhr@gmail.com>
191+ *
192+ * This program is free software; you can redistribute it and/or modify
193+ * it under the terms of the GNU General Public License as published by
194+ * the Free Software Foundation; either version 2 of the License, or
195+ * (at your option) any later version.
196+ *
197+ * This program is distributed in the hope that it will be useful,
198+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
199+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
200+ * GNU General Public License for more details.
201+ *
202+ * You should have received a copy of the GNU General Public License
203+ * along with this program; if not, write to the Free Software
204+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
205+ *
206+ * Author : Alberto Aldegheri <albyrock87+dev@gmail.com>
207+ * Thanks to: Matt <sharkbaitbobby@gmail.com>
208+ * for the code section to analyze expanders
209+ *
210+ */
211+
212+#include "config.h"
213+
214+#include <gdk/gdk.h>
215+#include <libawn/awn-cairo-utils.h>
216+#include <math.h>
217+
218+#include "awn-applet-manager.h"
219+#include "awn-background-lucido.h"
220+#include "awn-separator.h"
221+
222+G_DEFINE_TYPE (AwnBackgroundLucido, awn_background_lucido, AWN_TYPE_BACKGROUND_FLAT)
223+
224+#define AWN_BACKGROUND_LUCIDO_GET_PRIVATE(obj) ( \
225+ G_TYPE_INSTANCE_GET_PRIVATE (obj, AWN_TYPE_BACKGROUND_LUCIDO, \
226+ AwnBackgroundLucidoPrivate))
227+
228+static void awn_background_lucido_draw (AwnBackground *bg,
229+ cairo_t *cr,
230+ GtkPositionType position,
231+ GdkRectangle *area);
232+
233+static void awn_background_lucido_get_shape_mask (AwnBackground *bg,
234+ cairo_t *cr,
235+ GtkPositionType position,
236+ GdkRectangle *area);
237+
238+static void awn_background_lucido_padding_request (AwnBackground *bg,
239+ GtkPositionType position,
240+ guint *padding_top,
241+ guint *padding_bottom,
242+ guint *padding_left,
243+ guint *padding_right);
244+
245+static gboolean
246+awn_background_lucido_get_needs_redraw (AwnBackground *bg,
247+ GtkPositionType position,
248+ GdkRectangle *area);
249+
250+static void
251+awn_background_lucido_constructed (GObject *object)
252+{
253+ G_OBJECT_CLASS (awn_background_lucido_parent_class)->constructed (object);
254+}
255+
256+static void
257+awn_background_lucido_dispose (GObject *object)
258+{
259+ G_OBJECT_CLASS (awn_background_lucido_parent_class)->dispose (object);
260+}
261+
262+static void
263+awn_background_lucido_class_init (AwnBackgroundLucidoClass *klass)
264+{
265+ AwnBackgroundClass *bg_class = AWN_BACKGROUND_CLASS (klass);
266+
267+ GObjectClass *obj_class = G_OBJECT_CLASS (klass);
268+ obj_class->constructed = awn_background_lucido_constructed;
269+ obj_class->dispose = awn_background_lucido_dispose;
270+
271+ bg_class->draw = awn_background_lucido_draw;
272+ bg_class->padding_request = awn_background_lucido_padding_request;
273+ bg_class->get_shape_mask = awn_background_lucido_get_shape_mask;
274+ bg_class->get_input_shape_mask = awn_background_lucido_get_shape_mask;
275+ bg_class->get_needs_redraw = awn_background_lucido_get_needs_redraw;
276+}
277+
278+static void
279+awn_background_lucido_init (AwnBackgroundLucido *bg)
280+{
281+
282+}
283+
284+AwnBackground *
285+awn_background_lucido_new (DesktopAgnosticConfigClient *client,
286+ AwnPanel *panel)
287+{
288+ AwnBackground *bg;
289+
290+ bg = g_object_new (AWN_TYPE_BACKGROUND_LUCIDO,
291+ "client", client,
292+ "panel", panel,
293+ NULL);
294+ return bg;
295+}
296+
297+/*
298+ * Drawing functions
299+ */
300+static void
301+_line_from_to ( cairo_t *cr,
302+ gfloat *xs,
303+ gfloat *ys,
304+ gfloat xf,
305+ gfloat yf)
306+{
307+ if ( *xs==xf || *ys==yf ) /* Vertical/Horizontal line */
308+ cairo_line_to (cr, xf, yf);
309+ else
310+ { /* Oblique */
311+ gfloat xm = ( *xs + xf ) / 2.0;
312+ cairo_curve_to (cr, xm, *ys, xm, yf, xf, yf);
313+ }
314+ *xs = xf;
315+ *ys = yf;
316+}
317+
318+static GList*
319+_get_applet_widgets (AwnBackground* bg)
320+{
321+ AwnAppletManager *manager = NULL;
322+ g_object_get (bg->panel, "applet-manager", &manager, NULL);
323+
324+ return gtk_container_get_children (GTK_CONTAINER (manager));
325+}
326+
327+/**
328+ * _create_path_lucido:
329+ * @bg: The background pointer
330+ * @position: The position of the bar
331+ * @cairo_t: The cairo context
332+ * @y: The top left coordinate of the "bar rect" - default = 0
333+ * @w: The width of the bar
334+ * @h: The height of the bar
335+ * @stripe: The width of the stripe (0.0-1.0). Zero for auto-stripe.
336+ * @d: The width of each curve in the path
337+ * @dc: The width of the external curves in non-expanded&auto mode
338+ * @symmetry: The symmetry of the stripe when @stripe > 0
339+ * @internal: If Zero, creates the path for the stripe
340+ * @expanded: If Zero, the bar is not expanded
341+ *
342+ * This function creates paths on which the bar will be drawn.
343+ * In atuo-stripe, it searchs for expanders applet, each expander
344+ * equals to one curve.
345+ * If the first widget is an expander, start from bottom-left,
346+ * otherwise start from top-left
347+ */
348+
349+static void
350+_create_path_lucido ( AwnBackground* bg,
351+ GtkPositionType position,
352+ cairo_t* cr,
353+ gfloat y,
354+ gfloat w,
355+ gfloat h,
356+ gfloat stripe,
357+ gfloat d,
358+ gfloat dc,
359+ gfloat symmetry,
360+ gboolean internal,
361+ gboolean expanded)
362+{
363+ cairo_new_path (cr);
364+
365+ gfloat lx = 0.0;
366+ gfloat ly = y;
367+ gfloat y3 = y + h;
368+ gfloat y2 = y3 - 5;
369+
370+ if (stripe > 0)
371+ {
372+ if (expanded)
373+ {
374+ stripe = (w * stripe); /* now stripe = non-stripe */
375+ if (internal)
376+ {
377+ /* Manual-Stripe & Expanded & Internal */
378+ lx = stripe * symmetry;
379+ cairo_move_to (cr, lx, ly);
380+ _line_from_to (cr, &lx, &ly, lx+d, y2);
381+ _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - d, y2);
382+ _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry), y);
383+ cairo_close_path (cr);
384+ }
385+ else
386+ {
387+ /* Manual-Stripe & Expanded & External */
388+ ly = y3;
389+ cairo_move_to (cr, lx, ly);
390+ _line_from_to (cr, &lx, &ly, lx, y);
391+ _line_from_to (cr, &lx, &ly, stripe * symmetry, y);
392+ _line_from_to (cr, &lx, &ly, stripe * symmetry + d, y2);
393+ _line_from_to (cr, &lx, &ly, w - stripe * (1. - symmetry) - d, y2);
394+ _line_from_to (cr, &lx, &ly, w - stripe * (1. - symmetry), y);
395+ _line_from_to (cr, &lx, &ly, w, y);
396+ _line_from_to (cr, &lx, &ly, w, y3);
397+ cairo_close_path (cr);
398+ }
399+ }
400+ else
401+ {
402+ if (stripe == 1.)
403+ {
404+ _create_path_lucido (bg, position, cr, y, w, h, 0.,
405+ d, dc, 0., internal, expanded);
406+ return;
407+ }
408+ stripe = ((w - dc * 2) * stripe); /* now stripe = non-stripe */
409+ if (internal)
410+ {
411+ /* Manual-Stripe & Not-Expanded & Internal */
412+ lx = stripe * symmetry + dc;
413+ cairo_move_to (cr, lx, ly);
414+ _line_from_to (cr, &lx, &ly, lx + d, y2);
415+ _line_from_to (cr, &lx, &ly, w - stripe * (1.- symmetry) - dc - d, y2);
416+ _line_from_to (cr, &lx, &ly, w - stripe * (1.- symmetry) - dc, y);
417+ cairo_close_path (cr);
418+ }
419+ else
420+ {
421+ /* Manual-Stripe & Not-Expanded & External */
422+ ly = y3;
423+ cairo_move_to (cr, lx, ly);
424+ _line_from_to (cr, &lx, &ly, lx+dc, y);
425+ _line_from_to (cr, &lx, &ly, stripe * symmetry + dc, y);
426+ _line_from_to (cr, &lx, &ly, stripe * symmetry + d + dc, y2);
427+ _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - dc - d, y2);
428+ _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - dc, y);
429+ _line_from_to (cr, &lx, &ly, w-dc, y);
430+ _line_from_to (cr, &lx, &ly, w, y3);
431+ cairo_close_path(cr);
432+ }
433+ }
434+ }
435+ else
436+ {
437+ gint exps_found = 0;
438+ gfloat curx = 0.0;
439+
440+ if (expanded)
441+ {
442+ if (internal)
443+ {
444+ /* Auto-Stripe & Expanded & Internal */
445+ GList *widgets = _get_applet_widgets (bg);
446+ GList *i = widgets;
447+ GtkWidget *widget = NULL;
448+
449+ /* analyze first widget*/
450+ widget = GTK_WIDGET (i->data);
451+
452+ /* if first widget is an expander */
453+ if (widget && GTK_IS_IMAGE (widget) && !AWN_IS_SEPARATOR (widget))
454+ {
455+ /* start from bottom */
456+ lx = curx;
457+ ly = y;
458+ cairo_move_to (cr, lx, ly);
459+ _line_from_to (cr, &lx, &ly, lx, y2);
460+ ++exps_found;
461+ }
462+ /* else start from top */
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+ curx += widget->allocation.width;
481+ break;
482+ default:
483+ curx = widget->allocation.y;
484+ if ( exps_found % 2 != 0)
485+ curx += widget->allocation.height;
486+ break;
487+ }
488+ if (curx < 0)
489+ continue;
490+
491+ if (exps_found == 0)
492+ {
493+ /* this is the first expander */
494+ lx = curx;
495+ cairo_move_to (cr, lx, ly);
496+ _line_from_to (cr, &lx, &ly, curx + d, y2);
497+ }
498+ else
499+ {
500+ if (exps_found % 2 != 0)
501+ {
502+ /* odd expander - curve at the end of expander */
503+ _line_from_to (cr, &lx, &ly, curx - d, y2);
504+ _line_from_to (cr, &lx, &ly, curx, y);
505+ }
506+ else
507+ {
508+ /* even expander - curve at the start of expander */
509+ _line_from_to (cr, &lx, &ly, curx, y);
510+ _line_from_to (cr, &lx, &ly, curx + d, y2);
511+ }
512+ }
513+
514+ ++exps_found;
515+ }
516+ g_list_free (widgets);
517+
518+ _line_from_to (cr, &lx, &ly, w, ly);
519+
520+ if (exps_found % 2 != 0)
521+ _line_from_to (cr, &lx, &ly, lx, y);
522+
523+ cairo_close_path (cr);
524+ }
525+ else
526+ {
527+ /* Auto-Stripe & Expanded & External */
528+
529+ GList *widgets = _get_applet_widgets (bg);
530+ GList *i = widgets;
531+ GtkWidget *widget = NULL;
532+
533+ /* analyze first widget*/
534+ widget = GTK_WIDGET (i->data);
535+
536+ ly = y3;
537+ cairo_move_to (cr, lx, ly);
538+
539+ /* if first widget is an expander */
540+ if (widget && GTK_IS_IMAGE (widget) && !AWN_IS_SEPARATOR (widget))
541+ {
542+ /* start from bottom */
543+ _line_from_to (cr, &lx, &ly, lx, y2);
544+ ++exps_found;
545+ }
546+ else
547+ {
548+ /* start from top */
549+ _line_from_to (cr, &lx, &ly, lx, y);
550+ }
551+
552+ for (; i; i = i->next)
553+ {
554+ widget = GTK_WIDGET (i->data);
555+
556+ if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
557+ {
558+ /* if not expander continue */
559+ continue;
560+ }
561+ /* expander found */
562+ switch (position)
563+ {
564+ case GTK_POS_BOTTOM:
565+ case GTK_POS_TOP:
566+ curx = widget->allocation.x;
567+ if (exps_found % 2 != 0)
568+ curx += widget->allocation.width;
569+ break;
570+ default:
571+ curx = widget->allocation.y;
572+ if (exps_found % 2 != 0)
573+ curx += widget->allocation.height;
574+ break;
575+ }
576+ if (curx < 0)
577+ continue;
578+
579+ if (exps_found % 2 != 0)
580+ {
581+ _line_from_to (cr, &lx, &ly, curx - d, y2);
582+ _line_from_to (cr, &lx, &ly, curx, y);
583+ }
584+ else
585+ {
586+ _line_from_to (cr, &lx, &ly, curx, y);
587+ _line_from_to (cr, &lx, &ly, curx + d, y2);
588+ }
589+ ++exps_found;
590+ }
591+ g_list_free (widgets);
592+
593+ _line_from_to (cr, &lx, &ly, w, ly);
594+ _line_from_to (cr, &lx, &ly, lx, y3);
595+
596+ cairo_close_path (cr);
597+ }
598+ }
599+ else
600+ {
601+ if (internal)
602+ {
603+ /* Auto-Stripe & Not-Expanded & Internal */
604+ /* no-path */
605+ }
606+ else
607+ {
608+ /* Auto-Stripe & Not-Expanded & External */
609+ ly = y3;
610+ cairo_move_to (cr, lx, ly);
611+ _line_from_to (cr, &lx, &ly, lx + dc, y);
612+ _line_from_to (cr, &lx, &ly, w - dc, y);
613+ _line_from_to (cr, &lx, &ly, w, y3);
614+ cairo_close_path (cr);
615+ }
616+ }
617+ }
618+}
619+
620+static void
621+draw_top_bottom_background (AwnBackground* bg,
622+ GtkPositionType position,
623+ cairo_t* cr,
624+ gint width,
625+ gint height)
626+{
627+ cairo_pattern_t *pat = NULL;
628+ cairo_pattern_t *pat_hi = NULL;
629+
630+ /* Make sure the bar gets drawn on the 0.5 pixels (for sharp edges) */
631+ cairo_translate (cr, 0.5, 0.5);
632+
633+ /* Basic set-up */
634+ cairo_set_line_width (cr, 1.0);
635+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
636+
637+ if(gtk_widget_is_composited (GTK_WIDGET (bg->panel) ) == FALSE)
638+ {
639+ goto paint_lines;
640+ }
641+
642+ gboolean expand = FALSE;
643+ g_object_get (bg->panel, "expand", &expand, NULL);
644+
645+ /* create internal path */
646+ _create_path_lucido (bg, position, cr, 0, width, height,
647+ bg->stripe_width, bg->curviness,
648+ bg->curviness, bg->curves_symmetry,
649+ 1, expand);
650+
651+ /* Draw internal pattern if needed */
652+ if (bg->enable_pattern && bg->pattern)
653+ {
654+ /* Prepare pattern */
655+ pat = cairo_pattern_create_for_surface (bg->pattern);
656+ cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT);
657+ /* Draw */
658+ cairo_save (cr);
659+ cairo_clip_preserve (cr);
660+ cairo_set_source (cr, pat);
661+ cairo_paint (cr);
662+ cairo_restore (cr);
663+ cairo_pattern_destroy (pat);
664+ }
665+
666+ /* Prepare the internal background */
667+ pat = cairo_pattern_create_linear (0, 0, 0, height);
668+ awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->border_color);
669+ awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->hilight_color);
670+
671+ /* Draw the internal background gradient */
672+ cairo_save (cr);
673+ cairo_clip_preserve (cr);
674+ cairo_set_source (cr, pat);
675+ cairo_paint (cr);
676+ cairo_restore (cr);
677+ cairo_pattern_destroy (pat);
678+
679+ /* Prepare external background gradient*/
680+ pat = cairo_pattern_create_linear (0, 0, 0, height);
681+ awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_step_1);
682+ awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);
683+
684+ /* create external path */
685+ _create_path_lucido (bg, position, cr, 0, width, height,
686+ bg->stripe_width, bg->curviness,
687+ bg->curviness, bg->curves_symmetry,
688+ 0, expand);
689+
690+ /* Draw the external background */
691+ cairo_save (cr);
692+ cairo_clip_preserve (cr);
693+ cairo_set_source (cr, pat);
694+ cairo_paint (cr);
695+ cairo_restore (cr);
696+ cairo_pattern_destroy (pat);
697+
698+ /* Draw the hi-light */
699+ pat_hi = cairo_pattern_create_linear (0, 0, 0, (height / 3.0));
700+ awn_cairo_pattern_add_color_stop_color (pat_hi, 0.0, bg->g_histep_1);
701+ awn_cairo_pattern_add_color_stop_color (pat_hi, 1.0, bg->g_histep_2);
702+
703+ if (expand)
704+ {
705+ cairo_new_path (cr);
706+ cairo_rectangle (cr, 0, 0, width, (height / 3.0));
707+ }
708+
709+ cairo_set_source (cr, pat_hi);
710+ cairo_fill (cr);
711+ cairo_pattern_destroy (pat_hi);
712+
713+ return;
714+ /* if not composited */
715+paint_lines:
716+
717+ /* Internal border */
718+ awn_cairo_set_source_color (cr, bg->hilight_color);
719+ cairo_rectangle (cr, 1, 1, width - 3, height + 3);
720+ cairo_stroke (cr);
721+
722+ /* External border */
723+ awn_cairo_set_source_color (cr, bg->border_color);
724+ cairo_rectangle (cr, 1, 1, width - 1, height + 3);
725+ cairo_stroke (cr);
726+}
727+
728+
729+static
730+void awn_background_lucido_padding_request (AwnBackground *bg,
731+ GtkPositionType position,
732+ guint *padding_top,
733+ guint *padding_bottom,
734+ guint *padding_left,
735+ guint *padding_right)
736+{
737+ #define TOP_PADDING 2
738+ gboolean expand = FALSE;
739+ g_object_get (bg->panel, "expand", &expand, NULL);
740+ gint side_padding = expand ? 0 : bg->curviness;
741+ gint zero_padding = 0;
742+
743+ gfloat align = awn_background_get_panel_alignment (bg);
744+ if (awn_background_do_rtl_swap (bg))
745+ {
746+ if (align <= 0.0 || align >= 1.0)
747+ {
748+ zero_padding = side_padding;
749+ side_padding = 0;
750+ }
751+ }
752+
753+ switch (position)
754+ {
755+ case GTK_POS_TOP:
756+ *padding_top = 0;
757+ *padding_bottom = TOP_PADDING;
758+ *padding_left = align == 0.0 ? zero_padding : side_padding;
759+ *padding_right = align == 1.0 ? zero_padding : side_padding;
760+ break;
761+ case GTK_POS_BOTTOM:
762+ *padding_top = TOP_PADDING;
763+ *padding_bottom = 0;
764+ *padding_left = align == 0.0 ? zero_padding : side_padding;
765+ *padding_right = align == 1.0 ? zero_padding : side_padding;
766+ break;
767+ case GTK_POS_LEFT:
768+ *padding_top = align == 0.0 ? zero_padding : side_padding;
769+ *padding_bottom = align == 1.0 ? zero_padding : side_padding;
770+ *padding_left = 0;
771+ *padding_right = TOP_PADDING;
772+ break;
773+ case GTK_POS_RIGHT:
774+ *padding_top = align == 0.0 ? zero_padding : side_padding;
775+ *padding_bottom = align == 1.0 ? zero_padding : side_padding;
776+ *padding_left = TOP_PADDING;
777+ *padding_right = 0;
778+ break;
779+ default:
780+ break;
781+ }
782+}
783+
784+
785+
786+static void
787+awn_background_lucido_draw (AwnBackground *bg,
788+ cairo_t *cr,
789+ GtkPositionType position,
790+ GdkRectangle *area)
791+{
792+ gint temp;
793+ gint x = area->x, y = area->y;
794+ gint width = area->width, height = area->height;
795+ cairo_save (cr);
796+
797+ switch (position)
798+ {
799+ case GTK_POS_RIGHT:
800+ cairo_translate (cr, 0., y + height);
801+ cairo_scale (cr, 1., -1.);
802+ cairo_translate (cr, x, height);
803+ cairo_rotate (cr, M_PI * 1.5);
804+ temp = width;
805+ width = height;
806+ height = temp;
807+ break;
808+ case GTK_POS_LEFT:
809+ cairo_translate (cr, x + width, y);
810+ cairo_rotate (cr, M_PI * 0.5);
811+ temp = width;
812+ width = height;
813+ height = temp;
814+ break;
815+ case GTK_POS_TOP:
816+ cairo_translate (cr, x, y + height);
817+ cairo_scale (cr, 1., -1.);
818+ break;
819+ default:
820+ cairo_translate (cr, x, y);
821+ break;
822+ }
823+
824+ draw_top_bottom_background (bg, position, cr, width, height);
825+
826+ cairo_restore (cr);
827+}
828+
829+static gboolean
830+awn_background_lucido_get_needs_redraw (AwnBackground *bg,
831+ GtkPositionType position,
832+ GdkRectangle *area)
833+{
834+ /* Check default needs redraw */
835+ gboolean nr = AWN_BACKGROUND_CLASS (awn_background_lucido_parent_class)->
836+ get_needs_redraw (bg, position, area);
837+ if (nr)
838+ return TRUE;
839+
840+ /* Check expanders positions & sizes changed */
841+ GList *widgets = _get_applet_widgets (bg);
842+ GList *i = widgets;
843+ GtkWidget *widget = NULL;
844+ gint wcheck = 0;
845+
846+ for (; i; i = i->next)
847+ {
848+ widget = GTK_WIDGET (i->data);
849+
850+ if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
851+ {
852+ /* if not expander continue */
853+ continue;
854+ }
855+ switch (position)
856+ {
857+ case GTK_POS_BOTTOM:
858+ case GTK_POS_TOP:
859+ wcheck += widget->allocation.x + widget->allocation.width;
860+ break;
861+ default:
862+ wcheck += widget->allocation.y + widget->allocation.height;
863+ break;
864+ }
865+ }
866+ g_list_free (widgets);
867+
868+ AwnBackgroundLucido *lbg = NULL;
869+ lbg = AWN_BACKGROUND_LUCIDO (bg);
870+ if (lbg->expw != wcheck)
871+ {
872+ lbg->expw = wcheck;
873+ return TRUE;
874+ }
875+ return FALSE;
876+}
877+
878+static void
879+awn_background_lucido_get_shape_mask (AwnBackground *bg,
880+ cairo_t *cr,
881+ GtkPositionType position,
882+ GdkRectangle *area)
883+{
884+ AWN_BACKGROUND_CLASS (awn_background_lucido_parent_class)->get_shape_mask (
885+ bg, cr, position, area);
886+}
887+
888+/* vim: set et ts=2 sts=2 sw=2 : */
889
890=== added file 'src/awn-background-lucido.h'
891--- src/awn-background-lucido.h 1970-01-01 00:00:00 +0000
892+++ src/awn-background-lucido.h 2010-05-24 12:32:29 +0000
893@@ -0,0 +1,70 @@
894+/*
895+ * Copyright (C) 2009 Michal Hruby <michal.mhr@gmail.com>
896+ *
897+ * This program is free software; you can redistribute it and/or modify
898+ * it under the terms of the GNU General Public License as published by
899+ * the Free Software Foundation; either version 2 of the License, or
900+ * (at your option) any later version.
901+ *
902+ * This program is distributed in the hope that it will be useful,
903+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
904+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
905+ * GNU General Public License for more details.
906+ *
907+ * You should have received a copy of the GNU General Public License
908+ * along with this program; if not, write to the Free Software
909+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
910+ *
911+ * Author : Alberto Aldegheri <albyrock87+dev@gmail.com>
912+*/
913+
914+#ifndef _AWN_BACKGROUND_LUCIDO_H
915+#define _AWN_BACKGROUND_LUCIDO_H
916+
917+#include <glib.h>
918+#include <glib-object.h>
919+#include <gtk/gtk.h>
920+
921+#include "awn-background-flat.h"
922+
923+G_BEGIN_DECLS
924+
925+#define AWN_TYPE_BACKGROUND_LUCIDO (awn_background_lucido_get_type())
926+
927+#define AWN_BACKGROUND_LUCIDO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AWN_TYPE_BACKGROUND_LUCIDO, \
928+ AwnBackgroundLucido))
929+
930+#define AWN_BACKGROUND_LUCIDO_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), AWN_BACKGROUND_LUCIDO, \
931+ AwnBackgroundLucidoClass))
932+
933+#define AWN_IS_BACKGROUND_LUCIDO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AWN_TYPE_BACKGROUND_LUCIDO))
934+
935+#define AWN_IS_BACKGROUND_LUCIDO_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), \
936+ AWN_TYPE_BACKGROUND_LUCIDO))
937+
938+#define AWN_BACKGROUND_LUCIDO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
939+ AWN_TYPE_BACKGROUND_LUCIDO, AwnBackgroundLucidoClass))
940+
941+typedef struct _AwnBackgroundLucido AwnBackgroundLucido;
942+typedef struct _AwnBackgroundLucidoClass AwnBackgroundLucidoClass;
943+
944+struct _AwnBackgroundLucido
945+{
946+ AwnBackgroundFlat parent;
947+ gint expw;
948+};
949+
950+struct _AwnBackgroundLucidoClass
951+{
952+ AwnBackgroundFlatClass parent_class;
953+};
954+
955+GType awn_background_lucido_get_type (void) G_GNUC_CONST;
956+
957+AwnBackground * awn_background_lucido_new (DesktopAgnosticConfigClient *client,
958+ AwnPanel *panel);
959+
960+G_END_DECLS
961+
962+#endif /* _AWN_BACKGROUND_LUCIDO_H */
963+
964
965=== modified file 'src/awn-background.c'
966--- src/awn-background.c 2010-04-08 15:38:05 +0000
967+++ src/awn-background.c 2010-05-24 12:32:29 +0000
968@@ -58,7 +58,8 @@
969 PROP_CORNER_RADIUS,
970 PROP_PANEL_ANGLE,
971 PROP_CURVINESS,
972- PROP_CURVES_SYMEMETRY
973+ PROP_CURVES_SYMEMETRY,
974+ PROP_STRIPE_WIDTH
975 };
976
977 enum
978@@ -90,6 +91,10 @@
979 GtkPositionType position,
980 GdkRectangle *area);
981
982+static gboolean awn_background_get_needs_redraw (AwnBackground *bg,
983+ GtkPositionType position,
984+ GdkRectangle *area);
985+
986 static AwnPathType awn_background_path_default (AwnBackground *bg,
987 gfloat *offset_mod);
988
989@@ -186,6 +191,11 @@
990 object, "curves-symmetry", TRUE,
991 DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,
992 NULL);
993+ desktop_agnostic_config_client_bind (bg->client,
994+ AWN_GROUP_THEME, AWN_THEME_STRIPE_WIDTH,
995+ object, "stripe-width", TRUE,
996+ DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,
997+ NULL);
998 }
999
1000 static void
1001@@ -342,12 +352,15 @@
1002 case PROP_CURVES_SYMEMETRY:
1003 bg->curves_symmetry = g_value_get_float (value);
1004 break;
1005+ case PROP_STRIPE_WIDTH:
1006+ bg->stripe_width = g_value_get_float (value);
1007+ break;
1008
1009 default:
1010 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1011 return;
1012 }
1013-
1014+ awn_background_invalidate (bg);
1015 g_signal_emit (object, _bg_signals[CHANGED], 0);
1016 }
1017
1018@@ -380,6 +393,12 @@
1019 if (bg->hilight_color) g_object_unref (bg->hilight_color);
1020 if (bg->sep_color) g_object_unref (bg->sep_color);
1021
1022+ if (bg->helper_surface != NULL)
1023+ {
1024+ cairo_surface_finish (bg->helper_surface);
1025+ cairo_surface_destroy (bg->helper_surface);
1026+ }
1027+
1028 G_OBJECT_CLASS (awn_background_parent_class)->finalize (object);
1029 }
1030
1031@@ -398,6 +417,7 @@
1032 klass->get_input_shape_mask = awn_background_mask_none;
1033 klass->get_path_type = awn_background_path_default;
1034 klass->get_strut_offsets = NULL;
1035+ klass->get_needs_redraw = awn_background_get_needs_redraw;
1036
1037 /* Object properties */
1038 g_object_class_install_property (obj_class,
1039@@ -575,6 +595,15 @@
1040 0.0, 1.0, 0.5,
1041 G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
1042 G_PARAM_STATIC_STRINGS));
1043+
1044+ g_object_class_install_property (obj_class,
1045+ PROP_STRIPE_WIDTH,
1046+ g_param_spec_float ("stripe-width",
1047+ "Stripe Width",
1048+ "The width of the stripe",
1049+ 0.0, 1.0, 0.0,
1050+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
1051+ G_PARAM_STATIC_STRINGS));
1052
1053 /* Add signals to the class */
1054 _bg_signals[CHANGED] =
1055@@ -650,6 +679,11 @@
1056 bg->border_color = NULL;
1057 bg->hilight_color = NULL;
1058 bg->sep_color = NULL;
1059+ bg->needs_redraw = TRUE;
1060+ bg->helper_surface = NULL;
1061+ bg->cache_enabled = TRUE;
1062+ bg->last_height = 0;
1063+ bg->last_width = 0;
1064 }
1065
1066 void
1067@@ -664,8 +698,40 @@
1068
1069 klass = AWN_BACKGROUND_GET_CLASS (bg);
1070 g_return_if_fail (klass->draw != NULL);
1071-
1072- klass->draw (bg, cr, position, area);
1073+
1074+ /* Check if background caching is enabled - TRUE by default */
1075+ if (bg->cache_enabled)
1076+ {
1077+ g_return_if_fail (klass->get_needs_redraw != NULL);
1078+ cairo_save (cr);
1079+
1080+ /* Check if background needs to be redrawn */
1081+ if (klass->get_needs_redraw (bg, position, area))
1082+ {
1083+ /* Free last surface */
1084+ if (bg->helper_surface != NULL)
1085+ {
1086+ cairo_surface_finish (bg->helper_surface);
1087+ cairo_surface_destroy (bg->helper_surface);
1088+ }
1089+ /* Create new surface */
1090+ bg->helper_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
1091+ area->x + area->width,
1092+ area->y + area->height);
1093+ cairo_t* temp_cr = cairo_create (bg->helper_surface);
1094+ /* Draw background on temp cairo_t */
1095+ klass->draw (bg, temp_cr, position, area);
1096+ cairo_destroy (temp_cr);
1097+ }
1098+ /* Paint saved surface */
1099+ cairo_set_source_surface (cr, bg->helper_surface, 0., 0.);
1100+ cairo_paint(cr);
1101+ cairo_restore (cr);
1102+ }
1103+ else
1104+ {
1105+ klass->draw (bg, cr, position, area);
1106+ }
1107 }
1108
1109 void
1110@@ -1009,4 +1075,25 @@
1111 return AWN_PATH_LINEAR;
1112 }
1113
1114+static gboolean awn_background_get_needs_redraw (AwnBackground *bg,
1115+ GtkPositionType position,
1116+ GdkRectangle *area)
1117+{
1118+ if (bg->needs_redraw == 1 ||
1119+ bg->last_height != area->height ||
1120+ bg->last_width != area->width)
1121+ {
1122+ bg->needs_redraw = 0;
1123+ bg->last_height = area->height;
1124+ bg->last_width = area->width;
1125+ return TRUE;
1126+ }
1127+ return FALSE;
1128+}
1129+
1130+void awn_background_invalidate (AwnBackground *bg)
1131+{
1132+ bg->needs_redraw = 1;
1133+}
1134+
1135 /* vim: set et ts=2 sts=2 sw=2 : */
1136
1137=== modified file 'src/awn-background.h'
1138--- src/awn-background.h 2010-03-07 18:38:07 +0000
1139+++ src/awn-background.h 2010-05-24 12:32:29 +0000
1140@@ -76,6 +76,15 @@
1141 gfloat pattern_alpha;
1142 GdkPixbuf *pattern_original;
1143 cairo_surface_t *pattern;
1144+
1145+ /* Speedup code.
1146+ * We can save the bg and redraw only when properties changes
1147+ */
1148+ gboolean cache_enabled;
1149+ gboolean needs_redraw;
1150+ cairo_surface_t* helper_surface;
1151+ gint last_height;
1152+ gint last_width;
1153
1154 /* FIXME:
1155 * These two should ultimately go somewhere else (once we do multiple panels)
1156@@ -89,6 +98,7 @@
1157 gint panel_angle;
1158 gfloat curviness;
1159 gfloat curves_symmetry;
1160+ gfloat stripe_width;
1161
1162 /* private */
1163 guint changed;
1164@@ -129,6 +139,10 @@
1165 GdkRectangle *area,
1166 gint *strut,
1167 gint *strut_start, gint *strut_end);
1168+
1169+ gboolean (*get_needs_redraw) (AwnBackground *bg,
1170+ GtkPositionType position,
1171+ GdkRectangle *area);
1172
1173 /*< signals >*/
1174 void (*changed) (AwnBackground *bg);
1175@@ -142,6 +156,8 @@
1176 GtkPositionType position,
1177 GdkRectangle *area);
1178
1179+void awn_background_invalidate (AwnBackground *bg);
1180+
1181 void awn_background_padding_request (AwnBackground *bg,
1182 GtkPositionType position,
1183 guint *padding_top,
1184
1185=== modified file 'src/awn-defines.h'
1186--- src/awn-defines.h 2010-02-06 13:34:02 +0000
1187+++ src/awn-defines.h 2010-05-24 12:32:29 +0000
1188@@ -87,6 +87,7 @@
1189 #define AWN_THEME_PANEL_ANGLE "panel_angle"
1190 #define AWN_THEME_CURVINESS "curviness"
1191 #define AWN_THEME_CURVES_SYMMETRY "curves_symmetry"
1192+#define AWN_THEME_STRIPE_WIDTH "stripe_width"
1193
1194 #endif /*_HAVE_AWN_DEFINES_H */
1195
1196
1197=== modified file 'src/awn-panel.c'
1198--- src/awn-panel.c 2010-04-10 21:24:01 +0000
1199+++ src/awn-panel.c 2010-05-24 12:32:29 +0000
1200@@ -43,6 +43,7 @@
1201 #include "awn-background-3d.h"
1202 #include "awn-background-curves.h"
1203 #include "awn-background-edgy.h"
1204+#include "awn-background-lucido.h"
1205 #include "awn-background-floaty.h"
1206 #include "awn-defines.h"
1207 #include "awn-marshal.h"
1208@@ -222,6 +223,7 @@
1209 STYLE_EDGY,
1210 STYLE_FLOATY,
1211
1212+ STYLE_LUCIDO,
1213 STYLE_LAST
1214 };
1215
1216@@ -2973,6 +2975,9 @@
1217 position_window (panel);
1218
1219 gtk_widget_queue_resize (GTK_WIDGET (panel));
1220+
1221+ if (priv->bg)
1222+ awn_background_invalidate (priv->bg);
1223 }
1224
1225 static void
1226@@ -3168,6 +3173,9 @@
1227 case STYLE_EDGY:
1228 priv->bg = awn_background_edgy_new (priv->client, panel);
1229 break;
1230+ case STYLE_LUCIDO:
1231+ priv->bg = awn_background_lucido_new (priv->client, panel);
1232+ break;
1233 case STYLE_FLOATY:
1234 priv->bg = awn_background_floaty_new (priv->client, panel);
1235 break;

Subscribers

People subscribed via source and target branches