Merge lp:~azzar1/nux/rm-coverflow into lp:nux
- rm-coverflow
- Merge into trunk
Proposed by
Andrea Azzarone
Status: | Merged |
---|---|
Approved by: | Marco Trevisan (Treviño) |
Approved revision: | 864 |
Merged at revision: | 870 |
Proposed branch: | lp:~azzar1/nux/rm-coverflow |
Merge into: | lp:nux |
Prerequisite: | lp:~azzar1/nux/rm-bw-loop |
Diff against target: |
1805 lines (+1/-1713) 11 files modified
.bzrignore (+0/-1) Nux/Coverflow.cpp (+0/-1154) Nux/Coverflow.h (+0/-103) Nux/CoverflowItem.cpp (+0/-30) Nux/CoverflowItem.h (+0/-49) Nux/CoverflowModel.cpp (+0/-141) Nux/CoverflowModel.h (+0/-70) Nux/Makefile.am (+0/-6) data/Makefile.am (+1/-3) examples/Makefile.am (+0/-4) examples/coverflow.cpp (+0/-152) |
To merge this branch: | bzr merge lp:~azzar1/nux/rm-coverflow |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Trevisan (Treviño) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+266096@code.launchpad.net |
Commit message
Remove coverflow code.
Description of the change
Remove coverflow code.
To post a comment you must log in.
lp:~azzar1/nux/rm-coverflow
updated
- 864. By Andrea Azzarone <email address hidden>
-
Remove coverflow.
oval-shadow. png.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Approve
(continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) : | # |
review:
Approve
lp:~azzar1/nux/rm-coverflow
updated
- 865. By Andrea Azzarone
-
Merge with trunk.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2012-11-05 21:31:06 +0000 |
3 | +++ .bzrignore 2015-10-28 09:38:25 +0000 |
4 | @@ -30,7 +30,6 @@ |
5 | examples/canvas |
6 | examples/checkbox |
7 | examples/combobox |
8 | -examples/coverflow |
9 | examples/focus |
10 | examples/gestures |
11 | examples/gridlayout |
12 | |
13 | === removed file 'Nux/Coverflow.cpp' |
14 | --- Nux/Coverflow.cpp 2015-02-16 17:11:44 +0000 |
15 | +++ Nux/Coverflow.cpp 1970-01-01 00:00:00 +0000 |
16 | @@ -1,1154 +0,0 @@ |
17 | -// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
18 | -/* |
19 | - * Copyright (C) 2012 Canonical Ltd |
20 | - * |
21 | - * This program is free software: you can redistribute it and/or modify |
22 | - * it under the terms of the GNU General Public License version 3 as |
23 | - * published by the Free Software Foundation. |
24 | - * |
25 | - * This program is distributed in the hope that it will be useful, |
26 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
27 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
28 | - * GNU General Public License for more details. |
29 | - * |
30 | - * You should have received a copy of the GNU General Public License |
31 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
32 | - * |
33 | - * Authored by: Jason Smith <jason.smith@canonical.com> |
34 | - * Jay Taoko <jay.taoko@canonical.com> |
35 | - */ |
36 | - |
37 | -#include "Nux.h" |
38 | -#include "HLayout.h" |
39 | -#include "StaticText.h" |
40 | -#include "TextLoader.h" |
41 | - |
42 | -#include "NuxGraphics/GraphicsDisplay.h" |
43 | -#include "NuxGraphics/GLShader.h" |
44 | -#include "NuxGraphics/GpuDevice.h" |
45 | -#include "NuxGraphics/GLDeviceObjects.h" |
46 | -#include "NuxGraphics/GLShader.h" |
47 | -#include "NuxGraphics/GraphicsEngine.h" |
48 | - |
49 | -#include "NuxGraphics/IOpenGLBaseTexture.h" |
50 | - |
51 | - |
52 | -#include <glib.h> |
53 | - |
54 | -#include "Coverflow.h" |
55 | - |
56 | - |
57 | -namespace nux |
58 | -{ |
59 | -namespace |
60 | -{ |
61 | - float EaseSin(float x) |
62 | - { |
63 | - return sin(x * nux::constants::pi / 2.0f); |
64 | - } |
65 | - |
66 | - float RoundFloor(float x) |
67 | - { |
68 | - return std::floor(x + 0.5f); |
69 | - } |
70 | - |
71 | - std::string texture_vertex_code = "attribute vec4 iVertex; \n\ |
72 | - attribute vec4 iTextureCoord0; \n\ |
73 | - attribute vec4 iVertexColor; \n\ |
74 | - uniform mat4 ViewProjectionMatrix; \n\ |
75 | - varying vec4 varyTexCoord0; \n\ |
76 | - varying vec4 varyVertexColor; \n\ |
77 | - void main() \n\ |
78 | - { \n\ |
79 | - gl_Position = ViewProjectionMatrix * (iVertex); \n\ |
80 | - varyTexCoord0 = iTextureCoord0; \n\ |
81 | - varyVertexColor = iVertexColor; \n\ |
82 | - }"; |
83 | - |
84 | - std::string texture_fragment_code = "varying vec4 varyTexCoord0; \n\ |
85 | - varying vec4 varyVertexColor; \n\ |
86 | - uniform sampler2D TextureObject0; \n\ |
87 | - void main() \n\ |
88 | - { \n\ |
89 | - vec4 v = texture2D(TextureObject0, varyTexCoord0.xy); \n\ |
90 | - gl_FragColor = v*varyVertexColor; \n\ |
91 | - }"; |
92 | - |
93 | - std::string single_color_fragment_code = "varying vec4 varyTexCoord0; \n\ |
94 | - varying vec4 varyVertexColor; \n\ |
95 | - uniform sampler2D TextureObject0; \n\ |
96 | - void main() \n\ |
97 | - { \n\ |
98 | - gl_FragColor = varyVertexColor; \n\ |
99 | - }"; |
100 | - struct Vec4_ |
101 | - { |
102 | - float x; |
103 | - float y; |
104 | - float z; |
105 | - float rot; |
106 | - }; |
107 | - |
108 | - struct VelocityEvent |
109 | - { |
110 | - float velocity; |
111 | - gint64 time; |
112 | - }; |
113 | - |
114 | - struct Cover |
115 | - { |
116 | - Vec4_ position; |
117 | - float opacity; |
118 | - bool selected; |
119 | - bool mouse_over; |
120 | - CoverflowItem::Ptr item; |
121 | - }; |
122 | - |
123 | - typedef std::vector<Cover> CoverList; |
124 | -} |
125 | -} |
126 | - |
127 | -namespace nux |
128 | -{ |
129 | - struct Coverflow::Impl : public sigc::trackable |
130 | - { |
131 | - Impl(Coverflow* parent); |
132 | - ~Impl(); |
133 | - |
134 | - void HandleKeyDown(unsigned long eventType, |
135 | - unsigned long keysym, |
136 | - unsigned long state, |
137 | - const char* character, |
138 | - unsigned short keyCount); |
139 | - void HandleKeyUp(unsigned int keysym, |
140 | - unsigned long x11_key_code, |
141 | - unsigned long special_keys_state); |
142 | - |
143 | - void HandleMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags); |
144 | - void HandleMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags); |
145 | - void HandleMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags); |
146 | - void HandleMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags); |
147 | - void HandleMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); |
148 | - void HandleMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); |
149 | - void HandleMouseClick(int x, int y, unsigned long button_flags, unsigned long key_flags); |
150 | - void HandleMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags); |
151 | - void HandleGeometryChange(Area* area, Geometry geo); |
152 | - |
153 | - void DrawCover(nux::GraphicsEngine& graphics_engine, nux::DrawAreaContext &ctx, Cover const& cover); |
154 | - void RenderCover(nux::GraphicsEngine& graphics_engine, Cover const& cover, int width, int height, nux::Matrix4 combined_matrix); |
155 | - void LoadVertexBuffer(int VertexLocation, int TextureCoord0Location, int VertexColorLocation, float* VtxBuffer); |
156 | - |
157 | - CoverList GetCoverList(float animation_progress, gint64 timestep); |
158 | - |
159 | - void OnItemAdded(CoverflowModel* owner, CoverflowItem::Ptr new_item); |
160 | - void OnItemRemoved(CoverflowModel* owner, CoverflowItem::Ptr old_item); |
161 | - void OnSelectionChanged(CoverflowModel* owner, CoverflowItem::Ptr selection); |
162 | - |
163 | - void SetPosition(float position, bool animate); |
164 | - |
165 | - void UpdateModelSelection(); |
166 | - |
167 | - float GetCurrentVelocity(int ms); |
168 | - |
169 | - void MaybeQueueDraw(); |
170 | - |
171 | - bool CoverAtPoint(int x, int y, Cover& out_cover); |
172 | - void Get3DBoundingBox(float distance_from_camera, nux::Point2& top_left_corner, nux::Point2& bottom_right_corner); |
173 | - void GetCoverScreenCoord(Cover const& cover, nux::Vector4& P0, nux::Vector4& P1, nux::Vector4& P2, nux::Vector4& P3); |
174 | - |
175 | - bool TestMouseOverCover(int x, int y, Cover const& cover); |
176 | - bool TestCoverVisible(Cover const& cover); |
177 | - |
178 | - static gboolean OnAnimationTimeout(gpointer data); |
179 | - static gboolean OnVelocityTimeout(gpointer data); |
180 | - |
181 | - nux::Vector3 camera_position_; |
182 | - nux::Vector3 camera_rotation_; |
183 | - |
184 | - nux::ObjectPtr<nux::IOpenGLShaderProgram> cover_shader_program_; |
185 | - nux::ObjectPtr<nux::IOpenGLShaderProgram> highlight_shader_program_; |
186 | - |
187 | - nux::Matrix4 perspective_; |
188 | - nux::Matrix4 modelview_; |
189 | - |
190 | - std::vector<VelocityEvent> velocity_events_; |
191 | - |
192 | - Coverflow* parent_; |
193 | - guint animation_handle_; |
194 | - float camera_drift_factor_; |
195 | - gint64 last_draw_time_; |
196 | - float last_position_; |
197 | - bool mouse_inside_view_; |
198 | - float position_; |
199 | - gint64 position_set_time_; |
200 | - float saved_position_; |
201 | - float velocity_; |
202 | - guint velocity_handle_; |
203 | - nux::Point2 mouse_down_position_; |
204 | - nux::Point2 mouse_position_; |
205 | - CoverList last_covers_; |
206 | - float cover_width_in_3d_space_; |
207 | - float near_clip_plan_; |
208 | - float far_clip_plan_; |
209 | - TextLoader text_loader_; |
210 | - ObjectPtr<IOpenGLBaseTexture> drop_shadow_texture_; |
211 | - |
212 | - sigc::connection model_selection_connection_; |
213 | - }; |
214 | - |
215 | - Coverflow::Impl::Impl(Coverflow* parent) |
216 | - : parent_(parent) |
217 | - , animation_handle_(0) |
218 | - , camera_drift_factor_(0) |
219 | - , last_draw_time_(0) |
220 | - , last_position_(0) |
221 | - , mouse_inside_view_(false) |
222 | - , position_(0) |
223 | - , position_set_time_(0) |
224 | - , saved_position_(0) |
225 | - , velocity_(0) |
226 | - , velocity_handle_(0) |
227 | - , cover_width_in_3d_space_(1.0f) |
228 | - , near_clip_plan_(1.0f) |
229 | - , far_clip_plan_(200.0f) |
230 | - { |
231 | - mouse_position_ = nux::Point2(0, 0); |
232 | - |
233 | - parent_->key_down.connect(sigc::mem_fun(this, &Impl::HandleKeyDown)); |
234 | - parent_->key_up.connect(sigc::mem_fun(this, &Impl::HandleKeyUp)); |
235 | - parent_->mouse_move.connect(sigc::mem_fun(this, &Impl::HandleMouseMove)); |
236 | - parent_->mouse_enter.connect(sigc::mem_fun(this, &Impl::HandleMouseEnter)); |
237 | - parent_->mouse_leave.connect(sigc::mem_fun(this, &Impl::HandleMouseLeave)); |
238 | - parent_->mouse_click.connect(sigc::mem_fun(this, &Impl::HandleMouseClick)); |
239 | - parent_->mouse_drag.connect(sigc::mem_fun(this, &Impl::HandleMouseDrag)); |
240 | - parent_->mouse_up.connect(sigc::mem_fun(this, &Impl::HandleMouseUp)); |
241 | - parent_->mouse_down.connect(sigc::mem_fun(this, &Impl::HandleMouseDown)); |
242 | - parent_->mouse_wheel.connect(sigc::mem_fun(this, &Impl::HandleMouseWheel)); |
243 | - parent_->geometry_changed.connect(sigc::mem_fun(this, &Impl::HandleGeometryChange)); |
244 | - |
245 | - |
246 | - camera_position_.x = 0.0f; |
247 | - camera_position_.y = 0.0f; |
248 | - camera_position_.z = 5.0f; |
249 | - camera_rotation_.x = 0.0f; |
250 | - camera_rotation_.y = 0.0f; |
251 | - camera_rotation_.z = 0.0f; |
252 | - |
253 | - // Create a shader to render a textured quad. |
254 | - { |
255 | - // Create the GLSL shader objects: Vertex, Fragment and the Program. |
256 | - // The Program object act as a container for the Vertex and Fragment object. |
257 | - nux::ObjectPtr<nux::IOpenGLPixelShader> fragment_shader_prog_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreatePixelShader(); |
258 | - nux::ObjectPtr<nux::IOpenGLVertexShader> vertex_shader_prog_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateVertexShader(); |
259 | - cover_shader_program_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateShaderProgram(); |
260 | - |
261 | - // Set the actual shader code into the Vertex and Fragment objects. |
262 | - vertex_shader_prog_->SetShaderCode(texture_vertex_code.c_str()); |
263 | - fragment_shader_prog_->SetShaderCode(texture_fragment_code.c_str()); |
264 | - |
265 | - // Remove all Vertex and Fragment objects from the Program (Not necessary here but do it anyway). |
266 | - cover_shader_program_->ClearShaderObjects(); |
267 | - // Add the Vertex and Fragment objects to the Program object. |
268 | - cover_shader_program_->AddShaderObject(vertex_shader_prog_); |
269 | - cover_shader_program_->AddShaderObject(fragment_shader_prog_); |
270 | - // Link |
271 | - cover_shader_program_->Link(); |
272 | - |
273 | - // The shaders have been loaded into the program. They can be discarded. |
274 | - vertex_shader_prog_.Release(); |
275 | - fragment_shader_prog_.Release(); |
276 | - } |
277 | - |
278 | - // Create a shader to render a the cover highlight. |
279 | - { |
280 | - // Create the GLSL shader objects: Vertex, Fragment and the Program. |
281 | - // The Program object act as a container for the Vertex and Fragment object. |
282 | - nux::ObjectPtr<nux::IOpenGLPixelShader> fragment_shader_prog_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreatePixelShader(); |
283 | - nux::ObjectPtr<nux::IOpenGLVertexShader> vertex_shader_prog_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateVertexShader(); |
284 | - highlight_shader_program_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateShaderProgram(); |
285 | - |
286 | - // Set the actual shader code into the Vertex and Fragment objects. |
287 | - vertex_shader_prog_->SetShaderCode(texture_vertex_code.c_str()); |
288 | - fragment_shader_prog_->SetShaderCode(single_color_fragment_code.c_str()); |
289 | - |
290 | - // Remove all Vertex and Fragment objects from the Program (Not necessary here but do it anyway). |
291 | - highlight_shader_program_->ClearShaderObjects(); |
292 | - // Add the Vertex and Fragment objects to the Program object. |
293 | - highlight_shader_program_->AddShaderObject(vertex_shader_prog_); |
294 | - highlight_shader_program_->AddShaderObject(fragment_shader_prog_); |
295 | - // Link |
296 | - highlight_shader_program_->Link(); |
297 | - |
298 | - // The shaders have been loaded into the program. They can be discarded. |
299 | - vertex_shader_prog_.Release(); |
300 | - fragment_shader_prog_.Release(); |
301 | - } |
302 | - |
303 | - text_loader_.font_size = 10; |
304 | - |
305 | - std::string resource_path = NUX_FIND_RESOURCE_LOCATION_NOFAIL("UITextures/coverflow.oval-shadow.png"); |
306 | - BaseTexture* texture = LoadTextureFromFile(resource_path.c_str()); |
307 | - drop_shadow_texture_ = texture->GetDeviceTexture(); |
308 | - texture->UnReference(); |
309 | - |
310 | - text_loader_.lines = 2; |
311 | - } |
312 | - |
313 | - Coverflow::Impl::~Impl() |
314 | - { |
315 | - if (animation_handle_) |
316 | - { |
317 | - g_source_remove(animation_handle_); |
318 | - animation_handle_ = 0; |
319 | - } |
320 | - } |
321 | - |
322 | - void Coverflow::Impl::UpdateModelSelection() |
323 | - { |
324 | - model_selection_connection_.disconnect(); |
325 | - parent_->model()->SetSelection((size_t)RoundFloor(position_)); |
326 | - model_selection_connection_ = parent_->model()->selection_changed.connect(sigc::mem_fun(this, &Coverflow::Impl::OnSelectionChanged)); |
327 | - } |
328 | - |
329 | - void Coverflow::Impl::Get3DBoundingBox(float distance_from_camera, nux::Point2& top_left_corner, nux::Point2& bottom_right_corner) |
330 | - { |
331 | - int width = parent_->GetBaseWidth(); |
332 | - int height = parent_->GetBaseHeight(); |
333 | - |
334 | - top_left_corner.y = std::tan(DEGTORAD(parent_->fov() * 0.5f)) * distance_from_camera; |
335 | - top_left_corner.x = -top_left_corner.y * (width / (float)height); |
336 | - |
337 | - bottom_right_corner.x = -top_left_corner.x; |
338 | - bottom_right_corner.y = -top_left_corner.y; |
339 | - } |
340 | - |
341 | - void Coverflow::Impl::GetCoverScreenCoord(Cover const& cover, nux::Vector4& out_p0, nux::Vector4& out_p1, nux::Vector4& out_p2, nux::Vector4& out_p3) |
342 | - { |
343 | - if (cover.item->GetTexture().IsNull()) |
344 | - return; |
345 | - |
346 | - int width = parent_->GetBaseWidth(); |
347 | - int height = parent_->GetBaseHeight(); |
348 | - |
349 | - ObjectPtr<IOpenGLBaseTexture> texture = cover.item->GetTexture()->GetDeviceTexture(); |
350 | - float ratio = texture->GetWidth()/(float)texture->GetHeight(); |
351 | - |
352 | - float fx = cover_width_in_3d_space_/2.0f; |
353 | - float fy_top = cover.position.y + (cover_width_in_3d_space_) * (1.0f/ratio); |
354 | - float fy_bot = cover.position.y; |
355 | - |
356 | - if (parent_->true_perspective) |
357 | - { |
358 | - modelview_ = nux::Matrix4::TRANSLATE(-camera_position_.x, -camera_position_.y, -camera_position_.z) * |
359 | - nux::Matrix4::ROTATEX(DEGTORAD(-camera_rotation_.x)) * |
360 | - nux::Matrix4::ROTATEY(DEGTORAD(-camera_rotation_.y)) * |
361 | - nux::Matrix4::ROTATEZ(DEGTORAD(-camera_rotation_.z)) * |
362 | - nux::Matrix4::TRANSLATE(cover.position.x, 0.0f, cover.position.z); |
363 | - } |
364 | - else |
365 | - { |
366 | - modelview_ = nux::Matrix4::TRANSLATE(-camera_position_.x, -camera_position_.y, -camera_position_.z) * |
367 | - nux::Matrix4::ROTATEX(DEGTORAD(-camera_rotation_.x)) * |
368 | - nux::Matrix4::ROTATEY(DEGTORAD(-camera_rotation_.y)) * |
369 | - nux::Matrix4::ROTATEZ(DEGTORAD(-camera_rotation_.z)) * |
370 | - nux::Matrix4::TRANSLATE(0.0f, 0.0f, cover.position.z); |
371 | - } |
372 | - |
373 | - nux::Matrix4 m = nux::Matrix4::ROTATEY(DEGTORAD(cover.position.rot)); |
374 | - nux::Matrix4 combined_matrix = perspective_ * modelview_ * m; |
375 | - |
376 | - nux::Vector4 p0(-fx, fy_top, 0.0f, 1.0f); |
377 | - nux::Vector4 p1(-fx, fy_bot, 0.0f, 1.0f); |
378 | - nux::Vector4 p2(fx, fy_bot, 0.0f, 1.0f); |
379 | - nux::Vector4 p3(fx, fy_top, 0.0f, 1.0f); |
380 | - |
381 | - nux::Vector4 p0_proj = combined_matrix * p0; |
382 | - nux::Vector4 p1_proj = combined_matrix * p1; |
383 | - nux::Vector4 p2_proj = combined_matrix * p2; |
384 | - nux::Vector4 p3_proj = combined_matrix * p3; |
385 | - |
386 | - p0_proj.x = p0_proj.x/p0_proj.w; p0_proj.y = p0_proj.y/p0_proj.w; p0_proj.z = p0_proj.z/p0_proj.w; |
387 | - p1_proj.x = p1_proj.x/p1_proj.w; p1_proj.y = p1_proj.y/p1_proj.w; p1_proj.z = p1_proj.z/p1_proj.w; |
388 | - p2_proj.x = p2_proj.x/p2_proj.w; p2_proj.y = p2_proj.y/p2_proj.w; p2_proj.z = p2_proj.z/p2_proj.w; |
389 | - p3_proj.x = p3_proj.x/p3_proj.w; p3_proj.y = p3_proj.y/p3_proj.w; p3_proj.z = p3_proj.z/p3_proj.w; |
390 | - |
391 | - p0_proj.x = width * (p0_proj.x + 1.0f)/2.0f; |
392 | - p1_proj.x = width * (p1_proj.x + 1.0f)/2.0f; |
393 | - p2_proj.x = width * (p2_proj.x + 1.0f)/2.0f; |
394 | - p3_proj.x = width * (p3_proj.x + 1.0f)/2.0f; |
395 | - |
396 | - p0_proj.y = -height * (p0_proj.y - 1.0f)/2.0f; |
397 | - p1_proj.y = -height * (p1_proj.y - 1.0f)/2.0f; |
398 | - p2_proj.y = -height * (p2_proj.y - 1.0f)/2.0f; |
399 | - p3_proj.y = -height * (p3_proj.y - 1.0f)/2.0f; |
400 | - |
401 | - float scalar = 0.0f; |
402 | - |
403 | - if (!parent_->true_perspective) |
404 | - { |
405 | - nux::Point2 top_left, bottom_right; |
406 | - Get3DBoundingBox(camera_position_.z, top_left, bottom_right); |
407 | - scalar = parent_->GetGeometry().width / (bottom_right.x - top_left.x); |
408 | - } |
409 | - |
410 | - out_p0.x = p0_proj.x + cover.position.x * scalar; out_p0.y = p0_proj.y; |
411 | - out_p1.x = p1_proj.x + cover.position.x * scalar; out_p1.y = p1_proj.y; |
412 | - out_p2.x = p2_proj.x + cover.position.x * scalar; out_p2.y = p2_proj.y; |
413 | - out_p3.x = p3_proj.x + cover.position.x * scalar; out_p3.y = p3_proj.y; |
414 | - } |
415 | - |
416 | - bool Coverflow::Impl::TestMouseOverCover(int x, int y, Cover const& cover) |
417 | - { |
418 | - nux::Vector4 P0; |
419 | - nux::Vector4 P1; |
420 | - nux::Vector4 P2; |
421 | - nux::Vector4 P3; |
422 | - |
423 | - GetCoverScreenCoord(cover, P0, P1, P2, P3); |
424 | - // The polygon is convex and P0->P1->P2->P3 follows the right hand rule |
425 | - bool test01 = ((y - P0.y) * (P1.x - P0.x) - (x - P0.x) * (P1.y - P0.y)) <= 0.0f; |
426 | - bool test12 = ((y - P1.y) * (P2.x - P1.x) - (x - P1.x) * (P2.y - P1.y)) <= 0.0f; |
427 | - bool test23 = ((y - P2.y) * (P3.x - P2.x) - (x - P2.x) * (P3.y - P2.y)) <= 0.0f; |
428 | - bool test30 = ((y - P3.y) * (P0.x - P3.x) - (x - P3.x) * (P0.y - P3.y)) <= 0.0f; |
429 | - |
430 | - if (test01 && test12 && test23 && test30) |
431 | - { |
432 | - return true; |
433 | - } |
434 | - |
435 | - return false; |
436 | - } |
437 | - |
438 | - bool Coverflow::Impl::TestCoverVisible(Cover const& cover) |
439 | - { |
440 | - int width = parent_->GetBaseWidth(); |
441 | - int height = parent_->GetBaseHeight(); |
442 | - |
443 | - nux::Vector4 P0; |
444 | - nux::Vector4 P1; |
445 | - nux::Vector4 P2; |
446 | - nux::Vector4 P3; |
447 | - |
448 | - GetCoverScreenCoord(cover, P0, P1, P2, P3); |
449 | - bool test0 = ((P0.x >= 0) && (P0.x < width)) && ((P0.y >= 0) && (P0.y < height)); |
450 | - bool test1 = ((P1.x >= 0) && (P1.x < width)) && ((P1.y >= 0) && (P1.y < height)); |
451 | - bool test2 = ((P2.x >= 0) && (P2.x < width)) && ((P2.y >= 0) && (P2.y < height)); |
452 | - bool test3 = ((P3.x >= 0) && (P3.x < width)) && ((P3.y >= 0) && (P3.y < height)); |
453 | - |
454 | - if (test0 || test1 || test2 || test3) |
455 | - { |
456 | - // The quad is convex. If any of its vertices is inside the view, then the quad is visible. |
457 | - return true; |
458 | - } |
459 | - |
460 | - return false; |
461 | - } |
462 | - |
463 | - bool Coverflow::Impl::CoverAtPoint(int /* x */, int /* y */, Cover& out_cover) |
464 | - { |
465 | - Cover best; |
466 | - |
467 | - CoverList::iterator it; |
468 | - for (it = last_covers_.begin(); it != last_covers_.end(); ++it) |
469 | - { |
470 | - Cover cover = *it; |
471 | - if (cover.item->GetTexture().IsNull()) |
472 | - continue; |
473 | - if (cover.position.rot > 0 && TestMouseOverCover(mouse_position_.x, mouse_position_.y, cover)) |
474 | - { |
475 | - best = cover; |
476 | - } |
477 | - } |
478 | - |
479 | - CoverList::reverse_iterator rit; |
480 | - for (rit = last_covers_.rbegin(); rit != last_covers_.rend(); ++rit) |
481 | - { |
482 | - Cover cover = *rit; |
483 | - if (cover.item->GetTexture().IsNull()) |
484 | - continue; |
485 | - if (cover.position.rot <= 0 && TestMouseOverCover(mouse_position_.x, mouse_position_.y, cover)) |
486 | - { |
487 | - best = cover; |
488 | - } |
489 | - } |
490 | - |
491 | - if (best.item) |
492 | - { |
493 | - out_cover = best; |
494 | - return true; |
495 | - } |
496 | - |
497 | - return false; |
498 | - } |
499 | - |
500 | - void Coverflow::Impl::HandleKeyDown(unsigned long /* eventType */ , /*event type*/ |
501 | - unsigned long keysym , /*event keysym*/ |
502 | - unsigned long /* state */ , /*event state*/ |
503 | - const char* /* character */ , /*character*/ |
504 | - unsigned short /* keyCount */ /*key repeat count*/) |
505 | - { |
506 | - switch (keysym) |
507 | - { |
508 | - case NUX_VK_LEFT: |
509 | - parent_->model()->SelectPrev(); |
510 | - break; |
511 | - case NUX_VK_RIGHT: |
512 | - parent_->model()->SelectNext(); |
513 | - break; |
514 | - |
515 | - } |
516 | - } |
517 | - |
518 | - void Coverflow::Impl::HandleMouseClick(int x, int y, unsigned long button_flags, unsigned long /* key_flags */) |
519 | - { |
520 | - if (std::abs(mouse_down_position_.x - x) > 10 || std::abs(mouse_down_position_.y - y) > 10) |
521 | - return; |
522 | - |
523 | - Cover best; |
524 | - if (CoverAtPoint(x, y, best)) |
525 | - { |
526 | - if (std::abs(best.position.rot) <= .001) |
527 | - { |
528 | - best.item->Activate(nux::GetEventButton(button_flags)); |
529 | - } |
530 | - else |
531 | - { |
532 | - SetPosition((float)parent_->model()->IndexOf(best.item), true); |
533 | - UpdateModelSelection(); |
534 | - } |
535 | - } |
536 | - } |
537 | - |
538 | - void Coverflow::Impl::HandleKeyUp(unsigned int keysym, |
539 | - unsigned long /* x11_key_code */, |
540 | - unsigned long /* special_keys_state */) |
541 | - { |
542 | - switch (keysym) |
543 | - { |
544 | - case NUX_VK_ENTER: |
545 | - case NUX_KP_ENTER: |
546 | - { |
547 | - Cover best; |
548 | - if (CoverAtPoint(0, 0, best)) |
549 | - best.item->Activate(1); |
550 | - break; |
551 | - } |
552 | - default: |
553 | - break; |
554 | - } |
555 | - } |
556 | - |
557 | - void Coverflow::Impl::HandleMouseMove(int x, int y, int /* dx */, int /* dy */, unsigned long /* button_flags */, unsigned long /* key_flags */) |
558 | - { |
559 | - mouse_position_.x = x; |
560 | - mouse_position_.y = y; |
561 | - MaybeQueueDraw(); |
562 | - } |
563 | - |
564 | - void Coverflow::Impl::HandleMouseEnter(int x, int y, unsigned long /* button_flags */, unsigned long /* key_flags */) |
565 | - { |
566 | - mouse_position_.x = x; |
567 | - mouse_position_.y = y; |
568 | - mouse_inside_view_ = true; |
569 | - MaybeQueueDraw(); |
570 | - } |
571 | - |
572 | - void Coverflow::Impl::HandleMouseLeave(int /* x */, int /* y */, unsigned long /* button_flags */, unsigned long /* key_flags */) |
573 | - { |
574 | - mouse_position_.x = 0xFFFFFFFF; |
575 | - mouse_position_.y = 0xFFFFFFFF; |
576 | - mouse_inside_view_ = false; |
577 | - MaybeQueueDraw(); |
578 | - } |
579 | - |
580 | - void Coverflow::Impl::HandleMouseDown(int x, int y, unsigned long /* button_flags */, unsigned long /* key_flags */) |
581 | - { |
582 | - velocity_ = 0; // stop an current velocity based animations |
583 | - mouse_down_position_.x = x; |
584 | - mouse_down_position_.y = y; |
585 | - MaybeQueueDraw(); |
586 | - } |
587 | - |
588 | - bool TooOld (VelocityEvent event) |
589 | - { |
590 | - gint64 current_time = g_get_monotonic_time(); |
591 | - int ms = (current_time - event.time) / 1000; |
592 | - return ms > 1000; |
593 | - } |
594 | - |
595 | - float Coverflow::Impl::GetCurrentVelocity(int cutoff_ms) |
596 | - { |
597 | - gint64 current_time = g_get_monotonic_time(); |
598 | - float result = 0.0f; |
599 | - |
600 | - std::vector<VelocityEvent>::iterator it; |
601 | - for (it = velocity_events_.begin(); it != velocity_events_.end(); ++it) |
602 | - { |
603 | - VelocityEvent event = *it; |
604 | - int ms = (current_time - event.time) / 1000; |
605 | - if (ms > cutoff_ms) |
606 | - continue; |
607 | - |
608 | - result += event.velocity; |
609 | - } |
610 | - result = result / (cutoff_ms / 16); // 16ms timestep |
611 | - |
612 | - velocity_events_.erase(std::remove_if(velocity_events_.begin(), velocity_events_.end(), &TooOld), velocity_events_.end()); |
613 | - |
614 | - return result; |
615 | - } |
616 | - |
617 | - void Coverflow::Impl::HandleMouseUp(int /* x */, int /* y */, unsigned long /* button_flags */, unsigned long /* key_flags */) |
618 | - { |
619 | - MaybeQueueDraw(); |
620 | - velocity_ = GetCurrentVelocity(32); |
621 | - |
622 | - if (velocity_ != 0 && !velocity_handle_) |
623 | - { |
624 | - velocity_handle_ = g_timeout_add(16, &Coverflow::Impl::OnVelocityTimeout, this); |
625 | - } |
626 | - else if (!velocity_handle_) |
627 | - { |
628 | - SetPosition(RoundFloor(position_), true); |
629 | - UpdateModelSelection(); |
630 | - } |
631 | - } |
632 | - |
633 | - void Coverflow::Impl::HandleMouseDrag(int /* x */, int /* y */, int dx, int /* dy */, unsigned long /* button_flags */, unsigned long /* key_flags */) |
634 | - { |
635 | - nux::Point2 top_left, bottom_right; |
636 | - Get3DBoundingBox(camera_position_.z, top_left, bottom_right); |
637 | - nux::Geometry geo = parent_->GetGeometry(); |
638 | - |
639 | - float scalar = (((float)bottom_right.x - (float)top_left.x) / (float)geo.width) / parent_->space_between_icons; |
640 | - SetPosition(position_ - (dx * scalar * parent_->mouse_drag_rate), false); |
641 | - } |
642 | - |
643 | - void Coverflow::Impl::HandleMouseWheel(int /* x */, int /* y */, int /* wheel_delta */, unsigned long /* button_flags */, unsigned long /* key_flags */) |
644 | - { |
645 | - // do nothing yet |
646 | - } |
647 | - |
648 | - void Coverflow::Impl::HandleGeometryChange(Area* /* area */, Geometry /* geo */) |
649 | - { |
650 | - } |
651 | - |
652 | - CoverList Coverflow::Impl::GetCoverList(float animation_progress, gint64 /* timestep */) |
653 | - { |
654 | - CoverList results; |
655 | - |
656 | - animation_progress = std::min<float>(1.0f, animation_progress); |
657 | - |
658 | - float coverflow_position = position_ - ((position_ - saved_position_) * (1.0f - animation_progress)); |
659 | - |
660 | - size_t i = 0; |
661 | - float flat_right = parent_->space_between_icons * (parent_->flat_icons) + .1; |
662 | - float flat_left = -flat_right; |
663 | - |
664 | - CoverflowModel::CoverflowItemList::const_iterator it; |
665 | - for (it = parent_->model()->Items().begin(); it != parent_->model()->Items().end(); ++it) |
666 | - { |
667 | - CoverflowItem::Ptr item = *it; |
668 | - float item_position = (float)i - coverflow_position; |
669 | - |
670 | - Cover cover; |
671 | - cover.opacity = 1.0f; |
672 | - cover.selected = item == parent_->model()->Selection(); |
673 | - cover.item = item; |
674 | - |
675 | - // This position refers to the bottom center of the cover. |
676 | - cover.position.x = 0; |
677 | - cover.position.y = -0.5f + parent_->y_offset; |
678 | - cover.position.z = 0; |
679 | - cover.position.rot = 0; |
680 | - |
681 | - float x = item_position * parent_->space_between_icons; |
682 | - cover.position.x = x; |
683 | - |
684 | - float neg_pinch = 1.0f - parent_->pinching; |
685 | - |
686 | - if (x < flat_left) |
687 | - { |
688 | - cover.position.rot = (atan((x - flat_left) * parent_->folding_rate) / (nux::constants::pi / 2)) * -parent_->folding_angle; |
689 | - float scale_in_factor = neg_pinch + (1.0f - (std::abs(cover.position.rot) / parent_->folding_angle)) * parent_->pinching; |
690 | - cover.position.x = flat_left - ((flat_left - x) * scale_in_factor); |
691 | - } |
692 | - else if (x > flat_right) |
693 | - { |
694 | - cover.position.rot = (atan((x - flat_right) * parent_->folding_rate) / (nux::constants::pi / 2)) * -parent_->folding_angle; |
695 | - float scale_in_factor = neg_pinch+ (1.0f - (std::abs(cover.position.rot) / parent_->folding_angle)) * parent_->pinching; |
696 | - cover.position.x = flat_right + ((x - flat_right) * scale_in_factor); |
697 | - } |
698 | - |
699 | - if (cover.selected && parent_->pop_out_selected) |
700 | - cover.position.z = 0.3f; |
701 | - |
702 | - float fold_progress = std::abs(cover.position.rot / parent_->folding_angle()); |
703 | - cover.position.z -= parent_->folding_depth() * fold_progress; |
704 | - |
705 | - nux::Point2 top_left, bottom_right; |
706 | - Get3DBoundingBox(camera_position_.z, top_left, bottom_right); |
707 | - |
708 | - float window_width = bottom_right.x - top_left.x; |
709 | - float distance_from_edge = std::max<float>(0.0f, std::abs(bottom_right.x) - std::abs(cover.position.x)); |
710 | - cover.opacity = std::min<float>(1.0f, distance_from_edge / (window_width * parent_->edge_fade)); |
711 | - |
712 | - results.push_back(cover); |
713 | - ++i; |
714 | - } |
715 | - |
716 | - last_position_ = coverflow_position; |
717 | - return results; |
718 | - } |
719 | - |
720 | - void Coverflow::Impl::SetPosition(float position, bool animate) |
721 | - { |
722 | - float min = std::min<float>((float)parent_->flat_icons,(float)parent_->model()->Items().size() - 1.0f); |
723 | - float max = std::max<float>(0.0f, (float)parent_->model()->Items().size() - 1.0f - (float)parent_->flat_icons); |
724 | - position = std::max<float>(min, std::min<float>(max, position)); |
725 | - if (position == position_) |
726 | - return; |
727 | - |
728 | - if (animate) |
729 | - { |
730 | - position_set_time_ = g_get_monotonic_time(); |
731 | - saved_position_ = last_position_; |
732 | - } |
733 | - else |
734 | - { |
735 | - position_set_time_ = 0; |
736 | - } |
737 | - |
738 | - position_ = position; |
739 | - |
740 | - VelocityEvent ve; |
741 | - ve.velocity = position_ - last_position_; |
742 | - ve.time = g_get_monotonic_time(); |
743 | - velocity_events_.push_back(ve); |
744 | - |
745 | - MaybeQueueDraw(); |
746 | - } |
747 | - |
748 | - void Coverflow::Impl::OnItemAdded(CoverflowModel* /* owner */, CoverflowItem::Ptr /* new_item */) |
749 | - { |
750 | - SetPosition(position_, true); |
751 | - MaybeQueueDraw(); |
752 | - } |
753 | - |
754 | - void Coverflow::Impl::OnItemRemoved(CoverflowModel* /* owner */, CoverflowItem::Ptr /* old_item */) |
755 | - { |
756 | - SetPosition(position_, true); |
757 | - MaybeQueueDraw(); |
758 | - } |
759 | - |
760 | - void Coverflow::Impl::OnSelectionChanged(CoverflowModel* /* owner */, CoverflowItem::Ptr /* selection */) |
761 | - { |
762 | - size_t selection_index = parent_->model()->SelectionIndex(); |
763 | - |
764 | - if (selection_index > (position_ + parent_->flat_icons)) |
765 | - SetPosition(selection_index - parent_->flat_icons, true); |
766 | - else if (selection_index < (position_ - parent_->flat_icons)) |
767 | - SetPosition(selection_index + parent_->flat_icons, true); |
768 | - MaybeQueueDraw(); |
769 | - } |
770 | - |
771 | - void Coverflow::Impl::MaybeQueueDraw() |
772 | - { |
773 | - if (!animation_handle_) |
774 | - animation_handle_ = g_timeout_add(0, &Coverflow::Impl::OnAnimationTimeout, this); |
775 | - } |
776 | - |
777 | - void Coverflow::Impl::LoadVertexBuffer(int VertexLocation, int TextureCoord0Location, int VertexColorLocation, float* VtxBuffer) |
778 | - { |
779 | - CHECKGL(glEnableVertexAttribArrayARB(VertexLocation)); |
780 | - CHECKGL(glVertexAttribPointerARB((GLuint) VertexLocation, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer)); |
781 | - |
782 | - if (TextureCoord0Location != -1) |
783 | - { |
784 | - CHECKGL(glEnableVertexAttribArrayARB(TextureCoord0Location)); |
785 | - CHECKGL(glVertexAttribPointerARB((GLuint) TextureCoord0Location, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 4)); |
786 | - } |
787 | - |
788 | - if (VertexColorLocation != -1) |
789 | - { |
790 | - CHECKGL(glEnableVertexAttribArrayARB(VertexColorLocation)); |
791 | - CHECKGL(glVertexAttribPointerARB((GLuint) VertexColorLocation, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 8)); |
792 | - } |
793 | - } |
794 | - |
795 | - void Coverflow::Impl::RenderCover(nux::GraphicsEngine& graphics_engine, Cover const& cover, int width, int height, nux::Matrix4 combined_matrix) |
796 | - { |
797 | - ObjectPtr<IOpenGLBaseTexture> texture = cover.item->GetTexture()->GetDeviceTexture(); |
798 | - nux::TexCoordXForm texxform; |
799 | - nux::Color ref_color = nux::color::White; |
800 | - |
801 | - QRP_Compute_Texture_Coord(width, height, texture, texxform); |
802 | - |
803 | - float ratio = texture->GetWidth()/(float)texture->GetHeight(); |
804 | - float drop_shadow_ratio = drop_shadow_texture_->GetWidth()/(float)drop_shadow_texture_->GetHeight(); |
805 | - |
806 | - float fx = cover_width_in_3d_space_/2.0f; |
807 | - |
808 | - float fy_top = cover.position.y + (cover_width_in_3d_space_) * (1.0f/ratio); |
809 | - float fy_bot = cover.position.y; |
810 | - float fy_bot_reflec = cover.position.y - (cover_width_in_3d_space_) * (1.0f/ratio) * parent_->reflection_size; |
811 | - |
812 | - float fx_shadow = 0.5 * (1.1 * cover_width_in_3d_space_); |
813 | - float fy_top_shadow = fy_bot + 0.5 * (1.4 * cover_width_in_3d_space_) * (1.0f/drop_shadow_ratio); |
814 | - float fy_bot_shadow = fy_bot - 0.5 * (1.4 * cover_width_in_3d_space_) * (1.0f/drop_shadow_ratio); |
815 | - |
816 | - |
817 | - cover_shader_program_->Begin(); |
818 | - |
819 | - int TextureObjectLocation = cover_shader_program_->GetUniformLocationARB("TextureObject0"); |
820 | - int VertexLocation = cover_shader_program_->GetAttributeLocation("iVertex"); |
821 | - int TextureCoord0Location = cover_shader_program_->GetAttributeLocation("iTextureCoord0"); |
822 | - int VertexColorLocation = cover_shader_program_->GetAttributeLocation("iVertexColor"); |
823 | - int VPMatrixLocation = cover_shader_program_->GetUniformLocationARB("ViewProjectionMatrix"); |
824 | - |
825 | - nux::Matrix4 MVPMatrix = perspective_ * combined_matrix; |
826 | - |
827 | - cover_shader_program_->SetUniformLocMatrix4fv((GLint) VPMatrixLocation, 1, true, (GLfloat*) &(MVPMatrix.m)); |
828 | - |
829 | - // *** Compute the opacities *** |
830 | - float angular_opacity = 1.0f; |
831 | - if (parent_->folding_angle == 0) |
832 | - { |
833 | - angular_opacity = 1.0f; |
834 | - } |
835 | - else |
836 | - { |
837 | - float rotation_ratio = std::abs(cover.position.rot / parent_->folding_angle); |
838 | - angular_opacity = 1.0f - rotation_ratio; |
839 | - } |
840 | - |
841 | - float opacity = 1.0f - std::abs(cover.position.x) / (parent_->reflection_fadeout_distance); |
842 | - if (opacity < 0.0f) |
843 | - { |
844 | - opacity = 0.0f; |
845 | - } |
846 | - |
847 | - opacity *= angular_opacity; |
848 | - |
849 | - drop_shadow_texture_->SetFiltering (GL_LINEAR, GL_LINEAR); |
850 | - graphics_engine.SetTexture(GL_TEXTURE0, drop_shadow_texture_); |
851 | - CHECKGL(glUniform1iARB(TextureObjectLocation, 0)); |
852 | - |
853 | - // **** Render the cover drop shadow **** |
854 | - if (parent_->show_drop_shadow) |
855 | - { |
856 | - Color color = ref_color * cover.opacity * angular_opacity; |
857 | - float VtxBuffer[] = |
858 | - { |
859 | - -fx_shadow, fy_top_shadow, 0.0f, 1.0f, texxform.u0, texxform.v0, 0, 0, color.red, color.green, color.blue, color.alpha, |
860 | - -fx_shadow, fy_bot_shadow, 0.0f, 1.0f, texxform.u0, texxform.v1, 0, 0, color.red, color.green, color.blue, color.alpha, |
861 | - fx_shadow, fy_bot_shadow, 0.0f, 1.0f, texxform.u1, texxform.v1, 0, 0, color.red, color.green, color.blue, color.alpha, |
862 | - fx_shadow, fy_top_shadow, 0.0f, 1.0f, texxform.u1, texxform.v0, 0, 0, color.red, color.green, color.blue, color.alpha, |
863 | - }; |
864 | - |
865 | - LoadVertexBuffer(VertexLocation, TextureCoord0Location, VertexColorLocation, VtxBuffer); |
866 | - CHECKGL(glDrawArrays(GL_TRIANGLE_FAN, 0, 4)); |
867 | - } |
868 | - |
869 | - |
870 | - texture->SetFiltering (GL_LINEAR, GL_LINEAR); |
871 | - graphics_engine.SetTexture(GL_TEXTURE0, texture); |
872 | - CHECKGL(glUniform1iARB(TextureObjectLocation, 0)); |
873 | - |
874 | - // **** Render the cover **** |
875 | - { |
876 | - Color color = ref_color * cover.opacity; |
877 | - float VtxBuffer[] = |
878 | - { |
879 | - -fx, fy_top, 0.0f, 1.0f, texxform.u0, texxform.v0, 0, 0, color.red, color.green, color.blue, color.alpha, |
880 | - -fx, fy_bot, 0.0f, 1.0f, texxform.u0, texxform.v1, 0, 0, color.red, color.green, color.blue, color.alpha, |
881 | - fx, fy_bot, 0.0f, 1.0f, texxform.u1, texxform.v1, 0, 0, color.red, color.green, color.blue, color.alpha, |
882 | - fx, fy_top, 0.0f, 1.0f, texxform.u1, texxform.v0, 0, 0, color.red, color.green, color.blue, color.alpha, |
883 | - }; |
884 | - |
885 | - LoadVertexBuffer(VertexLocation, TextureCoord0Location, VertexColorLocation, VtxBuffer); |
886 | - CHECKGL(glDrawArrays(GL_TRIANGLE_FAN, 0, 4)); |
887 | - } |
888 | - |
889 | - // **** Reflection opacity **** |
890 | - if (parent_->show_reflection) |
891 | - { |
892 | - texxform.flip_v_coord = true; |
893 | - QRP_Compute_Texture_Coord(width, height, texture, texxform); |
894 | - |
895 | - // texture offset use to prevent the texture from scaling when the reflection size changes. |
896 | - float toff = 1.0f - parent_->reflection_size; |
897 | - |
898 | - float opacity_start = opacity*parent_->reflection_strength * cover.opacity; |
899 | - float opacity_end = 0.0f; |
900 | - float VtxBuffer[] = |
901 | - { |
902 | - -fx, fy_bot, 0.0f, 1.0f, texxform.u0, texxform.v0, 0, 0, opacity_start, opacity_start, opacity_start, opacity_start, |
903 | - -fx, fy_bot_reflec, 0.0f, 1.0f, texxform.u0, texxform.v1 + toff, 0, 0, opacity_end, opacity_end, opacity_end, opacity_end, |
904 | - fx, fy_bot_reflec, 0.0f, 1.0f, texxform.u1, texxform.v1 + toff, 0, 0, opacity_end, opacity_end, opacity_end, opacity_end, |
905 | - fx, fy_bot, 0.0f, 1.0f, texxform.u1, texxform.v0, 0, 0, opacity_start, opacity_start, opacity_start, opacity_start, |
906 | - }; |
907 | - |
908 | - LoadVertexBuffer(VertexLocation, TextureCoord0Location, VertexColorLocation, VtxBuffer); |
909 | - CHECKGL(glDrawArrays(GL_TRIANGLE_FAN, 0, 4)); |
910 | - } |
911 | - |
912 | - // **** Render Cover label **** |
913 | - if (parent_->show_labels()) |
914 | - { |
915 | - if (!cover.item->text_texture().IsValid()) |
916 | - { |
917 | - nux::Point2 top_left, bottom_right; |
918 | - Get3DBoundingBox(camera_position_.z, top_left, bottom_right); |
919 | - int individual_width = (int) RoundFloor((float)width / (bottom_right.x - top_left.x)); |
920 | - |
921 | - char *escaped_text = g_markup_escape_text(cover.item->name().c_str(), -1); |
922 | - text_loader_.text = escaped_text; |
923 | - text_loader_.width = individual_width; |
924 | - text_loader_.minimum_width = individual_width; |
925 | - cover.item->text_texture = text_loader_.CreateTexture(); |
926 | - g_free(escaped_text); |
927 | - } |
928 | - |
929 | - if (cover.item->text_texture().IsValid()) |
930 | - { |
931 | - ObjectPtr<IOpenGLBaseTexture> label_texture = cover.item->text_texture()->GetDeviceTexture(); |
932 | - QRP_Compute_Texture_Coord(label_texture->GetWidth(), label_texture->GetHeight(), label_texture, texxform); |
933 | - |
934 | - ratio = label_texture->GetWidth() / (float)label_texture->GetHeight(); |
935 | - |
936 | - |
937 | - float fx = cover_width_in_3d_space_ / 2.0f; |
938 | - float fy_top_text = fy_bot - 0.05f; // push it down a bit |
939 | - float fy_bot_text = fy_top_text - (cover_width_in_3d_space_) * (1.0f/ratio); |
940 | - |
941 | - label_texture->SetFiltering(GL_NEAREST, GL_NEAREST); |
942 | - graphics_engine.SetTexture(GL_TEXTURE0, label_texture); |
943 | - CHECKGL(glUniform1iARB(TextureObjectLocation, 0)); |
944 | - |
945 | - texxform.flip_v_coord = true; |
946 | - QRP_Compute_Texture_Coord(width, height, texture, texxform); |
947 | - |
948 | - float opacity_start = angular_opacity; |
949 | - float opacity_end = angular_opacity; |
950 | - |
951 | - if (cover.position.rot != 0.0f) |
952 | - { |
953 | - opacity_start = 0.4f * angular_opacity; |
954 | - opacity_end = 0.4f * angular_opacity; |
955 | - } |
956 | - |
957 | - float VtxBuffer[] = |
958 | - { |
959 | - -fx, fy_top_text, 0.0f, 1.0f, texxform.u0, texxform.v1, 0, 0, opacity_start, opacity_start, opacity_start, opacity_start, |
960 | - -fx, fy_bot_text, 0.0f, 1.0f, texxform.u0, texxform.v0, 0, 0, opacity_end, opacity_end, opacity_end, opacity_end, |
961 | - fx, fy_bot_text, 0.0f, 1.0f, texxform.u1, texxform.v0, 0, 0, opacity_end, opacity_end, opacity_end, opacity_end, |
962 | - fx, fy_top_text, 0.0f, 1.0f, texxform.u1, texxform.v1, 0, 0, opacity_start, opacity_start, opacity_start, opacity_start, |
963 | - }; |
964 | - |
965 | - LoadVertexBuffer(VertexLocation, TextureCoord0Location, VertexColorLocation, VtxBuffer); |
966 | - CHECKGL(glDrawArrays(GL_TRIANGLE_FAN, 0, 4)); |
967 | - } |
968 | - } |
969 | - |
970 | - CHECKGL(glDisableVertexAttribArrayARB(VertexLocation)); |
971 | - |
972 | - if (TextureCoord0Location != -1) |
973 | - CHECKGL(glDisableVertexAttribArrayARB(TextureCoord0Location)); |
974 | - |
975 | - if (VertexColorLocation != -1) |
976 | - CHECKGL(glDisableVertexAttribArrayARB(VertexColorLocation)); |
977 | - |
978 | - cover_shader_program_->End(); |
979 | - } |
980 | - |
981 | - void Coverflow::Impl::DrawCover(nux::GraphicsEngine& graphics_engine, nux::DrawAreaContext &ctx, Cover const& cover) |
982 | - { |
983 | - if (cover.item->GetTexture().IsNull() || !TestCoverVisible(cover)) |
984 | - return; |
985 | - |
986 | - int width = parent_->GetBaseWidth(); |
987 | - int height = parent_->GetBaseHeight(); |
988 | - |
989 | - // Note that (cover.position.x, cover.position.y, cover.position.z) is the position of the bottom |
990 | - // center of the cover in 3d space. |
991 | - // We translate the cover to an y coordinate of 0.0 in the matrix below and we take care of rendering |
992 | - // the cover at the right location in Y. |
993 | - |
994 | - if (parent_->true_perspective) |
995 | - { |
996 | - modelview_ = nux::Matrix4::TRANSLATE(-camera_position_.x, -camera_position_.y, -camera_position_.z) * |
997 | - nux::Matrix4::ROTATEX(DEGTORAD(-camera_rotation_.x)) * |
998 | - nux::Matrix4::ROTATEY(DEGTORAD(camera_drift_factor_ * parent_->camera_motion_drift_angle + -camera_rotation_.y)) * |
999 | - nux::Matrix4::ROTATEZ(DEGTORAD(-camera_rotation_.z)) * |
1000 | - nux::Matrix4::TRANSLATE(cover.position.x, 0.0f, cover.position.z); |
1001 | - } |
1002 | - else |
1003 | - { |
1004 | - modelview_ = nux::Matrix4::TRANSLATE(-camera_position_.x, -camera_position_.y, -camera_position_.z) * |
1005 | - nux::Matrix4::ROTATEX(DEGTORAD(-camera_rotation_.x)) * |
1006 | - nux::Matrix4::ROTATEY(DEGTORAD(camera_drift_factor_ * parent_->camera_motion_drift_angle + -camera_rotation_.y)) * |
1007 | - nux::Matrix4::ROTATEZ(DEGTORAD(-camera_rotation_.z)) * |
1008 | - nux::Matrix4::TRANSLATE(0.0f, 0.0f, cover.position.z); |
1009 | - |
1010 | - nux::Point2 top_left, bottom_right; |
1011 | - Get3DBoundingBox(camera_position_.z, top_left, bottom_right); |
1012 | - float scalar = ctx.width / (bottom_right.x - top_left.x); |
1013 | - glViewport((int) (cover.position.x * scalar), 0.0f, ctx.width, ctx.height); |
1014 | - } |
1015 | - |
1016 | - nux::Matrix4 m = nux::Matrix4::ROTATEY(DEGTORAD(cover.position.rot)); |
1017 | - nux::Matrix4 combined_matrix = modelview_ * m; |
1018 | - |
1019 | - RenderCover(graphics_engine, cover, width, height, combined_matrix); |
1020 | - } |
1021 | - |
1022 | - gboolean Coverflow::Impl::OnAnimationTimeout(gpointer data) |
1023 | - { |
1024 | - Coverflow::Impl* self = static_cast<Coverflow::Impl*> (data); |
1025 | - self->parent_->QueueDraw(); |
1026 | - self->animation_handle_ = 0; |
1027 | - return FALSE; |
1028 | - } |
1029 | - |
1030 | - gboolean Coverflow::Impl::OnVelocityTimeout(gpointer data) |
1031 | - { |
1032 | - Coverflow::Impl* self = static_cast<Coverflow::Impl*>(data); |
1033 | - if (self->velocity_ == 0) |
1034 | - { |
1035 | - self->SetPosition(RoundFloor(self->position_), true); |
1036 | - self->UpdateModelSelection(); |
1037 | - self->velocity_handle_ = 0; |
1038 | - return FALSE; |
1039 | - } |
1040 | - |
1041 | - self->SetPosition(self->position_ + self->velocity_, false); |
1042 | - self->velocity_ = (std::max<float>(0.0f, std::abs(self->velocity_) - self->parent_->kinetic_scroll_rate)) * (self->velocity_ / std::abs(self->velocity_)); |
1043 | - self->MaybeQueueDraw(); |
1044 | - return TRUE; |
1045 | - } |
1046 | - |
1047 | - NUX_IMPLEMENT_OBJECT_TYPE(Coverflow); |
1048 | - |
1049 | - Coverflow::Coverflow() |
1050 | - : animation_length(250) |
1051 | - , camera_motion_drift_angle(10.0f) |
1052 | - , camera_motion_drift_enabled(false) |
1053 | - , edge_fade(0.07) |
1054 | - , flat_icons(2) |
1055 | - , folding_angle(90.0f) |
1056 | - , folding_depth(0.0f) |
1057 | - , folding_rate(2) |
1058 | - , fov(45) |
1059 | - , kinetic_scroll_rate(0.1f) |
1060 | - , mouse_drag_rate(1) |
1061 | - , pinching(.6) |
1062 | - , pop_out_selected(false) |
1063 | - , reflection_fadeout_distance(4.0f) |
1064 | - , reflection_strength(0.45f) |
1065 | - , space_between_icons(1.25f) |
1066 | - , model(CoverflowModel::Ptr(new CoverflowModel())) |
1067 | - , show_labels(true) |
1068 | - , show_drop_shadow(false) |
1069 | - , show_reflection(false) |
1070 | - , true_perspective(true) |
1071 | - , reflection_size(1.0f) |
1072 | - , pimpl(new Impl(this)) |
1073 | - { |
1074 | - SetAcceptKeyboardEvent(true); |
1075 | - |
1076 | - model()->item_added.connect(sigc::mem_fun(pimpl, &Coverflow::Impl::OnItemAdded)); |
1077 | - model()->item_removed.connect(sigc::mem_fun(pimpl, &Coverflow::Impl::OnItemRemoved)); |
1078 | - pimpl->model_selection_connection_ = model()->selection_changed.connect(sigc::mem_fun(pimpl, &Coverflow::Impl::OnSelectionChanged)); |
1079 | - } |
1080 | - |
1081 | - Coverflow::~Coverflow() |
1082 | - { |
1083 | - delete pimpl; |
1084 | - } |
1085 | - |
1086 | - void Coverflow::SetCameraDistance(float distance) |
1087 | - { |
1088 | - pimpl->camera_position_.z = distance; |
1089 | - pimpl->MaybeQueueDraw(); |
1090 | - } |
1091 | - |
1092 | - bool Coverflow::InspectKeyEvent(unsigned int /* eventType */, unsigned int /* keysym */, const char* /* character */) |
1093 | - { |
1094 | - return true; |
1095 | - } |
1096 | - |
1097 | - void Coverflow::ClientDraw(nux::GraphicsEngine& graphics_engine, nux::DrawAreaContext &ctx, bool /* force_draw */) |
1098 | - { |
1099 | - gint64 current_time = g_get_monotonic_time(); |
1100 | - float animation_progress = std::min<float>(1.0f, (current_time - pimpl->position_set_time_) / static_cast<float>(animation_length() * 1000)); |
1101 | - gint64 timestep = (current_time - pimpl->last_draw_time_) / 1000; |
1102 | - |
1103 | - graphics_engine.GetRenderStates().SetBlend(true); |
1104 | - graphics_engine.GetRenderStates().SetPremultipliedBlend(SRC_OVER); |
1105 | - graphics_engine.GetRenderStates().SetColorMask(true, true, true, true); |
1106 | - |
1107 | - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
1108 | - |
1109 | - glViewport(0, 0, ctx.width, ctx.height); |
1110 | - |
1111 | - pimpl->perspective_.Perspective(DEGTORAD(fov()), (float)ctx.width / (float)ctx.height, pimpl->near_clip_plan_, pimpl->far_clip_plan_); |
1112 | - |
1113 | - if (camera_motion_drift_enabled) |
1114 | - { |
1115 | - float current_velocity = pimpl->GetCurrentVelocity(250); |
1116 | - pimpl->camera_drift_factor_ = std::max<float>(-1.0f, std::min<float>(1.0f, current_velocity / 1.5f)); |
1117 | - } |
1118 | - |
1119 | - CoverList covers = pimpl->GetCoverList(EaseSin(animation_progress), timestep); |
1120 | - CoverList::iterator it; |
1121 | - for (it = covers.begin(); it != covers.end(); ++it) |
1122 | - { |
1123 | - Cover cover = *it; |
1124 | - if (cover.position.rot > 0) |
1125 | - pimpl->DrawCover(graphics_engine, ctx, cover); |
1126 | - else |
1127 | - break; |
1128 | - } |
1129 | - |
1130 | - CoverList::reverse_iterator rit; |
1131 | - for (rit = covers.rbegin(); rit != covers.rend(); ++rit) |
1132 | - { |
1133 | - Cover cover = *rit; |
1134 | - if (cover.position.rot <= 0) |
1135 | - pimpl->DrawCover(graphics_engine, ctx, cover); |
1136 | - } |
1137 | - |
1138 | - //graphics_engine.GetRenderStates().SetBlend(false); |
1139 | - |
1140 | - if ((pimpl->camera_drift_factor_ != 0 || animation_progress < 1.0f) && !pimpl->animation_handle_) |
1141 | - { |
1142 | - pimpl->animation_handle_ = g_timeout_add(0, &Coverflow::Impl::OnAnimationTimeout, pimpl); |
1143 | - } |
1144 | - |
1145 | - pimpl->last_draw_time_ = current_time; |
1146 | - pimpl->last_covers_ = covers; |
1147 | - } |
1148 | - |
1149 | - bool Coverflow::AcceptKeyNavFocus() |
1150 | - { |
1151 | - return true; |
1152 | - } |
1153 | - |
1154 | - float Coverflow::ViewportWidthAtDepth(float depth) |
1155 | - { |
1156 | - nux::Point2 top_left; |
1157 | - nux::Point2 bottom_right; |
1158 | - pimpl->Get3DBoundingBox(pimpl->camera_position_.z + depth, top_left, bottom_right); |
1159 | - return bottom_right.x - top_left.x; |
1160 | - } |
1161 | - |
1162 | - float Coverflow::ViewportHeightAtDepth(float depth) |
1163 | - { |
1164 | - nux::Point2 top_left; |
1165 | - nux::Point2 bottom_right; |
1166 | - pimpl->Get3DBoundingBox(pimpl->camera_position_.z + depth, top_left, bottom_right); |
1167 | - return top_left.y - bottom_right.y; |
1168 | - } |
1169 | - |
1170 | -} // namespace nux |
1171 | |
1172 | === removed file 'Nux/Coverflow.h' |
1173 | --- Nux/Coverflow.h 2012-11-05 21:31:06 +0000 |
1174 | +++ Nux/Coverflow.h 1970-01-01 00:00:00 +0000 |
1175 | @@ -1,103 +0,0 @@ |
1176 | -// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
1177 | -/* |
1178 | - * Copyright (C) 2012 Canonical Ltd |
1179 | - * |
1180 | - * This program is free software: you can redistribute it and/or modify |
1181 | - * it under the terms of the GNU General Public License version 3 as |
1182 | - * published by the Free Software Foundation. |
1183 | - * |
1184 | - * This program is distributed in the hope that it will be useful, |
1185 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1186 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1187 | - * GNU General Public License for more details. |
1188 | - * |
1189 | - * You should have received a copy of the GNU General Public License |
1190 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1191 | - * |
1192 | - * Authored by: Jason Smith <jason.smith@canonical.com> |
1193 | - */ |
1194 | - |
1195 | -#ifndef COVERFLOWVIEW_H |
1196 | -#define COVERFLOWVIEW_H |
1197 | - |
1198 | -#include "NuxCore/Math/Vector4.h" |
1199 | -#include "CoverflowModel.h" |
1200 | -#include "ClientArea.h" |
1201 | - |
1202 | -#if defined(NUX_OS_WINDOWS) |
1203 | - #define PKGDATADIR "../../data/" |
1204 | -#endif |
1205 | - |
1206 | -namespace nux |
1207 | -{ |
1208 | - class Coverflow: public nux::ClientArea |
1209 | - { |
1210 | - NUX_DECLARE_OBJECT_TYPE(Coverflow, ClientArea); |
1211 | - public: |
1212 | - Coverflow(); |
1213 | - ~Coverflow(); |
1214 | - |
1215 | - Property<unsigned int> animation_length; |
1216 | - |
1217 | - Property<float> camera_motion_drift_angle; |
1218 | - |
1219 | - Property<bool> camera_motion_drift_enabled; |
1220 | - |
1221 | - Property<float> edge_fade; |
1222 | - |
1223 | - Property<int> flat_icons; |
1224 | - |
1225 | - Property<float> folding_angle; |
1226 | - |
1227 | - Property<float> folding_depth; |
1228 | - |
1229 | - Property<float> folding_rate; |
1230 | - |
1231 | - Property<float> fov; |
1232 | - |
1233 | - Property<float> kinetic_scroll_rate; |
1234 | - |
1235 | - Property<float> mouse_drag_rate; |
1236 | - |
1237 | - Property<float> pinching; |
1238 | - |
1239 | - Property<bool> pop_out_selected; |
1240 | - |
1241 | - Property<float> reflection_fadeout_distance; |
1242 | - |
1243 | - Property<float> reflection_strength; |
1244 | - |
1245 | - Property<float> space_between_icons; |
1246 | - |
1247 | - Property<CoverflowModel::Ptr> model; |
1248 | - |
1249 | - Property<bool> show_labels; |
1250 | - |
1251 | - Property<bool> show_drop_shadow; |
1252 | - |
1253 | - Property<bool> show_reflection; |
1254 | - |
1255 | - Property<bool> true_perspective; |
1256 | - |
1257 | - Property<float> y_offset; |
1258 | - |
1259 | - Property<float> reflection_size; |
1260 | - |
1261 | - bool AcceptKeyNavFocus(); |
1262 | - |
1263 | - void SetCameraDistance(float distance); |
1264 | - |
1265 | - float ViewportWidthAtDepth(float depth); |
1266 | - float ViewportHeightAtDepth(float depth); |
1267 | - protected: |
1268 | - virtual bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character); |
1269 | - virtual void ClientDraw(nux::GraphicsEngine& graphics_engine, nux::DrawAreaContext &ctx, bool force_draw); |
1270 | - |
1271 | - private: |
1272 | - struct Impl; |
1273 | - Impl* pimpl; |
1274 | - }; |
1275 | -} |
1276 | - |
1277 | -#endif // COVERFLOWVIEW_H |
1278 | - |
1279 | |
1280 | === removed file 'Nux/CoverflowItem.cpp' |
1281 | --- Nux/CoverflowItem.cpp 2012-02-10 03:50:04 +0000 |
1282 | +++ Nux/CoverflowItem.cpp 1970-01-01 00:00:00 +0000 |
1283 | @@ -1,30 +0,0 @@ |
1284 | -// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
1285 | -/* |
1286 | - * Copyright (C) 2012 Canonical Ltd |
1287 | - * |
1288 | - * This program is free software: you can redistribute it and/or modify |
1289 | - * it under the terms of the GNU General Public License version 3 as |
1290 | - * published by the Free Software Foundation. |
1291 | - * |
1292 | - * This program is distributed in the hope that it will be useful, |
1293 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1294 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1295 | - * GNU General Public License for more details. |
1296 | - * |
1297 | - * You should have received a copy of the GNU General Public License |
1298 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1299 | - * |
1300 | - * Authored by: Jason Smith <jason.smith@canonical.com> |
1301 | - */ |
1302 | - |
1303 | -#include "CoverflowItem.h" |
1304 | - |
1305 | -namespace nux |
1306 | -{ |
1307 | -NUX_IMPLEMENT_OBJECT_TYPE(CoverflowItem); |
1308 | -CoverflowItem::CoverflowItem(std::string const& name_) |
1309 | -: name(name_) |
1310 | -{ |
1311 | -} |
1312 | - |
1313 | -} |
1314 | |
1315 | === removed file 'Nux/CoverflowItem.h' |
1316 | --- Nux/CoverflowItem.h 2012-11-05 21:31:06 +0000 |
1317 | +++ Nux/CoverflowItem.h 1970-01-01 00:00:00 +0000 |
1318 | @@ -1,49 +0,0 @@ |
1319 | -// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
1320 | -/* |
1321 | - * Copyright (C) 2012 Canonical Ltd |
1322 | - * |
1323 | - * This program is free software: you can redistribute it and/or modify |
1324 | - * it under the terms of the GNU General Public License version 3 as |
1325 | - * published by the Free Software Foundation. |
1326 | - * |
1327 | - * This program is distributed in the hope that it will be useful, |
1328 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1329 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1330 | - * GNU General Public License for more details. |
1331 | - * |
1332 | - * You should have received a copy of the GNU General Public License |
1333 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1334 | - * |
1335 | - * Authored by: Jason Smith <jason.smith@canonical.com> |
1336 | - */ |
1337 | - |
1338 | -#ifndef NUX_COVERFLOWITEM_H |
1339 | -#define NUX_COVERFLOWITEM_H |
1340 | - |
1341 | -#include <memory> |
1342 | -#include <string> |
1343 | - |
1344 | -#include "Nux.h" |
1345 | -#include <sigc++/sigc++.h> |
1346 | - |
1347 | -namespace nux |
1348 | -{ |
1349 | - |
1350 | -class CoverflowItem : public InitiallyUnownedObject |
1351 | -{ |
1352 | - NUX_DECLARE_OBJECT_TYPE(CoverflowItem, InitiallyUnownedObject); |
1353 | -public: |
1354 | - typedef ObjectPtr<CoverflowItem> Ptr; |
1355 | - |
1356 | - CoverflowItem(std::string const& name); |
1357 | - |
1358 | - Property<std::string> name; |
1359 | - Property<ObjectPtr<BaseTexture> > text_texture; |
1360 | - |
1361 | - virtual ObjectPtr<BaseTexture> GetTexture() const = 0; |
1362 | - virtual void Activate(int /* button */) {} |
1363 | -}; |
1364 | - |
1365 | -} |
1366 | - |
1367 | -#endif |
1368 | |
1369 | === removed file 'Nux/CoverflowModel.cpp' |
1370 | --- Nux/CoverflowModel.cpp 2012-02-18 21:32:06 +0000 |
1371 | +++ Nux/CoverflowModel.cpp 1970-01-01 00:00:00 +0000 |
1372 | @@ -1,141 +0,0 @@ |
1373 | -// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
1374 | -/* |
1375 | - * Copyright (C) 2012 Canonical Ltd |
1376 | - * |
1377 | - * This program is free software: you can redistribute it and/or modify |
1378 | - * it under the terms of the GNU General Public License version 3 as |
1379 | - * published by the Free Software Foundation. |
1380 | - * |
1381 | - * This program is distributed in the hope that it will be useful, |
1382 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1383 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1384 | - * GNU General Public License for more details. |
1385 | - * |
1386 | - * You should have received a copy of the GNU General Public License |
1387 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1388 | - * |
1389 | - * Authored by: Jason Smith <jason.smith@canonical.com> |
1390 | - */ |
1391 | - |
1392 | -#include "CoverflowModel.h" |
1393 | - |
1394 | -namespace nux |
1395 | -{ |
1396 | - |
1397 | -struct CoverflowModel::Impl |
1398 | -{ |
1399 | - Impl(CoverflowModel *parent); |
1400 | - ~Impl(); |
1401 | - |
1402 | - CoverflowModel* parent_; |
1403 | - size_t selection_index_; |
1404 | - CoverflowItemList items_; |
1405 | -}; |
1406 | - |
1407 | -CoverflowModel::Impl::Impl(CoverflowModel* parent) |
1408 | - : parent_(parent) |
1409 | - , selection_index_(0) |
1410 | -{ |
1411 | -} |
1412 | - |
1413 | -CoverflowModel::Impl::~Impl() |
1414 | -{ |
1415 | -} |
1416 | - |
1417 | -NUX_IMPLEMENT_OBJECT_TYPE(CoverflowModel); |
1418 | - |
1419 | -CoverflowModel::CoverflowModel() |
1420 | - : pimpl(new CoverflowModel::Impl(this)) |
1421 | -{ |
1422 | -} |
1423 | - |
1424 | -CoverflowModel::~CoverflowModel() |
1425 | -{ |
1426 | - delete pimpl; |
1427 | -} |
1428 | - |
1429 | -CoverflowModel::CoverflowItemList const& CoverflowModel::Items() const |
1430 | -{ |
1431 | - return pimpl->items_; |
1432 | -} |
1433 | - |
1434 | -void CoverflowModel::AddItem(CoverflowItem::Ptr const& item) |
1435 | -{ |
1436 | - pimpl->items_.push_back(item); |
1437 | - item_added.emit(this, item); |
1438 | - SetSelection(pimpl->selection_index_); // perform bounds check |
1439 | -} |
1440 | - |
1441 | -void CoverflowModel::InsertItem(CoverflowItem::Ptr const& item, size_t index) |
1442 | -{ |
1443 | - pimpl->items_.insert(pimpl->items_.begin() + std::max<float>(index, pimpl->items_.size()), item); |
1444 | - item_added.emit(this, item); |
1445 | - SetSelection(pimpl->selection_index_); // perform bounds check |
1446 | -} |
1447 | - |
1448 | -void CoverflowModel::RemoveItem(CoverflowItem::Ptr const& item) |
1449 | -{ |
1450 | - pimpl->items_.erase(std::remove(pimpl->items_.begin(), pimpl->items_.end(), item), pimpl->items_.end()); |
1451 | - item_removed.emit(this, item); |
1452 | - SetSelection(pimpl->selection_index_); // perform bounds check |
1453 | -} |
1454 | - |
1455 | -size_t CoverflowModel::IndexOf(CoverflowItem::Ptr const& item) |
1456 | -{ |
1457 | - size_t i = 0; |
1458 | - |
1459 | - CoverflowItemList::iterator it; |
1460 | - |
1461 | - for (it = pimpl->items_.begin(); it != pimpl->items_.end(); ++it) |
1462 | - { |
1463 | - CoverflowItem::Ptr compare = *it; |
1464 | - if (item == compare) |
1465 | - return i; |
1466 | - ++i; |
1467 | - } |
1468 | - |
1469 | - return 0; |
1470 | -} |
1471 | - |
1472 | -CoverflowItem::Ptr CoverflowModel::Selection() |
1473 | -{ |
1474 | - if (pimpl->selection_index_ >= pimpl->items_.size()) |
1475 | - return CoverflowItem::Ptr(); |
1476 | - return pimpl->items_[pimpl->selection_index_]; |
1477 | -} |
1478 | - |
1479 | -size_t CoverflowModel::SelectionIndex() |
1480 | -{ |
1481 | - return pimpl->selection_index_; |
1482 | -} |
1483 | - |
1484 | -void CoverflowModel::SetSelection(size_t index) |
1485 | -{ |
1486 | - index = std::min<size_t>(index, pimpl->items_.size() - 1); |
1487 | - if (index != pimpl->selection_index_) |
1488 | - { |
1489 | - pimpl->selection_index_ = index; |
1490 | - selection_changed.emit(this, Selection()); |
1491 | - } |
1492 | -} |
1493 | - |
1494 | -void CoverflowModel::SetSelection(CoverflowItem::Ptr item) |
1495 | -{ |
1496 | - SetSelection(IndexOf(item)); |
1497 | -} |
1498 | - |
1499 | -void CoverflowModel::SelectNext() |
1500 | -{ |
1501 | - SetSelection(pimpl->selection_index_ + 1); |
1502 | -} |
1503 | - |
1504 | -void CoverflowModel::SelectPrev() |
1505 | -{ |
1506 | - if (pimpl->selection_index_ == 0) |
1507 | - return; |
1508 | - |
1509 | - SetSelection(pimpl->selection_index_ - 1); |
1510 | -} |
1511 | - |
1512 | - |
1513 | -} |
1514 | |
1515 | === removed file 'Nux/CoverflowModel.h' |
1516 | --- Nux/CoverflowModel.h 2012-02-13 09:40:34 +0000 |
1517 | +++ Nux/CoverflowModel.h 1970-01-01 00:00:00 +0000 |
1518 | @@ -1,70 +0,0 @@ |
1519 | -// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
1520 | -/* |
1521 | - * Copyright (C) 2012 Canonical Ltd |
1522 | - * |
1523 | - * This program is free software: you can redistribute it and/or modify |
1524 | - * it under the terms of the GNU General Public License version 3 as |
1525 | - * published by the Free Software Foundation. |
1526 | - * |
1527 | - * This program is distributed in the hope that it will be useful, |
1528 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1529 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1530 | - * GNU General Public License for more details. |
1531 | - * |
1532 | - * You should have received a copy of the GNU General Public License |
1533 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1534 | - * |
1535 | - * Authored by: Jason Smith <jason.smith@canonical.com> |
1536 | - */ |
1537 | - |
1538 | -#ifndef NUX_COVERFLOWMODEL_H |
1539 | -#define NUX_COVERFLOWMODEL_H |
1540 | - |
1541 | -#include <memory> |
1542 | -#include <vector> |
1543 | - |
1544 | -#include <sigc++/sigc++.h> |
1545 | -#include "CoverflowItem.h" |
1546 | - |
1547 | -namespace nux |
1548 | -{ |
1549 | - |
1550 | -class CoverflowModel : public InitiallyUnownedObject |
1551 | -{ |
1552 | - NUX_DECLARE_OBJECT_TYPE(CoverflowModel, InitiallyUnownedObject); |
1553 | -public: |
1554 | - typedef ObjectPtr<CoverflowModel> Ptr; |
1555 | - typedef std::vector<CoverflowItem::Ptr> CoverflowItemList; |
1556 | - |
1557 | - CoverflowModel(); |
1558 | - ~CoverflowModel(); |
1559 | - |
1560 | - CoverflowItemList const& Items() const; |
1561 | - |
1562 | - void AddItem(CoverflowItem::Ptr const& item); |
1563 | - void InsertItem(CoverflowItem::Ptr const& item, size_t index); |
1564 | - void RemoveItem(CoverflowItem::Ptr const& item); |
1565 | - |
1566 | - size_t IndexOf(CoverflowItem::Ptr const& item); |
1567 | - |
1568 | - CoverflowItem::Ptr Selection(); |
1569 | - size_t SelectionIndex(); |
1570 | - |
1571 | - void SetSelection(size_t index); |
1572 | - void SetSelection(CoverflowItem::Ptr item); |
1573 | - |
1574 | - void SelectNext(); |
1575 | - void SelectPrev(); |
1576 | - |
1577 | - sigc::signal<void, CoverflowModel*, CoverflowItem::Ptr> item_added; |
1578 | - sigc::signal<void, CoverflowModel*, CoverflowItem::Ptr> item_removed; |
1579 | - sigc::signal<void, CoverflowModel*, CoverflowItem::Ptr> selection_changed; |
1580 | - |
1581 | -private: |
1582 | - struct Impl; |
1583 | - Impl* pimpl; |
1584 | -}; |
1585 | - |
1586 | -} |
1587 | - |
1588 | -#endif |
1589 | |
1590 | === modified file 'Nux/Makefile.am' |
1591 | --- Nux/Makefile.am 2015-08-12 14:50:30 +0000 |
1592 | +++ Nux/Makefile.am 2015-10-28 09:38:25 +0000 |
1593 | @@ -45,9 +45,6 @@ |
1594 | Canvas.cpp \ |
1595 | CheckBox.cpp \ |
1596 | ClientArea.cpp \ |
1597 | - Coverflow.cpp \ |
1598 | - CoverflowItem.cpp \ |
1599 | - CoverflowModel.cpp \ |
1600 | EMMetrics.cpp \ |
1601 | GridHLayout.cpp \ |
1602 | HLayout.cpp \ |
1603 | @@ -158,9 +155,6 @@ |
1604 | Canvas.h \ |
1605 | CheckBox.h \ |
1606 | ClientArea.h \ |
1607 | - Coverflow.h \ |
1608 | - CoverflowItem.h \ |
1609 | - CoverflowModel.h \ |
1610 | EMMetrics.h \ |
1611 | GridHLayout.h \ |
1612 | HLayout.h \ |
1613 | |
1614 | === modified file 'data/Makefile.am' |
1615 | --- data/Makefile.am 2015-08-12 14:50:30 +0000 |
1616 | +++ data/Makefile.am 2015-10-28 09:38:25 +0000 |
1617 | @@ -87,6 +87,4 @@ |
1618 | UITextures/VectorZLabel.tga \ |
1619 | UITextures/VScrollBar.tga \ |
1620 | UITextures/WindowSizeGrip.tga \ |
1621 | - UITextures/nux.png \ |
1622 | - UITextures/coverflow.oval-shadow.png |
1623 | - |
1624 | + UITextures/nux.png |
1625 | |
1626 | === removed file 'data/UITextures/coverflow.oval-shadow.png' |
1627 | Binary files data/UITextures/coverflow.oval-shadow.png 2012-02-11 05:26:49 +0000 and data/UITextures/coverflow.oval-shadow.png 1970-01-01 00:00:00 +0000 differ |
1628 | === modified file 'examples/Makefile.am' |
1629 | --- examples/Makefile.am 2015-08-12 14:50:30 +0000 |
1630 | +++ examples/Makefile.am 2015-10-28 09:38:25 +0000 |
1631 | @@ -31,7 +31,6 @@ |
1632 | |
1633 | noinst_PROGRAMS = text_entry_focus \ |
1634 | shortcut_keys \ |
1635 | - coverflow \ |
1636 | kinetic_scroll_view |
1637 | |
1638 | #button \ |
1639 | @@ -133,9 +132,6 @@ |
1640 | shortcut_keys_SOURCES = shortcut-keys.cpp line-separator.cpp line-separator.h abstract-separator.h abstract-separator.cpp |
1641 | shortcut_keys_LDADD = $(ALL_LIBS) |
1642 | |
1643 | -coverflow_SOURCES = coverflow.cpp |
1644 | -coverflow_LDADD = $(ALL_LIBS) |
1645 | - |
1646 | kinetic_scroll_view_SOURCES = kinetic_scroll_view.cpp TestButton.h TestButton.cpp |
1647 | kinetic_scroll_view_LDADD = $(ALL_LIBS) |
1648 | |
1649 | |
1650 | === removed file 'examples/coverflow.cpp' |
1651 | --- examples/coverflow.cpp 2012-09-26 06:44:12 +0000 |
1652 | +++ examples/coverflow.cpp 1970-01-01 00:00:00 +0000 |
1653 | @@ -1,152 +0,0 @@ |
1654 | -// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
1655 | -/* |
1656 | - * Copyright (C) 2012 Canonical Ltd |
1657 | - * |
1658 | - * This program is free software: you can redistribute it and/or modify |
1659 | - * it under the terms of the GNU General Public License version 3 as |
1660 | - * published by the Free Software Foundation. |
1661 | - * |
1662 | - * This program is distributed in the hope that it will be useful, |
1663 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1664 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1665 | - * GNU General Public License for more details. |
1666 | - * |
1667 | - * You should have received a copy of the GNU General Public License |
1668 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1669 | - * |
1670 | - * Authored by: Jason Smith <jason.smith@canonical.com> |
1671 | - * Authored by: Jay Taoko <jay.taoko@canonical.com> |
1672 | - */ |
1673 | - |
1674 | -const char* movie_list[] = { |
1675 | -"nux.png", |
1676 | -"nux.png", |
1677 | -"nux.png", |
1678 | -"nux.png", |
1679 | -"nux.png", |
1680 | -"nux.png", |
1681 | -"nux.png", |
1682 | -"nux.png", |
1683 | -"nux.png", |
1684 | -"nux.png", |
1685 | -"nux.png", |
1686 | -"nux.png", |
1687 | -"nux.png", |
1688 | -"nux.png", |
1689 | -"nux.png", |
1690 | -"nux.png", |
1691 | -"nux.png", |
1692 | -"nux.png", |
1693 | -"nux.png", |
1694 | -"nux.png", |
1695 | -"nux.png", |
1696 | -"nux.png", |
1697 | -"nux.png", |
1698 | -"nux.png", |
1699 | -"nux.png", |
1700 | -"nux.png", |
1701 | -"nux.png", |
1702 | -"nux.png", |
1703 | -"nux.png", |
1704 | -"nux.png", |
1705 | -"nux.png", |
1706 | -"nux.png", |
1707 | -"nux.png", |
1708 | -"nux.png", |
1709 | -"nux.png", |
1710 | -"nux.png", |
1711 | -"nux.png", |
1712 | -"nux.png", |
1713 | -"nux.png", |
1714 | -"nux.png", |
1715 | -"nux.png", |
1716 | -"nux.png", |
1717 | -"nux.png", |
1718 | -"nux.png", |
1719 | -"nux.png", |
1720 | -"nux.png", |
1721 | -"nux.png", |
1722 | -"nux.png", |
1723 | -"nux.png", |
1724 | -"nux.png", |
1725 | -"nux.png", |
1726 | -"nux.png", |
1727 | -0 |
1728 | -}; |
1729 | - |
1730 | -#include "Nux/Nux.h" |
1731 | -#include "Nux/HLayout.h" |
1732 | - |
1733 | -#include "NuxGraphics/GraphicsDisplay.h" |
1734 | -#include "NuxGraphics/GLShader.h" |
1735 | -#include "NuxGraphics/GpuDevice.h" |
1736 | -#include "NuxGraphics/GLDeviceObjects.h" |
1737 | -#include "NuxGraphics/GLShader.h" |
1738 | -#include "NuxGraphics/GraphicsEngine.h" |
1739 | - |
1740 | -#include "Nux/Coverflow.h" |
1741 | -#include "Nux/CoverflowItem.h" |
1742 | - |
1743 | -namespace nux |
1744 | -{ |
1745 | -//class BaseTexture; |
1746 | - |
1747 | -class BasicCoverflowItem : public CoverflowItem |
1748 | -{ |
1749 | -public: |
1750 | - BasicCoverflowItem(std::string const& name, std::string const& filename); |
1751 | - ObjectPtr<BaseTexture> GetTexture() const; |
1752 | - |
1753 | -private: |
1754 | - ObjectPtr<BaseTexture> texture_; |
1755 | -}; |
1756 | - |
1757 | -BasicCoverflowItem::BasicCoverflowItem(std::string const& name, |
1758 | - std::string const& filename) |
1759 | -: CoverflowItem(name) |
1760 | -{ |
1761 | - texture_.Adopt(LoadTextureFromFile(filename)); |
1762 | -} |
1763 | - |
1764 | -ObjectPtr<BaseTexture> BasicCoverflowItem::GetTexture() const |
1765 | -{ |
1766 | - return texture_; |
1767 | -} |
1768 | - |
1769 | -} |
1770 | - |
1771 | -void CoverflowThread(nux::NThread* thread, void* /* InitData */) |
1772 | -{ |
1773 | - nux::Coverflow* coverflow = new nux::Coverflow(); |
1774 | - coverflow->fov = 45; |
1775 | - coverflow->true_perspective = false; |
1776 | - coverflow->folding_angle = 45; |
1777 | - coverflow->reflection_size = 0.5f; |
1778 | - coverflow->show_reflection = true; |
1779 | - nux::HLayout* main_layout(new nux::HLayout(NUX_TRACKER_LOCATION)); |
1780 | - main_layout->AddView(coverflow, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); |
1781 | - |
1782 | - static_cast<nux::WindowThread*>(thread)->SetLayout(main_layout); |
1783 | - |
1784 | - int i = 0; |
1785 | - nux::CoverflowModel::Ptr model = coverflow->model(); |
1786 | - std::string base_path = PKGDATADIR"/UITextures/"; |
1787 | - while(movie_list[i] != NULL) |
1788 | - { |
1789 | - std::string name = "Nux The Movie"; |
1790 | - std::string movie_path = base_path + movie_list[i]; |
1791 | - nux::CoverflowItem::Ptr item(new nux::BasicCoverflowItem(name, movie_path)); |
1792 | - model->AddItem(item); |
1793 | - i++; |
1794 | - } |
1795 | -} |
1796 | - |
1797 | -int main() |
1798 | -{ |
1799 | - nux::NuxInitialize(0); |
1800 | - |
1801 | - std::unique_ptr<nux::WindowThread> wt(nux::CreateGUIThread("CoverFlow", 1100, 480, 0, &CoverflowThread, 0)); |
1802 | - wt->Run(0); |
1803 | - |
1804 | - return 0; |
1805 | -} |
PASSED: Continuous integration, rev:864 jenkins. qa.ubuntu. com/job/ nux-ci/ 123/ jenkins. qa.ubuntu. com/job/ nux-wily- amd64-ci/ 5 jenkins. qa.ubuntu. com/job/ nux-wily- armhf-ci/ 5 jenkins. qa.ubuntu. com/job/ nux-wily- i386-ci/ 5
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/nux- ci/123/ rebuild
http://