Merge lp:~azzar1/unity/shortcut-hint into lp:unity
- shortcut-hint
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Andrea Azzarone |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1833 |
Proposed branch: | lp:~azzar1/unity/shortcut-hint |
Merge into: | lp:unity |
Diff against target: |
2326 lines (+2055/-7) 25 files modified
plugins/unityshell/src/AbstractSeparator.cpp (+68/-0) plugins/unityshell/src/AbstractSeparator.h (+49/-0) plugins/unityshell/src/AbstractShortcutHint.h (+102/-0) plugins/unityshell/src/BackgroundEffectHelper.cpp (+1/-1) plugins/unityshell/src/LineSeparator.cpp (+73/-0) plugins/unityshell/src/LineSeparator.h (+44/-0) plugins/unityshell/src/MockShortcutHint.h (+72/-0) plugins/unityshell/src/ShortcutController.cpp (+194/-0) plugins/unityshell/src/ShortcutController.h (+87/-0) plugins/unityshell/src/ShortcutHint.cpp (+137/-0) plugins/unityshell/src/ShortcutHint.h (+53/-0) plugins/unityshell/src/ShortcutHintPrivate.cpp (+79/-0) plugins/unityshell/src/ShortcutHintPrivate.h (+39/-0) plugins/unityshell/src/ShortcutModel.cpp (+60/-0) plugins/unityshell/src/ShortcutModel.h (+64/-0) plugins/unityshell/src/ShortcutView.cpp (+424/-0) plugins/unityshell/src/ShortcutView.h (+93/-0) plugins/unityshell/src/unityshell.cpp (+99/-1) plugins/unityshell/src/unityshell.h (+9/-1) plugins/unityshell/unityshell.xml.in (+6/-0) standalone-clients/CMakeLists.txt (+26/-3) standalone-clients/TestShortcut.cpp (+109/-0) tests/CMakeLists.txt (+9/-1) tests/test_shortcut_model.cpp (+84/-0) tests/test_shortcut_private.cpp (+74/-0) |
To merge this branch: | bzr merge lp:~azzar1/unity/shortcut-hint |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Trevisan (Treviño) | Approve | ||
John Lea (community) | design | Approve | |
Tim Penhey (community) | Approve | ||
Review via email: mp+85575@code.launchpad.net |
This proposal supersedes a proposal from 2011-12-07.
Commit message
Description of the change
Display a shortcut hints overlay during the super key pressing.
It includes two unit tests and a standalone test.
Mockup: https:/
Branch: http://
Visual diff: http://
Keep in mind that something is different because the shortcuts values are not hardcoded.
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal | # |
Andrea Azzarone (azzar1) wrote : Posted in a previous version of this proposal | # |
Marco you should not review a WIP :P
> I've just looked at few things but it seem good, however remember to unregister the ubus controller (i.e as done in lp:~vanvugt/unity/fix-887465-trunk )
Thanks for tip.
> and to use g_markup_
We no longer need it ;)
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal | # |
That was not a review, just a comment! :)
Jeremy Bícha (jbicha) wrote : Posted in a previous version of this proposal | # |
Hi, I hope you don't mind me giving feedback on the wording choices since it's still WIP...
Please use Trash instead of Rubbish Bin; the en_GB translation can change it back to Rubbish Bin.
The verb should consistently add the trailing "s" or not. In other words, "open" or "opens". For the Ubuntu system help, we left off the "s" but it could just as easily go the other way.
I'd like to see the keyboard keys always capitalized; I think some are stored as lowercase in metacity or whatever, but for display you should be able to upper-case them. ("Super + s" should be "Super + S").
How about "arrow keys" instead of "cursor keys"?
I believe menu bar is slightly preferred over top bar.
Andrea Azzarone (azzar1) wrote : Posted in a previous version of this proposal | # |
It's a WIP btw here's the mockup: https:/
Marco Biscaro (marcobiscaro2112) wrote : Posted in a previous version of this proposal | # |
Another comment :) there is a typo here:
+ hints_.
Tim Penhey (thumper) wrote : Posted in a previous version of this proposal | # |
another comment, since this isn't yet a review :-)
properties should be lower case.
Tim Penhey (thumper) wrote : | # |
Hi Andy,
Can you add links for the design mockup, and a picture of what is
rendered with this branch?
Cheers,
Tim
Tim Penhey (thumper) wrote : | # |
Purely visual review:
The mockup lines are not white, but either transparent white or
transparent grey. The headings of each group are also not white.
The lines in the mockup are 1px thin grey with distinct ends. The view
has thicker lines that are brighter that taper at the ends.
The white-space above the "Windows" header is greater than the rest.
Some of the key-bindings are lower case, why is that?
Why are we missing some of the key bindings, like moving the focused
window to other workspaces?
Tim
Andrea Azzarone (azzar1) wrote : | # |
> Purely visual review:
>
> The mockup lines are not white, but either transparent white or
> transparent grey. The headings of each group are also not white.
>
> The lines in the mockup are 1px thin grey with distinct ends. The view
> has thicker lines that are brighter that taper at the ends.
>
I'll look to it.
>
> The white-space above the "Windows" header is greater than the rest.
>
Yeah, because i've commented a couple of key bindings because they are not yet implemented.
>
> Some of the key-bindings are lower case, why is that?
>
Because Compiz CompOption gives me something like that: <Super>f... I've writed a very simple function to change it in "Super + f". I think the best solution is to capitalize each word of the shortcut.
> Why are we missing some of the key bindings, like moving the focused
> window to other workspaces?
As said, some options are not yet implmented. For example, regarding "Move focused window to different workspace" I can't find it in CCSM.
John Lea (johnlea) wrote : | # |
Looking great! ;-) However there are a few minor issues that need to be fixed before this lands.
The feedback below is based on comparing the implementation screenshot posted with the following designs:
- https:/
- https:/
Items in need of fixing:
1. The divider lines should by 10% opacity (while remaining 100% white)
2. The divider should start flush with text, and end flush with grid (see grid design above)
3. The divider lines should have flat ends
4. The spacing of the title "Keyboard Shortcuts" is slightly out, should have slightly more space above than below (see design)
5. The spacing of the section titles is slightly out, should have slightly more space above each title than below (see design)
6. The shortcuts need updating to exactly match those specified in the following document https:/
Once these are fixed we are good to go, thx!
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
> > Why are we missing some of the key bindings, like moving the focused
> > window to other workspaces?
>
> As said, some options are not yet implmented. For example, regarding "Move
> focused window to different workspace" I can't find it in CCSM.
It's under desktop wall -> bindings -> Move with window within wall
Plus, I put here for reference as well, the bottom edge has some issues here:
- http://
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
> 6. The shortcuts need updating to exactly match those specified in the
> following document https:/
> /1jqeKtIJwqLtl5
About the Alt+` shortcut... As it depends to the keyboard layout (i.e. in the Italian we have Alt+\ in fact), I guess that it should be localized...
Andrea Azzarone (azzar1) wrote : | # |
> Looking great! ;-) However there are a few minor issues that need to be fixed
> before this lands.
>
> The feedback below is based on comparing the implementation screenshot posted
> with the following designs:
> - https:/
> design itself)
> - https:/
> grid the design is build on)
>
> Items in need of fixing:
>
> 1. The divider lines should by 10% opacity (while remaining 100% white)
>
Done.
> 2. The divider should start flush with text, and end flush with grid (see grid
> design above)
Done.
>
> 3. The divider lines should have flat ends
Done.
>
> 4. The spacing of the title "Keyboard Shortcuts" is slightly out, should have
> slightly more space above than below (see design)
>
Done.
> 5. The spacing of the section titles is slightly out, should have slightly
> more space above each title than below (see design)
Done.
>
> 6. The shortcuts need updating to exactly match those specified in the
> following document https:/
> /1jqeKtIJwqLtl5
>
> Once these are fixed we are good to go, thx!
I'll do it tomorrow.
Andrea Azzarone (azzar1) wrote : | # |
Ok ready for the review. I've fixed something in the layout but I don't know if I've fixed the Marco's problem. Marco can you test it please? If you still have the same problem, can you check your DPI?
Tim Penhey (thumper) wrote : | # |
A general pass over the code and it seems OK, but nothing in UnityCore.
John Lea (johnlea) wrote : | # |
awesome, everything perfect, great to see a attached .png with the visual design matched up against the implementation.
thanks!
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
I've just checked again this branch, but I still get that visual issue that I've already mentioned :(
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
I'm working on a branch dependent on this (lp:~3v1n0/unity/unity-dialog), working to fix the issue I got.
So, approving.
Unity Merger (unity-merger) wrote : | # |
Attempt to merge into lp:unity failed due to conflicts:
text conflict in standalone-
Preview Diff
1 | === added file 'plugins/unityshell/src/AbstractSeparator.cpp' | |||
2 | --- plugins/unityshell/src/AbstractSeparator.cpp 1970-01-01 00:00:00 +0000 | |||
3 | +++ plugins/unityshell/src/AbstractSeparator.cpp 2012-01-13 15:39:27 +0000 | |||
4 | @@ -0,0 +1,68 @@ | |||
5 | 1 | /* | ||
6 | 2 | * Copyright (C) 2011 Canonical Ltd | ||
7 | 3 | * | ||
8 | 4 | * This program is free software: you can redistribute it and/or modify | ||
9 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
10 | 6 | * published by the Free Software Foundation. | ||
11 | 7 | * | ||
12 | 8 | * This program is distributed in the hope that it will be useful, | ||
13 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | 11 | * GNU General Public License for more details. | ||
16 | 12 | * | ||
17 | 13 | * You should have received a copy of the GNU General Public License | ||
18 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | 15 | * | ||
20 | 16 | * Authored by: Jay Taoko <jaytaoko@inalogic.com> | ||
21 | 17 | * | ||
22 | 18 | */ | ||
23 | 19 | |||
24 | 20 | #include "AbstractSeparator.h" | ||
25 | 21 | |||
26 | 22 | #include "Nux/Nux.h" | ||
27 | 23 | |||
28 | 24 | namespace unity | ||
29 | 25 | { | ||
30 | 26 | |||
31 | 27 | AbstractSeparator::AbstractSeparator(NUX_FILE_LINE_DECL) | ||
32 | 28 | : nux::View(NUX_FILE_LINE_PARAM) | ||
33 | 29 | , color_(nux::color::White) | ||
34 | 30 | , alpha0_(0.0f) | ||
35 | 31 | , alpha1_(0.10f) | ||
36 | 32 | , border_size_(0) | ||
37 | 33 | { | ||
38 | 34 | } | ||
39 | 35 | |||
40 | 36 | // Maybe it's better to use default arguments? | ||
41 | 37 | AbstractSeparator::AbstractSeparator(nux::Color const& color, float alpha0, | ||
42 | 38 | float alpha1, int border, NUX_FILE_LINE_DECL) | ||
43 | 39 | : nux::View(NUX_FILE_LINE_PARAM) | ||
44 | 40 | , color_(color) | ||
45 | 41 | , alpha0_(alpha0) | ||
46 | 42 | , alpha1_(alpha1) | ||
47 | 43 | , border_size_(border) | ||
48 | 44 | { | ||
49 | 45 | } | ||
50 | 46 | |||
51 | 47 | AbstractSeparator::~AbstractSeparator() | ||
52 | 48 | { | ||
53 | 49 | |||
54 | 50 | } | ||
55 | 51 | |||
56 | 52 | void AbstractSeparator::SetColor(nux::Color const &color) | ||
57 | 53 | { | ||
58 | 54 | color_ = color; | ||
59 | 55 | } | ||
60 | 56 | |||
61 | 57 | void AbstractSeparator::SetAlpha(float alpha0, float alpha1) | ||
62 | 58 | { | ||
63 | 59 | alpha0_ = alpha0; | ||
64 | 60 | alpha1_ = alpha1; | ||
65 | 61 | } | ||
66 | 62 | |||
67 | 63 | void AbstractSeparator::SetBorderSize(int border) | ||
68 | 64 | { | ||
69 | 65 | border_size_ = border; | ||
70 | 66 | } | ||
71 | 67 | |||
72 | 68 | } // namespace unity | ||
73 | 0 | 69 | ||
74 | === added file 'plugins/unityshell/src/AbstractSeparator.h' | |||
75 | --- plugins/unityshell/src/AbstractSeparator.h 1970-01-01 00:00:00 +0000 | |||
76 | +++ plugins/unityshell/src/AbstractSeparator.h 2012-01-13 15:39:27 +0000 | |||
77 | @@ -0,0 +1,49 @@ | |||
78 | 1 | /* | ||
79 | 2 | * Copyright (C) 2011 Canonical Ltd | ||
80 | 3 | * | ||
81 | 4 | * This program is free software: you can redistribute it and/or modify | ||
82 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
83 | 6 | * published by the Free Software Foundation. | ||
84 | 7 | * | ||
85 | 8 | * This program is distributed in the hope that it will be useful, | ||
86 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
87 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
88 | 11 | * GNU General Public License for more details. | ||
89 | 12 | * | ||
90 | 13 | * You should have received a copy of the GNU General Public License | ||
91 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
92 | 15 | * | ||
93 | 16 | * Authored by: Jay Taoko <jaytaoko@inalogic.com> | ||
94 | 17 | * | ||
95 | 18 | */ | ||
96 | 19 | |||
97 | 20 | #ifndef UNITYSHELL_ABSTRACTSEPARATOR_H | ||
98 | 21 | #define UNITYSHELL_ABSTRACTSEPARATOR_H | ||
99 | 22 | |||
100 | 23 | #include <Nux/Nux.h> | ||
101 | 24 | #include <Nux/View.h> | ||
102 | 25 | |||
103 | 26 | namespace unity | ||
104 | 27 | { | ||
105 | 28 | |||
106 | 29 | class AbstractSeparator: public nux::View | ||
107 | 30 | { | ||
108 | 31 | public: | ||
109 | 32 | AbstractSeparator(NUX_FILE_LINE_PROTO); | ||
110 | 33 | AbstractSeparator(nux::Color const& color, float alpha0, float alpha1, int vorder, NUX_FILE_LINE_PROTO); | ||
111 | 34 | ~AbstractSeparator(); | ||
112 | 35 | |||
113 | 36 | void SetColor(nux::Color const& color); | ||
114 | 37 | void SetAlpha(float alpha0, float alpha1); | ||
115 | 38 | void SetBorderSize(int border); | ||
116 | 39 | |||
117 | 40 | protected: | ||
118 | 41 | nux::Color color_; | ||
119 | 42 | float alpha0_; | ||
120 | 43 | float alpha1_; | ||
121 | 44 | int border_size_; | ||
122 | 45 | }; | ||
123 | 46 | |||
124 | 47 | } // namespace unity | ||
125 | 48 | |||
126 | 49 | #endif // UNITYSHELL_ABSTRACTSEPARATOR_H | ||
127 | 0 | 50 | ||
128 | === added file 'plugins/unityshell/src/AbstractShortcutHint.h' | |||
129 | --- plugins/unityshell/src/AbstractShortcutHint.h 1970-01-01 00:00:00 +0000 | |||
130 | +++ plugins/unityshell/src/AbstractShortcutHint.h 2012-01-13 15:39:27 +0000 | |||
131 | @@ -0,0 +1,102 @@ | |||
132 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
133 | 2 | /* | ||
134 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
135 | 4 | * | ||
136 | 5 | * This program is free software: you can redistribute it and/or modify | ||
137 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
138 | 7 | * published by the Free Software Foundation. | ||
139 | 8 | * | ||
140 | 9 | * This program is distributed in the hope that it will be useful, | ||
141 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
142 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
143 | 12 | * GNU General Public License for more details. | ||
144 | 13 | * | ||
145 | 14 | * You should have received a copy of the GNU General Public License | ||
146 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
147 | 16 | * | ||
148 | 17 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
149 | 18 | */ | ||
150 | 19 | |||
151 | 20 | #ifndef UNITYSHELL_ABSTRACT_SHORTCUT_ICON_H | ||
152 | 21 | #define UNITYSHELL_ABSTRACT_SHORTCUT_ICON_H | ||
153 | 22 | |||
154 | 23 | #include <string> | ||
155 | 24 | |||
156 | 25 | #include <Nux/Nux.h> | ||
157 | 26 | #include <NuxCore/Property.h> | ||
158 | 27 | |||
159 | 28 | namespace unity | ||
160 | 29 | { | ||
161 | 30 | namespace shortcut | ||
162 | 31 | { | ||
163 | 32 | |||
164 | 33 | enum OptionType | ||
165 | 34 | { | ||
166 | 35 | COMPIZ_KEY_OPTION = 0, | ||
167 | 36 | COMPIZ_MOUSE_OPTION, | ||
168 | 37 | HARDCODED_OPTION | ||
169 | 38 | /* GSETTINGS_OPTION, | ||
170 | 39 | * GCONF_OPTION */ | ||
171 | 40 | }; | ||
172 | 41 | |||
173 | 42 | class AbstractHint | ||
174 | 43 | { | ||
175 | 44 | public: | ||
176 | 45 | // Ctor | ||
177 | 46 | AbstractHint(std::string const& category, | ||
178 | 47 | std::string const& prefix, | ||
179 | 48 | std::string const& postfix, | ||
180 | 49 | std::string const& description, | ||
181 | 50 | OptionType const type, | ||
182 | 51 | std::string const& arg1, | ||
183 | 52 | std::string const& arg2 = "", | ||
184 | 53 | std::string const& arg3 = "") | ||
185 | 54 | : category(category) | ||
186 | 55 | , prefix(prefix) | ||
187 | 56 | , postfix(postfix) | ||
188 | 57 | , description(description) | ||
189 | 58 | , type(type) | ||
190 | 59 | , arg1(arg1) | ||
191 | 60 | , arg2(arg2) | ||
192 | 61 | , arg3(arg3) | ||
193 | 62 | { | ||
194 | 63 | } | ||
195 | 64 | |||
196 | 65 | // Copy ctor | ||
197 | 66 | AbstractHint(unity::shortcut::AbstractHint const& obj) | ||
198 | 67 | : category(obj.category()) | ||
199 | 68 | , prefix(obj.prefix()) | ||
200 | 69 | , postfix(obj.postfix()) | ||
201 | 70 | , description(obj.description()) | ||
202 | 71 | , type(obj.type()) | ||
203 | 72 | , arg1(obj.arg1()) | ||
204 | 73 | , arg2(obj.arg2()) | ||
205 | 74 | , arg3(obj.arg3()) | ||
206 | 75 | , value(obj.value()) | ||
207 | 76 | , shortkey(obj.shortkey()) | ||
208 | 77 | { | ||
209 | 78 | } | ||
210 | 79 | |||
211 | 80 | // Dtor | ||
212 | 81 | virtual ~AbstractHint(){}; | ||
213 | 82 | |||
214 | 83 | // Public Methods | ||
215 | 84 | virtual bool Fill() = 0; | ||
216 | 85 | |||
217 | 86 | // Properties | ||
218 | 87 | nux::Property<std::string> category; | ||
219 | 88 | nux::Property<std::string> prefix; | ||
220 | 89 | nux::Property<std::string> postfix; | ||
221 | 90 | nux::Property<std::string> description; | ||
222 | 91 | nux::Property<OptionType> type; | ||
223 | 92 | nux::Property<std::string> arg1; | ||
224 | 93 | nux::Property<std::string> arg2; | ||
225 | 94 | nux::Property<std::string> arg3; | ||
226 | 95 | nux::Property<std::string> value; | ||
227 | 96 | nux::Property<std::string> shortkey; | ||
228 | 97 | }; | ||
229 | 98 | |||
230 | 99 | } // namespace shortcut | ||
231 | 100 | } // namespace unity | ||
232 | 101 | |||
233 | 102 | #endif // UNITYSHELL_ABSTRACT_SHORTCUT_ICON_H | ||
234 | 0 | 103 | ||
235 | === modified file 'plugins/unityshell/src/BackgroundEffectHelper.cpp' | |||
236 | --- plugins/unityshell/src/BackgroundEffectHelper.cpp 2012-01-05 02:47:09 +0000 | |||
237 | +++ plugins/unityshell/src/BackgroundEffectHelper.cpp 2012-01-13 15:39:27 +0000 | |||
238 | @@ -72,7 +72,7 @@ | |||
239 | 72 | { | 72 | { |
240 | 73 | for (BackgroundEffectHelper * bg_effect_helper : registered_list_) | 73 | for (BackgroundEffectHelper * bg_effect_helper : registered_list_) |
241 | 74 | { | 74 | { |
243 | 75 | if (bg_effect_helper->cache_dirty || !bg_effect_helper->owner) | 75 | if (bg_effect_helper->cache_dirty || !bg_effect_helper->owner || !bg_effect_helper->enabled) |
244 | 76 | continue; | 76 | continue; |
245 | 77 | 77 | ||
246 | 78 | if (!geo.Intersect (bg_effect_helper->blur_geometry_).IsNull()) | 78 | if (!geo.Intersect (bg_effect_helper->blur_geometry_).IsNull()) |
247 | 79 | 79 | ||
248 | === added file 'plugins/unityshell/src/LineSeparator.cpp' | |||
249 | --- plugins/unityshell/src/LineSeparator.cpp 1970-01-01 00:00:00 +0000 | |||
250 | +++ plugins/unityshell/src/LineSeparator.cpp 2012-01-13 15:39:27 +0000 | |||
251 | @@ -0,0 +1,73 @@ | |||
252 | 1 | /* | ||
253 | 2 | * Copyright (C) 2011 Canonical Ltd | ||
254 | 3 | * | ||
255 | 4 | * This program is free software: you can redistribute it and/or modify | ||
256 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
257 | 6 | * published by the Free Software Foundation. | ||
258 | 7 | * | ||
259 | 8 | * This program is distributed in the hope that it will be useful, | ||
260 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
261 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
262 | 11 | * GNU General Public License for more details. | ||
263 | 12 | * | ||
264 | 13 | * You should have received a copy of the GNU General Public License | ||
265 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
266 | 15 | * | ||
267 | 16 | * Authored by: Jay Taoko <jaytaoko@inalogic.com> | ||
268 | 17 | * | ||
269 | 18 | */ | ||
270 | 19 | |||
271 | 20 | #include "LineSeparator.h" | ||
272 | 21 | |||
273 | 22 | #include "Nux/Nux.h" | ||
274 | 23 | |||
275 | 24 | namespace unity | ||
276 | 25 | { | ||
277 | 26 | |||
278 | 27 | HSeparator::HSeparator() | ||
279 | 28 | { | ||
280 | 29 | SetMinimumHeight(1); | ||
281 | 30 | SetMaximumHeight(1); | ||
282 | 31 | } | ||
283 | 32 | |||
284 | 33 | HSeparator::HSeparator(nux::Color const& color, float alpha0, float alpha1, int border) | ||
285 | 34 | : AbstractSeparator(color, alpha0, alpha1, border) | ||
286 | 35 | { | ||
287 | 36 | SetMinimumHeight(1); | ||
288 | 37 | SetMaximumHeight(1); | ||
289 | 38 | } | ||
290 | 39 | |||
291 | 40 | HSeparator::~HSeparator() | ||
292 | 41 | { | ||
293 | 42 | } | ||
294 | 43 | |||
295 | 44 | void HSeparator::Draw(nux::GraphicsEngine &GfxContext, bool force_draw) | ||
296 | 45 | { | ||
297 | 46 | nux::Geometry base = GetGeometry(); | ||
298 | 47 | base.OffsetPosition(3, 0); | ||
299 | 48 | base.OffsetSize(-6, 0); | ||
300 | 49 | int y0 = base.y + base.GetHeight() / 2; | ||
301 | 50 | |||
302 | 51 | nux::GetGraphicsDisplay()->GetGraphicsEngine()->GetRenderStates().SetBlend(TRUE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||
303 | 52 | |||
304 | 53 | if (base.GetWidth() - 2 * border_size_ > 0) | ||
305 | 54 | { | ||
306 | 55 | nux::Color color0 = color_; | ||
307 | 56 | nux::Color color1 = color_; | ||
308 | 57 | color0.alpha = alpha0_; | ||
309 | 58 | color1.alpha = alpha1_; | ||
310 | 59 | nux::GetPainter().Draw2DLine(GfxContext, base.x, y0, base.x + border_size_, y0, color0, color1); | ||
311 | 60 | nux::GetPainter().Draw2DLine(GfxContext, base.x + border_size_, y0, base.x + base.GetWidth() - border_size_, y0, color1, color1); | ||
312 | 61 | nux::GetPainter().Draw2DLine(GfxContext, base.x + base.GetWidth() - border_size_, y0, base.x + base.GetWidth(), y0, color1, color0); | ||
313 | 62 | } | ||
314 | 63 | else | ||
315 | 64 | { | ||
316 | 65 | nux::Color color1 = color_; | ||
317 | 66 | color1.alpha = alpha1_; | ||
318 | 67 | nux::GetPainter().Draw2DLine(GfxContext, base.x, y0, base.x + base.GetWidth(), y0, color1, color1); | ||
319 | 68 | } | ||
320 | 69 | |||
321 | 70 | nux::GetGraphicsDisplay()->GetGraphicsEngine()->GetRenderStates().SetBlend(FALSE); | ||
322 | 71 | } | ||
323 | 72 | |||
324 | 73 | } // namespace unity | ||
325 | 0 | 74 | ||
326 | === added file 'plugins/unityshell/src/LineSeparator.h' | |||
327 | --- plugins/unityshell/src/LineSeparator.h 1970-01-01 00:00:00 +0000 | |||
328 | +++ plugins/unityshell/src/LineSeparator.h 2012-01-13 15:39:27 +0000 | |||
329 | @@ -0,0 +1,44 @@ | |||
330 | 1 | /* | ||
331 | 2 | * Copyright (C) 2011 Canonical Ltd | ||
332 | 3 | * | ||
333 | 4 | * This program is free software: you can redistribute it and/or modify | ||
334 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
335 | 6 | * published by the Free Software Foundation. | ||
336 | 7 | * | ||
337 | 8 | * This program is distributed in the hope that it will be useful, | ||
338 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
339 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
340 | 11 | * GNU General Public License for more details. | ||
341 | 12 | * | ||
342 | 13 | * You should have received a copy of the GNU General Public License | ||
343 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
344 | 15 | * | ||
345 | 16 | * Authored by: Jay Taoko <jaytaoko@inalogic.com> | ||
346 | 17 | * | ||
347 | 18 | */ | ||
348 | 19 | |||
349 | 20 | #ifndef UNITYSHELL_HSEPARATOR_H | ||
350 | 21 | #define UNITYSHELL_HSEPARATOR_H | ||
351 | 22 | |||
352 | 23 | #include "AbstractSeparator.h" | ||
353 | 24 | |||
354 | 25 | namespace unity | ||
355 | 26 | { | ||
356 | 27 | |||
357 | 28 | class HSeparator: public AbstractSeparator | ||
358 | 29 | { | ||
359 | 30 | public: | ||
360 | 31 | HSeparator(); | ||
361 | 32 | HSeparator(nux::Color const& color, float alpha0, float alpha1, int border); | ||
362 | 33 | |||
363 | 34 | ~HSeparator(); | ||
364 | 35 | |||
365 | 36 | protected: | ||
366 | 37 | virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); | ||
367 | 38 | virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) {}; | ||
368 | 39 | |||
369 | 40 | }; | ||
370 | 41 | |||
371 | 42 | } // namespace unity | ||
372 | 43 | |||
373 | 44 | #endif // UNITYSHELL_HSEPARATOR_H | ||
374 | 0 | 45 | ||
375 | === added file 'plugins/unityshell/src/MockShortcutHint.h' | |||
376 | --- plugins/unityshell/src/MockShortcutHint.h 1970-01-01 00:00:00 +0000 | |||
377 | +++ plugins/unityshell/src/MockShortcutHint.h 2012-01-13 15:39:27 +0000 | |||
378 | @@ -0,0 +1,72 @@ | |||
379 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
380 | 2 | /* | ||
381 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
382 | 4 | * | ||
383 | 5 | * This program is free software: you can redistribute it and/or modify | ||
384 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
385 | 7 | * published by the Free Software Foundation. | ||
386 | 8 | * | ||
387 | 9 | * This program is distributed in the hope that it will be useful, | ||
388 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
389 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
390 | 12 | * GNU General Public License for more details. | ||
391 | 13 | * | ||
392 | 14 | * You should have received a copy of the GNU General Public License | ||
393 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
394 | 16 | * | ||
395 | 17 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
396 | 18 | */ | ||
397 | 19 | |||
398 | 20 | #ifndef UNITYSHELL_MOCK_SHORTCUT_HINT_H | ||
399 | 21 | #define UNITYSHELL_MOCK_SHORTCUT_HINT_H | ||
400 | 22 | |||
401 | 23 | #include "AbstractShortcutHint.h" | ||
402 | 24 | |||
403 | 25 | namespace unity | ||
404 | 26 | { | ||
405 | 27 | namespace shortcut | ||
406 | 28 | { | ||
407 | 29 | |||
408 | 30 | class MockHint : public AbstractHint | ||
409 | 31 | { | ||
410 | 32 | public: | ||
411 | 33 | // Ctor and dtor | ||
412 | 34 | MockHint(std::string const& category, | ||
413 | 35 | std::string const& prefix, | ||
414 | 36 | std::string const& postfix, | ||
415 | 37 | std::string const& description, | ||
416 | 38 | OptionType const type, | ||
417 | 39 | std::string const& arg1, | ||
418 | 40 | std::string const& arg2 = "", | ||
419 | 41 | std::string const& arg3 = "") | ||
420 | 42 | : AbstractHint(category, prefix, postfix, description, type, arg1, arg2, arg3) | ||
421 | 43 | { | ||
422 | 44 | } | ||
423 | 45 | |||
424 | 46 | ~MockHint() {}; | ||
425 | 47 | |||
426 | 48 | // Methods... | ||
427 | 49 | bool Fill() | ||
428 | 50 | { | ||
429 | 51 | switch (type()) | ||
430 | 52 | { | ||
431 | 53 | case COMPIZ_MOUSE_OPTION: | ||
432 | 54 | case COMPIZ_KEY_OPTION: | ||
433 | 55 | value = arg1() + "-" + arg2(); | ||
434 | 56 | shortkey = prefix() + value() + postfix(); | ||
435 | 57 | return true; | ||
436 | 58 | |||
437 | 59 | case HARDCODED_OPTION: | ||
438 | 60 | value = arg1(); | ||
439 | 61 | shortkey = prefix() + value() + postfix(); | ||
440 | 62 | return true; | ||
441 | 63 | } | ||
442 | 64 | |||
443 | 65 | return false; | ||
444 | 66 | } | ||
445 | 67 | }; | ||
446 | 68 | |||
447 | 69 | } // shortcut hint | ||
448 | 70 | } // namespace unity | ||
449 | 71 | |||
450 | 72 | #endif // UNITYSHELL_MOCK_SHORTCUT_HINT_H | ||
451 | 0 | 73 | ||
452 | === added file 'plugins/unityshell/src/ShortcutController.cpp' | |||
453 | --- plugins/unityshell/src/ShortcutController.cpp 1970-01-01 00:00:00 +0000 | |||
454 | +++ plugins/unityshell/src/ShortcutController.cpp 2012-01-13 15:39:27 +0000 | |||
455 | @@ -0,0 +1,194 @@ | |||
456 | 1 | /* | ||
457 | 2 | * Copyright (C) 2011 Canonical Ltd | ||
458 | 3 | * | ||
459 | 4 | * This program is free software: you can redistribute it and/or modify | ||
460 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
461 | 6 | * published by the Free Software Foundation. | ||
462 | 7 | * | ||
463 | 8 | * This program is distributed in the hope that it will be useful, | ||
464 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
465 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
466 | 11 | * GNU General Public License for more details. | ||
467 | 12 | * | ||
468 | 13 | * You should have received a copy of the GNU General Public License | ||
469 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
470 | 15 | * | ||
471 | 16 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
472 | 17 | */ | ||
473 | 18 | |||
474 | 19 | #include "ShortcutController.h" | ||
475 | 20 | |||
476 | 21 | #include "UBusMessages.h" | ||
477 | 22 | #include "ubus-server.h" | ||
478 | 23 | #include "WindowManager.h" | ||
479 | 24 | |||
480 | 25 | namespace unity | ||
481 | 26 | { | ||
482 | 27 | namespace shortcut | ||
483 | 28 | { | ||
484 | 29 | namespace | ||
485 | 30 | { | ||
486 | 31 | const unsigned int SUPER_TAP_DURATION = 650; | ||
487 | 32 | } // anonymouse namespace; | ||
488 | 33 | |||
489 | 34 | Controller::Controller(std::list<AbstractHint*>& hints) | ||
490 | 35 | : view_window_(0) | ||
491 | 36 | , visible_(false) | ||
492 | 37 | , show_timer_(0) | ||
493 | 38 | , fade_in_animator_(new Animator(100)) | ||
494 | 39 | , fade_out_animator_(new Animator(100)) | ||
495 | 40 | |||
496 | 41 | { | ||
497 | 42 | bg_color_ = nux::Color(0.0, 0.0, 0.0, 0.5); | ||
498 | 43 | |||
499 | 44 | UBusServer *ubus = ubus_server_get_default(); | ||
500 | 45 | bg_update_handle_ = ubus_server_register_interest(ubus, UBUS_BACKGROUND_COLOR_CHANGED, | ||
501 | 46 | (UBusCallback)&Controller::OnBackgroundUpdate, | ||
502 | 47 | this); | ||
503 | 48 | |||
504 | 49 | model_.reset(new Model(hints)); | ||
505 | 50 | |||
506 | 51 | model_->Fill(); | ||
507 | 52 | ConstructView(); | ||
508 | 53 | |||
509 | 54 | fade_in_animator_->animation_updated.connect(sigc::mem_fun(this, &Controller::OnFadeInUpdated)); | ||
510 | 55 | fade_in_animator_->animation_ended.connect(sigc::mem_fun(this, &Controller::OnFadeInEnded)); | ||
511 | 56 | fade_out_animator_->animation_updated.connect(sigc::mem_fun(this, &Controller::OnFadeOutUpdated)); | ||
512 | 57 | fade_out_animator_->animation_ended.connect(sigc::mem_fun(this, &Controller::OnFadeOutEnded)); | ||
513 | 58 | } | ||
514 | 59 | |||
515 | 60 | Controller::~Controller() | ||
516 | 61 | { | ||
517 | 62 | ubus_server_unregister_interest(ubus_server_get_default(), bg_update_handle_); | ||
518 | 63 | |||
519 | 64 | if (fade_in_animator_) | ||
520 | 65 | delete fade_in_animator_; | ||
521 | 66 | |||
522 | 67 | if (fade_out_animator_) | ||
523 | 68 | delete fade_out_animator_; | ||
524 | 69 | |||
525 | 70 | if (view_window_) | ||
526 | 71 | view_window_->UnReference(); | ||
527 | 72 | |||
528 | 73 | view_.Release(); | ||
529 | 74 | } | ||
530 | 75 | |||
531 | 76 | |||
532 | 77 | void Controller::OnFadeInUpdated(double opacity) | ||
533 | 78 | { | ||
534 | 79 | view_window_->SetOpacity(opacity); | ||
535 | 80 | } | ||
536 | 81 | |||
537 | 82 | void Controller::OnFadeInEnded() | ||
538 | 83 | { | ||
539 | 84 | view_window_->SetOpacity(1.0); | ||
540 | 85 | } | ||
541 | 86 | |||
542 | 87 | void Controller::OnFadeOutUpdated(double progress) | ||
543 | 88 | { | ||
544 | 89 | double opacity = CLAMP(1.0f - progress, 0.0f, 1.0f); | ||
545 | 90 | view_window_->SetOpacity(opacity); | ||
546 | 91 | } | ||
547 | 92 | |||
548 | 93 | void Controller::OnFadeOutEnded() | ||
549 | 94 | { | ||
550 | 95 | view_window_->SetOpacity(0.0); | ||
551 | 96 | } | ||
552 | 97 | |||
553 | 98 | |||
554 | 99 | void Controller::OnBackgroundUpdate(GVariant* data, Controller* self) | ||
555 | 100 | { | ||
556 | 101 | gdouble red, green, blue, alpha; | ||
557 | 102 | g_variant_get(data, "(dddd)", &red, &green, &blue, &alpha); | ||
558 | 103 | self->bg_color_ = nux::Color(red, green, blue, alpha); | ||
559 | 104 | |||
560 | 105 | if (self->view_) | ||
561 | 106 | self->view_->background_color = self->bg_color_; | ||
562 | 107 | } | ||
563 | 108 | |||
564 | 109 | void Controller::Show() | ||
565 | 110 | { | ||
566 | 111 | if (show_timer_) | ||
567 | 112 | g_source_remove (show_timer_); | ||
568 | 113 | show_timer_ = g_timeout_add(SUPER_TAP_DURATION, &Controller::OnShowTimer, this); | ||
569 | 114 | |||
570 | 115 | model_->Fill(); | ||
571 | 116 | visible_ = true; | ||
572 | 117 | } | ||
573 | 118 | |||
574 | 119 | gboolean Controller::OnShowTimer(gpointer data) | ||
575 | 120 | { | ||
576 | 121 | Controller* self = static_cast<Controller*>(data); | ||
577 | 122 | |||
578 | 123 | ubus_server_send_message(ubus_server_get_default(), | ||
579 | 124 | UBUS_PLACE_VIEW_CLOSE_REQUEST, | ||
580 | 125 | NULL); | ||
581 | 126 | |||
582 | 127 | if (self->visible_) | ||
583 | 128 | { | ||
584 | 129 | self->view_->SetupBackground(true); | ||
585 | 130 | self->fade_out_animator_->Stop(); | ||
586 | 131 | self->fade_in_animator_->Start(self->view_window_->GetOpacity()); | ||
587 | 132 | } | ||
588 | 133 | |||
589 | 134 | self->show_timer_ = 0; | ||
590 | 135 | return FALSE; | ||
591 | 136 | } | ||
592 | 137 | |||
593 | 138 | void Controller::ConstructView() | ||
594 | 139 | { | ||
595 | 140 | view_ = View::Ptr(new View()); | ||
596 | 141 | view_->SetModel(model_); | ||
597 | 142 | view_->background_color = bg_color_; | ||
598 | 143 | |||
599 | 144 | if (!view_window_) | ||
600 | 145 | { | ||
601 | 146 | main_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); | ||
602 | 147 | main_layout_->SetVerticalExternalMargin(0); | ||
603 | 148 | main_layout_->SetHorizontalExternalMargin(0); | ||
604 | 149 | |||
605 | 150 | view_window_ = new nux::BaseWindow("ShortcutHint"); | ||
606 | 151 | view_window_->SinkReference(); | ||
607 | 152 | view_window_->SetLayout(main_layout_); | ||
608 | 153 | view_window_->SetBackgroundColor(nux::Color(0x00000000)); | ||
609 | 154 | } | ||
610 | 155 | |||
611 | 156 | main_layout_->AddView(view_.GetPointer(), 1); | ||
612 | 157 | |||
613 | 158 | view_->SetupBackground(false); | ||
614 | 159 | view_window_->SetOpacity(0.0); | ||
615 | 160 | view_window_->ShowWindow(true); | ||
616 | 161 | } | ||
617 | 162 | |||
618 | 163 | void Controller::SetWorkspace(nux::Geometry const& geo) | ||
619 | 164 | { | ||
620 | 165 | workarea_ = geo; | ||
621 | 166 | view_window_->SetGeometry(workarea_); | ||
622 | 167 | } | ||
623 | 168 | |||
624 | 169 | void Controller::Hide() | ||
625 | 170 | { | ||
626 | 171 | if (!visible_) | ||
627 | 172 | return; | ||
628 | 173 | |||
629 | 174 | visible_ = false; | ||
630 | 175 | |||
631 | 176 | if (view_window_) | ||
632 | 177 | { | ||
633 | 178 | view_->SetupBackground(false); | ||
634 | 179 | fade_in_animator_->Stop(); | ||
635 | 180 | fade_out_animator_->Start(1.0 - view_window_->GetOpacity()); | ||
636 | 181 | } | ||
637 | 182 | |||
638 | 183 | if (show_timer_) | ||
639 | 184 | g_source_remove(show_timer_); | ||
640 | 185 | show_timer_ = 0; | ||
641 | 186 | } | ||
642 | 187 | |||
643 | 188 | bool Controller::Visible() | ||
644 | 189 | { | ||
645 | 190 | return visible_; | ||
646 | 191 | } | ||
647 | 192 | |||
648 | 193 | } // namespace shortcut | ||
649 | 194 | } // namespace unity | ||
650 | 0 | 195 | ||
651 | === added file 'plugins/unityshell/src/ShortcutController.h' | |||
652 | --- plugins/unityshell/src/ShortcutController.h 1970-01-01 00:00:00 +0000 | |||
653 | +++ plugins/unityshell/src/ShortcutController.h 2012-01-13 15:39:27 +0000 | |||
654 | @@ -0,0 +1,87 @@ | |||
655 | 1 | /* | ||
656 | 2 | * Copyright (C) 2011 Canonical Ltd | ||
657 | 3 | * | ||
658 | 4 | * This program is free software: you can redistribute it and/or modify | ||
659 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
660 | 6 | * published by the Free Software Foundation. | ||
661 | 7 | * | ||
662 | 8 | * This program is distributed in the hope that it will be useful, | ||
663 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
664 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
665 | 11 | * GNU General Public License for more details. | ||
666 | 12 | * | ||
667 | 13 | * You should have received a copy of the GNU General Public License | ||
668 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
669 | 15 | * | ||
670 | 16 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
671 | 17 | */ | ||
672 | 18 | |||
673 | 19 | #ifndef UNITYSHELL_SHORTCUTCONTROLLER_H | ||
674 | 20 | #define UNITYSHELL_SHORTCUTCONTROLLER_H | ||
675 | 21 | |||
676 | 22 | #include <boost/shared_ptr.hpp> | ||
677 | 23 | |||
678 | 24 | #include <Nux/Nux.h> | ||
679 | 25 | #include <Nux/BaseWindow.h> | ||
680 | 26 | #include <Nux/HLayout.h> | ||
681 | 27 | #include <NuxCore/Color.h> | ||
682 | 28 | |||
683 | 29 | #include "Animator.h" | ||
684 | 30 | #include "ShortcutModel.h" | ||
685 | 31 | #include "ShortcutView.h" | ||
686 | 32 | |||
687 | 33 | namespace unity | ||
688 | 34 | { | ||
689 | 35 | namespace shortcut | ||
690 | 36 | { | ||
691 | 37 | |||
692 | 38 | class Controller | ||
693 | 39 | { | ||
694 | 40 | public: | ||
695 | 41 | typedef std::shared_ptr<Controller> Ptr; | ||
696 | 42 | |||
697 | 43 | // Ctor and dtor | ||
698 | 44 | Controller(std::list<AbstractHint*>& hints); | ||
699 | 45 | ~Controller(); | ||
700 | 46 | |||
701 | 47 | // Public Methods | ||
702 | 48 | void Show(); | ||
703 | 49 | void Hide(); | ||
704 | 50 | |||
705 | 51 | bool Visible(); | ||
706 | 52 | |||
707 | 53 | void SetWorkspace(nux::Geometry const& geo); | ||
708 | 54 | |||
709 | 55 | private: | ||
710 | 56 | // Private Methods | ||
711 | 57 | void ConstructView(); | ||
712 | 58 | static void OnBackgroundUpdate(GVariant* data, Controller* self); | ||
713 | 59 | void OnFadeInUpdated(double opacity); | ||
714 | 60 | void OnFadeInEnded(); | ||
715 | 61 | void OnFadeOutUpdated(double opacity); | ||
716 | 62 | void OnFadeOutEnded(); | ||
717 | 63 | |||
718 | 64 | static gboolean OnShowTimer(gpointer data); | ||
719 | 65 | |||
720 | 66 | // Private Members | ||
721 | 67 | View::Ptr view_; | ||
722 | 68 | Model::Ptr model_; | ||
723 | 69 | |||
724 | 70 | nux::Geometry workarea_; | ||
725 | 71 | nux::BaseWindow* view_window_; | ||
726 | 72 | nux::HLayout* main_layout_; | ||
727 | 73 | |||
728 | 74 | bool visible_; | ||
729 | 75 | nux::Color bg_color_; | ||
730 | 76 | guint show_timer_; | ||
731 | 77 | guint bg_update_handle_; | ||
732 | 78 | |||
733 | 79 | Animator* fade_in_animator_; | ||
734 | 80 | Animator* fade_out_animator_; | ||
735 | 81 | }; | ||
736 | 82 | |||
737 | 83 | } // namespace shortcut | ||
738 | 84 | } // namespace unity | ||
739 | 85 | |||
740 | 86 | #endif //UNITYSHELL_SHORTCUTHINTCONTROLLER_H | ||
741 | 87 | |||
742 | 0 | 88 | ||
743 | === added file 'plugins/unityshell/src/ShortcutHint.cpp' | |||
744 | --- plugins/unityshell/src/ShortcutHint.cpp 1970-01-01 00:00:00 +0000 | |||
745 | +++ plugins/unityshell/src/ShortcutHint.cpp 2012-01-13 15:39:27 +0000 | |||
746 | @@ -0,0 +1,137 @@ | |||
747 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
748 | 2 | /* | ||
749 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
750 | 4 | * | ||
751 | 5 | * This program is free software: you can redistribute it and/or modify | ||
752 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
753 | 7 | * published by the Free Software Foundation. | ||
754 | 8 | * | ||
755 | 9 | * This program is distributed in the hope that it will be useful, | ||
756 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
757 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
758 | 12 | * GNU General Public License for more details. | ||
759 | 13 | * | ||
760 | 14 | * You should have received a copy of the GNU General Public License | ||
761 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
762 | 16 | * | ||
763 | 17 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
764 | 18 | */ | ||
765 | 19 | |||
766 | 20 | #include "ShortcutHint.h" | ||
767 | 21 | |||
768 | 22 | #include <core/core.h> // Compiz... | ||
769 | 23 | #include <NuxCore/Logger.h> | ||
770 | 24 | |||
771 | 25 | #include "ShortcutHintPrivate.h" | ||
772 | 26 | |||
773 | 27 | namespace unity | ||
774 | 28 | { | ||
775 | 29 | namespace shortcut | ||
776 | 30 | { | ||
777 | 31 | namespace | ||
778 | 32 | { | ||
779 | 33 | nux::logging::Logger logger("unity.shortcut"); | ||
780 | 34 | } // anonymouse namespace | ||
781 | 35 | |||
782 | 36 | // Ctor | ||
783 | 37 | Hint::Hint(std::string const& category, | ||
784 | 38 | std::string const& prefix, | ||
785 | 39 | std::string const& postfix, | ||
786 | 40 | std::string const& description, | ||
787 | 41 | OptionType const type, | ||
788 | 42 | std::string const& arg1, | ||
789 | 43 | std::string const& arg2, | ||
790 | 44 | std::string const& arg3) | ||
791 | 45 | : AbstractHint(category, prefix, postfix, description, type, arg1, arg2, arg3) | ||
792 | 46 | { | ||
793 | 47 | } | ||
794 | 48 | |||
795 | 49 | // Dtor | ||
796 | 50 | Hint::~Hint() | ||
797 | 51 | { | ||
798 | 52 | } | ||
799 | 53 | |||
800 | 54 | /* | ||
801 | 55 | * Gets and fills the shortcut value. | ||
802 | 56 | * Returns true if everything was OK, returns false otherwise. | ||
803 | 57 | * Use member property Value to get it. | ||
804 | 58 | */ | ||
805 | 59 | bool Hint::Fill() | ||
806 | 60 | { | ||
807 | 61 | switch(type()) | ||
808 | 62 | { | ||
809 | 63 | case COMPIZ_MOUSE_OPTION: | ||
810 | 64 | { | ||
811 | 65 | // Arg1 = Plugin name | ||
812 | 66 | // Arg2 = key Option name | ||
813 | 67 | CompPlugin* p = CompPlugin::find(arg1().c_str()); | ||
814 | 68 | |||
815 | 69 | if (!p) | ||
816 | 70 | return false; | ||
817 | 71 | |||
818 | 72 | foreach (CompOption &opt, p->vTable->getOptions()) | ||
819 | 73 | { | ||
820 | 74 | if (opt.name() == arg2()) | ||
821 | 75 | { | ||
822 | 76 | std::string temp = impl::FixMouseShortcut(impl::FixShortcutFormat(opt.value().action().buttonToString())); | ||
823 | 77 | temp = impl::ProperCase(temp); | ||
824 | 78 | |||
825 | 79 | if (value() != temp) | ||
826 | 80 | { | ||
827 | 81 | value = temp; | ||
828 | 82 | shortkey = prefix() + value() + postfix(); | ||
829 | 83 | } | ||
830 | 84 | |||
831 | 85 | return true; | ||
832 | 86 | } | ||
833 | 87 | } | ||
834 | 88 | |||
835 | 89 | break; | ||
836 | 90 | } | ||
837 | 91 | break; | ||
838 | 92 | |||
839 | 93 | case COMPIZ_KEY_OPTION: | ||
840 | 94 | { | ||
841 | 95 | // Arg1 = Plugin name | ||
842 | 96 | // Arg2 = key Option name | ||
843 | 97 | CompPlugin* p = CompPlugin::find(arg1().c_str()); | ||
844 | 98 | |||
845 | 99 | if (!p) | ||
846 | 100 | return false; | ||
847 | 101 | |||
848 | 102 | foreach (CompOption &opt, p->vTable->getOptions()) | ||
849 | 103 | { | ||
850 | 104 | if (opt.name() == arg2()) | ||
851 | 105 | { | ||
852 | 106 | std::string temp = impl::FixShortcutFormat(opt.value().action().keyToString()); | ||
853 | 107 | temp = impl::ProperCase(temp); | ||
854 | 108 | |||
855 | 109 | if (value() != temp) | ||
856 | 110 | { | ||
857 | 111 | value = temp; | ||
858 | 112 | shortkey = prefix() + value() + postfix(); | ||
859 | 113 | } | ||
860 | 114 | |||
861 | 115 | return true; | ||
862 | 116 | } | ||
863 | 117 | } | ||
864 | 118 | |||
865 | 119 | break; | ||
866 | 120 | } | ||
867 | 121 | case HARDCODED_OPTION: | ||
868 | 122 | if (value != arg1()) | ||
869 | 123 | { | ||
870 | 124 | value = arg1(); | ||
871 | 125 | shortkey = prefix() + value() + postfix(); | ||
872 | 126 | } | ||
873 | 127 | return true; | ||
874 | 128 | |||
875 | 129 | default: | ||
876 | 130 | LOG_WARNING(logger) << "Unable to find the option type" << type(); | ||
877 | 131 | } | ||
878 | 132 | |||
879 | 133 | return false; | ||
880 | 134 | } | ||
881 | 135 | |||
882 | 136 | } // namespace shortcut | ||
883 | 137 | } // namespace unity | ||
884 | 0 | 138 | ||
885 | === added file 'plugins/unityshell/src/ShortcutHint.h' | |||
886 | --- plugins/unityshell/src/ShortcutHint.h 1970-01-01 00:00:00 +0000 | |||
887 | +++ plugins/unityshell/src/ShortcutHint.h 2012-01-13 15:39:27 +0000 | |||
888 | @@ -0,0 +1,53 @@ | |||
889 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
890 | 2 | /* | ||
891 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
892 | 4 | * | ||
893 | 5 | * This program is free software: you can redistribute it and/or modify | ||
894 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
895 | 7 | * published by the Free Software Foundation. | ||
896 | 8 | * | ||
897 | 9 | * This program is distributed in the hope that it will be useful, | ||
898 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
899 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
900 | 12 | * GNU General Public License for more details. | ||
901 | 13 | * | ||
902 | 14 | * You should have received a copy of the GNU General Public License | ||
903 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
904 | 16 | * | ||
905 | 17 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
906 | 18 | */ | ||
907 | 19 | |||
908 | 20 | #ifndef UNITYSHELL_SHORTCUTHINT_H | ||
909 | 21 | #define UNITYSHELL_SHORTCUTHINT_H | ||
910 | 22 | |||
911 | 23 | #include "AbstractShortcutHint.h" | ||
912 | 24 | |||
913 | 25 | namespace unity | ||
914 | 26 | { | ||
915 | 27 | namespace shortcut | ||
916 | 28 | { | ||
917 | 29 | |||
918 | 30 | class Hint : public AbstractHint | ||
919 | 31 | { | ||
920 | 32 | public: | ||
921 | 33 | // Ctor | ||
922 | 34 | Hint(std::string const& category, | ||
923 | 35 | std::string const& prefix, | ||
924 | 36 | std::string const& postfix, | ||
925 | 37 | std::string const& description, | ||
926 | 38 | OptionType const type, | ||
927 | 39 | std::string const& arg1, | ||
928 | 40 | std::string const& arg2 = "", | ||
929 | 41 | std::string const& arg3 = ""); | ||
930 | 42 | |||
931 | 43 | // Dtor | ||
932 | 44 | ~Hint(); | ||
933 | 45 | |||
934 | 46 | // Public methods | ||
935 | 47 | bool Fill(); | ||
936 | 48 | }; | ||
937 | 49 | |||
938 | 50 | } // namespace shortcut | ||
939 | 51 | } // namespace unity | ||
940 | 52 | |||
941 | 53 | #endif // UNITYSHELL_SHORTCUTHINT_H | ||
942 | 0 | 54 | ||
943 | === added file 'plugins/unityshell/src/ShortcutHintPrivate.cpp' | |||
944 | --- plugins/unityshell/src/ShortcutHintPrivate.cpp 1970-01-01 00:00:00 +0000 | |||
945 | +++ plugins/unityshell/src/ShortcutHintPrivate.cpp 2012-01-13 15:39:27 +0000 | |||
946 | @@ -0,0 +1,79 @@ | |||
947 | 1 | /* | ||
948 | 2 | * Copyright (C) 2011 Canonical Ltd | ||
949 | 3 | * | ||
950 | 4 | * This program is free software: you can redistribute it and/or modify | ||
951 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
952 | 6 | * published by the Free Software Foundation. | ||
953 | 7 | * | ||
954 | 8 | * This program is distributed in the hope that it will be useful, | ||
955 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
956 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
957 | 11 | * GNU General Public License for more details. | ||
958 | 12 | * | ||
959 | 13 | * You should have received a copy of the GNU General Public License | ||
960 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
961 | 15 | * | ||
962 | 16 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
963 | 17 | */ | ||
964 | 18 | |||
965 | 19 | #include "ShortcutHintPrivate.h" | ||
966 | 20 | |||
967 | 21 | #include <boost/algorithm/string/replace.hpp> | ||
968 | 22 | |||
969 | 23 | namespace unity | ||
970 | 24 | { | ||
971 | 25 | namespace shortcut | ||
972 | 26 | { | ||
973 | 27 | namespace impl | ||
974 | 28 | { | ||
975 | 29 | |||
976 | 30 | std::string FixShortcutFormat(std::string const& scut) | ||
977 | 31 | { | ||
978 | 32 | std::string ret(scut.begin(), scut.end() - 1); | ||
979 | 33 | |||
980 | 34 | boost::replace_all(ret, "<", ""); | ||
981 | 35 | boost::replace_all(ret, ">", " + "); | ||
982 | 36 | |||
983 | 37 | if (scut[scut.size()-1] != '>') | ||
984 | 38 | ret += scut[scut.size()-1]; | ||
985 | 39 | |||
986 | 40 | return ret; | ||
987 | 41 | } | ||
988 | 42 | |||
989 | 43 | std::string FixMouseShortcut(std::string const& scut) | ||
990 | 44 | { | ||
991 | 45 | std::string ret(scut); | ||
992 | 46 | |||
993 | 47 | boost::replace_all(ret, "Button1", "Left Mouse"); | ||
994 | 48 | boost::replace_all(ret, "Button2", "Middle Mouse"); | ||
995 | 49 | boost::replace_all(ret, "Button3", "Right Mouse"); | ||
996 | 50 | |||
997 | 51 | return ret; | ||
998 | 52 | } | ||
999 | 53 | |||
1000 | 54 | std::string ProperCase(std::string const& str) | ||
1001 | 55 | { | ||
1002 | 56 | std::string ret = str; | ||
1003 | 57 | |||
1004 | 58 | bool cap_next = true; | ||
1005 | 59 | |||
1006 | 60 | for (unsigned int i = 0; i < ret.length(); ++i) | ||
1007 | 61 | { | ||
1008 | 62 | if (cap_next and isalpha(ret[i])) | ||
1009 | 63 | { | ||
1010 | 64 | ret[i]=toupper(ret[i]); | ||
1011 | 65 | cap_next = false; | ||
1012 | 66 | } | ||
1013 | 67 | else | ||
1014 | 68 | { | ||
1015 | 69 | cap_next = ispunct(ret[i]) || isspace(ret[i]); | ||
1016 | 70 | } | ||
1017 | 71 | } | ||
1018 | 72 | |||
1019 | 73 | return ret; | ||
1020 | 74 | } | ||
1021 | 75 | |||
1022 | 76 | } // namespace impl | ||
1023 | 77 | } // namespace shortcut | ||
1024 | 78 | } // namespace unity | ||
1025 | 79 | |||
1026 | 0 | 80 | ||
1027 | === added file 'plugins/unityshell/src/ShortcutHintPrivate.h' | |||
1028 | --- plugins/unityshell/src/ShortcutHintPrivate.h 1970-01-01 00:00:00 +0000 | |||
1029 | +++ plugins/unityshell/src/ShortcutHintPrivate.h 2012-01-13 15:39:27 +0000 | |||
1030 | @@ -0,0 +1,39 @@ | |||
1031 | 1 | /* | ||
1032 | 2 | * Copyright (C) 2011 Canonical Ltd | ||
1033 | 3 | * | ||
1034 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1035 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1036 | 6 | * published by the Free Software Foundation. | ||
1037 | 7 | * | ||
1038 | 8 | * This program is distributed in the hope that it will be useful, | ||
1039 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1040 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1041 | 11 | * GNU General Public License for more details. | ||
1042 | 12 | * | ||
1043 | 13 | * You should have received a copy of the GNU General Public License | ||
1044 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1045 | 15 | * | ||
1046 | 16 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
1047 | 17 | */ | ||
1048 | 18 | |||
1049 | 19 | #ifndef UNITYSHELL_SHORTCUT_HINT_PRIVATE_H | ||
1050 | 20 | #define UNITYSHELL_SHORTCUT_HINT_PRIVATE_H | ||
1051 | 21 | |||
1052 | 22 | #include <string> | ||
1053 | 23 | |||
1054 | 24 | namespace unity | ||
1055 | 25 | { | ||
1056 | 26 | namespace shortcut | ||
1057 | 27 | { | ||
1058 | 28 | namespace impl | ||
1059 | 29 | { | ||
1060 | 30 | |||
1061 | 31 | std::string FixShortcutFormat(std::string const& scut); | ||
1062 | 32 | std::string FixMouseShortcut(std::string const& scut); | ||
1063 | 33 | std::string ProperCase(std::string const& str); | ||
1064 | 34 | |||
1065 | 35 | } // namespace impl | ||
1066 | 36 | } // namespace shortcut | ||
1067 | 37 | } // namespace unity | ||
1068 | 38 | |||
1069 | 39 | #endif // UNITYSHELL_SHORTCUT_HINT_PRIVATE_H | ||
1070 | 0 | 40 | ||
1071 | === added file 'plugins/unityshell/src/ShortcutModel.cpp' | |||
1072 | --- plugins/unityshell/src/ShortcutModel.cpp 1970-01-01 00:00:00 +0000 | |||
1073 | +++ plugins/unityshell/src/ShortcutModel.cpp 2012-01-13 15:39:27 +0000 | |||
1074 | @@ -0,0 +1,60 @@ | |||
1075 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
1076 | 2 | /* | ||
1077 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
1078 | 4 | * | ||
1079 | 5 | * This program is free software: you can redistribute it and/or modify | ||
1080 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
1081 | 7 | * published by the Free Software Foundation. | ||
1082 | 8 | * | ||
1083 | 9 | * This program is distributed in the hope that it will be useful, | ||
1084 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1085 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1086 | 12 | * GNU General Public License for more details. | ||
1087 | 13 | * | ||
1088 | 14 | * You should have received a copy of the GNU General Public License | ||
1089 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1090 | 16 | * | ||
1091 | 17 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
1092 | 18 | */ | ||
1093 | 19 | |||
1094 | 20 | #include "ShortcutModel.h" | ||
1095 | 21 | |||
1096 | 22 | namespace unity | ||
1097 | 23 | { | ||
1098 | 24 | namespace shortcut | ||
1099 | 25 | { | ||
1100 | 26 | |||
1101 | 27 | // Ctor | ||
1102 | 28 | Model::Model(std::list<AbstractHint*>& hints) | ||
1103 | 29 | { | ||
1104 | 30 | for (auto hint : hints) | ||
1105 | 31 | AddHint(hint); | ||
1106 | 32 | } | ||
1107 | 33 | |||
1108 | 34 | // Dtor | ||
1109 | 35 | Model::~Model() | ||
1110 | 36 | { | ||
1111 | 37 | } | ||
1112 | 38 | |||
1113 | 39 | |||
1114 | 40 | void Model::AddHint(AbstractHint* hint) | ||
1115 | 41 | { | ||
1116 | 42 | if (!hint) | ||
1117 | 43 | return; | ||
1118 | 44 | |||
1119 | 45 | if (hints_.find(hint->category()) == hints_.end()) | ||
1120 | 46 | categories_.push_back(hint->category()); | ||
1121 | 47 | |||
1122 | 48 | hints_[hint->category()].push_back(hint); | ||
1123 | 49 | } | ||
1124 | 50 | |||
1125 | 51 | |||
1126 | 52 | void Model::Fill() | ||
1127 | 53 | { | ||
1128 | 54 | for (auto category : categories_) | ||
1129 | 55 | for (auto item : hints_[category]) | ||
1130 | 56 | item->Fill(); | ||
1131 | 57 | } | ||
1132 | 58 | |||
1133 | 59 | } // namespace shortcut | ||
1134 | 60 | } // namespace unity | ||
1135 | 0 | 61 | ||
1136 | === added file 'plugins/unityshell/src/ShortcutModel.h' | |||
1137 | --- plugins/unityshell/src/ShortcutModel.h 1970-01-01 00:00:00 +0000 | |||
1138 | +++ plugins/unityshell/src/ShortcutModel.h 2012-01-13 15:39:27 +0000 | |||
1139 | @@ -0,0 +1,64 @@ | |||
1140 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
1141 | 2 | /* | ||
1142 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
1143 | 4 | * | ||
1144 | 5 | * This program is free software: you can redistribute it and/or modify | ||
1145 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
1146 | 7 | * published by the Free Software Foundation. | ||
1147 | 8 | * | ||
1148 | 9 | * This program is distributed in the hope that it will be useful, | ||
1149 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1150 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1151 | 12 | * GNU General Public License for more details. | ||
1152 | 13 | * | ||
1153 | 14 | * You should have received a copy of the GNU General Public License | ||
1154 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1155 | 16 | * | ||
1156 | 17 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
1157 | 18 | */ | ||
1158 | 19 | |||
1159 | 20 | #ifndef UNITYSHELL_SHORTCUSMODEL_H | ||
1160 | 21 | #define UNITYSHELL_SHORTCUSMODEL_H | ||
1161 | 22 | |||
1162 | 23 | #include <boost/noncopyable.hpp> | ||
1163 | 24 | #include <map> | ||
1164 | 25 | #include <memory> | ||
1165 | 26 | #include <list> | ||
1166 | 27 | #include <string> | ||
1167 | 28 | #include <vector> | ||
1168 | 29 | |||
1169 | 30 | #include "AbstractShortcutHint.h" | ||
1170 | 31 | |||
1171 | 32 | namespace unity | ||
1172 | 33 | { | ||
1173 | 34 | namespace shortcut | ||
1174 | 35 | { | ||
1175 | 36 | |||
1176 | 37 | class Model : boost::noncopyable | ||
1177 | 38 | { | ||
1178 | 39 | public: | ||
1179 | 40 | typedef std::shared_ptr<Model> Ptr; | ||
1180 | 41 | |||
1181 | 42 | // Ctor and dtor | ||
1182 | 43 | Model(std::list<AbstractHint*>& hints); | ||
1183 | 44 | ~Model(); | ||
1184 | 45 | |||
1185 | 46 | // Accessors | ||
1186 | 47 | std::vector<std::string>& categories() { return categories_; } | ||
1187 | 48 | std::map<std::string, std::list<AbstractHint*>>& hints() { return hints_; } | ||
1188 | 49 | |||
1189 | 50 | void Fill(); | ||
1190 | 51 | |||
1191 | 52 | private: | ||
1192 | 53 | // Private functions | ||
1193 | 54 | void AddHint(AbstractHint* hint); | ||
1194 | 55 | |||
1195 | 56 | // Private members | ||
1196 | 57 | std::vector<std::string> categories_; | ||
1197 | 58 | std::map<std::string, std::list<AbstractHint*>> hints_; | ||
1198 | 59 | }; | ||
1199 | 60 | |||
1200 | 61 | } // shortcut | ||
1201 | 62 | } // unity | ||
1202 | 63 | |||
1203 | 64 | #endif // UNITYSHELL_SHORTCUTS_H | ||
1204 | 0 | 65 | ||
1205 | === added file 'plugins/unityshell/src/ShortcutView.cpp' | |||
1206 | --- plugins/unityshell/src/ShortcutView.cpp 1970-01-01 00:00:00 +0000 | |||
1207 | +++ plugins/unityshell/src/ShortcutView.cpp 2012-01-13 15:39:27 +0000 | |||
1208 | @@ -0,0 +1,424 @@ | |||
1209 | 1 | /* | ||
1210 | 2 | * Copyright (C) 2011 Canonical Ltd | ||
1211 | 3 | * | ||
1212 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1213 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1214 | 6 | * published by the Free Software Foundation. | ||
1215 | 7 | * | ||
1216 | 8 | * This program is distributed in the hope that it will be useful, | ||
1217 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1218 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1219 | 11 | * GNU General Public License for more details. | ||
1220 | 12 | * | ||
1221 | 13 | * You should have received a copy of the GNU General Public License | ||
1222 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1223 | 15 | * | ||
1224 | 16 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
1225 | 17 | * Jay Taoko <jay.taoko@canonical.com> | ||
1226 | 18 | */ | ||
1227 | 19 | |||
1228 | 20 | #include "ShortcutView.h" | ||
1229 | 21 | |||
1230 | 22 | #include <glib/gi18n-lib.h> | ||
1231 | 23 | #include <boost/algorithm/string.hpp> | ||
1232 | 24 | #include <UnityCore/GLibWrapper.h> | ||
1233 | 25 | |||
1234 | 26 | #include "LineSeparator.h" | ||
1235 | 27 | #include "StaticCairoText.h" | ||
1236 | 28 | |||
1237 | 29 | namespace unity | ||
1238 | 30 | { | ||
1239 | 31 | namespace shortcut | ||
1240 | 32 | { | ||
1241 | 33 | namespace | ||
1242 | 34 | { | ||
1243 | 35 | int SECTION_NAME_FONT_SIZE = 17/1.33; | ||
1244 | 36 | int SHORTKEY_ENTRY_FONT_SIZE = 13/1.33; | ||
1245 | 37 | int INTER_SPACE_SHORTKEY_DESCRIPTION = 10; | ||
1246 | 38 | int SHORTKEY_COLUMN_WIDTH = 150; | ||
1247 | 39 | int DESCRIPTION_COLUMN_WIDTH = 265; | ||
1248 | 40 | int LINE_SPACING = 5; | ||
1249 | 41 | } // namespace anonymouse | ||
1250 | 42 | |||
1251 | 43 | NUX_IMPLEMENT_OBJECT_TYPE(View); | ||
1252 | 44 | |||
1253 | 45 | View::View(NUX_FILE_LINE_DECL) | ||
1254 | 46 | : nux::View(NUX_FILE_LINE_PARAM) | ||
1255 | 47 | { | ||
1256 | 48 | layout_ = new nux::VLayout(); | ||
1257 | 49 | layout_->SetPadding(50, 38); | ||
1258 | 50 | layout_->SetSpaceBetweenChildren(20); | ||
1259 | 51 | SetLayout(layout_); | ||
1260 | 52 | |||
1261 | 53 | background_top_ = nux::CreateTexture2DFromFile(PKGDATADIR"/switcher_top.png", -1, true); | ||
1262 | 54 | background_left_ = nux::CreateTexture2DFromFile(PKGDATADIR"/switcher_left.png", -1, true); | ||
1263 | 55 | background_corner_ = nux::CreateTexture2DFromFile(PKGDATADIR"/switcher_corner.png", -1, true); | ||
1264 | 56 | rounding_texture_ = nux::CreateTexture2DFromFile(PKGDATADIR"/switcher_round_rect.png", -1, true); | ||
1265 | 57 | |||
1266 | 58 | std::string header = "<b>"; | ||
1267 | 59 | header += _("Keyboard Shortcuts"); | ||
1268 | 60 | header += "</b>"; | ||
1269 | 61 | |||
1270 | 62 | nux::StaticText* header_view = new nux::StaticText(header.c_str(), NUX_TRACKER_LOCATION); | ||
1271 | 63 | header_view->SetTextPointSize(20/1.33); | ||
1272 | 64 | header_view->SetFontName("Ubuntu"); | ||
1273 | 65 | layout_->AddView(header_view, 1 , nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); | ||
1274 | 66 | |||
1275 | 67 | layout_->AddView(new HSeparator(), 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); | ||
1276 | 68 | |||
1277 | 69 | columns_layout_ = new nux::HLayout(); | ||
1278 | 70 | columns_layout_->SetSpaceBetweenChildren(30); | ||
1279 | 71 | layout_->AddLayout(columns_layout_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); | ||
1280 | 72 | |||
1281 | 73 | // Column 1... | ||
1282 | 74 | columns_.push_back(new nux::VLayout()); | ||
1283 | 75 | columns_layout_->AddLayout(columns_[0], 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); | ||
1284 | 76 | |||
1285 | 77 | // Column 2... | ||
1286 | 78 | columns_.push_back(new nux::VLayout()); | ||
1287 | 79 | columns_layout_->AddLayout(columns_[1], 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); | ||
1288 | 80 | |||
1289 | 81 | bg_effect_helper_.owner = this; | ||
1290 | 82 | } | ||
1291 | 83 | |||
1292 | 84 | View::~View() | ||
1293 | 85 | { | ||
1294 | 86 | if (background_top_ != NULL) | ||
1295 | 87 | background_top_->UnReference(); | ||
1296 | 88 | |||
1297 | 89 | if (background_left_ != NULL) | ||
1298 | 90 | background_left_->UnReference(); | ||
1299 | 91 | |||
1300 | 92 | if (background_corner_ != NULL) | ||
1301 | 93 | background_corner_->UnReference(); | ||
1302 | 94 | |||
1303 | 95 | if (rounding_texture_ != NULL) | ||
1304 | 96 | rounding_texture_->UnReference(); | ||
1305 | 97 | } | ||
1306 | 98 | |||
1307 | 99 | void View::SetModel(Model::Ptr model) | ||
1308 | 100 | { | ||
1309 | 101 | model_ = model; | ||
1310 | 102 | |||
1311 | 103 | // Fills the columns... | ||
1312 | 104 | RenderColumns(); | ||
1313 | 105 | } | ||
1314 | 106 | |||
1315 | 107 | Model::Ptr View::GetModel() | ||
1316 | 108 | { | ||
1317 | 109 | return model_; | ||
1318 | 110 | } | ||
1319 | 111 | |||
1320 | 112 | void View::SetupBackground(bool enabled) | ||
1321 | 113 | { | ||
1322 | 114 | bg_effect_helper_.enabled = enabled; | ||
1323 | 115 | } | ||
1324 | 116 | |||
1325 | 117 | nux::LinearLayout* View::CreateSectionLayout(const char* section_name) | ||
1326 | 118 | { | ||
1327 | 119 | nux::VLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION); | ||
1328 | 120 | |||
1329 | 121 | std::string name = "<b>"; | ||
1330 | 122 | name += std::string(section_name); | ||
1331 | 123 | name += "</b>"; | ||
1332 | 124 | |||
1333 | 125 | |||
1334 | 126 | nux::StaticText* section_name_view = new nux::StaticText(name.c_str(), NUX_TRACKER_LOCATION); | ||
1335 | 127 | section_name_view->SetTextPointSize(SECTION_NAME_FONT_SIZE); | ||
1336 | 128 | section_name_view->SetFontName("Ubuntu"); | ||
1337 | 129 | layout->AddView(new nux::SpaceLayout(10, 10, 10, 10), 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_MATCHCONTENT); | ||
1338 | 130 | layout->AddView(section_name_view, 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_MATCHCONTENT); | ||
1339 | 131 | layout->AddView(new nux::SpaceLayout(15, 15, 15, 15), 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_MATCHCONTENT); | ||
1340 | 132 | |||
1341 | 133 | return layout; | ||
1342 | 134 | } | ||
1343 | 135 | |||
1344 | 136 | nux::LinearLayout* View::CreateShortKeyEntryLayout(AbstractHint* hint) | ||
1345 | 137 | { | ||
1346 | 138 | nux::HLayout* layout = new nux::HLayout("EntryLayout", NUX_TRACKER_LOCATION); | ||
1347 | 139 | nux::HLayout* shortkey_layout = new nux::HLayout(NUX_TRACKER_LOCATION); | ||
1348 | 140 | nux::HLayout* description_layout = new nux::HLayout(NUX_TRACKER_LOCATION); | ||
1349 | 141 | |||
1350 | 142 | glib::String shortkey(g_markup_escape_text(hint->shortkey().c_str(), -1)); | ||
1351 | 143 | |||
1352 | 144 | std::string skey = "<b>"; | ||
1353 | 145 | skey += shortkey.Str(); | ||
1354 | 146 | skey += "</b>"; | ||
1355 | 147 | |||
1356 | 148 | nux::StaticText* shortkey_view = new nux::StaticText(skey, NUX_TRACKER_LOCATION); | ||
1357 | 149 | shortkey_view->SetTextAlignment(nux::StaticText::ALIGN_LEFT); | ||
1358 | 150 | shortkey_view->SetFontName("Ubuntu"); | ||
1359 | 151 | shortkey_view->SetTextPointSize(SHORTKEY_ENTRY_FONT_SIZE); | ||
1360 | 152 | shortkey_view->SetMinimumWidth(SHORTKEY_COLUMN_WIDTH); | ||
1361 | 153 | shortkey_view->SetMaximumWidth(SHORTKEY_COLUMN_WIDTH); | ||
1362 | 154 | |||
1363 | 155 | glib::String es_desc(g_markup_escape_text(hint->description().c_str(), -1)); | ||
1364 | 156 | |||
1365 | 157 | nux::StaticText* description_view = new nux::StaticText(es_desc.Value(), NUX_TRACKER_LOCATION); | ||
1366 | 158 | description_view->SetTextAlignment(nux::StaticText::ALIGN_LEFT); | ||
1367 | 159 | shortkey_view->SetFontName("Ubuntu"); | ||
1368 | 160 | description_view->SetTextPointSize(SHORTKEY_ENTRY_FONT_SIZE); | ||
1369 | 161 | description_view->SetMinimumWidth(DESCRIPTION_COLUMN_WIDTH); | ||
1370 | 162 | description_view->SetMaximumWidth(DESCRIPTION_COLUMN_WIDTH); | ||
1371 | 163 | |||
1372 | 164 | shortkey_layout->AddView(shortkey_view, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT); | ||
1373 | 165 | shortkey_layout->SetContentDistribution(nux::MAJOR_POSITION_START); | ||
1374 | 166 | shortkey_layout->SetMinimumWidth(SHORTKEY_COLUMN_WIDTH); | ||
1375 | 167 | shortkey_layout->SetMaximumWidth(SHORTKEY_COLUMN_WIDTH); | ||
1376 | 168 | |||
1377 | 169 | description_layout->AddView(description_view, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT); | ||
1378 | 170 | description_layout->SetContentDistribution(nux::MAJOR_POSITION_START); | ||
1379 | 171 | description_layout->SetMinimumWidth(DESCRIPTION_COLUMN_WIDTH); | ||
1380 | 172 | description_layout->SetMaximumWidth(DESCRIPTION_COLUMN_WIDTH); | ||
1381 | 173 | |||
1382 | 174 | layout->AddLayout(shortkey_layout, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT); | ||
1383 | 175 | layout->AddLayout(description_layout, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT); | ||
1384 | 176 | layout->SetSpaceBetweenChildren(INTER_SPACE_SHORTKEY_DESCRIPTION); | ||
1385 | 177 | description_layout->SetContentDistribution(nux::MAJOR_POSITION_START); | ||
1386 | 178 | |||
1387 | 179 | auto on_shortkey_changed = [](std::string const& new_shortkey, nux::StaticText* view) { | ||
1388 | 180 | std::string skey = "<b>"; | ||
1389 | 181 | skey += new_shortkey; | ||
1390 | 182 | skey += "</b>"; | ||
1391 | 183 | |||
1392 | 184 | view->SetText(skey); | ||
1393 | 185 | }; | ||
1394 | 186 | |||
1395 | 187 | hint->shortkey.changed.connect(sigc::bind(sigc::slot<void, std::string const&, nux::StaticText*>(on_shortkey_changed), shortkey_view)); | ||
1396 | 188 | |||
1397 | 189 | return layout; | ||
1398 | 190 | } | ||
1399 | 191 | |||
1400 | 192 | nux::LinearLayout* View::CreateIntermediateLayout() | ||
1401 | 193 | { | ||
1402 | 194 | nux::VLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION); | ||
1403 | 195 | layout->SetSpaceBetweenChildren(LINE_SPACING); | ||
1404 | 196 | |||
1405 | 197 | return layout; | ||
1406 | 198 | } | ||
1407 | 199 | |||
1408 | 200 | void View::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) | ||
1409 | 201 | { | ||
1410 | 202 | return; | ||
1411 | 203 | } | ||
1412 | 204 | |||
1413 | 205 | void View::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) | ||
1414 | 206 | { | ||
1415 | 207 | nux::Geometry base = GetGeometry(); | ||
1416 | 208 | GfxContext.PushClippingRectangle(base); | ||
1417 | 209 | |||
1418 | 210 | // clear region | ||
1419 | 211 | gPainter.PaintBackground(GfxContext, base); | ||
1420 | 212 | |||
1421 | 213 | nux::Geometry background_geo; | ||
1422 | 214 | |||
1423 | 215 | background_geo.width = base.width; | ||
1424 | 216 | background_geo.height = base.height; | ||
1425 | 217 | background_geo.x = (base.width - background_geo.width)/2; | ||
1426 | 218 | background_geo.y = (base.height - background_geo.height)/2; | ||
1427 | 219 | |||
1428 | 220 | // magic constant comes from texture contents (distance to cleared area) | ||
1429 | 221 | const int internal_offset = 20; | ||
1430 | 222 | nux::Geometry internal_clip(background_geo.x + internal_offset, | ||
1431 | 223 | background_geo.y + internal_offset, | ||
1432 | 224 | background_geo.width - internal_offset * 2, | ||
1433 | 225 | background_geo.height - internal_offset * 2); | ||
1434 | 226 | GfxContext.PushClippingRectangle(internal_clip); | ||
1435 | 227 | |||
1436 | 228 | nux::Geometry geo_absolute = GetAbsoluteGeometry(); | ||
1437 | 229 | if (BackgroundEffectHelper::blur_type != BLUR_NONE) | ||
1438 | 230 | { | ||
1439 | 231 | nux::Geometry blur_geo(geo_absolute.x, geo_absolute.y, base.width, base.height); | ||
1440 | 232 | auto blur_texture = bg_effect_helper_.GetBlurRegion(blur_geo); | ||
1441 | 233 | |||
1442 | 234 | if (blur_texture.IsValid()) | ||
1443 | 235 | { | ||
1444 | 236 | nux::TexCoordXForm texxform_blur_bg; | ||
1445 | 237 | texxform_blur_bg.flip_v_coord = true; | ||
1446 | 238 | texxform_blur_bg.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); | ||
1447 | 239 | texxform_blur_bg.uoffset = ((float) base.x) / geo_absolute.width; | ||
1448 | 240 | texxform_blur_bg.voffset = ((float) base.y) / geo_absolute.height; | ||
1449 | 241 | |||
1450 | 242 | nux::ROPConfig rop; | ||
1451 | 243 | rop.Blend = false; | ||
1452 | 244 | rop.SrcBlend = GL_ONE; | ||
1453 | 245 | rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA; | ||
1454 | 246 | |||
1455 | 247 | gPainter.PushDrawTextureLayer(GfxContext, base, | ||
1456 | 248 | blur_texture, | ||
1457 | 249 | texxform_blur_bg, | ||
1458 | 250 | nux::color::White, | ||
1459 | 251 | true, | ||
1460 | 252 | rop); | ||
1461 | 253 | } | ||
1462 | 254 | } | ||
1463 | 255 | |||
1464 | 256 | nux::ROPConfig rop; | ||
1465 | 257 | rop.Blend = true; | ||
1466 | 258 | rop.SrcBlend = GL_ONE; | ||
1467 | 259 | rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA; | ||
1468 | 260 | gPainter.PushDrawColorLayer(GfxContext, internal_clip, background_color, false, rop); | ||
1469 | 261 | |||
1470 | 262 | // Make round corners | ||
1471 | 263 | rop.Blend = true; | ||
1472 | 264 | rop.SrcBlend = GL_ZERO; | ||
1473 | 265 | rop.DstBlend = GL_SRC_ALPHA; | ||
1474 | 266 | gPainter.PaintShapeCornerROP(GfxContext, | ||
1475 | 267 | internal_clip, | ||
1476 | 268 | nux::color::White, | ||
1477 | 269 | nux::eSHAPE_CORNER_ROUND4, | ||
1478 | 270 | nux::eCornerTopLeft | nux::eCornerTopRight | | ||
1479 | 271 | nux::eCornerBottomLeft | nux::eCornerBottomRight, | ||
1480 | 272 | true, | ||
1481 | 273 | rop); | ||
1482 | 274 | |||
1483 | 275 | GfxContext.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER); | ||
1484 | 276 | |||
1485 | 277 | GfxContext.PopClippingRectangle(); | ||
1486 | 278 | GfxContext.PopClippingRectangle(); | ||
1487 | 279 | |||
1488 | 280 | DrawBackground(GfxContext, background_geo); | ||
1489 | 281 | |||
1490 | 282 | |||
1491 | 283 | layout_->ProcessDraw(GfxContext, force_draw); | ||
1492 | 284 | } | ||
1493 | 285 | |||
1494 | 286 | |||
1495 | 287 | void View::DrawBackground(nux::GraphicsEngine& GfxContext, nux::Geometry const& geo) | ||
1496 | 288 | { | ||
1497 | 289 | int border = 30; | ||
1498 | 290 | |||
1499 | 291 | GfxContext.GetRenderStates().SetBlend(TRUE, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | ||
1500 | 292 | |||
1501 | 293 | nux::TexCoordXForm texxform; | ||
1502 | 294 | texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); | ||
1503 | 295 | texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT); | ||
1504 | 296 | |||
1505 | 297 | // Draw TOP-LEFT CORNER | ||
1506 | 298 | texxform.u0 = 0; | ||
1507 | 299 | texxform.v0 = 0; | ||
1508 | 300 | texxform.u1 = border; | ||
1509 | 301 | texxform.v1 = border; | ||
1510 | 302 | GfxContext.QRP_1Tex(geo.x, geo.y, | ||
1511 | 303 | border, border, background_corner_->GetDeviceTexture(), texxform, nux::color::White); | ||
1512 | 304 | |||
1513 | 305 | // Draw TOP-RIGHT CORNER | ||
1514 | 306 | texxform.u0 = 0; | ||
1515 | 307 | texxform.v0 = 0; | ||
1516 | 308 | texxform.u1 = border; | ||
1517 | 309 | texxform.v1 = border; | ||
1518 | 310 | texxform.flip_u_coord = true; | ||
1519 | 311 | texxform.flip_v_coord = false; | ||
1520 | 312 | GfxContext.QRP_1Tex(geo.x + geo.width - border, geo.y, | ||
1521 | 313 | border, border, background_corner_->GetDeviceTexture(), texxform, nux::color::White); | ||
1522 | 314 | |||
1523 | 315 | // Draw BOTTOM-LEFT CORNER | ||
1524 | 316 | texxform.u0 = 0; | ||
1525 | 317 | texxform.v0 = 0; | ||
1526 | 318 | texxform.u1 = border; | ||
1527 | 319 | texxform.v1 = border; | ||
1528 | 320 | texxform.flip_u_coord = false; | ||
1529 | 321 | texxform.flip_v_coord = true; | ||
1530 | 322 | GfxContext.QRP_1Tex(geo.x, geo.y + geo.height - border, | ||
1531 | 323 | border, border, background_corner_->GetDeviceTexture(), texxform, nux::color::White); | ||
1532 | 324 | |||
1533 | 325 | // Draw BOTTOM-RIGHT CORNER | ||
1534 | 326 | texxform.u0 = 0; | ||
1535 | 327 | texxform.v0 = 0; | ||
1536 | 328 | texxform.u1 = border; | ||
1537 | 329 | texxform.v1 = border; | ||
1538 | 330 | texxform.flip_u_coord = true; | ||
1539 | 331 | texxform.flip_v_coord = true; | ||
1540 | 332 | GfxContext.QRP_1Tex(geo.x + geo.width - border, geo.y + geo.height - border, | ||
1541 | 333 | border, border, background_corner_->GetDeviceTexture(), texxform, nux::color::White); | ||
1542 | 334 | |||
1543 | 335 | int top_width = background_top_->GetWidth(); | ||
1544 | 336 | int top_height = background_top_->GetHeight(); | ||
1545 | 337 | |||
1546 | 338 | // Draw TOP BORDER | ||
1547 | 339 | texxform.u0 = 0; | ||
1548 | 340 | texxform.v0 = 0; | ||
1549 | 341 | texxform.u1 = top_width; | ||
1550 | 342 | texxform.v1 = top_height; | ||
1551 | 343 | texxform.flip_u_coord = false; | ||
1552 | 344 | texxform.flip_v_coord = false; | ||
1553 | 345 | GfxContext.QRP_1Tex(geo.x + border, geo.y, geo.width - border - border, border, background_top_->GetDeviceTexture(), texxform, nux::color::White); | ||
1554 | 346 | |||
1555 | 347 | // Draw BOTTOM BORDER | ||
1556 | 348 | texxform.u0 = 0; | ||
1557 | 349 | texxform.v0 = 0; | ||
1558 | 350 | texxform.u1 = top_width; | ||
1559 | 351 | texxform.v1 = top_height; | ||
1560 | 352 | texxform.flip_u_coord = false; | ||
1561 | 353 | texxform.flip_v_coord = true; | ||
1562 | 354 | GfxContext.QRP_1Tex(geo.x + border, geo.y + geo.height - border, geo.width - border - border, border, background_top_->GetDeviceTexture(), texxform, nux::color::White); | ||
1563 | 355 | |||
1564 | 356 | |||
1565 | 357 | int left_width = background_left_->GetWidth(); | ||
1566 | 358 | int left_height = background_left_->GetHeight(); | ||
1567 | 359 | |||
1568 | 360 | // Draw LEFT BORDER | ||
1569 | 361 | texxform.u0 = 0; | ||
1570 | 362 | texxform.v0 = 0; | ||
1571 | 363 | texxform.u1 = left_width; | ||
1572 | 364 | texxform.v1 = left_height; | ||
1573 | 365 | texxform.flip_u_coord = false; | ||
1574 | 366 | texxform.flip_v_coord = false; | ||
1575 | 367 | GfxContext.QRP_1Tex(geo.x, geo.y + border, border, geo.height - border - border, background_left_->GetDeviceTexture(), texxform, nux::color::White); | ||
1576 | 368 | |||
1577 | 369 | // Draw RIGHT BORDER | ||
1578 | 370 | texxform.u0 = 0; | ||
1579 | 371 | texxform.v0 = 0; | ||
1580 | 372 | texxform.u1 = left_width; | ||
1581 | 373 | texxform.v1 = left_height; | ||
1582 | 374 | texxform.flip_u_coord = true; | ||
1583 | 375 | texxform.flip_v_coord = false; | ||
1584 | 376 | GfxContext.QRP_1Tex(geo.x + geo.width - border, geo.y + border, border, geo.height - border - border, background_left_->GetDeviceTexture(), texxform, nux::color::White); | ||
1585 | 377 | |||
1586 | 378 | GfxContext.GetRenderStates().SetBlend(FALSE); | ||
1587 | 379 | } | ||
1588 | 380 | |||
1589 | 381 | void View::RenderColumns() | ||
1590 | 382 | { | ||
1591 | 383 | int i = 0; | ||
1592 | 384 | int column = 0; | ||
1593 | 385 | |||
1594 | 386 | for (auto category : model_->categories()) | ||
1595 | 387 | { | ||
1596 | 388 | // Three sections in the fist column... | ||
1597 | 389 | if (i > 2) | ||
1598 | 390 | column = 1; | ||
1599 | 391 | |||
1600 | 392 | nux::LinearLayout* section_layout = CreateSectionLayout(category.c_str()); | ||
1601 | 393 | nux::LinearLayout* intermediate_layout = CreateIntermediateLayout(); | ||
1602 | 394 | intermediate_layout->SetContentDistribution(nux::MAJOR_POSITION_START); | ||
1603 | 395 | |||
1604 | 396 | for (auto hint : model_->hints()[category]) | ||
1605 | 397 | { | ||
1606 | 398 | //std::string str_value = hint->prefix() + hint->value() + hint->postfix(); | ||
1607 | 399 | //boost::replace_all(str_value, "&", "&"); | ||
1608 | 400 | //boost::replace_all(str_value, "<", "<"); | ||
1609 | 401 | //boost::replace_all(str_value, ">", ">"); | ||
1610 | 402 | |||
1611 | 403 | intermediate_layout->AddLayout(CreateShortKeyEntryLayout(hint), 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL); | ||
1612 | 404 | } | ||
1613 | 405 | |||
1614 | 406 | section_layout->AddLayout(intermediate_layout, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); | ||
1615 | 407 | |||
1616 | 408 | if (i == 0 or i==1 or i==3 or i==4) | ||
1617 | 409 | { | ||
1618 | 410 | // Add space before the line | ||
1619 | 411 | section_layout->AddView(new nux::SpaceLayout(23, 23, 23, 23), 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_MATCHCONTENT); | ||
1620 | 412 | section_layout->AddView(new HSeparator(), 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); | ||
1621 | 413 | // Add space after the line | ||
1622 | 414 | section_layout->AddView(new nux::SpaceLayout(20, 20, 20, 20), 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_MATCHCONTENT); | ||
1623 | 415 | } | ||
1624 | 416 | |||
1625 | 417 | columns_[column]->AddView(section_layout, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL); | ||
1626 | 418 | |||
1627 | 419 | i++; | ||
1628 | 420 | } | ||
1629 | 421 | } | ||
1630 | 422 | |||
1631 | 423 | } // namespace shortcut | ||
1632 | 424 | } // namespace unity | ||
1633 | 0 | 425 | ||
1634 | === added file 'plugins/unityshell/src/ShortcutView.h' | |||
1635 | --- plugins/unityshell/src/ShortcutView.h 1970-01-01 00:00:00 +0000 | |||
1636 | +++ plugins/unityshell/src/ShortcutView.h 2012-01-13 15:39:27 +0000 | |||
1637 | @@ -0,0 +1,93 @@ | |||
1638 | 1 | /* | ||
1639 | 2 | * Copyright (C) 2011 Canonical Ltd | ||
1640 | 3 | * | ||
1641 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1642 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1643 | 6 | * published by the Free Software Foundation. | ||
1644 | 7 | * | ||
1645 | 8 | * This program is distributed in the hope that it will be useful, | ||
1646 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1647 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1648 | 11 | * GNU General Public License for more details. | ||
1649 | 12 | * | ||
1650 | 13 | * You should have received a copy of the GNU General Public License | ||
1651 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1652 | 15 | * | ||
1653 | 16 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
1654 | 17 | */ | ||
1655 | 18 | |||
1656 | 19 | #ifndef UNITYSHELL_SHORTCUTVIEW_H | ||
1657 | 20 | #define UNITYSHELL_SHORTCUTVIEW_H | ||
1658 | 21 | |||
1659 | 22 | #include <Nux/Nux.h> | ||
1660 | 23 | #include <Nux/GridHLayout.h> | ||
1661 | 24 | #include <Nux/HLayout.h> | ||
1662 | 25 | #include <NuxCore/ObjectPtr.h> | ||
1663 | 26 | #include <NuxCore/Property.h> | ||
1664 | 27 | #include <Nux/StaticText.h> | ||
1665 | 28 | #include <Nux/View.h> | ||
1666 | 29 | #include <Nux/VLayout.h> | ||
1667 | 30 | |||
1668 | 31 | #include "BackgroundEffectHelper.h" | ||
1669 | 32 | #include "ShortcutModel.h" | ||
1670 | 33 | |||
1671 | 34 | namespace unity | ||
1672 | 35 | { | ||
1673 | 36 | namespace shortcut | ||
1674 | 37 | { | ||
1675 | 38 | |||
1676 | 39 | class View : public nux::View | ||
1677 | 40 | { | ||
1678 | 41 | NUX_DECLARE_OBJECT_TYPE(View, nux::View); | ||
1679 | 42 | public: | ||
1680 | 43 | typedef nux::ObjectPtr<View> Ptr; | ||
1681 | 44 | |||
1682 | 45 | // Ctor and dtor | ||
1683 | 46 | View(NUX_FILE_LINE_PROTO); | ||
1684 | 47 | ~View(); | ||
1685 | 48 | |||
1686 | 49 | // Public methods | ||
1687 | 50 | void SetModel(Model::Ptr model); | ||
1688 | 51 | Model::Ptr GetModel(); | ||
1689 | 52 | |||
1690 | 53 | void SetupBackground(bool enabled); | ||
1691 | 54 | |||
1692 | 55 | // Properties | ||
1693 | 56 | nux::Property<nux::Color> background_color; | ||
1694 | 57 | |||
1695 | 58 | protected: | ||
1696 | 59 | // Protected methods | ||
1697 | 60 | void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); | ||
1698 | 61 | void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); | ||
1699 | 62 | |||
1700 | 63 | private: | ||
1701 | 64 | // Private methods | ||
1702 | 65 | nux::LinearLayout* CreateSectionLayout(const char* section_name); | ||
1703 | 66 | nux::LinearLayout* CreateShortKeyEntryLayout(AbstractHint* hint); | ||
1704 | 67 | nux::LinearLayout* CreateIntermediateLayout(); | ||
1705 | 68 | |||
1706 | 69 | void DrawBackground(nux::GraphicsEngine& GfxContext, nux::Geometry const& geo); | ||
1707 | 70 | void RenderColumns(); | ||
1708 | 71 | |||
1709 | 72 | // Private members | ||
1710 | 73 | Model::Ptr model_; | ||
1711 | 74 | |||
1712 | 75 | nux::BaseTexture* background_top_; | ||
1713 | 76 | nux::BaseTexture* background_left_; | ||
1714 | 77 | nux::BaseTexture* background_corner_; | ||
1715 | 78 | nux::BaseTexture* rounding_texture_; | ||
1716 | 79 | |||
1717 | 80 | nux::VLayout* layout_; | ||
1718 | 81 | nux::HLayout* columns_layout_; | ||
1719 | 82 | std::vector<nux::VLayout*> columns_; | ||
1720 | 83 | |||
1721 | 84 | BackgroundEffectHelper bg_effect_helper_; | ||
1722 | 85 | |||
1723 | 86 | }; | ||
1724 | 87 | |||
1725 | 88 | } // namespace shortcut | ||
1726 | 89 | |||
1727 | 90 | } // namespace unity | ||
1728 | 91 | |||
1729 | 92 | #endif // UNITYSHELL_SHORTCUTVIEW_H | ||
1730 | 93 | |||
1731 | 0 | 94 | ||
1732 | === modified file 'plugins/unityshell/src/unityshell.cpp' | |||
1733 | --- plugins/unityshell/src/unityshell.cpp 2012-01-09 16:49:50 +0000 | |||
1734 | +++ plugins/unityshell/src/unityshell.cpp 2012-01-13 15:39:27 +0000 | |||
1735 | @@ -97,6 +97,7 @@ | |||
1736 | 97 | , screen(screen) | 97 | , screen(screen) |
1737 | 98 | , cScreen(CompositeScreen::get(screen)) | 98 | , cScreen(CompositeScreen::get(screen)) |
1738 | 99 | , gScreen(GLScreen::get(screen)) | 99 | , gScreen(GLScreen::get(screen)) |
1739 | 100 | , enable_shortcut_overlay_(true) | ||
1740 | 100 | , gestureEngine(nullptr) | 101 | , gestureEngine(nullptr) |
1741 | 101 | , wt(nullptr) | 102 | , wt(nullptr) |
1742 | 102 | , panelWindow(nullptr) | 103 | , panelWindow(nullptr) |
1743 | @@ -258,7 +259,8 @@ | |||
1744 | 258 | optionSetIconSizeNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); | 259 | optionSetIconSizeNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); |
1745 | 259 | optionSetAutohideAnimationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); | 260 | optionSetAutohideAnimationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); |
1746 | 260 | optionSetDashBlurExperimentalNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); | 261 | optionSetDashBlurExperimentalNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); |
1748 | 261 | optionSetDevicesOptionNotify(boost::bind (&UnityScreen::optionChanged, this, _1, _2)); | 262 | optionSetDevicesOptionNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); |
1749 | 263 | optionSetShortcutOverlayNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); | ||
1750 | 262 | optionSetShowDesktopIconNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); | 264 | optionSetShowDesktopIconNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); |
1751 | 263 | optionSetShowLauncherInitiate(boost::bind(&UnityScreen::showLauncherKeyInitiate, this, _1, _2, _3)); | 265 | optionSetShowLauncherInitiate(boost::bind(&UnityScreen::showLauncherKeyInitiate, this, _1, _2, _3)); |
1752 | 264 | optionSetShowLauncherTerminate(boost::bind(&UnityScreen::showLauncherKeyTerminate, this, _1, _2, _3)); | 266 | optionSetShowLauncherTerminate(boost::bind(&UnityScreen::showLauncherKeyTerminate, this, _1, _2, _3)); |
1753 | @@ -1120,6 +1122,7 @@ | |||
1754 | 1120 | // thing that could possibly make sense here. | 1122 | // thing that could possibly make sense here. |
1755 | 1121 | key_string[result] = 0; | 1123 | key_string[result] = 0; |
1756 | 1122 | if (super_keypressed_) { | 1124 | if (super_keypressed_) { |
1757 | 1125 | shortcut_controller_->Hide(); | ||
1758 | 1123 | skip_other_plugins = launcher.CheckSuperShortcutPressed(screen->dpy(), key_sym, event->xkey.keycode, event->xkey.state, key_string); | 1126 | skip_other_plugins = launcher.CheckSuperShortcutPressed(screen->dpy(), key_sym, event->xkey.keycode, event->xkey.state, key_string); |
1759 | 1124 | if (!skip_other_plugins) { | 1127 | if (!skip_other_plugins) { |
1760 | 1125 | skip_other_plugins = dash_controller_->CheckShortcutActivation(key_string); | 1128 | skip_other_plugins = dash_controller_->CheckShortcutActivation(key_string); |
1761 | @@ -1234,6 +1237,33 @@ | |||
1762 | 1234 | super_keypressed_ = true; | 1237 | super_keypressed_ = true; |
1763 | 1235 | launcher_controller_->launcher().StartKeyShowLauncher(); | 1238 | launcher_controller_->launcher().StartKeyShowLauncher(); |
1764 | 1236 | EnsureSuperKeybindings (); | 1239 | EnsureSuperKeybindings (); |
1765 | 1240 | |||
1766 | 1241 | if (enable_shortcut_overlay_ and !shortcut_controller_->Visible()) | ||
1767 | 1242 | { | ||
1768 | 1243 | static nux::Geometry last_geo; | ||
1769 | 1244 | UScreen* uscreen = UScreen::GetDefault(); | ||
1770 | 1245 | int primary_monitor = uscreen->GetPrimaryMonitor(); | ||
1771 | 1246 | auto monitor_geo = uscreen->GetMonitorGeometry(primary_monitor); | ||
1772 | 1247 | |||
1773 | 1248 | int width = 970; | ||
1774 | 1249 | int height = 680; | ||
1775 | 1250 | int launcher_width = optionGetIconSize() + 18; | ||
1776 | 1251 | int panel_height = 24; | ||
1777 | 1252 | int x = monitor_geo.x + launcher_width + (monitor_geo.width - launcher_width- width) / 2; | ||
1778 | 1253 | int y = monitor_geo.y + panel_height + (monitor_geo.height - panel_height - height) / 2; | ||
1779 | 1254 | |||
1780 | 1255 | nux::Geometry geo (x, y, width, height); | ||
1781 | 1256 | |||
1782 | 1257 | if (last_geo != geo) | ||
1783 | 1258 | { | ||
1784 | 1259 | shortcut_controller_->SetWorkspace(geo); | ||
1785 | 1260 | last_geo = geo; | ||
1786 | 1261 | } | ||
1787 | 1262 | |||
1788 | 1263 | if (last_geo.x > monitor_geo.x and last_geo.y > monitor_geo.y) | ||
1789 | 1264 | shortcut_controller_->Show(); | ||
1790 | 1265 | } | ||
1791 | 1266 | |||
1792 | 1237 | return false; | 1267 | return false; |
1793 | 1238 | } | 1268 | } |
1794 | 1239 | 1269 | ||
1795 | @@ -1243,6 +1273,7 @@ | |||
1796 | 1243 | { | 1273 | { |
1797 | 1244 | super_keypressed_ = false; | 1274 | super_keypressed_ = false; |
1798 | 1245 | launcher_controller_->launcher().EndKeyShowLauncher(); | 1275 | launcher_controller_->launcher().EndKeyShowLauncher(); |
1799 | 1276 | shortcut_controller_->Hide(); | ||
1800 | 1246 | return false; | 1277 | return false; |
1801 | 1247 | } | 1278 | } |
1802 | 1248 | 1279 | ||
1803 | @@ -2176,6 +2207,9 @@ | |||
1804 | 2176 | screen->enterShowDesktopModeSetEnabled (this, optionGetShowMinimizedWindows ()); | 2207 | screen->enterShowDesktopModeSetEnabled (this, optionGetShowMinimizedWindows ()); |
1805 | 2177 | screen->leaveShowDesktopModeSetEnabled (this, optionGetShowMinimizedWindows ()); | 2208 | screen->leaveShowDesktopModeSetEnabled (this, optionGetShowMinimizedWindows ()); |
1806 | 2178 | break; | 2209 | break; |
1807 | 2210 | case UnityshellOptions::ShortcutOverlay: | ||
1808 | 2211 | enable_shortcut_overlay_ = optionGetShortcutOverlay(); | ||
1809 | 2212 | break; | ||
1810 | 2179 | case UnityshellOptions::ShowDesktopIcon: | 2213 | case UnityshellOptions::ShowDesktopIcon: |
1811 | 2180 | launcher_controller_->SetShowDesktopIcon(optionGetShowDesktopIcon()); | 2214 | launcher_controller_->SetShowDesktopIcon(optionGetShowDesktopIcon()); |
1812 | 2181 | break; | 2215 | break; |
1813 | @@ -2304,6 +2338,10 @@ | |||
1814 | 2304 | /* Setup Places */ | 2338 | /* Setup Places */ |
1815 | 2305 | dash_controller_.reset(new dash::Controller()); | 2339 | dash_controller_.reset(new dash::Controller()); |
1816 | 2306 | dash_controller_->on_realize.connect(sigc::mem_fun(this, &UnityScreen::OnDashRealized)); | 2340 | dash_controller_->on_realize.connect(sigc::mem_fun(this, &UnityScreen::OnDashRealized)); |
1817 | 2341 | |||
1818 | 2342 | // Setup Shortcut Hint | ||
1819 | 2343 | InitHints(); | ||
1820 | 2344 | shortcut_controller_.reset(new shortcut::Controller(hints_)); | ||
1821 | 2307 | 2345 | ||
1822 | 2308 | AddChild(dash_controller_.get()); | 2346 | AddChild(dash_controller_.get()); |
1823 | 2309 | 2347 | ||
1824 | @@ -2316,6 +2354,66 @@ | |||
1825 | 2316 | OnLauncherHiddenChanged(); | 2354 | OnLauncherHiddenChanged(); |
1826 | 2317 | } | 2355 | } |
1827 | 2318 | 2356 | ||
1828 | 2357 | void UnityScreen::InitHints() | ||
1829 | 2358 | { | ||
1830 | 2359 | // TODO move category text into a vector... | ||
1831 | 2360 | |||
1832 | 2361 | // Launcher... | ||
1833 | 2362 | std::string const launcher = _("Launcher"); | ||
1834 | 2363 | |||
1835 | 2364 | hints_.push_back(new shortcut::Hint(launcher, "", _(" (Press)"), _("Open Launcher, displays shortcuts."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "show_launcher" )); | ||
1836 | 2365 | hints_.push_back(new shortcut::Hint(launcher, "", "", _("Open Launcher keyboard navigation mode."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "keyboard_focus")); | ||
1837 | 2366 | hints_.push_back(new shortcut::Hint(launcher, "", "", _("Switch applications via Launcher."), shortcut::HARDCODED_OPTION, "Super + Tab")); | ||
1838 | 2367 | hints_.push_back(new shortcut::Hint(launcher, "", _(" + 1 to 9"), _("Same as clicking on a Launcher icon."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "show_launcher")); | ||
1839 | 2368 | hints_.push_back(new shortcut::Hint(launcher, "", _(" + Shift + 1 to 9"), _("Open new window of the app."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "show_launcher")); | ||
1840 | 2369 | hints_.push_back(new shortcut::Hint(launcher, "", " + T", _("Open the Rubbish Bin."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "show_launcher")); | ||
1841 | 2370 | |||
1842 | 2371 | // Dash... | ||
1843 | 2372 | std::string const dash = _("Dash"); | ||
1844 | 2373 | |||
1845 | 2374 | hints_.push_back(new shortcut::Hint(dash, "", _(" (Tap)"), _("Open the Dash Home."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "show_launcher")); | ||
1846 | 2375 | hints_.push_back(new shortcut::Hint(dash, "", " + A", _("Open the Dash App Lens."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "show_launcher")); | ||
1847 | 2376 | hints_.push_back(new shortcut::Hint(dash, "", " + F", _("Open the Dash Files Lens."), shortcut::COMPIZ_KEY_OPTION,"unityshell", "show_launcher")); | ||
1848 | 2377 | hints_.push_back(new shortcut::Hint(dash, "", " + M", _("Open the Dash Music Lens."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "show_launcher")); | ||
1849 | 2378 | hints_.push_back(new shortcut::Hint(dash, "", "", _("Switches between Lenses."), shortcut::HARDCODED_OPTION, "Ctrl + Tab")); | ||
1850 | 2379 | hints_.push_back(new shortcut::Hint(dash, "", "", _("Moves the focus."), shortcut::HARDCODED_OPTION, _("Cursor Keys"))); | ||
1851 | 2380 | hints_.push_back(new shortcut::Hint(dash, "", "", _("Open currently focused item."), shortcut::HARDCODED_OPTION, _("Enter & Return"))); | ||
1852 | 2381 | hints_.push_back(new shortcut::Hint(dash, "", "", _("'Run Command' mode."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "execute_command")); | ||
1853 | 2382 | |||
1854 | 2383 | // Top Bar | ||
1855 | 2384 | std::string const topbar = _("Top Bar"); | ||
1856 | 2385 | |||
1857 | 2386 | hints_.push_back(new shortcut::Hint(topbar, "", "", _("Reveals application menu."), shortcut::HARDCODED_OPTION, "Alt")); | ||
1858 | 2387 | hints_.push_back(new shortcut::Hint(topbar, "", "", _("Opens the indicator menu."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "panel_first_menu")); | ||
1859 | 2388 | hints_.push_back(new shortcut::Hint(topbar, "", "", _("Moves focus between indicators."), shortcut::HARDCODED_OPTION, _("Cursor Left or Right"))); | ||
1860 | 2389 | |||
1861 | 2390 | // Switching | ||
1862 | 2391 | std::string const switching = _("Switching"); | ||
1863 | 2392 | |||
1864 | 2393 | hints_.push_back(new shortcut::Hint(switching, "", "", _("Switch between applications."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "alt_tab_forward")); | ||
1865 | 2394 | hints_.push_back(new shortcut::Hint(switching, "", "", _("Switch windows of current application."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "alt_tab_next_window")); | ||
1866 | 2395 | hints_.push_back(new shortcut::Hint(switching, "", "", _("Moves the focus."), shortcut::HARDCODED_OPTION, _("Cursor Left or Right"))); | ||
1867 | 2396 | |||
1868 | 2397 | // Workspaces | ||
1869 | 2398 | std::string const workspaces = _("Workspaces"); | ||
1870 | 2399 | hints_.push_back(new shortcut::Hint(workspaces, "", "", _("Spread workspaces."), shortcut::COMPIZ_KEY_OPTION, "expo", "expo_key")); | ||
1871 | 2400 | hints_.push_back(new shortcut::Hint(workspaces, "", "", _("Switch workspaces."), shortcut::HARDCODED_OPTION, _("Super + Cursor Keys"))); | ||
1872 | 2401 | hints_.push_back(new shortcut::Hint(workspaces, "", " or Right", _("Move focused window to different workspace."), shortcut::HARDCODED_OPTION, _("Super + Alt + Cursor Keys"))); | ||
1873 | 2402 | |||
1874 | 2403 | // Windows | ||
1875 | 2404 | std::string const windows = _("Windows"); | ||
1876 | 2405 | hints_.push_back(new shortcut::Hint(windows, "", "", _("Spreads all windows in the current workspace."), shortcut::COMPIZ_KEY_OPTION, "scale", "initiate_all_key")); | ||
1877 | 2406 | hints_.push_back(new shortcut::Hint(windows, "", "", _("Minimises all windows."), shortcut::COMPIZ_KEY_OPTION, "core", "show_desktop_key")); | ||
1878 | 2407 | hints_.push_back(new shortcut::Hint(windows, "", "", _("Maximises the current window."), shortcut::COMPIZ_KEY_OPTION, "core", "maximize_window_key")); | ||
1879 | 2408 | hints_.push_back(new shortcut::Hint(windows, "", "", _("Restores or minimises current window."), shortcut::COMPIZ_KEY_OPTION, "core", "unmaximize_window_key")); | ||
1880 | 2409 | hints_.push_back(new shortcut::Hint(windows, "", " or Right", _("Semi-maximises current window."), shortcut::COMPIZ_KEY_OPTION, "grid", "put_left_key")); | ||
1881 | 2410 | hints_.push_back(new shortcut::Hint(windows, "", "", _("Closes current window."), shortcut::COMPIZ_KEY_OPTION, "core", "close_window_key")); | ||
1882 | 2411 | hints_.push_back(new shortcut::Hint(windows, "", "", _("Opens window accessibility menu."), shortcut::HARDCODED_OPTION, "Alt + Space")); | ||
1883 | 2412 | hints_.push_back(new shortcut::Hint(windows, "", "", _("Places window in corresponding positions."), shortcut::HARDCODED_OPTION, "Ctrl + Alt + Num")); | ||
1884 | 2413 | hints_.push_back(new shortcut::Hint(windows, "", " Drag", _("Move window."), shortcut::COMPIZ_MOUSE_OPTION, "move", "initiate_button")); | ||
1885 | 2414 | hints_.push_back(new shortcut::Hint(windows, "", " Drag", _("Resize window."), shortcut::COMPIZ_MOUSE_OPTION, "resize", "initiate_button")); | ||
1886 | 2415 | } | ||
1887 | 2416 | |||
1888 | 2319 | /* Window init */ | 2417 | /* Window init */ |
1889 | 2320 | UnityWindow::UnityWindow(CompWindow* window) | 2418 | UnityWindow::UnityWindow(CompWindow* window) |
1890 | 2321 | : BaseSwitchWindow (dynamic_cast<BaseSwitchScreen *> (UnityScreen::get (screen)), window) | 2419 | : BaseSwitchWindow (dynamic_cast<BaseSwitchScreen *> (UnityScreen::get (screen)), window) |
1891 | 2322 | 2420 | ||
1892 | === modified file 'plugins/unityshell/src/unityshell.h' | |||
1893 | --- plugins/unityshell/src/unityshell.h 2012-01-06 04:53:09 +0000 | |||
1894 | +++ plugins/unityshell/src/unityshell.h 2012-01-13 15:39:27 +0000 | |||
1895 | @@ -39,6 +39,8 @@ | |||
1896 | 39 | #include "DashSettings.h" | 39 | #include "DashSettings.h" |
1897 | 40 | #include "DashStyle.h" | 40 | #include "DashStyle.h" |
1898 | 41 | #include "FontSettings.h" | 41 | #include "FontSettings.h" |
1899 | 42 | #include "ShortcutController.h" | ||
1900 | 43 | #include "ShortcutHint.h" | ||
1901 | 42 | #include "LauncherController.h" | 44 | #include "LauncherController.h" |
1902 | 43 | #include "PanelController.h" | 45 | #include "PanelController.h" |
1903 | 44 | #include "PanelStyle.h" | 46 | #include "PanelStyle.h" |
1904 | @@ -242,6 +244,8 @@ | |||
1905 | 242 | static void OnQuicklistEndKeyNav(GVariant* data, void* value); | 244 | static void OnQuicklistEndKeyNav(GVariant* data, void* value); |
1906 | 243 | static void OnLauncherStartKeyNav(GVariant* data, void* value); | 245 | static void OnLauncherStartKeyNav(GVariant* data, void* value); |
1907 | 244 | static void OnLauncherEndKeyNav(GVariant* data, void* value); | 246 | static void OnLauncherEndKeyNav(GVariant* data, void* value); |
1908 | 247 | |||
1909 | 248 | void InitHints(); | ||
1910 | 245 | 249 | ||
1911 | 246 | dash::Settings dash_settings_; | 250 | dash::Settings dash_settings_; |
1912 | 247 | dash::Style dash_style_; | 251 | dash::Style dash_style_; |
1913 | @@ -253,6 +257,10 @@ | |||
1914 | 253 | panel::Controller::Ptr panel_controller_; | 257 | panel::Controller::Ptr panel_controller_; |
1915 | 254 | switcher::Controller::Ptr switcher_controller_; | 258 | switcher::Controller::Ptr switcher_controller_; |
1916 | 255 | 259 | ||
1917 | 260 | shortcut::Controller::Ptr shortcut_controller_; | ||
1918 | 261 | std::list<shortcut::AbstractHint*> hints_; | ||
1919 | 262 | bool enable_shortcut_overlay_; | ||
1920 | 263 | |||
1921 | 256 | GestureEngine* gestureEngine; | 264 | GestureEngine* gestureEngine; |
1922 | 257 | nux::WindowThread* wt; | 265 | nux::WindowThread* wt; |
1923 | 258 | nux::BaseWindow* panelWindow; | 266 | nux::BaseWindow* panelWindow; |
1924 | @@ -266,7 +274,7 @@ | |||
1925 | 266 | guint32 _redraw_handle; | 274 | guint32 _redraw_handle; |
1926 | 267 | gint _edge_pointerY; | 275 | gint _edge_pointerY; |
1927 | 268 | guint _ubus_handles[3]; | 276 | guint _ubus_handles[3]; |
1929 | 269 | 277 | ||
1930 | 270 | typedef std::shared_ptr<CompAction> CompActionPtr; | 278 | typedef std::shared_ptr<CompAction> CompActionPtr; |
1931 | 271 | typedef std::vector<CompActionPtr> ShortcutActions; | 279 | typedef std::vector<CompActionPtr> ShortcutActions; |
1932 | 272 | ShortcutActions _shortcut_actions; | 280 | ShortcutActions _shortcut_actions; |
1933 | 273 | 281 | ||
1934 | === modified file 'plugins/unityshell/unityshell.xml.in' | |||
1935 | --- plugins/unityshell/unityshell.xml.in 2011-12-08 21:16:50 +0000 | |||
1936 | +++ plugins/unityshell/unityshell.xml.in 2012-01-13 15:39:27 +0000 | |||
1937 | @@ -341,6 +341,12 @@ | |||
1938 | 341 | <_name>Always</_name> | 341 | <_name>Always</_name> |
1939 | 342 | </desc> | 342 | </desc> |
1940 | 343 | </option> | 343 | </option> |
1941 | 344 | |||
1942 | 345 | <option name="shortcut_overlay" type="bool"> | ||
1943 | 346 | <_short>Enable Shortcut Hints Overlay</_short> | ||
1944 | 347 | <_long>Enable Shortcut Hints Overlay</_long> | ||
1945 | 348 | <default>true</default> | ||
1946 | 349 | </option> | ||
1947 | 344 | 350 | ||
1948 | 345 | <option name="show_desktop_icon" type="bool"> | 351 | <option name="show_desktop_icon" type="bool"> |
1949 | 346 | <_short>Show "Desktop Icon" in the launcher</_short> | 352 | <_short>Show "Desktop Icon" in the launcher</_short> |
1950 | 347 | 353 | ||
1951 | === modified file 'standalone-clients/CMakeLists.txt' | |||
1952 | --- standalone-clients/CMakeLists.txt 2012-01-06 13:10:01 +0000 | |||
1953 | +++ standalone-clients/CMakeLists.txt 2012-01-13 15:39:27 +0000 | |||
1954 | @@ -452,8 +452,32 @@ | |||
1955 | 452 | ) | 452 | ) |
1956 | 453 | add_dependencies (bg-hash unity-core-${UNITY_API_VERSION}) | 453 | add_dependencies (bg-hash unity-core-${UNITY_API_VERSION}) |
1957 | 454 | 454 | ||
1958 | 455 | add_executable (test-shortcut | ||
1959 | 456 | TestShortcut.cpp | ||
1960 | 457 | ${UNITY_SRC}/AbstractSeparator.cpp | ||
1961 | 458 | ${UNITY_SRC}/AbstractSeparator.h | ||
1962 | 459 | ${UNITY_SRC}/AbstractShortcutHint.h | ||
1963 | 460 | ${UNITY_SRC}/Animator.cpp | ||
1964 | 461 | ${UNITY_SRC}/Animator.h | ||
1965 | 462 | ${UNITY_SRC}/BackgroundEffectHelper.cpp | ||
1966 | 463 | ${UNITY_SRC}/BackgroundEffectHelper.h | ||
1967 | 464 | ${UNITY_SRC}/LineSeparator.cpp | ||
1968 | 465 | ${UNITY_SRC}/LineSeparator.h | ||
1969 | 466 | ${UNITY_SRC}/MockShortcutHint.h | ||
1970 | 467 | ${UNITY_SRC}/ShortcutController.cpp | ||
1971 | 468 | ${UNITY_SRC}/ShortcutController.h | ||
1972 | 469 | ${UNITY_SRC}/ShortcutModel.cpp | ||
1973 | 470 | ${UNITY_SRC}/ShortcutModel.h | ||
1974 | 471 | ${UNITY_SRC}/ShortcutView.cpp | ||
1975 | 472 | ${UNITY_SRC}/ShortcutView.h | ||
1976 | 473 | ${UNITY_SRC}/StaticCairoText.cpp | ||
1977 | 474 | ${UNITY_SRC}/StaticCairoText.h | ||
1978 | 475 | ${UNITY_SRC}/UBusMessages.h | ||
1979 | 476 | ${UNITY_SRC}/ubus-server.cpp | ||
1980 | 477 | ${UNITY_SRC}/ubus-server.h | ||
1981 | 478 | ) | ||
1982 | 479 | |||
1983 | 455 | find_package (OpenGL) | 480 | find_package (OpenGL) |
1984 | 456 | |||
1985 | 457 | include_directories (${OPENGL_gl_INCDIRS}) | 481 | include_directories (${OPENGL_gl_INCDIRS}) |
1986 | 458 | add_library (glfuncloader SHARED | 482 | add_library (glfuncloader SHARED |
1987 | 459 | ${CMAKE_CURRENT_SOURCE_DIR}/GLFuncLoader.cpp) | 483 | ${CMAKE_CURRENT_SOURCE_DIR}/GLFuncLoader.cpp) |
1988 | @@ -467,9 +491,8 @@ | |||
1989 | 467 | target_link_libraries (screen-effect-fbo glfuncloader ${OPENGL_gl_LIBRARY}) | 491 | target_link_libraries (screen-effect-fbo glfuncloader ${OPENGL_gl_LIBRARY}) |
1990 | 468 | add_dependencies (screen-effect-fbo ${UNITY_API_VERSION}) | 492 | add_dependencies (screen-effect-fbo ${UNITY_API_VERSION}) |
1991 | 469 | 493 | ||
1992 | 470 | |||
1993 | 471 | # Custom target to make all the other targets here, add your test to this list | 494 | # Custom target to make all the other targets here, add your test to this list |
1995 | 472 | add_custom_target(standalone-clients DEPENDS dash panel launcher switcher keyutil quicklist quicklist-visuals filters filter-bar preview-applicaiton preview-generic preview-music result-view dash-style bg-hash) | 495 | add_custom_target(standalone-clients DEPENDS dash panel launcher switcher keyutil quicklist quicklist-visuals filters filter-bar preview-applicaiton preview-generic preview-music result-view dash-style bg-hash shortcut-view) |
1996 | 473 | 496 | ||
1997 | 474 | 497 | ||
1998 | 475 | 498 | ||
1999 | 476 | 499 | ||
2000 | === added file 'standalone-clients/TestShortcut.cpp' | |||
2001 | --- standalone-clients/TestShortcut.cpp 1970-01-01 00:00:00 +0000 | |||
2002 | +++ standalone-clients/TestShortcut.cpp 2012-01-13 15:39:27 +0000 | |||
2003 | @@ -0,0 +1,109 @@ | |||
2004 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
2005 | 2 | /* | ||
2006 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
2007 | 4 | * | ||
2008 | 5 | * This program is free software: you can redistribute it and/or modify | ||
2009 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
2010 | 7 | * published by the Free Software Foundation. | ||
2011 | 8 | * | ||
2012 | 9 | * This program is distributed in the hope that it will be useful, | ||
2013 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2014 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2015 | 12 | * GNU General Public License for more details. | ||
2016 | 13 | * | ||
2017 | 14 | * You should have received a copy of the GNU General Public License | ||
2018 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2019 | 16 | * | ||
2020 | 17 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
2021 | 18 | */ | ||
2022 | 19 | |||
2023 | 20 | #include <dbus/dbus-glib.h> | ||
2024 | 21 | #include <glib/gi18n-lib.h> | ||
2025 | 22 | #include <gtk/gtk.h> | ||
2026 | 23 | #include <Nux/Nux.h> | ||
2027 | 24 | #include <Nux/WindowThread.h> | ||
2028 | 25 | |||
2029 | 26 | #include "BackgroundEffectHelper.h" | ||
2030 | 27 | #include "MockShortcutHint.h" | ||
2031 | 28 | #include "ShortcutController.h" | ||
2032 | 29 | |||
2033 | 30 | using namespace unity; | ||
2034 | 31 | |||
2035 | 32 | static shortcut::Controller::Ptr controller; | ||
2036 | 33 | |||
2037 | 34 | void ThreadWidgetInit(nux::NThread* thread, void* InitData) | ||
2038 | 35 | { | ||
2039 | 36 | std::list<shortcut::AbstractHint*> hints; | ||
2040 | 37 | |||
2041 | 38 | // Launcher... | ||
2042 | 39 | hints.push_back(new shortcut::MockHint(_("Launcher"), "", _(" (Press)"), _("Open Launcher, displays shortcuts."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "show_launcher" )); | ||
2043 | 40 | hints.push_back(new shortcut::MockHint(_("Launcher"), "", "", _("Open Launcher keyboard navigation mode."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "keyboard_focus")); | ||
2044 | 41 | // FIXME: Implement it... | ||
2045 | 42 | hints.push_back(new shortcut::MockHint(_("Launcher"), "", "", _("Switch application via Launcher."), shortcut::HARDCODED_OPTION, "Super + Tab")); | ||
2046 | 43 | hints.push_back(new shortcut::MockHint(_("Launcher"), "", _(" + 1 to 9"), _("Same as clicking on a Launcher icon."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "show_launcher")); | ||
2047 | 44 | hints.push_back(new shortcut::MockHint(_("Launcher"), "", _(" + Shift + 1 to 9"), _("Open a new window of the app."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "show_launcher")); | ||
2048 | 45 | hints.push_back(new shortcut::MockHint(_("Launcher"), "", " + T", _("Open the Rubbish Bin."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "show_launcher")); | ||
2049 | 46 | |||
2050 | 47 | // Dash... | ||
2051 | 48 | hints.push_back(new shortcut::MockHint(_("Dash"), "", _(" (Tap)"), _("Open the Dash Home."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "show_launcher")); | ||
2052 | 49 | // These are not really hardcoded... | ||
2053 | 50 | hints.push_back(new shortcut::MockHint(_("Dash"), "", " + A", _("Open the Dash App Lens."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "show_launcher")); | ||
2054 | 51 | hints.push_back(new shortcut::MockHint(_("Dash"), "", " + F", _("Open the Dash Files Lens."), shortcut::COMPIZ_KEY_OPTION,"unityshell", "show_launcher")); | ||
2055 | 52 | hints.push_back(new shortcut::MockHint(_("Dash"), "", " + M", _("Open the Dash Music Lens."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "show_launcher")); | ||
2056 | 53 | hints.push_back(new shortcut::MockHint(_("Dash"), "", "", _("Switches between Lenses."), shortcut::HARDCODED_OPTION, "Ctrl + Tab")); | ||
2057 | 54 | hints.push_back(new shortcut::MockHint(_("Dash"), "", "", _("Moves the focus."), shortcut::HARDCODED_OPTION, _("Cursor Keys"))); | ||
2058 | 55 | hints.push_back(new shortcut::MockHint(_("Dash"), "", "", _("Open currently focused item."), shortcut::HARDCODED_OPTION, _("Enter / Return"))); | ||
2059 | 56 | hints.push_back(new shortcut::MockHint(_("Dash"), "", "", _("'Run Command' mode."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "execute_command")); | ||
2060 | 57 | |||
2061 | 58 | // Top Bar | ||
2062 | 59 | // Is it really hard coded? | ||
2063 | 60 | hints.push_back(new shortcut::MockHint(_("Top Bar"), "", "", _("Reveals application menu."), shortcut::HARDCODED_OPTION, "Alt")); | ||
2064 | 61 | hints.push_back(new shortcut::MockHint(_("Top Bar"), "", "", _("Opens the indicator menu."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "panel_first_menu")); | ||
2065 | 62 | hints.push_back(new shortcut::MockHint(_("Top Bar"), "", "", _("Moves focus between indicators."), shortcut::HARDCODED_OPTION, _("Cursor Left & Right"))); | ||
2066 | 63 | |||
2067 | 64 | // Switching | ||
2068 | 65 | hints.push_back(new shortcut::MockHint(_("Switching"), "", "", _("Switch between applications."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "alt_tab_forward")); | ||
2069 | 66 | hints.push_back(new shortcut::MockHint(_("Switching"), "", "", _("Switch windows of current application."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "alt_tab_next_window")); | ||
2070 | 67 | hints.push_back(new shortcut::MockHint(_("Switching"), "", "", _("Close window switch, return to app switch."), shortcut::COMPIZ_KEY_OPTION, "unityshell", "alt_tab_detail_stop")); | ||
2071 | 68 | hints.push_back(new shortcut::MockHint(_("Switching"), "", "", _("Moves the foucs."), shortcut::HARDCODED_OPTION, _("Cursor Left & Right"))); | ||
2072 | 69 | |||
2073 | 70 | // Workspaces | ||
2074 | 71 | hints.push_back(new shortcut::MockHint(_("Workspaces"), "", "", _("Spread workspaces."), shortcut::COMPIZ_KEY_OPTION, "expo", "expo_key")); | ||
2075 | 72 | hints.push_back(new shortcut::MockHint(_("Workspaces"), "", "", _("Switch workspaces."), shortcut::HARDCODED_OPTION, _("Cursor Keys"))); | ||
2076 | 73 | //hints.push_back(new shortcut::MockHint(_("Workspaces"), "", "", _("Move focused window to other workspace."), ...) | ||
2077 | 74 | |||
2078 | 75 | // Windows | ||
2079 | 76 | hints.push_back(new shortcut::MockHint(_("Windows"), "", "", _("Spreads all windows in current workspace."), shortcut::COMPIZ_KEY_OPTION, "scale", "initiate_output_key")); | ||
2080 | 77 | hints.push_back(new shortcut::MockHint(_("Windows"), "", "", _("Minimises all windows."), shortcut::COMPIZ_KEY_OPTION, "core", "show_desktop_key")); | ||
2081 | 78 | // I don't know if it is really hardcoded, but I can't find where this option is stored. | ||
2082 | 79 | hints.push_back(new shortcut::MockHint(_("Windows"), "", "", _("Open window accessibility menu."), shortcut::HARDCODED_OPTION, "Alt+Space")); | ||
2083 | 80 | hints.push_back(new shortcut::MockHint(_("Windows"), "", "", _("Maximises current window."), shortcut::COMPIZ_KEY_OPTION, "core", "maximize_window_key")); | ||
2084 | 81 | hints.push_back(new shortcut::MockHint(_("Windows"), "", "", _("Un-maximises current window."), shortcut::COMPIZ_KEY_OPTION, "core", "unmaximize_window_key")); | ||
2085 | 82 | hints.push_back(new shortcut::MockHint(_("Windows"), "", "", _("Minimises current window."), shortcut::COMPIZ_KEY_OPTION, "core", "minimize_window_key")); | ||
2086 | 83 | hints.push_back(new shortcut::MockHint(_("Windows"), "", "", _("Resizes current window."), shortcut::COMPIZ_KEY_OPTION, "resize", "initiate_key")); | ||
2087 | 84 | hints.push_back(new shortcut::MockHint(_("Windows"), "", "", _("Closes current window."), shortcut::COMPIZ_KEY_OPTION, "core", "close_window_key")); | ||
2088 | 85 | hints.push_back(new shortcut::MockHint(_("Windows"), "", "", _("Places window in corresponding positions."), shortcut::HARDCODED_OPTION, "Ctrl + Alt + Num")); | ||
2089 | 86 | hints.push_back(new shortcut::MockHint(_("Windows"), "", "", _("Move window."), shortcut::COMPIZ_KEY_OPTION, "move", "initiate_key")); | ||
2090 | 87 | |||
2091 | 88 | controller.reset(new shortcut::Controller(hints)); | ||
2092 | 89 | controller->SetWorkspace(nux::Geometry(25, 17, 1200 - 50, 720 - 35)); | ||
2093 | 90 | controller->Show(); | ||
2094 | 91 | } | ||
2095 | 92 | |||
2096 | 93 | int main(int argc, char** argv) | ||
2097 | 94 | { | ||
2098 | 95 | g_type_init(); | ||
2099 | 96 | //g_thread_init(NULL); | ||
2100 | 97 | gtk_init(&argc, &argv); | ||
2101 | 98 | |||
2102 | 99 | dbus_g_thread_init(); | ||
2103 | 100 | |||
2104 | 101 | nux::NuxInitialize(0); | ||
2105 | 102 | |||
2106 | 103 | BackgroundEffectHelper::blur_type = BLUR_NONE; | ||
2107 | 104 | nux::WindowThread* wt = nux::CreateGUIThread(TEXT("Unity Shortcut Hint Overlay"), 1200, 720, 0, &ThreadWidgetInit, 0); | ||
2108 | 105 | |||
2109 | 106 | wt->Run(NULL); | ||
2110 | 107 | delete wt; | ||
2111 | 108 | return 0; | ||
2112 | 109 | } | ||
2113 | 0 | 110 | ||
2114 | === modified file 'tests/CMakeLists.txt' | |||
2115 | --- tests/CMakeLists.txt 2011-12-22 06:27:26 +0000 | |||
2116 | +++ tests/CMakeLists.txt 2012-01-13 15:39:27 +0000 | |||
2117 | @@ -70,7 +70,6 @@ | |||
2118 | 70 | ${UNITY_SRC}/ | 70 | ${UNITY_SRC}/ |
2119 | 71 | ) | 71 | ) |
2120 | 72 | add_dependencies (test-unit unity-core-${UNITY_API_VERSION}) | 72 | add_dependencies (test-unit unity-core-${UNITY_API_VERSION}) |
2121 | 73 | |||
2122 | 74 | add_subdirectory (test-input-remover) | 73 | add_subdirectory (test-input-remover) |
2123 | 75 | add_subdirectory (test-minimize-window-handler) | 74 | add_subdirectory (test-minimize-window-handler) |
2124 | 76 | add_subdirectory (test-get-transients) | 75 | add_subdirectory (test-get-transients) |
2125 | @@ -107,6 +106,7 @@ | |||
2126 | 107 | test_service_model.h) | 106 | test_service_model.h) |
2127 | 108 | add_dependencies (test-gtest-service unity-core-${UNITY_API_VERSION}) | 107 | add_dependencies (test-gtest-service unity-core-${UNITY_API_VERSION}) |
2128 | 109 | 108 | ||
2129 | 109 | |||
2130 | 110 | # The actual test executable (xless) - do not put anything that requires X in here | 110 | # The actual test executable (xless) - do not put anything that requires X in here |
2131 | 111 | add_executable(test-gtest-xless | 111 | add_executable(test-gtest-xless |
2132 | 112 | test_animator.cpp | 112 | test_animator.cpp |
2133 | @@ -118,10 +118,13 @@ | |||
2134 | 118 | test_glib_signals_utils.h | 118 | test_glib_signals_utils.h |
2135 | 119 | ${CMAKE_CURRENT_BINARY_DIR}/test_glib_signals_utils_marshal.cpp | 119 | ${CMAKE_CURRENT_BINARY_DIR}/test_glib_signals_utils_marshal.cpp |
2136 | 120 | test_favorite_store_gsettings.cpp | 120 | test_favorite_store_gsettings.cpp |
2137 | 121 | test_shortcut_model.cpp | ||
2138 | 122 | test_shortcut_private.cpp | ||
2139 | 121 | test_introspection.cpp | 123 | test_introspection.cpp |
2140 | 122 | test_main_xless.cpp | 124 | test_main_xless.cpp |
2141 | 123 | test_grabhandle.cpp | 125 | test_grabhandle.cpp |
2142 | 124 | ${UNITY_SRC}/AbstractLauncherIcon.h | 126 | ${UNITY_SRC}/AbstractLauncherIcon.h |
2143 | 127 | ${UNITY_SRC}/AbstractShortcutHint.h | ||
2144 | 125 | ${UNITY_SRC}/Animator.cpp | 128 | ${UNITY_SRC}/Animator.cpp |
2145 | 126 | ${UNITY_SRC}/Animator.h | 129 | ${UNITY_SRC}/Animator.h |
2146 | 127 | ${UNITY_SRC}/DebugDBusInterface.h | 130 | ${UNITY_SRC}/DebugDBusInterface.h |
2147 | @@ -133,6 +136,11 @@ | |||
2148 | 133 | ${UNITY_SRC}/FavoriteStoreGSettings.cpp | 136 | ${UNITY_SRC}/FavoriteStoreGSettings.cpp |
2149 | 134 | ${UNITY_SRC}/FavoriteStoreGSettings.h | 137 | ${UNITY_SRC}/FavoriteStoreGSettings.h |
2150 | 135 | ${UNITY_SRC}/MockLauncherIcon.h | 138 | ${UNITY_SRC}/MockLauncherIcon.h |
2151 | 139 | ${UNITY_SRC}/MockShortcutHint.h | ||
2152 | 140 | ${UNITY_SRC}/ShortcutModel.cpp | ||
2153 | 141 | ${UNITY_SRC}/ShortcutModel.h | ||
2154 | 142 | ${UNITY_SRC}/ShortcutHintPrivate.cpp | ||
2155 | 143 | ${UNITY_SRC}/ShortcutHintPrivate.h | ||
2156 | 136 | ${UNITY_SRC}/SwitcherModel.cpp | 144 | ${UNITY_SRC}/SwitcherModel.cpp |
2157 | 137 | ${UNITY_SRC}/SwitcherModel.h | 145 | ${UNITY_SRC}/SwitcherModel.h |
2158 | 138 | ${UNITY_SRC}/Introspectable.cpp | 146 | ${UNITY_SRC}/Introspectable.cpp |
2159 | 139 | 147 | ||
2160 | === added file 'tests/test_shortcut_model.cpp' | |||
2161 | --- tests/test_shortcut_model.cpp 1970-01-01 00:00:00 +0000 | |||
2162 | +++ tests/test_shortcut_model.cpp 2012-01-13 15:39:27 +0000 | |||
2163 | @@ -0,0 +1,84 @@ | |||
2164 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
2165 | 2 | /* | ||
2166 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
2167 | 4 | * | ||
2168 | 5 | * This program is free software: you can redistribute it and/or modify | ||
2169 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
2170 | 7 | * published by the Free Software Foundation. | ||
2171 | 8 | * | ||
2172 | 9 | * This program is distributed in the hope that it will be useful, | ||
2173 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2174 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2175 | 12 | * GNU General Public License for more details. | ||
2176 | 13 | * | ||
2177 | 14 | * You should have received a copy of the GNU General Public License | ||
2178 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2179 | 16 | * | ||
2180 | 17 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
2181 | 18 | */ | ||
2182 | 19 | |||
2183 | 20 | #include <gtest/gtest.h> | ||
2184 | 21 | |||
2185 | 22 | #include "MockShortcutHint.h" | ||
2186 | 23 | #include "ShortcutModel.h" | ||
2187 | 24 | |||
2188 | 25 | using namespace unity::shortcut; | ||
2189 | 26 | |||
2190 | 27 | namespace { | ||
2191 | 28 | |||
2192 | 29 | TEST(TestShortcutModel, TestConstruction) | ||
2193 | 30 | { | ||
2194 | 31 | std::list<AbstractHint*> hints; | ||
2195 | 32 | |||
2196 | 33 | hints.push_back(new MockHint("Launcher", "", "", "Description 1", COMPIZ_KEY_OPTION, "Plugin 1", "key_option_1")); | ||
2197 | 34 | hints.push_back(new MockHint("Launcher", "", "", "Description 2", HARDCODED_OPTION, "Value 2")); | ||
2198 | 35 | hints.push_back(new MockHint("Dash", "Prefix", "Postfix", "Description 3", COMPIZ_KEY_OPTION, "Plugin 3", "key_option_3")); | ||
2199 | 36 | hints.push_back(new MockHint("Top Bar", "Prefix", "Postfix", "Description 4", HARDCODED_OPTION, "Value4")); | ||
2200 | 37 | |||
2201 | 38 | Model model(hints); | ||
2202 | 39 | |||
2203 | 40 | EXPECT_EQ(model.categories().size(), 3); | ||
2204 | 41 | EXPECT_EQ(model.hints()["Launcher"].size(), 2); | ||
2205 | 42 | EXPECT_EQ(model.hints()["Dash"].size(), 1); | ||
2206 | 43 | EXPECT_EQ(model.hints()["Top Bar"].size(), 1); | ||
2207 | 44 | EXPECT_EQ(model.hints()["Unity"].size(), 0); | ||
2208 | 45 | } | ||
2209 | 46 | |||
2210 | 47 | TEST(TestShortcutModel, TestFill) | ||
2211 | 48 | { | ||
2212 | 49 | std::list<AbstractHint*> hints; | ||
2213 | 50 | |||
2214 | 51 | hints.push_back(new MockHint("Launcher", "", "", "Description 1", COMPIZ_KEY_OPTION, "Plugin 1", "key_option_1")); | ||
2215 | 52 | hints.push_back(new MockHint("Launcher", "", "", "Description 2", HARDCODED_OPTION, "Value 2")); | ||
2216 | 53 | hints.push_back(new MockHint("Dash", "Prefix", "Postfix", "Description 3", COMPIZ_KEY_OPTION, "Plugin 3", "key_option_3")); | ||
2217 | 54 | hints.push_back(new MockHint("Top Bar", "Prefix", "Postfix", "Description 4", HARDCODED_OPTION, "Value 4")); | ||
2218 | 55 | |||
2219 | 56 | Model model(hints); | ||
2220 | 57 | |||
2221 | 58 | model.Fill(); | ||
2222 | 59 | |||
2223 | 60 | // We cannot test CompOption here... :/ | ||
2224 | 61 | EXPECT_EQ(model.hints()["Launcher"].front()->value(), "Plugin 1-key_option_1"); | ||
2225 | 62 | EXPECT_EQ(model.hints()["Launcher"].back()->value(), "Value 2"); | ||
2226 | 63 | EXPECT_EQ(model.hints()["Dash"].front()->value(),"Plugin 3-key_option_3"); | ||
2227 | 64 | EXPECT_EQ(model.hints()["Top Bar"].front()->value(), "Value 4"); | ||
2228 | 65 | } | ||
2229 | 66 | |||
2230 | 67 | TEST(TestShortcutModel, TestProperty) | ||
2231 | 68 | { | ||
2232 | 69 | std::list<AbstractHint*> hints; | ||
2233 | 70 | |||
2234 | 71 | hints.push_back(new MockHint("Launcher", "Prefix1", "Postfix1", "Description1", COMPIZ_KEY_OPTION, "Plugin1", "key_option1")); | ||
2235 | 72 | |||
2236 | 73 | Model model(hints); | ||
2237 | 74 | |||
2238 | 75 | EXPECT_EQ(model.hints()["Launcher"].front()->category(), "Launcher"); | ||
2239 | 76 | EXPECT_EQ(model.hints()["Launcher"].front()->prefix(), "Prefix1"); | ||
2240 | 77 | EXPECT_EQ(model.hints()["Launcher"].front()->postfix(), "Postfix1"); | ||
2241 | 78 | EXPECT_EQ(model.hints()["Launcher"].front()->description(), "Description1"); | ||
2242 | 79 | EXPECT_EQ(model.hints()["Launcher"].front()->type(), COMPIZ_KEY_OPTION); | ||
2243 | 80 | EXPECT_EQ(model.hints()["Launcher"].front()->arg1(), "Plugin1"); | ||
2244 | 81 | EXPECT_EQ(model.hints()["Launcher"].front()->arg2(), "key_option1"); | ||
2245 | 82 | } | ||
2246 | 83 | |||
2247 | 84 | } // anonymouse namespace | ||
2248 | 0 | 85 | ||
2249 | === added file 'tests/test_shortcut_private.cpp' | |||
2250 | --- tests/test_shortcut_private.cpp 1970-01-01 00:00:00 +0000 | |||
2251 | +++ tests/test_shortcut_private.cpp 2012-01-13 15:39:27 +0000 | |||
2252 | @@ -0,0 +1,74 @@ | |||
2253 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
2254 | 2 | /* | ||
2255 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
2256 | 4 | * | ||
2257 | 5 | * This program is free software: you can redistribute it and/or modify | ||
2258 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
2259 | 7 | * published by the Free Software Foundation. | ||
2260 | 8 | * | ||
2261 | 9 | * This program is distributed in the hope that it will be useful, | ||
2262 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2263 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2264 | 12 | * GNU General Public License for more details. | ||
2265 | 13 | * | ||
2266 | 14 | * You should have received a copy of the GNU General Public License | ||
2267 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2268 | 16 | * | ||
2269 | 17 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
2270 | 18 | */ | ||
2271 | 19 | |||
2272 | 20 | #include <gtest/gtest.h> | ||
2273 | 21 | |||
2274 | 22 | #include "ShortcutHintPrivate.h" | ||
2275 | 23 | |||
2276 | 24 | using namespace unity::shortcut::impl; | ||
2277 | 25 | |||
2278 | 26 | namespace { | ||
2279 | 27 | |||
2280 | 28 | TEST(TestShortcutHintPrivate, TestFixShortcutFormatCorrect) | ||
2281 | 29 | { | ||
2282 | 30 | EXPECT_EQ(FixShortcutFormat("Super"), "Super"); | ||
2283 | 31 | EXPECT_EQ(FixShortcutFormat("Super + A"), "Super + A"); | ||
2284 | 32 | } | ||
2285 | 33 | |||
2286 | 34 | |||
2287 | 35 | TEST(TestShortcutHintPrivate, TestFixShortcutFormatLT) | ||
2288 | 36 | { | ||
2289 | 37 | EXPECT_EQ(FixShortcutFormat("<Super"), "Super"); | ||
2290 | 38 | EXPECT_EQ(FixShortcutFormat("<Super + <Alt"), "Super + Alt"); | ||
2291 | 39 | } | ||
2292 | 40 | |||
2293 | 41 | TEST(TestShortcutHintPrivate, TestFixShortcutFormatGT) | ||
2294 | 42 | { | ||
2295 | 43 | EXPECT_EQ(FixShortcutFormat("Super>"), "Super"); | ||
2296 | 44 | EXPECT_EQ(FixShortcutFormat("Super>A"), "Super + A"); | ||
2297 | 45 | EXPECT_EQ(FixShortcutFormat("Super>Alt>A"), "Super + Alt + A"); | ||
2298 | 46 | } | ||
2299 | 47 | |||
2300 | 48 | TEST(TestShortcutHintPrivate, TestFixShortcutComplete) | ||
2301 | 49 | { | ||
2302 | 50 | EXPECT_EQ(FixShortcutFormat("Super"), "Super"); | ||
2303 | 51 | EXPECT_EQ(FixShortcutFormat("Super + A"), "Super + A"); | ||
2304 | 52 | EXPECT_EQ(FixShortcutFormat("<Super>"), "Super"); | ||
2305 | 53 | EXPECT_EQ(FixShortcutFormat("<Super>A"), "Super + A"); | ||
2306 | 54 | EXPECT_EQ(FixShortcutFormat("<Super><Alt>A"), "Super + Alt + A"); | ||
2307 | 55 | } | ||
2308 | 56 | |||
2309 | 57 | TEST(TestShortcutHintPrivate, TestProperCase) | ||
2310 | 58 | { | ||
2311 | 59 | EXPECT_EQ(ProperCase("super"), "Super"); | ||
2312 | 60 | EXPECT_EQ(ProperCase("sUper"), "SUper"); | ||
2313 | 61 | EXPECT_EQ(ProperCase("super + a"), "Super + A"); | ||
2314 | 62 | EXPECT_EQ(ProperCase("super+a"), "Super+A"); | ||
2315 | 63 | EXPECT_EQ(ProperCase("<super><alt>a"), "<Super><Alt>A"); | ||
2316 | 64 | } | ||
2317 | 65 | |||
2318 | 66 | TEST(TestShortcutHintPrivate, TestFixMouseShortcut) | ||
2319 | 67 | { | ||
2320 | 68 | EXPECT_EQ(FixMouseShortcut("Super<Button1>"), "Super<Left Mouse>"); | ||
2321 | 69 | EXPECT_EQ(FixMouseShortcut("Super<Button2>"), "Super<Middle Mouse>"); | ||
2322 | 70 | EXPECT_EQ(FixMouseShortcut("Super<Button3>"), "Super<Right Mouse>"); | ||
2323 | 71 | |||
2324 | 72 | } | ||
2325 | 73 | |||
2326 | 74 | } // anonymouse namespace |
I've just looked at few things but it seem good, however remember to unregister the ubus controller (i.e as done in lp:~vanvugt/unity/fix-887465-trunk ) in ~Controller and to use g_markup_ escape_ text ;).