Merge lp:~jaytaoko/nux/nux-deprecated-api into lp:nux/2.0
- nux-deprecated-api
- Merge into 2.0
Proposed by
Jay Taoko
Status: | Merged |
---|---|
Approved by: | Jay Taoko |
Approved revision: | 532 |
Merged at revision: | 532 |
Proposed branch: | lp:~jaytaoko/nux/nux-deprecated-api |
Merge into: | lp:nux/2.0 |
Diff against target: |
2054 lines (+465/-318) 36 files modified
Nux/Area.cpp (+8/-8) Nux/Area.h (+2/-2) Nux/BaseWindow.cpp (+9/-9) Nux/Canvas.cpp (+1/-1) Nux/ComboBoxSimple.cpp (+2/-2) Nux/FloatingWindow.cpp (+1/-1) Nux/HSplitter.cpp (+2/-2) Nux/InputArea.cpp (+12/-12) Nux/MenuBar.cpp (+5/-5) Nux/MenuPage.cpp (+5/-5) Nux/Nux.cpp (+0/-27) Nux/Nux.h (+0/-7) Nux/Painter.cpp (+5/-5) Nux/PangoText.cpp (+1/-1) Nux/StaticText.cpp (+17/-10) Nux/StaticText.h (+31/-5) Nux/TextEntry.cpp (+50/-50) Nux/TextEntry.h (+2/-2) Nux/TextureArea.cpp (+0/-2) Nux/Theme.h (+4/-0) Nux/TimerProc.cpp (+22/-13) Nux/VLayout.cpp (+0/-1) Nux/VSplitter.cpp (+2/-2) Nux/WindowCompositor.cpp (+93/-93) Nux/WindowThread.h (+0/-24) NuxGraphics/GpuDevice.h (+5/-0) NuxGraphics/GraphicsDisplayX11.cpp (+39/-22) NuxGraphics/GraphicsEngine.h (+3/-0) NuxImage/CairoGraphics.cpp (+6/-0) NuxImage/CairoGraphics.h (+2/-0) configure.ac (+1/-1) tests/Makefile.am (+32/-1) tests/nux_automated_test_framework.cpp (+5/-5) tests/test-nux-main.cpp (+13/-0) tests/test-nux-statictext.cpp (+52/-0) tests/test-nux-windowthread.cpp (+33/-0) |
To merge this branch: | bzr merge lp:~jaytaoko/nux/nux-deprecated-api |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jason Smith (community) | Approve | ||
Review via email: mp+87269@code.launchpad.net |
Commit message
Description of the change
* Removed API:
GraphicsDisplay& GetWindow();
GraphicsEngine& GetGraphicsEngi
NThread* GetThreadApplic
WindowThread* GetGraphicsThre
* Modified code to to use GetWindowThread() to access its internal objects.
* Added tests:
- WindowThread
- StaticText
To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) : | # |
review:
Approve
- 530. By Andrea Azzarone
-
Makes sure that the scroll wheel works with nux::VScrollbar. Fixes: https:/
/bugs.launchpad .net/bugs/ 888819. Appoved by Jay Taoko. - 531. By Jay Taoko
-
Added separate file for GLib main loop functions
* Cleanup: variable renaming
* Marked some functions as obsolete
* Core objects take the WindowThread as a constructor parameters: Painter, WindowCompositor.... Fixes: . Appoved by Jason Smith. - 532. By Jay Taoko
-
* Changed ABI version
* Merged with trunk
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Nux/Area.cpp' |
2 | --- Nux/Area.cpp 2011-12-22 06:23:58 +0000 |
3 | +++ Nux/Area.cpp 2012-01-03 03:15:27 +0000 |
4 | @@ -52,8 +52,8 @@ |
5 | sensitive_ = true; |
6 | |
7 | on_geometry_change_reconfigure_parent_layout_ = true; |
8 | - _accept_mouse_wheel_event = false; |
9 | - _accept_keyboard_event = false; |
10 | + accept_mouse_wheel_event_ = false; |
11 | + accept_keyboard_event_ = false; |
12 | |
13 | _2d_xform.Identity(); |
14 | _3d_xform.Identity(); |
15 | @@ -845,22 +845,22 @@ |
16 | |
17 | void Area::SetAcceptKeyboardEvent(bool accept_keyboard_event) |
18 | { |
19 | - _accept_keyboard_event = accept_keyboard_event; |
20 | + accept_keyboard_event_ = accept_keyboard_event; |
21 | } |
22 | |
23 | bool Area::AcceptKeyboardEvent() const |
24 | { |
25 | - return _accept_keyboard_event; |
26 | + return accept_keyboard_event_; |
27 | } |
28 | |
29 | void Area::SetAcceptMouseWheelEvent(bool accept_mouse_wheel_event) |
30 | { |
31 | - _accept_mouse_wheel_event = accept_mouse_wheel_event; |
32 | + accept_mouse_wheel_event_ = accept_mouse_wheel_event; |
33 | } |
34 | |
35 | bool Area::AcceptMouseWheelEvent() const |
36 | { |
37 | - return _accept_mouse_wheel_event; |
38 | + return accept_mouse_wheel_event_; |
39 | } |
40 | |
41 | bool Area::TestMousePointerInclusion(const Point& mouse_position, NuxEventType event_type) |
42 | @@ -891,7 +891,7 @@ |
43 | |
44 | if ((event_type == NUX_MOUSE_WHEEL) && mouse_pointer_inside_area) |
45 | { |
46 | - if (_accept_mouse_wheel_event == false) |
47 | + if (accept_mouse_wheel_event_ == false) |
48 | return NULL; |
49 | } |
50 | |
51 | @@ -1020,7 +1020,7 @@ |
52 | bool Area::IsMousePointerInside() const |
53 | { |
54 | Geometry geo = GetAbsoluteGeometry(); |
55 | - Point position = GetWindowCompositor().GetMousePosition(); |
56 | + Point position = GetWindowThread()->GetWindowCompositor().GetMousePosition(); |
57 | |
58 | if (geo.IsInside(position)) |
59 | return true; |
60 | |
61 | === modified file 'Nux/Area.h' |
62 | --- Nux/Area.h 2011-11-22 07:13:53 +0000 |
63 | +++ Nux/Area.h 2012-01-03 03:15:27 +0000 |
64 | @@ -630,8 +630,8 @@ |
65 | |
66 | std::list<Area*> _children_list; |
67 | |
68 | - bool _accept_mouse_wheel_event; |
69 | - bool _accept_keyboard_event; |
70 | + bool accept_mouse_wheel_event_; |
71 | + bool accept_keyboard_event_; |
72 | |
73 | WindowThread* window_thread_; |
74 | |
75 | |
76 | === modified file 'Nux/BaseWindow.cpp' |
77 | --- Nux/BaseWindow.cpp 2011-10-17 21:23:50 +0000 |
78 | +++ Nux/BaseWindow.cpp 2012-01-03 03:15:27 +0000 |
79 | @@ -70,7 +70,7 @@ |
80 | accept_key_nav_focus_ = false; |
81 | |
82 | // Should be at the end of the constructor |
83 | - GetWindowCompositor().RegisterWindow(this); |
84 | + GetWindowThread()->GetWindowCompositor().RegisterWindow(this); |
85 | |
86 | SetMinimumSize(1, 1); |
87 | SetGeometry(Geometry(100, 100, 320, 200)); |
88 | @@ -360,7 +360,7 @@ |
89 | _entering_visible_state = true; |
90 | |
91 | sigVisible.emit(this); |
92 | - GetWindowCompositor().sigVisibleViewWindow.emit(this); |
93 | + GetWindowThread()->GetWindowCompositor().sigVisibleViewWindow.emit(this); |
94 | |
95 | ComputeContentSize(); |
96 | } |
97 | @@ -368,11 +368,11 @@ |
98 | { |
99 | _entering_hidden_state = true; |
100 | sigHidden.emit(this); |
101 | - GetWindowCompositor().sigHiddenViewWindow.emit(this); |
102 | + GetWindowThread()->GetWindowCompositor().sigHiddenViewWindow.emit(this); |
103 | } |
104 | |
105 | if (_is_modal) |
106 | - GetWindowCompositor().StartModalWindow(ObjectWeakPtr<BaseWindow>(this)); |
107 | + GetWindowThread()->GetWindowCompositor().StartModalWindow(ObjectWeakPtr<BaseWindow>(this)); |
108 | |
109 | // Whether this view is added or removed, call QueueDraw. in the case where this view is removed, this is a signal |
110 | // that the region below this view need to be redrawn. |
111 | @@ -389,7 +389,7 @@ |
112 | _is_visible = false; |
113 | _is_modal = false; |
114 | //ShowWindow(false); |
115 | - GetWindowCompositor().StopModalWindow(ObjectWeakPtr<BaseWindow> (this)); |
116 | + GetWindowThread()->GetWindowCompositor().StopModalWindow(ObjectWeakPtr<BaseWindow> (this)); |
117 | } |
118 | |
119 | bool BaseWindow::IsModal() const |
120 | @@ -436,17 +436,17 @@ |
121 | |
122 | void BaseWindow::PushHigher(BaseWindow* floating_view) |
123 | { |
124 | - GetWindowCompositor().PushHigher(this, floating_view); |
125 | + GetWindowThread()->GetWindowCompositor().PushHigher(this, floating_view); |
126 | } |
127 | |
128 | void BaseWindow::PushToFront() |
129 | { |
130 | - GetWindowCompositor().PushToFront(this); |
131 | + GetWindowThread()->GetWindowCompositor().PushToFront(this); |
132 | } |
133 | |
134 | void BaseWindow::PushToBack() |
135 | { |
136 | - GetWindowCompositor().PushToBack(this); |
137 | + GetWindowThread()->GetWindowCompositor().PushToBack(this); |
138 | } |
139 | |
140 | bool BaseWindow::ChildNeedsRedraw() |
141 | @@ -456,7 +456,7 @@ |
142 | |
143 | void* BaseWindow::GetBackupTextureData(int &width, int &height, int &format) |
144 | { |
145 | - return GetWindowCompositor().GetBackupTextureData(this, width, height, format); |
146 | + return GetWindowThread()->GetWindowCompositor().GetBackupTextureData(this, width, height, format); |
147 | } |
148 | |
149 | void BaseWindow::SetEnterFocusInputArea(InputArea *input_area) |
150 | |
151 | === modified file 'Nux/Canvas.cpp' |
152 | --- Nux/Canvas.cpp 2011-10-19 22:12:33 +0000 |
153 | +++ Nux/Canvas.cpp 2012-01-03 03:15:27 +0000 |
154 | @@ -168,7 +168,7 @@ |
155 | // draw the texture on screen |
156 | graphics_engine.PushClippingRectangle (geom); |
157 | |
158 | - GetGraphicsEngine().GetRenderStates().SetBlend (false); |
159 | + GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetBlend (false); |
160 | |
161 | TexCoordXForm texxform; |
162 | texxform.SetWrap(TEXWRAP_CLAMP, TEXWRAP_CLAMP); |
163 | |
164 | === modified file 'Nux/ComboBoxSimple.cpp' |
165 | --- Nux/ComboBoxSimple.cpp 2011-10-17 21:23:50 +0000 |
166 | +++ Nux/ComboBoxSimple.cpp 2012-01-03 03:15:27 +0000 |
167 | @@ -232,12 +232,12 @@ |
168 | |
169 | // When the menu is closing check if the mouse is still inside the combo box surface |
170 | // and set the _current_mouse_in flag accordingly. |
171 | - if (!_combo_box_area->TestMousePointerInclusion(GetWindowCompositor().GetMousePosition(), NUX_NO_EVENT)) |
172 | + if (!_combo_box_area->TestMousePointerInclusion(GetWindowThread()->GetWindowCompositor().GetMousePosition(), NUX_NO_EVENT)) |
173 | { |
174 | _combo_box_area->_event_processor._current_mouse_in = false; |
175 | } |
176 | |
177 | - if (!_combo_box_opening_area->TestMousePointerInclusion(GetWindowCompositor().GetMousePosition(), NUX_NO_EVENT)) |
178 | + if (!_combo_box_opening_area->TestMousePointerInclusion(GetWindowThread()->GetWindowCompositor().GetMousePosition(), NUX_NO_EVENT)) |
179 | { |
180 | _combo_box_opening_area->_event_processor._current_mouse_in = false; |
181 | } |
182 | |
183 | === modified file 'Nux/FloatingWindow.cpp' |
184 | --- Nux/FloatingWindow.cpp 2011-10-22 06:59:17 +0000 |
185 | +++ Nux/FloatingWindow.cpp 2012-01-03 03:15:27 +0000 |
186 | @@ -302,7 +302,7 @@ |
187 | } |
188 | #endif |
189 | |
190 | - GetWindowThread()->AddObjectToRefreshList(this); |
191 | + GetWindowThread()->QueueObjectLayout(this); |
192 | QueueDraw(); |
193 | } |
194 | |
195 | |
196 | === modified file 'Nux/HSplitter.cpp' |
197 | --- Nux/HSplitter.cpp 2011-10-21 22:06:35 +0000 |
198 | +++ Nux/HSplitter.cpp 2012-01-03 03:15:27 +0000 |
199 | @@ -440,7 +440,7 @@ |
200 | m_point = Point(x, y); |
201 | |
202 | m_focus_splitter_index = header_pos; |
203 | - GetWindowCompositor().SetWidgetDrawingOverlay(this, GetWindowCompositor().GetProcessingTopView()); |
204 | + GetWindowThread()->GetWindowCompositor().SetWidgetDrawingOverlay(this, GetWindowThread()->GetWindowCompositor().GetProcessingTopView()); |
205 | |
206 | |
207 | // Hint for the window to initiate a redraw |
208 | @@ -472,7 +472,7 @@ |
209 | mvt_dy = 0; |
210 | |
211 | // End overlay drawing; |
212 | - GetWindowCompositor().SetWidgetDrawingOverlay(0, GetWindowCompositor().GetProcessingTopView()); |
213 | + GetWindowThread()->GetWindowCompositor().SetWidgetDrawingOverlay(0, GetWindowThread()->GetWindowCompositor().GetProcessingTopView()); |
214 | // Hint for the window to initiate a redraw |
215 | GetWindowThread()->RequestRedraw(); |
216 | } |
217 | |
218 | === modified file 'Nux/InputArea.cpp' |
219 | --- Nux/InputArea.cpp 2011-10-17 21:23:50 +0000 |
220 | +++ Nux/InputArea.cpp 2012-01-03 03:15:27 +0000 |
221 | @@ -75,7 +75,7 @@ |
222 | |
223 | bool InputArea::HasKeyboardFocus() |
224 | { |
225 | - return GetWindowCompositor().GetKeyFocusArea() == this; |
226 | + return GetWindowThread()->GetWindowCompositor().GetKeyFocusArea() == this; |
227 | } |
228 | |
229 | void InputArea::SetKeyboardFocus(bool b) |
230 | @@ -150,7 +150,7 @@ |
231 | #if defined(NUX_OS_LINUX) |
232 | std::list<char *> mimes; |
233 | |
234 | - mimes = GetWindow().GetDndMimeTypes(); |
235 | + mimes = GetWindowThread()->GetGraphicsDisplay().GetDndMimeTypes(); |
236 | std::list<char *>::iterator it; |
237 | ProcessDndMove(event.e_x, event.e_y, mimes); |
238 | |
239 | @@ -169,12 +169,12 @@ |
240 | #if defined(NUX_OS_LINUX) |
241 | void InputArea::SendDndStatus(bool accept, DndAction action, Geometry region) |
242 | { |
243 | - GetWindow().SendDndStatus(accept, action, Rect(region.x, region.y, region.width, region.height)); |
244 | + GetWindowThread()->GetGraphicsDisplay().SendDndStatus(accept, action, Rect(region.x, region.y, region.width, region.height)); |
245 | } |
246 | |
247 | void InputArea::SendDndFinished(bool accepted, DndAction action) |
248 | { |
249 | - GetWindow().SendDndFinished(accepted, action); |
250 | + GetWindowThread()->GetGraphicsDisplay().SendDndFinished(accepted, action); |
251 | } |
252 | |
253 | void InputArea::ProcessDndMove(int x, int y, std::list<char *>mimes) |
254 | @@ -263,43 +263,43 @@ |
255 | funcs.drag_finished = &InputArea::InnerDndSourceDragFinished; |
256 | |
257 | if (DndSourceDragBegin()) |
258 | - GetWindow().StartDndDrag(funcs, this); |
259 | + GetWindowThread()->GetGraphicsDisplay().StartDndDrag(funcs, this); |
260 | } |
261 | #endif |
262 | |
263 | void InputArea::GrabPointer() |
264 | { |
265 | - GetWindowCompositor().GrabPointerAdd(this); |
266 | + GetWindowThread()->GetWindowCompositor().GrabPointerAdd(this); |
267 | } |
268 | |
269 | void InputArea::UnGrabPointer() |
270 | { |
271 | - GetWindowCompositor().GrabPointerRemove(this); |
272 | + GetWindowThread()->GetWindowCompositor().GrabPointerRemove(this); |
273 | } |
274 | |
275 | void InputArea::GrabKeyboard() |
276 | { |
277 | - GetWindowCompositor().GrabKeyboardAdd(this); |
278 | + GetWindowThread()->GetWindowCompositor().GrabKeyboardAdd(this); |
279 | } |
280 | |
281 | void InputArea::UnGrabKeyboard() |
282 | { |
283 | - GetWindowCompositor().GrabKeyboardRemove(this); |
284 | + GetWindowThread()->GetWindowCompositor().GrabKeyboardRemove(this); |
285 | } |
286 | |
287 | bool InputArea::OwnsPointerGrab() |
288 | { |
289 | - return GetWindowCompositor().GetPointerGrabArea() == this; |
290 | + return GetWindowThread()->GetWindowCompositor().GetPointerGrabArea() == this; |
291 | } |
292 | |
293 | bool InputArea::OwnsKeyboardGrab() |
294 | { |
295 | - return GetWindowCompositor().GetKeyboardGrabArea() == this; |
296 | + return GetWindowThread()->GetWindowCompositor().GetKeyboardGrabArea() == this; |
297 | } |
298 | |
299 | bool InputArea::IsMouseOwner() |
300 | { |
301 | - return (GetWindowCompositor().GetMouseOwnerArea() == this); |
302 | + return (GetWindowThread()->GetWindowCompositor().GetMouseOwnerArea() == this); |
303 | } |
304 | |
305 | // == Signals with 1 to 1 mapping to input device == |
306 | |
307 | === modified file 'Nux/MenuBar.cpp' |
308 | --- Nux/MenuBar.cpp 2011-10-21 22:06:35 +0000 |
309 | +++ Nux/MenuBar.cpp 2012-01-03 03:15:27 +0000 |
310 | @@ -261,7 +261,7 @@ |
311 | } |
312 | void MenuBar::EmitItemMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags, MenuBarItem *menubar_item) |
313 | { |
314 | - m_MenuBarWindow = GetWindowCompositor().GetProcessingTopView(); |
315 | + m_MenuBarWindow = GetWindowThread()->GetWindowCompositor().GetProcessingTopView(); |
316 | |
317 | if (m_MenuIsActive == false) |
318 | { |
319 | @@ -331,9 +331,9 @@ |
320 | { |
321 | // TODO: Port to new event architecture |
322 | // // Transition between one menu bar item to another |
323 | -// if (GetWindowCompositor().GetMouseFocusArea() == menubar_item->area) |
324 | +// if (GetWindowThread()->GetWindowCompositor().GetMouseFocusArea() == menubar_item->area) |
325 | // { |
326 | -// if (!menubar_item->area->IsMouseInside()) // can also test GetWindowCompositor().GetMouseOverArea() != &menubar_item->area |
327 | +// if (!menubar_item->area->IsMouseInside()) // can also test GetWindowThread()->GetWindowCompositor().GetMouseOverArea() != &menubar_item->area |
328 | // { |
329 | // std::list< MenuBarItem * >::iterator it; |
330 | // // compute window coordinates x and y; |
331 | @@ -356,8 +356,8 @@ |
332 | // m_IsOpeningMenu = true; |
333 | // area->ForceStartFocus(0, 0); |
334 | // |
335 | -// GetWindowCompositor().SetMouseFocusArea(area); |
336 | -// GetWindowCompositor().SetMouseOverArea(area); |
337 | +// GetWindowThread()->GetWindowCompositor().SetMouseFocusArea(area); |
338 | +// GetWindowThread()->GetWindowCompositor().SetMouseOverArea(area); |
339 | // } |
340 | // |
341 | // break; |
342 | |
343 | === modified file 'Nux/MenuPage.cpp' |
344 | --- Nux/MenuPage.cpp 2011-10-21 22:06:35 +0000 |
345 | +++ Nux/MenuPage.cpp 2012-01-03 03:15:27 +0000 |
346 | @@ -920,8 +920,8 @@ |
347 | base.SetX(MenuXPosition); |
348 | base.SetY(MenuYPosition); |
349 | |
350 | - int WindowWidth = GetGraphicsEngine().GetWindowWidth(); |
351 | - int WindowHeight = GetGraphicsEngine().GetWindowHeight(); |
352 | + int WindowWidth = GetWindowThread()->GetGraphicsEngine().GetWindowWidth(); |
353 | + int WindowHeight = GetWindowThread()->GetGraphicsEngine().GetWindowHeight(); |
354 | |
355 | // Correct the position of the MenuPage if is going out of the screen |
356 | // The first page of a menu chain has less opportunities to be adjusted than its child pages. |
357 | @@ -962,10 +962,10 @@ |
358 | if (GetParentMenu() == 0) |
359 | { |
360 | // This is the head of the menu chain |
361 | - m_MenuWindow = GetWindowCompositor().GetProcessingTopView(); |
362 | + m_MenuWindow = GetWindowThread()->GetWindowCompositor().GetProcessingTopView(); |
363 | } |
364 | |
365 | - GetWindowCompositor().AddMenu(this, m_MenuWindow/*, OverrideCurrentMenuChain*/); |
366 | + GetWindowThread()->GetWindowCompositor().AddMenu(this, m_MenuWindow/*, OverrideCurrentMenuChain*/); |
367 | m_NextMouseUpMeanStop = false; |
368 | |
369 | StopActionSubMenu(); |
370 | @@ -985,7 +985,7 @@ |
371 | // (where the menu is about to disappear). |
372 | QueueDraw(); |
373 | |
374 | - /*Area *top_area = GetWindowCompositor().GetProcessingTopView(); |
375 | + /*Area *top_area = GetWindowThread()->GetWindowCompositor().GetProcessingTopView(); |
376 | if (top_area) |
377 | { |
378 | if (top_area->IsView()) |
379 | |
380 | === modified file 'Nux/Nux.cpp' |
381 | --- Nux/Nux.cpp 2011-12-22 06:23:58 +0000 |
382 | +++ Nux/Nux.cpp 2012-01-03 03:15:27 +0000 |
383 | @@ -379,31 +379,4 @@ |
384 | NThread *thread = GetWindowThread(); |
385 | return NUX_STATIC_CAST(WindowThread *, thread)->GetTimerHandler(); |
386 | } |
387 | - |
388 | - // todo(jaytaoko): remove the following call. |
389 | - GraphicsDisplay& GetWindow() //deprecated |
390 | - { |
391 | - NThread* thread = GetWindowThread(); |
392 | - return NUX_STATIC_CAST(WindowThread*, thread)->GetWindow(); |
393 | - } |
394 | - |
395 | - // todo(jaytaoko): remove the following call. |
396 | - GraphicsEngine& GetGraphicsEngine() //deprecated |
397 | - { |
398 | - NThread* thread = GetWindowThread(); |
399 | - return NUX_STATIC_CAST(WindowThread*, thread)->GetGraphicsEngine(); |
400 | - } |
401 | - |
402 | - // todo(jaytaoko): remove the following call. |
403 | - NThread* GetThreadApplication() // deprecated |
404 | - { |
405 | - NThread* thread = static_cast<NThread*> (inlGetThreadLocalStorage(ThreadLocal_InalogicAppImpl)); |
406 | - return thread; |
407 | - } |
408 | - |
409 | - // todo(jaytaoko): remove the following call. |
410 | - WindowThread* GetGraphicsThread() // deprecated |
411 | - { |
412 | - return NUX_STATIC_CAST(WindowThread*, GetWindowThread()); |
413 | - } |
414 | } |
415 | |
416 | === modified file 'Nux/Nux.h' |
417 | --- Nux/Nux.h 2011-12-22 06:23:58 +0000 |
418 | +++ Nux/Nux.h 2012-01-03 03:15:27 +0000 |
419 | @@ -232,13 +232,6 @@ |
420 | UXTheme &GetTheme(); |
421 | TimerHandler &GetTimer(); |
422 | |
423 | - // todo(jaytaoko): remove the following calls. |
424 | - GraphicsDisplay& GetWindow(); //deprecated |
425 | - GraphicsEngine& GetGraphicsEngine(); //deprecated |
426 | - NThread* GetThreadApplication(); // deprecated |
427 | - WindowThread* GetGraphicsThread(); // deprecated |
428 | - |
429 | - |
430 | #define gPainter nux::GetPainter() // deprecated |
431 | #define gTheme nux::GetTheme() // deprecated |
432 | |
433 | |
434 | === modified file 'Nux/Painter.cpp' |
435 | --- Nux/Painter.cpp 2011-12-22 06:23:58 +0000 |
436 | +++ Nux/Painter.cpp 2012-01-03 03:15:27 +0000 |
437 | @@ -839,7 +839,7 @@ |
438 | void BasePainter::PushLayer(GraphicsEngine &graphics_engine, const Geometry &geo, AbstractPaintLayer *layer) |
439 | { |
440 | AbstractPaintLayer *l = layer->Clone(); |
441 | - l->SetModelViewMatrix(GetGraphicsEngine().GetModelViewMatrix()); |
442 | + l->SetModelViewMatrix(window_thread_->GetGraphicsEngine().GetModelViewMatrix()); |
443 | l->SetGeometry(geo); |
444 | active_paint_layer_stack_.push_front(l); |
445 | } |
446 | @@ -856,7 +856,7 @@ |
447 | const ROPConfig &ROP) |
448 | { |
449 | ColorLayer *cl = new ColorLayer(color, WriteAlpha, ROP); |
450 | - cl->SetModelViewMatrix(GetGraphicsEngine().GetModelViewMatrix()); |
451 | + cl->SetModelViewMatrix(window_thread_->GetGraphicsEngine().GetModelViewMatrix()); |
452 | cl->SetGeometry(geo); |
453 | active_paint_layer_stack_.push_front(cl); |
454 | } |
455 | @@ -878,7 +878,7 @@ |
456 | const ROPConfig &ROP) |
457 | { |
458 | ShapeLayer *sl = new ShapeLayer(imageStyle, color, Corners, WriteAlpha, ROP); |
459 | - sl->SetModelViewMatrix(GetGraphicsEngine().GetModelViewMatrix()); |
460 | + sl->SetModelViewMatrix(window_thread_->GetGraphicsEngine().GetModelViewMatrix()); |
461 | sl->SetGeometry(geo); |
462 | active_paint_layer_stack_.push_front(sl); |
463 | } |
464 | @@ -902,7 +902,7 @@ |
465 | const ROPConfig &ROP) |
466 | { |
467 | SliceScaledTextureLayer *sl = new SliceScaledTextureLayer(imageStyle, color, Corners, WriteAlpha, ROP); |
468 | - sl->SetModelViewMatrix(GetGraphicsEngine().GetModelViewMatrix()); |
469 | + sl->SetModelViewMatrix(window_thread_->GetGraphicsEngine().GetModelViewMatrix()); |
470 | sl->SetGeometry(geo); |
471 | active_paint_layer_stack_.push_front(sl); |
472 | } |
473 | @@ -926,7 +926,7 @@ |
474 | const ROPConfig &ROP) |
475 | { |
476 | TextureLayer *tl = new TextureLayer(DeviceTexture, texxform, color, WriteAlpha, ROP); |
477 | - tl->SetModelViewMatrix(GetGraphicsEngine().GetModelViewMatrix()); |
478 | + tl->SetModelViewMatrix(window_thread_->GetGraphicsEngine().GetModelViewMatrix()); |
479 | tl->SetGeometry(geo); |
480 | active_paint_layer_stack_.push_front(tl); |
481 | } |
482 | |
483 | === modified file 'Nux/PangoText.cpp' |
484 | --- Nux/PangoText.cpp 2011-10-17 21:23:50 +0000 |
485 | +++ Nux/PangoText.cpp 2012-01-03 03:15:27 +0000 |
486 | @@ -278,7 +278,7 @@ |
487 | // typedef struct { |
488 | // PangoLayout *layout; |
489 | // gint start_index; // start of line as byte index into layout->text. |
490 | -// gint length; // length of line in bytes. |
491 | +// gint length; // length of line in bytes. |
492 | // GSList *runs; // a list containing the runs of the line in visual order. |
493 | // guint is_paragraph_start : 1; // TRUE if this is the first line of the paragraph. |
494 | // guint resolved_dir : 3; // Resolved direction of line. |
495 | |
496 | === modified file 'Nux/StaticText.cpp' |
497 | --- Nux/StaticText.cpp 2011-12-08 18:14:50 +0000 |
498 | +++ Nux/StaticText.cpp 2012-01-03 03:15:27 +0000 |
499 | @@ -300,12 +300,14 @@ |
500 | return text_; |
501 | } |
502 | |
503 | - void StaticText::SetTextColor(const Color &textColor) |
504 | + void StaticText::SetTextColor(const Color &text_color) |
505 | { |
506 | - if (text_color_ == textColor) |
507 | - return; |
508 | + text_color_ = text_color; |
509 | + } |
510 | |
511 | - text_color_ = textColor; |
512 | + Color StaticText::GetTextColor() const |
513 | + { |
514 | + return text_color_; |
515 | } |
516 | |
517 | void StaticText::SetFontName(const std::string &font_name) |
518 | @@ -328,6 +330,11 @@ |
519 | QueueDraw(); |
520 | } |
521 | |
522 | + std::string StaticText::GetFontName() const |
523 | + { |
524 | + return font_name_; |
525 | + } |
526 | + |
527 | void StaticText::GetTextLayoutSize(int &width, int &height) const |
528 | { |
529 | if (text_ == "") |
530 | @@ -749,12 +756,12 @@ |
531 | |
532 | void StaticText::RasterizeText(void* cairo_context, Color color) |
533 | { |
534 | - cairo_t* cairo_ctx = (cairo_t*) cairo_context; |
535 | + cairo_t *cairo_ctx = (cairo_t*) cairo_context; |
536 | |
537 | - PangoLayout* pango_layout = NULL; |
538 | - PangoFontDescription* font_desc = NULL; |
539 | - PangoContext* pango_ctx = NULL; |
540 | - int dpi = 96; |
541 | + PangoLayout *pango_layout = NULL; |
542 | + PangoFontDescription *font_desc = NULL; |
543 | + PangoContext *pango_ctx = NULL; |
544 | + int dpi = 96; |
545 | |
546 | // Create layout. |
547 | pango_layout = pango_cairo_create_layout(cairo_ctx); |
548 | @@ -781,7 +788,7 @@ |
549 | CairoFontOptions font_options; |
550 | { |
551 | cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_DEFAULT); |
552 | - cairo_font_options_set_subpixel_order(font_options, CAIRO_SUBPIXEL_ORDER_DEFAULT); |
553 | + cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_DEFAULT); |
554 | cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_DEFAULT); |
555 | cairo_font_options_set_hint_metrics (font_options, CAIRO_HINT_METRICS_ON); |
556 | cairo_set_font_options(cairo_ctx, font_options); |
557 | |
558 | === modified file 'Nux/StaticText.h' |
559 | --- Nux/StaticText.h 2011-12-08 18:14:50 +0000 |
560 | +++ Nux/StaticText.h 2012-01-03 03:15:27 +0000 |
561 | @@ -38,7 +38,6 @@ |
562 | StaticText(const std::string &text, NUX_FILE_LINE_PROTO); |
563 | virtual ~StaticText(); |
564 | |
565 | - |
566 | //! Set size of widget according to the text extent. |
567 | /*! |
568 | @param size_match_text If true, the widget size is set to match the size of the text on the screen. |
569 | @@ -55,15 +54,42 @@ |
570 | std::string GetText() const; |
571 | |
572 | //! Set text color. |
573 | - void SetTextColor(const Color &textColor); |
574 | + /*! |
575 | + Set the text color. The default color is white. |
576 | + |
577 | + @param text_color The text color. |
578 | + */ |
579 | + void SetTextColor(const Color &text_color); |
580 | |
581 | + //! Get text color. |
582 | + /*! |
583 | + Get the text color. |
584 | + |
585 | + @return The text color. |
586 | + */ |
587 | + Color GetTextColor() const; |
588 | + |
589 | //! Set the font name. |
590 | + /*! |
591 | + Set the font name. On Ubuntu, the default is "Ubuntu". |
592 | + |
593 | + @param font_name The font name. |
594 | + */ |
595 | void SetFontName(const std::string &font_name); |
596 | |
597 | + //! Get the font name. |
598 | + /*! |
599 | + Get the font name. |
600 | + |
601 | + @return The font name. |
602 | + */ |
603 | + std::string GetFontName() const; |
604 | + |
605 | //! Set text point size. |
606 | /* |
607 | - Set the text point size. The value should be be greater than 0. Otherwise, the |
608 | - text point size is not changed. |
609 | + Set the text point size. The value should be greater than 0. Otherwise, the |
610 | + text point size is not changed. \n |
611 | + The default value is 10. |
612 | |
613 | @param size The text point size. |
614 | */ |
615 | @@ -133,7 +159,7 @@ |
616 | |
617 | #elif defined (NUX_STATIC_TEXT_USE_CAIRO) |
618 | float dpy_; |
619 | - std::string pango_font_name_; |
620 | + std::string pango_font_name_; //!< Input to pango_font_description_from_string. |
621 | |
622 | Size ComputeTextSize(bool assign = true, bool with_clipping = true); |
623 | void RasterizeText(void* cairo_context, Color color); |
624 | |
625 | === modified file 'Nux/TextEntry.cpp' |
626 | --- Nux/TextEntry.cpp 2011-10-21 22:06:35 +0000 |
627 | +++ Nux/TextEntry.cpp 2012-01-03 03:15:27 +0000 |
628 | @@ -372,7 +372,7 @@ |
629 | else if ((keyval == NUX_VK_a) && ctrl) |
630 | { |
631 | // Select all |
632 | - int text_length = static_cast<int>(_text.length()); |
633 | + int text_length = static_cast<int>(text_.length()); |
634 | SetSelectionBounds(0, text_length); |
635 | QueueRefresh(false, true); |
636 | return; |
637 | @@ -518,10 +518,10 @@ |
638 | g_utf8_validate(text, -1, &end); |
639 | |
640 | std::string txt((text && *text && end > text) ? std::string(text, end) : ""); |
641 | - if (txt == _text) |
642 | + if (txt == text_) |
643 | return; // prevent some redraws |
644 | |
645 | - _text = multiline_ ? txt : CleanupLineBreaks(txt.c_str()); |
646 | + text_ = multiline_ ? txt : CleanupLineBreaks(txt.c_str()); |
647 | cursor_ = 0; |
648 | selection_bound_ = 0; |
649 | need_im_reset_ = true; |
650 | @@ -532,7 +532,7 @@ |
651 | |
652 | std::string const& TextEntry::GetText() const |
653 | { |
654 | - return _text; |
655 | + return text_; |
656 | } |
657 | |
658 | void TextEntry::SetTextColor(const Color &text_color) |
659 | @@ -734,10 +734,10 @@ |
660 | |
661 | void TextEntry::ResetPreedit() { |
662 | // Reset layout if there were some content in preedit string |
663 | - if (_preedit.length()) |
664 | + if (preedit_.length()) |
665 | ResetLayout(); |
666 | |
667 | - _preedit.clear(); |
668 | + preedit_.clear(); |
669 | preedit_cursor_ = 0; |
670 | if (preedit_attrs_) { |
671 | pango_attr_list_unref(preedit_attrs_); |
672 | @@ -1078,26 +1078,26 @@ |
673 | |
674 | pango_layout_set_single_paragraph_mode(layout, !multiline_); |
675 | |
676 | - if (_preedit.length()) |
677 | + if (preedit_.length()) |
678 | { |
679 | size_t cursor_index = static_cast<size_t>(cursor_); |
680 | - size_t text_length = _text.length(); |
681 | - size_t preedit_length = _preedit.length(); |
682 | + size_t text_length = text_.length(); |
683 | + size_t preedit_length = preedit_.length(); |
684 | if (visible_) |
685 | { |
686 | - tmp_string = _text; |
687 | - tmp_string.insert(cursor_index, _preedit); |
688 | + tmp_string = text_; |
689 | + tmp_string.insert(cursor_index, preedit_); |
690 | } |
691 | else |
692 | { |
693 | - size_t nchars = g_utf8_strlen(_text.c_str(), text_length); |
694 | - size_t preedit_nchars = g_utf8_strlen(_preedit.c_str(), preedit_length); |
695 | + size_t nchars = g_utf8_strlen(text_.c_str(), text_length); |
696 | + size_t preedit_nchars = g_utf8_strlen(preedit_.c_str(), preedit_length); |
697 | nchars += preedit_nchars; |
698 | tmp_string.reserve(password_char_.length() * nchars); |
699 | for (size_t i = 0; i < nchars; ++i) |
700 | tmp_string.append(password_char_); |
701 | size_t cursor_offset = |
702 | - g_utf8_pointer_to_offset(_text.c_str(), _text.c_str() + cursor_index); |
703 | + g_utf8_pointer_to_offset(text_.c_str(), text_.c_str() + cursor_index); |
704 | /* Fix cursor index and preedit_length */ |
705 | cursor_index = cursor_offset * password_char_.length(); |
706 | preedit_length = preedit_nchars * password_char_.length(); |
707 | @@ -1111,11 +1111,11 @@ |
708 | { |
709 | if (visible_) |
710 | { |
711 | - tmp_string = _text; |
712 | + tmp_string = text_; |
713 | } |
714 | else |
715 | { |
716 | - size_t nchars = g_utf8_strlen(_text.c_str(), _text.length()); |
717 | + size_t nchars = g_utf8_strlen(text_.c_str(), text_.length()); |
718 | tmp_string.reserve(password_char_.length() * nchars); |
719 | for (size_t i = 0; i < nchars; ++i) |
720 | tmp_string.append(password_char_); |
721 | @@ -1251,21 +1251,21 @@ |
722 | if (text_index == cursor_ && consider_preedit_cursor) |
723 | return text_index + preedit_cursor_; |
724 | |
725 | - return text_index + static_cast<int>(_preedit.length()); |
726 | + return text_index + static_cast<int>(preedit_.length()); |
727 | } |
728 | |
729 | - const char *text = _text.c_str(); |
730 | + const char *text = text_.c_str(); |
731 | int offset = static_cast<int>( |
732 | g_utf8_pointer_to_offset(text, text + text_index)); |
733 | int preedit_offset = 0; |
734 | int preedit_chars = 0; |
735 | - if (_preedit.length()) |
736 | + if (preedit_.length()) |
737 | { |
738 | - const char *preedit_text = _preedit.c_str(); |
739 | + const char *preedit_text = preedit_.c_str(); |
740 | preedit_offset = static_cast<int>(g_utf8_pointer_to_offset( |
741 | preedit_text, preedit_text + preedit_cursor_)); |
742 | preedit_chars = static_cast<int>(g_utf8_strlen( |
743 | - preedit_text, _preedit.length())); |
744 | + preedit_text, preedit_.length())); |
745 | } |
746 | |
747 | int password_char_length = static_cast<int>(password_char_.length()); |
748 | @@ -1287,7 +1287,7 @@ |
749 | if (layout_index < cursor_) |
750 | return layout_index; |
751 | |
752 | - int preedit_length = static_cast<int>(_preedit.length()); |
753 | + int preedit_length = static_cast<int>(preedit_.length()); |
754 | if (layout_index >= cursor_ + preedit_length) |
755 | return layout_index - preedit_length; |
756 | |
757 | @@ -1299,11 +1299,11 @@ |
758 | |
759 | int offset = layout_index / password_char_length; |
760 | |
761 | - const char *text = _text.c_str(); |
762 | + const char *text = text_.c_str(); |
763 | int cursor_offset = static_cast<int>( |
764 | g_utf8_pointer_to_offset(text, text + cursor_)); |
765 | int preedit_chars = static_cast<int>( |
766 | - g_utf8_strlen(_preedit.c_str(), _preedit.length())); |
767 | + g_utf8_strlen(preedit_.c_str(), preedit_.length())); |
768 | |
769 | if (offset < cursor_offset) |
770 | return static_cast<int>(g_utf8_offset_to_pointer(text, offset) - text); |
771 | @@ -1317,16 +1317,16 @@ |
772 | |
773 | int TextEntry::GetCharLength(int index) |
774 | { |
775 | - const char *text = _text.c_str(); |
776 | + const char *text = text_.c_str(); |
777 | const char *ptr = text + index; |
778 | - const char *end = text + _text.length(); |
779 | + const char *end = text + text_.length(); |
780 | const char *next = g_utf8_find_next_char(ptr, end); |
781 | return static_cast<int>(next ? static_cast<int>(next - ptr) : end - ptr); |
782 | } |
783 | |
784 | int TextEntry::GetPrevCharLength(int index) |
785 | { |
786 | - const char *text = _text.c_str(); |
787 | + const char *text = text_.c_str(); |
788 | const char *ptr = text + index; |
789 | const char *prev = g_utf8_find_prev_char(text, ptr); |
790 | return static_cast<int>(prev ? static_cast<int>(ptr - prev) : ptr - text); |
791 | @@ -1340,7 +1340,7 @@ |
792 | { |
793 | DeleteSelection(); |
794 | } |
795 | - else if (overwrite_ && cursor_ != static_cast<int>(_text.length())) |
796 | + else if (overwrite_ && cursor_ != static_cast<int>(text_.length())) |
797 | { |
798 | DeleteText(cursor_, cursor_ + GetCharLength(cursor_)); |
799 | } |
800 | @@ -1358,7 +1358,7 @@ |
801 | { |
802 | size_t len = end - str; |
803 | |
804 | - _text.insert(cursor_, str, len); |
805 | + text_.insert(cursor_, str, len); |
806 | cursor_ += static_cast<int>(len); |
807 | selection_bound_ += static_cast<int>(len); |
808 | } |
809 | @@ -1371,7 +1371,7 @@ |
810 | { |
811 | if (readonly_) return; |
812 | |
813 | - int text_length = static_cast<int>(_text.length()); |
814 | + int text_length = static_cast<int>(text_.length()); |
815 | if (start < 0) |
816 | start = 0; |
817 | else if (start > text_length) |
818 | @@ -1387,7 +1387,7 @@ |
819 | else if (start == end) |
820 | return; |
821 | |
822 | - _text.erase(start, end - start); |
823 | + text_.erase(start, end - start); |
824 | |
825 | if (cursor_ >= end) |
826 | cursor_ -= (end - start); |
827 | @@ -1413,7 +1413,7 @@ |
828 | } |
829 | |
830 | void TextEntry::Select(int start, int end) { |
831 | - int text_length = static_cast<int>(_text.length()); |
832 | + int text_length = static_cast<int>(text_.length()); |
833 | if (start == -1) |
834 | start = text_length; |
835 | if (end == -1) |
836 | @@ -1426,7 +1426,7 @@ |
837 | } |
838 | |
839 | void TextEntry::SelectAll() { |
840 | - SetSelectionBounds(0, static_cast<int>(_text.length())); |
841 | + SetSelectionBounds(0, static_cast<int>(text_.length())); |
842 | QueueRefresh(false, true); |
843 | } |
844 | |
845 | @@ -1526,7 +1526,7 @@ |
846 | } |
847 | else |
848 | { |
849 | - if (cursor_ == static_cast<int>(_text.length())) |
850 | + if (cursor_ == static_cast<int>(text_.length())) |
851 | return; |
852 | if (step == VISUALLY) |
853 | { |
854 | @@ -1629,7 +1629,7 @@ |
855 | break; |
856 | case BUFFER: |
857 | nuxAssert(count == -1 || count == 1); |
858 | - new_cursor = static_cast<int>(count == -1 ? 0 : _text.length()); |
859 | + new_cursor = static_cast<int>(count == -1 ? 0 : text_.length()); |
860 | break; |
861 | } |
862 | |
863 | @@ -1644,9 +1644,9 @@ |
864 | int TextEntry::MoveVisually(int current_index, int count) |
865 | { |
866 | nuxAssert(current_index >= 0 && |
867 | - current_index <= static_cast<int>(_text.length())); |
868 | + current_index <= static_cast<int>(text_.length())); |
869 | nuxAssert(count); |
870 | - nuxAssert(_preedit.length() == 0); |
871 | + nuxAssert(preedit_.length() == 0); |
872 | |
873 | PangoLayout *layout = EnsureLayout(); |
874 | const char *text = pango_layout_get_text(layout); |
875 | @@ -1678,13 +1678,13 @@ |
876 | int TextEntry::MoveWords(int current_index, int count) |
877 | { |
878 | nuxAssert(current_index >= 0 && |
879 | - current_index <= static_cast<int>(_text.length())); |
880 | + current_index <= static_cast<int>(text_.length())); |
881 | nuxAssert(count); |
882 | - nuxAssert(_preedit.length() == 0); |
883 | + nuxAssert(preedit_.length() == 0); |
884 | |
885 | if (!visible_) |
886 | { |
887 | - return static_cast<int>(count > 0 ? _text.length() : 0); |
888 | + return static_cast<int>(count > 0 ? text_.length() : 0); |
889 | } |
890 | |
891 | // The cursor movement direction shall be determined by the direction of |
892 | @@ -1789,9 +1789,9 @@ |
893 | int TextEntry::MoveDisplayLines(int current_index, int count) |
894 | { |
895 | nuxAssert(current_index >= 0 && |
896 | - current_index <= static_cast<int>(_text.length())); |
897 | + current_index <= static_cast<int>(text_.length())); |
898 | nuxAssert(count); |
899 | - nuxAssert(_preedit.length() == 0); |
900 | + nuxAssert(preedit_.length() == 0); |
901 | |
902 | PangoLayout *layout = EnsureLayout(); |
903 | const char *text = pango_layout_get_text(layout); |
904 | @@ -1821,7 +1821,7 @@ |
905 | } |
906 | else if (line_index >= n_lines) |
907 | { |
908 | - return static_cast<int>(_text.length()); |
909 | + return static_cast<int>(text_.length()); |
910 | } |
911 | |
912 | int trailing; |
913 | @@ -1853,9 +1853,9 @@ |
914 | int TextEntry::MovePages(int current_index, int count) |
915 | { |
916 | nuxAssert(current_index >= 0 && |
917 | - current_index <= static_cast<int>(_text.length())); |
918 | + current_index <= static_cast<int>(text_.length())); |
919 | nuxAssert(count); |
920 | - nuxAssert(_preedit.length() == 0); |
921 | + nuxAssert(preedit_.length() == 0); |
922 | |
923 | // Transfer pages to display lines. |
924 | PangoLayout *layout = EnsureLayout(); |
925 | @@ -1870,9 +1870,9 @@ |
926 | int TextEntry::MoveLineEnds(int current_index, int count) |
927 | { |
928 | nuxAssert(current_index >= 0 && |
929 | - current_index <= static_cast<int>(_text.length())); |
930 | + current_index <= static_cast<int>(text_.length())); |
931 | nuxAssert(count); |
932 | - nuxAssert(_preedit.length() == 0); |
933 | + nuxAssert(preedit_.length() == 0); |
934 | |
935 | PangoLayout *layout = EnsureLayout(); |
936 | int index = TextIndexToLayoutIndex(current_index, false); |
937 | @@ -1939,7 +1939,7 @@ |
938 | } |
939 | else if (y >= height) |
940 | { |
941 | - return static_cast<int>(_text.length()); |
942 | + return static_cast<int>(text_.length()); |
943 | } |
944 | |
945 | int trailing; |
946 | @@ -1953,7 +1953,7 @@ |
947 | |
948 | // Adjust the offset if preedit is not empty and if the offset is after |
949 | // current cursor. |
950 | - int preedit_length = static_cast<int>(_preedit.length()); |
951 | + int preedit_length = static_cast<int>(preedit_.length()); |
952 | if (preedit_length && index > cursor_) |
953 | { |
954 | if (index >= cursor_ + preedit_length) |
955 | @@ -1961,7 +1961,7 @@ |
956 | else |
957 | index = cursor_; |
958 | } |
959 | - return Clamp(index, 0, static_cast<int>(_text.length())); |
960 | + return Clamp(index, 0, static_cast<int>(text_.length())); |
961 | } |
962 | |
963 | bool TextEntry::GetSelectionBounds(int *start, int *end) |
964 | |
965 | === modified file 'Nux/TextEntry.h' |
966 | --- Nux/TextEntry.h 2011-10-21 22:06:35 +0000 |
967 | +++ Nux/TextEntry.h 2012-01-03 03:15:27 +0000 |
968 | @@ -281,9 +281,9 @@ |
969 | PangoLayout* cached_layout_; |
970 | |
971 | /** The text content of the edit control */ |
972 | - std::string _text; |
973 | + std::string text_; |
974 | /** The preedit text of the edit control */ |
975 | - std::string _preedit; |
976 | + std::string preedit_; |
977 | /** Attribute list of the preedit text */ |
978 | PangoAttrList *preedit_attrs_; |
979 | /** |
980 | |
981 | === modified file 'Nux/TextureArea.cpp' |
982 | --- Nux/TextureArea.cpp 2011-10-20 19:55:31 +0000 |
983 | +++ Nux/TextureArea.cpp 2012-01-03 03:15:27 +0000 |
984 | @@ -108,8 +108,6 @@ |
985 | |
986 | BaseTexture *texture = LoadTextureFromFile(filename.c_str()); |
987 | |
988 | - BitmapFormat format = texture->GetFormat(); |
989 | - |
990 | if (texture) |
991 | { |
992 | TexCoordXForm texxform; |
993 | |
994 | === modified file 'Nux/Theme.h' |
995 | --- Nux/Theme.h 2011-10-10 01:52:00 +0000 |
996 | +++ Nux/Theme.h 2012-01-03 03:15:27 +0000 |
997 | @@ -127,6 +127,10 @@ |
998 | bool draw_borders_only; |
999 | }; |
1000 | |
1001 | + //! Load textures and other data for user interface rendering. |
1002 | + /*! |
1003 | + Load textures and other data for user interface rendering. |
1004 | + */ |
1005 | class UXTheme |
1006 | { |
1007 | public: |
1008 | |
1009 | === modified file 'Nux/TimerProc.cpp' |
1010 | --- Nux/TimerProc.cpp 2011-12-22 06:23:58 +0000 |
1011 | +++ Nux/TimerProc.cpp 2012-01-03 03:15:27 +0000 |
1012 | @@ -122,6 +122,11 @@ |
1013 | |
1014 | bool TimerHandle::IsValid() const |
1015 | { |
1016 | + return Activated(); |
1017 | + } |
1018 | + |
1019 | + bool TimerHandle::Activated() const |
1020 | + { |
1021 | return m_d != 0; |
1022 | } |
1023 | |
1024 | @@ -183,7 +188,7 @@ |
1025 | Addmillisecs(&timer_object->when, timer_object->Period); |
1026 | |
1027 | #if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP)) |
1028 | - timer_object->glibid = GetWindowThread()->AddGLibTimeout(timer_object->Period); |
1029 | + timer_object->glibid = GetWindowThread()->AddTimeout(timer_object->Period); |
1030 | #endif |
1031 | } |
1032 | |
1033 | @@ -204,16 +209,16 @@ |
1034 | if (window_thread) |
1035 | timer_object->Window = window_thread->GetWindowCompositor().GetProcessingTopView(); |
1036 | else |
1037 | - timer_object->Window = GetWindowCompositor().GetProcessingTopView(); |
1038 | + timer_object->Window = GetWindowThread()->GetWindowCompositor().GetProcessingTopView(); |
1039 | |
1040 | AddHandle(timer_object); |
1041 | |
1042 | #if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP)) |
1043 | { |
1044 | if (window_thread) |
1045 | - timer_object->glibid = window_thread->AddGLibTimeout(Period); |
1046 | + timer_object->glibid = window_thread->AddTimeout(Period); |
1047 | else |
1048 | - timer_object->glibid = GetWindowThread()->AddGLibTimeout(Period); |
1049 | + timer_object->glibid = GetWindowThread()->AddTimeout(Period); |
1050 | |
1051 | if (timer_object->glibid == 0) |
1052 | { |
1053 | @@ -246,7 +251,7 @@ |
1054 | |
1055 | #if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP)) |
1056 | { |
1057 | - timer_object->glibid = GetWindowThread()->AddGLibTimeout(Period); |
1058 | + timer_object->glibid = GetWindowThread()->AddTimeout(Period); |
1059 | |
1060 | if (timer_object->glibid == 0) |
1061 | { |
1062 | @@ -279,7 +284,7 @@ |
1063 | |
1064 | #if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP)) |
1065 | { |
1066 | - timer_object->glibid = GetWindowThread()->AddGLibTimeout(Period); |
1067 | + timer_object->glibid = GetWindowThread()->AddTimeout(Period); |
1068 | |
1069 | if (timer_object->glibid == 0) |
1070 | { |
1071 | @@ -299,6 +304,13 @@ |
1072 | // Sort timers and add them to the queue |
1073 | TimerObject *TimerHandler::AddHandle(TimerObject *timer_object) |
1074 | { |
1075 | + if (timer_object == NULL) |
1076 | + return NULL; |
1077 | + |
1078 | + // Give the Timer a unique ID; |
1079 | + timer_object->uid = TimerUID.GetValue(); |
1080 | + TimerUID.Increment(); |
1081 | + |
1082 | // If the queue is empty or the new timer will expire sooner than the first timer in the queue |
1083 | // then add the new timer at the start of the queue. |
1084 | if ((m_timer_object_queue == NULL) || TimeIsGreater(m_timer_object_queue->when, timer_object->when)) |
1085 | @@ -311,13 +323,10 @@ |
1086 | |
1087 | timer_object->prev = 0; |
1088 | m_timer_object_queue = timer_object; |
1089 | + |
1090 | return timer_object; |
1091 | } |
1092 | |
1093 | - // Give the Timer a unique ID; |
1094 | - timer_object->uid = TimerUID.GetValue(); |
1095 | - TimerUID.Increment(); |
1096 | - |
1097 | TimerObject *tmp = m_timer_object_queue; |
1098 | |
1099 | while (tmp->next != NULL) |
1100 | @@ -482,9 +491,9 @@ |
1101 | |
1102 | if (timer_object->timeout_signal != 0) |
1103 | { |
1104 | - GetWindowCompositor().SetProcessingTopView(timer_object->Window); |
1105 | + GetWindowThread()->GetWindowCompositor().SetProcessingTopView(timer_object->Window); |
1106 | timer_object->timeout_signal->time_expires.emit(timer_object->CallbackData); |
1107 | - GetWindowCompositor().SetProcessingTopView(NULL); |
1108 | + GetWindowThread()->GetWindowCompositor().SetProcessingTopView(NULL); |
1109 | // Reset glibid to 0. glibid is not null, if this element ever happened to be at the head of the queue |
1110 | // and we set a timer for it. |
1111 | //nuxDebugMsg("[TimerHandler::ExecTimerHandler] Executed Timeout ID: %d", timer_object->glibid); |
1112 | @@ -555,7 +564,7 @@ |
1113 | // // How long(in milliseconds) between now and the moment the timeout expires? |
1114 | // unsigned int time_difference = TimeDiff(now, m_timer_object_queue->when); |
1115 | // |
1116 | -// m_timer_object_queue->glibid = GetWindowThread()->AddGLibTimeout(time_difference); |
1117 | +// m_timer_object_queue->glibid = GetWindowThread()->AddTimeout(time_difference); |
1118 | // //nuxDebugMsg("[TimerHandler::ExecTimerHandler] Adding Timeout ID: %d", m_timer_object_queue->glibid); |
1119 | // } |
1120 | |
1121 | |
1122 | === modified file 'Nux/VLayout.cpp' |
1123 | --- Nux/VLayout.cpp 2011-12-08 04:59:23 +0000 |
1124 | +++ Nux/VLayout.cpp 2012-01-03 03:15:27 +0000 |
1125 | @@ -793,7 +793,6 @@ |
1126 | (*it)->SetBaseX(current_x); |
1127 | (*it)->SetBaseY(current_y); |
1128 | |
1129 | - MinorDimensionSize extend = (*it)->GetExtend(); |
1130 | MinorDimensionPosition positioning = (*it)->GetPositioning(); |
1131 | |
1132 | if ((*it)->GetBaseWidth() < width) |
1133 | |
1134 | === modified file 'Nux/VSplitter.cpp' |
1135 | --- Nux/VSplitter.cpp 2011-10-21 22:06:35 +0000 |
1136 | +++ Nux/VSplitter.cpp 2012-01-03 03:15:27 +0000 |
1137 | @@ -435,7 +435,7 @@ |
1138 | m_point = Point(x, y); |
1139 | |
1140 | m_focus_splitter_index = header_pos; |
1141 | - GetWindowCompositor().SetWidgetDrawingOverlay(this, GetWindowCompositor().GetProcessingTopView()); |
1142 | + GetWindowThread()->GetWindowCompositor().SetWidgetDrawingOverlay(this, GetWindowThread()->GetWindowCompositor().GetProcessingTopView()); |
1143 | |
1144 | // Hint for the window to initiate a redraw |
1145 | GetWindowThread()->RequestRedraw(); |
1146 | @@ -466,7 +466,7 @@ |
1147 | mvt_dy = 0; |
1148 | |
1149 | // End overlay drawing; |
1150 | - GetWindowCompositor().SetWidgetDrawingOverlay(0, GetWindowCompositor().GetProcessingTopView()); |
1151 | + GetWindowThread()->GetWindowCompositor().SetWidgetDrawingOverlay(0, GetWindowThread()->GetWindowCompositor().GetProcessingTopView()); |
1152 | // Hint for the window to initiate a redraw |
1153 | GetWindowThread()->RequestRedraw(); |
1154 | } |
1155 | |
1156 | === modified file 'Nux/WindowCompositor.cpp' |
1157 | --- Nux/WindowCompositor.cpp 2011-12-22 06:23:58 +0000 |
1158 | +++ Nux/WindowCompositor.cpp 2012-01-03 03:15:27 +0000 |
1159 | @@ -235,7 +235,7 @@ |
1160 | // any of the BaseWindow. Try the main window layout. |
1161 | if (*area_under_mouse_pointer == NULL) |
1162 | { |
1163 | - Layout* main_window_layout = GetWindowThread()->GetMainLayout(); |
1164 | + Layout* main_window_layout = window_thread_->GetLayout(); |
1165 | if (main_window_layout) |
1166 | *area_under_mouse_pointer = static_cast<InputArea*>(main_window_layout->FindAreaUnderMouse(mouse_position, event_type)); |
1167 | } |
1168 | @@ -335,7 +335,7 @@ |
1169 | } |
1170 | else if (event.e_event == NUX_DND_DROP) |
1171 | { |
1172 | - InputArea *current_dnd_area = GetWindowCompositor().GetDnDArea(); |
1173 | + InputArea *current_dnd_area = GetDnDArea(); |
1174 | if (current_dnd_area->GetGeometry().IsPointInside(event.e_x - event.e_x_root, event.e_y - event.e_y_root)) |
1175 | current_dnd_area->HandleDndDrop(event); |
1176 | } |
1177 | @@ -834,7 +834,7 @@ |
1178 | // If key_focus_area is NULL, then try the main window layout. |
1179 | if (*key_focus_area == NULL) |
1180 | { |
1181 | - Layout* main_window_layout = GetWindowThread()->GetMainLayout(); |
1182 | + Layout* main_window_layout = window_thread_->GetLayout(); |
1183 | if (main_window_layout) |
1184 | { |
1185 | *key_focus_area = NUX_STATIC_CAST(InputArea*, main_window_layout->FindKeyFocusArea(event_type, key_symbol, special_keys_state)); |
1186 | @@ -1206,24 +1206,24 @@ |
1187 | void WindowCompositor::Draw(bool SizeConfigurationEvent, bool force_draw) |
1188 | { |
1189 | inside_rendering_cycle_ = true; |
1190 | - if (!GetWindowThread()->GetWindow().isWindowMinimized()) |
1191 | + if (!window_thread_->GetGraphicsDisplay().isWindowMinimized()) |
1192 | { |
1193 | //int w, h; |
1194 | - GetWindowThread()->GetGraphicsEngine().GetContextSize(m_Width, m_Height); |
1195 | - GetWindowThread()->GetGraphicsEngine().SetViewport(0, 0, m_Width, m_Height); |
1196 | + window_thread_->GetGraphicsEngine().GetContextSize(m_Width, m_Height); |
1197 | + window_thread_->GetGraphicsEngine().SetViewport(0, 0, m_Width, m_Height); |
1198 | |
1199 | // Reset the Model view Matrix and the projection matrix |
1200 | - GetWindowThread()->GetGraphicsEngine().ResetProjectionMatrix(); |
1201 | + window_thread_->GetGraphicsEngine().ResetProjectionMatrix(); |
1202 | |
1203 | - GetWindowThread()->GetGraphicsEngine().ResetModelViewMatrixStack(); |
1204 | - GetWindowThread()->GetGraphicsEngine().Push2DTranslationModelViewMatrix(0.375f, 0.375f, 0.0f); |
1205 | + window_thread_->GetGraphicsEngine().ResetModelViewMatrixStack(); |
1206 | + window_thread_->GetGraphicsEngine().Push2DTranslationModelViewMatrix(0.375f, 0.375f, 0.0f); |
1207 | |
1208 | |
1209 | if (force_draw || SizeConfigurationEvent) |
1210 | { |
1211 | // We fall here after something dramatic has happen to the window such as a resizing. In this case |
1212 | // everything must be rendered. This is very costly and should happen rarely. |
1213 | - if (!GetWindowThread()->IsEmbeddedWindow()) |
1214 | + if (!window_thread_->IsEmbeddedWindow()) |
1215 | RenderMainWindowComposition(true); |
1216 | |
1217 | { |
1218 | @@ -1239,7 +1239,7 @@ |
1219 | { |
1220 | // A popup removed cause the whole window to be dirty(at least some part of it). |
1221 | // So exchange DrawList with a real Draw. |
1222 | - if (!GetWindowThread()->IsEmbeddedWindow()) |
1223 | + if (!window_thread_->IsEmbeddedWindow()) |
1224 | RenderMainWindowComposition(false); |
1225 | |
1226 | { |
1227 | @@ -1253,7 +1253,7 @@ |
1228 | } |
1229 | else |
1230 | { |
1231 | - if (!GetWindowThread()->IsEmbeddedWindow()) |
1232 | + if (!window_thread_->IsEmbeddedWindow()) |
1233 | RenderMainWindowComposition(false); |
1234 | |
1235 | { |
1236 | @@ -1269,7 +1269,7 @@ |
1237 | m_PopupRemoved = false; |
1238 | m_MenuRemoved = false; |
1239 | |
1240 | - GetWindowThread()->GetGraphicsEngine().Pop2DWindow(); |
1241 | + window_thread_->GetGraphicsEngine().Pop2DWindow(); |
1242 | } |
1243 | inside_rendering_cycle_ = false; |
1244 | } |
1245 | @@ -1280,16 +1280,16 @@ |
1246 | |
1247 | if (window.IsValid()) |
1248 | { |
1249 | - //GetWindowThread()->GetGraphicsEngine().SetContext(x, y, buffer_width, buffer_height); |
1250 | - GetWindowThread()->GetGraphicsEngine().SetOrthographicProjectionMatrix(GetWindowThread()->GetGraphicsEngine().GetWindowWidth(), |
1251 | - GetWindowThread()->GetGraphicsEngine().GetWindowHeight()); |
1252 | - GetWindowThread()->GetGraphicsEngine().EmptyClippingRegion(); |
1253 | + //window_thread_->GetGraphicsEngine().SetContext(x, y, buffer_width, buffer_height); |
1254 | + window_thread_->GetGraphicsEngine().SetOrthographicProjectionMatrix(window_thread_->GetGraphicsEngine().GetWindowWidth(), |
1255 | + window_thread_->GetGraphicsEngine().GetWindowHeight()); |
1256 | + window_thread_->GetGraphicsEngine().EmptyClippingRegion(); |
1257 | } |
1258 | else |
1259 | { |
1260 | - GetWindowThread()->GetGraphicsEngine().SetOrthographicProjectionMatrix(GetWindowThread()->GetGraphicsEngine().GetWindowWidth(), |
1261 | - GetWindowThread()->GetGraphicsEngine().GetWindowHeight()); |
1262 | - GetWindowThread()->GetGraphicsEngine().EmptyClippingRegion(); |
1263 | + window_thread_->GetGraphicsEngine().SetOrthographicProjectionMatrix(window_thread_->GetGraphicsEngine().GetWindowWidth(), |
1264 | + window_thread_->GetGraphicsEngine().GetWindowHeight()); |
1265 | + window_thread_->GetGraphicsEngine().EmptyClippingRegion(); |
1266 | } |
1267 | |
1268 | std::list<MenuPage *>::reverse_iterator rev_it_menu; |
1269 | @@ -1297,34 +1297,34 @@ |
1270 | for (rev_it_menu = _menu_chain->rbegin(); rev_it_menu != _menu_chain->rend( ); rev_it_menu++) |
1271 | { |
1272 | SetProcessingTopView(m_MenuWindow.GetPointer()); |
1273 | - (*rev_it_menu)->ProcessDraw(GetWindowThread()->GetGraphicsEngine(), force_draw); |
1274 | + (*rev_it_menu)->ProcessDraw(window_thread_->GetGraphicsEngine(), force_draw); |
1275 | SetProcessingTopView(NULL); |
1276 | } |
1277 | |
1278 | // GetGraphicsDisplay()->GetGraphicsEngine()->SetContext(0, 0, |
1279 | -// GetWindowThread()->GetGraphicsEngine().GetWindowWidth(), |
1280 | -// GetWindowThread()->GetGraphicsEngine().GetWindowHeight()); |
1281 | +// window_thread_->GetGraphicsEngine().GetWindowWidth(), |
1282 | +// window_thread_->GetGraphicsEngine().GetWindowHeight()); |
1283 | } |
1284 | |
1285 | void WindowCompositor::DrawOverlay(bool force_draw) |
1286 | { |
1287 | ObjectWeakPtr<BaseWindow> window = m_OverlayWindow; |
1288 | - int buffer_width = GetWindowThread()->GetGraphicsEngine().GetWindowWidth(); |
1289 | - int buffer_height = GetWindowThread()->GetGraphicsEngine().GetWindowHeight(); |
1290 | + int buffer_width = window_thread_->GetGraphicsEngine().GetWindowWidth(); |
1291 | + int buffer_height = window_thread_->GetGraphicsEngine().GetWindowHeight(); |
1292 | |
1293 | if (window.IsValid()) |
1294 | { |
1295 | - //GetWindowThread()->GetGraphicsEngine().SetContext(x, y, buffer_width, buffer_height); |
1296 | - GetWindowThread()->GetGraphicsEngine().SetOrthographicProjectionMatrix(buffer_width, buffer_height); |
1297 | - GetWindowThread()->GetGraphicsEngine().EmptyClippingRegion(); |
1298 | + //window_thread_->GetGraphicsEngine().SetContext(x, y, buffer_width, buffer_height); |
1299 | + window_thread_->GetGraphicsEngine().SetOrthographicProjectionMatrix(buffer_width, buffer_height); |
1300 | + window_thread_->GetGraphicsEngine().EmptyClippingRegion(); |
1301 | } |
1302 | else |
1303 | - GetWindowThread()->GetGraphicsEngine().SetOpenGLClippingRectangle(0, 0, buffer_width, buffer_height); |
1304 | + window_thread_->GetGraphicsEngine().SetOpenGLClippingRectangle(0, 0, buffer_width, buffer_height); |
1305 | |
1306 | if (OverlayDrawingCommand) |
1307 | { |
1308 | SetProcessingTopView(m_OverlayWindow.GetPointer()); |
1309 | - OverlayDrawingCommand->OverlayDrawing(GetWindowThread()->GetGraphicsEngine()); |
1310 | + OverlayDrawingCommand->OverlayDrawing(window_thread_->GetGraphicsEngine()); |
1311 | SetProcessingTopView(NULL); |
1312 | } |
1313 | |
1314 | @@ -1334,23 +1334,23 @@ |
1315 | void WindowCompositor::DrawTooltip(bool force_draw) |
1316 | { |
1317 | ObjectWeakPtr<BaseWindow> window = _tooltip_window; |
1318 | - int buffer_width = GetWindowThread()->GetGraphicsEngine().GetWindowWidth(); |
1319 | - int buffer_height = GetWindowThread()->GetGraphicsEngine().GetWindowHeight(); |
1320 | + int buffer_width = window_thread_->GetGraphicsEngine().GetWindowWidth(); |
1321 | + int buffer_height = window_thread_->GetGraphicsEngine().GetWindowHeight(); |
1322 | |
1323 | if (window.IsValid()) |
1324 | { |
1325 | - //GetWindowThread()->GetGraphicsEngine().SetContext(x, y, buffer_width, buffer_height); |
1326 | - GetWindowThread()->GetGraphicsEngine().SetOrthographicProjectionMatrix(buffer_width, buffer_height); |
1327 | - GetWindowThread()->GetGraphicsEngine().EmptyClippingRegion(); |
1328 | + //window_thread_->GetGraphicsEngine().SetContext(x, y, buffer_width, buffer_height); |
1329 | + window_thread_->GetGraphicsEngine().SetOrthographicProjectionMatrix(buffer_width, buffer_height); |
1330 | + window_thread_->GetGraphicsEngine().EmptyClippingRegion(); |
1331 | } |
1332 | else |
1333 | - GetWindowThread()->GetGraphicsEngine().SetOpenGLClippingRectangle(0, 0, buffer_width, buffer_height); |
1334 | + window_thread_->GetGraphicsEngine().SetOpenGLClippingRectangle(0, 0, buffer_width, buffer_height); |
1335 | |
1336 | if (m_TooltipText.Size()) |
1337 | { |
1338 | //SetProcessingTopView(_tooltip_window); |
1339 | - GetPainter().PaintShape(GetWindowThread()->GetGraphicsEngine(), _tooltip_geometry, Color(0xA0000000), eSHAPE_CORNER_ROUND10, true); |
1340 | - GetPainter().PaintTextLineStatic(GetWindowThread()->GetGraphicsEngine(), GetSysBoldFont(), _tooltip_text_geometry, m_TooltipText, Color(0xFFFFFFFF)); |
1341 | + GetPainter().PaintShape(window_thread_->GetGraphicsEngine(), _tooltip_geometry, Color(0xA0000000), eSHAPE_CORNER_ROUND10, true); |
1342 | + GetPainter().PaintTextLineStatic(window_thread_->GetGraphicsEngine(), GetSysBoldFont(), _tooltip_text_geometry, m_TooltipText, Color(0xFFFFFFFF)); |
1343 | //SetProcessingTopView(NULL); |
1344 | } |
1345 | |
1346 | @@ -1361,7 +1361,7 @@ |
1347 | { |
1348 | GetPainter().EmptyBackgroundStack(); |
1349 | SetProcessingTopView(window); |
1350 | - window->ProcessDraw(GetWindowThread()->GetGraphicsEngine(), force_draw || window->IsRedrawNeeded()); |
1351 | + window->ProcessDraw(window_thread_->GetGraphicsEngine(), force_draw || window->IsRedrawNeeded()); |
1352 | SetProcessingTopView(NULL); |
1353 | GetPainter().EmptyBackgroundStack(); |
1354 | } |
1355 | @@ -1374,7 +1374,7 @@ |
1356 | // to the size of the display and call EmptyClippingRegion(). |
1357 | // Then call GetScissorRect() to get the size of the global clipping area. |
1358 | // This is is hack until we implement SetGlobalClippingRectangle() (the opposite of SetGlobalClippingRectangle). |
1359 | - GraphicsEngine& graphics_engine = GetWindowThread()->GetGraphicsEngine(); |
1360 | + GraphicsEngine& graphics_engine = window_thread_->GetGraphicsEngine(); |
1361 | unsigned int window_width = graphics_engine.GetWindowWidth(); |
1362 | unsigned int window_height = graphics_engine.GetWindowHeight(); |
1363 | GetGraphicsDisplay()->GetGpuDevice()->DeactivateFrameBuffer(); |
1364 | @@ -1484,7 +1484,7 @@ |
1365 | // else |
1366 | // { |
1367 | // shadow.OffsetPosition(4, 4); |
1368 | -// GetPainter().PaintShape(GetWindowThread()->GetGraphicsEngine(), shadow, Color(0xFF000000), eSHAPE_CORNER_ROUND10_SHADOW); |
1369 | +// GetPainter().PaintShape(window_thread_->GetGraphicsEngine(), shadow, Color(0xFF000000), eSHAPE_CORNER_ROUND10_SHADOW); |
1370 | // } |
1371 | } |
1372 | |
1373 | @@ -1514,8 +1514,8 @@ |
1374 | { |
1375 | int buffer_width, buffer_height; |
1376 | |
1377 | - buffer_width = GetWindowThread()->GetGraphicsEngine().GetWindowWidth(); |
1378 | - buffer_height = GetWindowThread()->GetGraphicsEngine().GetWindowHeight(); |
1379 | + buffer_width = window_thread_->GetGraphicsEngine().GetWindowWidth(); |
1380 | + buffer_height = window_thread_->GetGraphicsEngine().GetWindowHeight(); |
1381 | |
1382 | if ((!m_MainColorRT.IsValid()) || (!m_MainDepthRT.IsValid()) || (m_MainColorRT->GetWidth() != buffer_width) || (m_MainColorRT->GetHeight() != buffer_height)) |
1383 | { |
1384 | @@ -1528,33 +1528,33 @@ |
1385 | m_FrameBufferObject->SetDepthSurface(m_MainDepthRT->GetSurfaceLevel(0)); |
1386 | m_FrameBufferObject->Activate(); |
1387 | |
1388 | - GetWindowThread()->GetGraphicsEngine().EmptyClippingRegion(); |
1389 | - GetWindowThread()->GetGraphicsEngine().SetOpenGLClippingRectangle(0, 0, buffer_width, buffer_height); |
1390 | - GetWindowThread()->GetGraphicsEngine().SetViewport(0, 0, buffer_width, buffer_height); |
1391 | - GetWindowThread()->GetGraphicsEngine().SetOrthographicProjectionMatrix(buffer_width, buffer_height); |
1392 | + window_thread_->GetGraphicsEngine().EmptyClippingRegion(); |
1393 | + window_thread_->GetGraphicsEngine().SetOpenGLClippingRectangle(0, 0, buffer_width, buffer_height); |
1394 | + window_thread_->GetGraphicsEngine().SetViewport(0, 0, buffer_width, buffer_height); |
1395 | + window_thread_->GetGraphicsEngine().SetOrthographicProjectionMatrix(buffer_width, buffer_height); |
1396 | { |
1397 | CHECKGL(glClear(/*GL_COLOR_BUFFER_BIT |*/ GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)); |
1398 | //Begin 2D Drawing |
1399 | { |
1400 | if (force_draw) |
1401 | { |
1402 | - GetPainter().PushDrawLayer(GetWindowThread()->GetGraphicsEngine(), Geometry(0, 0, buffer_width, buffer_height), m_Background); |
1403 | - //GetPainter().PushBackground(GetWindowThread()->GetGraphicsEngine(), Geometry(0, 0, buffer_width, buffer_height), m_Background, true); |
1404 | - |
1405 | - GetWindowThread()->ProcessDraw(GetWindowThread()->GetGraphicsEngine(), true); |
1406 | - |
1407 | - nuxAssert(GetWindowThread()->GetGraphicsEngine().GetNumberOfClippingRegions() == 0); |
1408 | + GetPainter().PushDrawLayer(window_thread_->GetGraphicsEngine(), Geometry(0, 0, buffer_width, buffer_height), m_Background); |
1409 | + //GetPainter().PushBackground(window_thread_->GetGraphicsEngine(), Geometry(0, 0, buffer_width, buffer_height), m_Background, true); |
1410 | + |
1411 | + window_thread_->ProcessDraw(window_thread_->GetGraphicsEngine(), true); |
1412 | + |
1413 | + nuxAssert(window_thread_->GetGraphicsEngine().GetNumberOfClippingRegions() == 0); |
1414 | GetPainter().PopBackground(); |
1415 | GetPainter().EmptyBackgroundStack(); |
1416 | } |
1417 | else |
1418 | { |
1419 | - GetPainter().PushLayer(GetWindowThread()->GetGraphicsEngine(), Geometry(0, 0, buffer_width, buffer_height), m_Background); |
1420 | - //GetPainter().PushBackground(GetWindowThread()->GetGraphicsEngine(), Geometry(0, 0, buffer_width, buffer_height), m_Background, false); |
1421 | - |
1422 | - GetWindowThread()->ProcessDraw(GetWindowThread()->GetGraphicsEngine(), false); |
1423 | - |
1424 | - nuxAssert(GetWindowThread()->GetGraphicsEngine().GetNumberOfClippingRegions() == 0); |
1425 | + GetPainter().PushLayer(window_thread_->GetGraphicsEngine(), Geometry(0, 0, buffer_width, buffer_height), m_Background); |
1426 | + //GetPainter().PushBackground(window_thread_->GetGraphicsEngine(), Geometry(0, 0, buffer_width, buffer_height), m_Background, false); |
1427 | + |
1428 | + window_thread_->ProcessDraw(window_thread_->GetGraphicsEngine(), false); |
1429 | + |
1430 | + nuxAssert(window_thread_->GetGraphicsEngine().GetNumberOfClippingRegions() == 0); |
1431 | GetPainter().PopBackground(); |
1432 | GetPainter().EmptyBackgroundStack(); |
1433 | } |
1434 | @@ -1569,16 +1569,16 @@ |
1435 | //GetGraphicsDisplay()->GetGraphicsEngine()->QRP_Color(geo.x, geo.y, geo.width, geo.height, color::Blue); |
1436 | } |
1437 | |
1438 | - GetWindowThread()->GetGraphicsEngine().SetOrthographicProjectionMatrix(buffer_width, buffer_height); |
1439 | + window_thread_->GetGraphicsEngine().SetOrthographicProjectionMatrix(buffer_width, buffer_height); |
1440 | m_FrameBufferObject->Deactivate(); |
1441 | |
1442 | unsigned int window_width, window_height; |
1443 | - window_width = GetWindowThread()->GetGraphicsEngine().GetWindowWidth(); |
1444 | - window_height = GetWindowThread()->GetGraphicsEngine().GetWindowHeight(); |
1445 | - GetWindowThread()->GetGraphicsEngine().EmptyClippingRegion(); |
1446 | - GetWindowThread()->GetGraphicsEngine().SetOpenGLClippingRectangle(0, 0, window_width, window_height); |
1447 | - GetWindowThread()->GetGraphicsEngine().SetViewport(0, 0, window_width, window_height); |
1448 | - GetWindowThread()->GetGraphicsEngine().SetOrthographicProjectionMatrix(window_width, window_height); |
1449 | + window_width = window_thread_->GetGraphicsEngine().GetWindowWidth(); |
1450 | + window_height = window_thread_->GetGraphicsEngine().GetWindowHeight(); |
1451 | + window_thread_->GetGraphicsEngine().EmptyClippingRegion(); |
1452 | + window_thread_->GetGraphicsEngine().SetOpenGLClippingRectangle(0, 0, window_width, window_height); |
1453 | + window_thread_->GetGraphicsEngine().SetViewport(0, 0, window_width, window_height); |
1454 | + window_thread_->GetGraphicsEngine().SetOrthographicProjectionMatrix(window_width, window_height); |
1455 | |
1456 | PresentBufferToScreen(m_MainColorRT, 0, 0, false); |
1457 | |
1458 | @@ -1592,8 +1592,8 @@ |
1459 | return; |
1460 | |
1461 | int window_width, window_height; |
1462 | - window_width = GetWindowThread()->GetGraphicsEngine().GetWindowWidth(); |
1463 | - window_height = GetWindowThread()->GetGraphicsEngine().GetWindowHeight(); |
1464 | + window_width = window_thread_->GetGraphicsEngine().GetWindowWidth(); |
1465 | + window_height = window_thread_->GetGraphicsEngine().GetWindowHeight(); |
1466 | |
1467 | |
1468 | if (RenderToMainTexture && (HWTexture != m_MainColorRT)) |
1469 | @@ -1610,10 +1610,10 @@ |
1470 | GetGraphicsDisplay()->GetGpuDevice()->DeactivateFrameBuffer(); |
1471 | } |
1472 | |
1473 | - GetWindowThread()->GetGraphicsEngine().EmptyClippingRegion(); |
1474 | - GetWindowThread()->GetGraphicsEngine().SetOpenGLClippingRectangle(0, 0, window_width, window_height); |
1475 | - GetWindowThread()->GetGraphicsEngine().SetViewport(0, 0, window_width, window_height); |
1476 | - GetWindowThread()->GetGraphicsEngine().SetOrthographicProjectionMatrix(window_width, window_height); |
1477 | + window_thread_->GetGraphicsEngine().EmptyClippingRegion(); |
1478 | + window_thread_->GetGraphicsEngine().SetOpenGLClippingRectangle(0, 0, window_width, window_height); |
1479 | + window_thread_->GetGraphicsEngine().SetViewport(0, 0, window_width, window_height); |
1480 | + window_thread_->GetGraphicsEngine().SetOrthographicProjectionMatrix(window_width, window_height); |
1481 | |
1482 | // Render the MAINFBO |
1483 | { |
1484 | @@ -1626,15 +1626,15 @@ |
1485 | |
1486 | if (premultiply) |
1487 | { |
1488 | - GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
1489 | + window_thread_->GetGraphicsEngine().GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
1490 | GetGraphicsDisplay()->GetGraphicsEngine()->QRP_1Tex(x, y, src_width, src_height, HWTexture, texxform0, Color(opacity, opacity, opacity, opacity)); |
1491 | } |
1492 | else |
1493 | { |
1494 | - GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetBlend(false); |
1495 | + window_thread_->GetGraphicsEngine().GetRenderStates().SetBlend(false); |
1496 | GetGraphicsDisplay()->GetGraphicsEngine()->QRP_1Tex(x, y, src_width, src_height, HWTexture, texxform0, Color(1.0f, 1.0f, 1.0f, opacity)); |
1497 | } |
1498 | - GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetBlend(false); |
1499 | + window_thread_->GetGraphicsEngine().GetRenderStates().SetBlend(false); |
1500 | } |
1501 | } |
1502 | |
1503 | @@ -1927,8 +1927,8 @@ |
1504 | |
1505 | void WindowCompositor::FormatRenderTargets(int width, int height) |
1506 | { |
1507 | - int buffer_width = GetWindowThread()->GetGraphicsEngine().GetWindowWidth(); |
1508 | - int buffer_height = GetWindowThread()->GetGraphicsEngine().GetWindowHeight(); |
1509 | + int buffer_width = window_thread_->GetGraphicsEngine().GetWindowWidth(); |
1510 | + int buffer_height = window_thread_->GetGraphicsEngine().GetWindowHeight(); |
1511 | |
1512 | nuxAssert(buffer_width >= 1); |
1513 | nuxAssert(buffer_height >= 1); |
1514 | @@ -1985,15 +1985,15 @@ |
1515 | m_FrameBufferObject->SetDepthSurface(rt.depth_rt->GetSurfaceLevel(0)); |
1516 | m_FrameBufferObject->Activate(); |
1517 | |
1518 | - GetWindowThread()->GetGraphicsEngine().SetViewport(0, 0, buffer_width, buffer_height); |
1519 | - GetWindowThread()->GetGraphicsEngine().SetOrthographicProjectionMatrix(buffer_width, buffer_height); |
1520 | - GetWindowThread()->GetGraphicsEngine().ApplyClippingRectangle(); |
1521 | - //GetWindowThread()->GetGraphicsEngine().ApplyModelViewMatrix(); ??? |
1522 | + window_thread_->GetGraphicsEngine().SetViewport(0, 0, buffer_width, buffer_height); |
1523 | + window_thread_->GetGraphicsEngine().SetOrthographicProjectionMatrix(buffer_width, buffer_height); |
1524 | + window_thread_->GetGraphicsEngine().ApplyClippingRectangle(); |
1525 | + //window_thread_->GetGraphicsEngine().ApplyModelViewMatrix(); ??? |
1526 | } |
1527 | else |
1528 | { |
1529 | - int buffer_width = GetWindowThread()->GetGraphicsEngine().GetWindowWidth(); |
1530 | - int buffer_height = GetWindowThread()->GetGraphicsEngine().GetWindowHeight(); |
1531 | + int buffer_width = window_thread_->GetGraphicsEngine().GetWindowWidth(); |
1532 | + int buffer_height = window_thread_->GetGraphicsEngine().GetWindowHeight(); |
1533 | |
1534 | nuxAssert(buffer_width >= 1); |
1535 | nuxAssert(buffer_height >= 1); |
1536 | @@ -2003,10 +2003,10 @@ |
1537 | m_FrameBufferObject->SetDepthSurface(m_MainDepthRT->GetSurfaceLevel(0)); |
1538 | m_FrameBufferObject->Activate(); |
1539 | |
1540 | - GetWindowThread()->GetGraphicsEngine().SetViewport(0, 0, buffer_width, buffer_height); |
1541 | - GetWindowThread()->GetGraphicsEngine().SetOrthographicProjectionMatrix(buffer_width, buffer_height); |
1542 | - GetWindowThread()->GetGraphicsEngine().ApplyClippingRectangle(); |
1543 | - //GetWindowThread()->GetGraphicsEngine().ApplyModelViewMatrix(); ??? |
1544 | + window_thread_->GetGraphicsEngine().SetViewport(0, 0, buffer_width, buffer_height); |
1545 | + window_thread_->GetGraphicsEngine().SetOrthographicProjectionMatrix(buffer_width, buffer_height); |
1546 | + window_thread_->GetGraphicsEngine().ApplyClippingRectangle(); |
1547 | + //window_thread_->GetGraphicsEngine().ApplyModelViewMatrix(); ??? |
1548 | } |
1549 | } |
1550 | |
1551 | @@ -2076,8 +2076,8 @@ |
1552 | return result; |
1553 | } |
1554 | |
1555 | - if (GetWindow().PointerGrabData() != this) |
1556 | - result = GetWindow().GrabPointer(NULL, this, true); |
1557 | + if (window_thread_->GetGraphicsDisplay().PointerGrabData() != this) |
1558 | + result = window_thread_->GetGraphicsDisplay().GrabPointer(NULL, this, true); |
1559 | |
1560 | if (result) |
1561 | pointer_grab_stack_.push_front(area); |
1562 | @@ -2103,7 +2103,7 @@ |
1563 | pointer_grab_stack_.erase(it); |
1564 | |
1565 | if (pointer_grab_stack_.empty()) |
1566 | - GetWindow().UngrabPointer(this); |
1567 | + window_thread_->GetGraphicsDisplay().UngrabPointer(this); |
1568 | |
1569 | // reset the mouse pointers areas. |
1570 | ResetMousePointerAreas(); |
1571 | @@ -2143,9 +2143,9 @@ |
1572 | return result; |
1573 | } |
1574 | |
1575 | - if (GetWindow().KeyboardGrabData() != this) |
1576 | + if (window_thread_->GetGraphicsDisplay().KeyboardGrabData() != this) |
1577 | { |
1578 | - result = GetWindow().GrabKeyboard(NULL, this, true); |
1579 | + result = window_thread_->GetGraphicsDisplay().GrabKeyboard(NULL, this, true); |
1580 | } |
1581 | |
1582 | if (result) |
1583 | @@ -2214,7 +2214,7 @@ |
1584 | |
1585 | if (keyboard_grab_stack_.empty()) |
1586 | { |
1587 | - GetWindow().UngrabKeyboard(this); |
1588 | + window_thread_->GetGraphicsDisplay().UngrabKeyboard(this); |
1589 | } |
1590 | |
1591 | // Must be called only after the area has been added to the front of keyboard_grab_stack_. |
1592 | |
1593 | === modified file 'Nux/WindowThread.h' |
1594 | --- Nux/WindowThread.h 2011-12-22 06:23:58 +0000 |
1595 | +++ Nux/WindowThread.h 2012-01-03 03:15:27 +0000 |
1596 | @@ -104,12 +104,6 @@ |
1597 | */ |
1598 | void SetWindowBackgroundPaintLayer(AbstractPaintLayer *background_layer); |
1599 | |
1600 | - // todo(jaytaoko): remove this function |
1601 | - GraphicsDisplay &GetWindow() const |
1602 | - { |
1603 | - return *graphics_display_; |
1604 | - } |
1605 | - |
1606 | /*! |
1607 | Get the graphics display (this is the physical window of this thread). |
1608 | @return The graphics display. |
1609 | @@ -159,12 +153,6 @@ |
1610 | */ |
1611 | Layout* GetLayout(); |
1612 | |
1613 | - // todo(jaytaoko): remove this function. |
1614 | - Layout* GetMainLayout() |
1615 | - { |
1616 | - return GetLayout(); |
1617 | - } |
1618 | - |
1619 | //! Return true if the process is inside a layout cycle. |
1620 | /*! |
1621 | @return True if the process is inside a layout cycle. |
1622 | @@ -187,12 +175,6 @@ |
1623 | */ |
1624 | bool QueueObjectLayout(Area *area); |
1625 | |
1626 | - // todo(jaytaoko): remove this function |
1627 | - void AddObjectToRefreshList(Area *area) |
1628 | - { |
1629 | - QueueObjectLayout(area); |
1630 | - } |
1631 | - |
1632 | //! Compute the layout of a specific element |
1633 | /*! |
1634 | Immediate size negotiation for a View or a layout. |
1635 | @@ -207,12 +189,6 @@ |
1636 | */ |
1637 | bool RemoveObjectFromLayoutQueue(Area *area); |
1638 | |
1639 | - // todo(jaytaoko): remove this function |
1640 | - bool RemoveObjectFromRefreshList(Area *area) |
1641 | - { |
1642 | - return RemoveObjectFromLayoutQueue(area); |
1643 | - } |
1644 | - |
1645 | /*! |
1646 | Return \i true while waiting for a modal window to return. |
1647 | |
1648 | |
1649 | === modified file 'NuxGraphics/GpuDevice.h' |
1650 | --- NuxGraphics/GpuDevice.h 2011-10-22 06:17:42 +0000 |
1651 | +++ NuxGraphics/GpuDevice.h 2012-01-03 03:15:27 +0000 |
1652 | @@ -166,6 +166,11 @@ |
1653 | friend class GpuDevice; |
1654 | }; |
1655 | |
1656 | + //! The interface to the GPU. |
1657 | + /*! |
1658 | + This is the object that serves as the interface between the program and the GPU device. |
1659 | + The GpuDevice creates the opengl primitives used for rendering. |
1660 | + */ |
1661 | class GpuDevice |
1662 | { |
1663 | private: |
1664 | |
1665 | === modified file 'NuxGraphics/GraphicsDisplayX11.cpp' |
1666 | --- NuxGraphics/GraphicsDisplayX11.cpp 2012-01-03 01:10:30 +0000 |
1667 | +++ NuxGraphics/GraphicsDisplayX11.cpp 2012-01-03 03:15:27 +0000 |
1668 | @@ -80,9 +80,9 @@ |
1669 | , m_ScreenBitDepth(32) |
1670 | , m_GfxInterfaceCreated(false) |
1671 | , m_BestMode(-1) |
1672 | + , m_CreatedFromForeignWindow(false) |
1673 | , last_click_time_(0) |
1674 | , double_click_counter_(0) |
1675 | - , m_CreatedFromForeignWindow(false) |
1676 | , m_num_device_modes(0) |
1677 | , m_pEvent(NULL) |
1678 | , _last_dnd_position(Point(0, 0)) //DND |
1679 | @@ -602,7 +602,7 @@ |
1680 | /* Create a GLX window to associate the frame buffer configuration |
1681 | ** with the created X window */ |
1682 | glx_window_ = glXCreateWindow(m_X11Display, _fb_config, m_X11Window, NULL); |
1683 | - |
1684 | + |
1685 | // Map the window to the screen, and wait for it to appear */ |
1686 | XMapWindow(m_X11Display, m_X11Window); |
1687 | XEvent event; |
1688 | @@ -633,25 +633,27 @@ |
1689 | #endif |
1690 | |
1691 | MakeGLContextCurrent(); |
1692 | + |
1693 | + m_GfxInterfaceCreated = true; |
1694 | + |
1695 | + m_DeviceFactory = new GpuDevice(m_ViewportSize.width, m_ViewportSize.height, BITFMT_R8G8B8A8, |
1696 | + m_X11Display, |
1697 | + m_X11Window, |
1698 | + _has_glx_13, |
1699 | + _fb_config, |
1700 | + m_GLCtx, |
1701 | + 1, 0, false); |
1702 | + |
1703 | + m_GraphicsContext = new GraphicsEngine(*this); |
1704 | + |
1705 | + //EnableVSyncSwapControl(); |
1706 | + DisableVSyncSwapControl(); |
1707 | + |
1708 | glClearColor(0.0, 0.0, 0.0, 0.0); |
1709 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
1710 | SwapBuffer(); |
1711 | - |
1712 | - m_GfxInterfaceCreated = true; |
1713 | - |
1714 | - m_DeviceFactory = new GpuDevice(m_ViewportSize.width, m_ViewportSize.height, BITFMT_R8G8B8A8, |
1715 | - m_X11Display, |
1716 | - m_X11Window, |
1717 | - _has_glx_13, |
1718 | - _fb_config, |
1719 | - m_GLCtx, |
1720 | - 1, 0, false); |
1721 | - |
1722 | - m_GraphicsContext = new GraphicsEngine(*this); |
1723 | - |
1724 | - //EnableVSyncSwapControl(); |
1725 | - DisableVSyncSwapControl(); |
1726 | |
1727 | + |
1728 | InitGlobalGrabWindow(); |
1729 | |
1730 | return TRUE; |
1731 | @@ -967,9 +969,21 @@ |
1732 | if (m_GLCtx) |
1733 | { |
1734 | #ifndef NUX_OPENGLES_20 |
1735 | - if (!glXMakeCurrent(m_X11Display, None, NULL)) |
1736 | - { |
1737 | - nuxAssert("[GraphicsDisplay::DestroyOpenGLWindow] glXMakeCurrent failed."); |
1738 | + |
1739 | + // Release the current context |
1740 | + if (_has_glx_13) |
1741 | + { |
1742 | + if (!glXMakeContextCurrent(m_X11Display, None, None, NULL)) |
1743 | + { |
1744 | + nuxAssert("[GraphicsDisplay::DestroyOpenGLWindow] glXMakeContextCurrent failed."); |
1745 | + } |
1746 | + } |
1747 | + else |
1748 | + { |
1749 | + if (!glXMakeCurrent(m_X11Display, None, NULL)) |
1750 | + { |
1751 | + nuxAssert("[GraphicsDisplay::DestroyOpenGLWindow] glXMakeCurrent failed."); |
1752 | + } |
1753 | } |
1754 | |
1755 | glXDestroyContext(m_X11Display, m_GLCtx); |
1756 | @@ -1041,7 +1055,7 @@ |
1757 | |
1758 | bool double_click = false; |
1759 | Time current_time = xevent.xbutton.time; |
1760 | - if ((double_click_counter_ == 1) && (current_time - last_click_time_ < double_click_time_delay)) |
1761 | + if ((double_click_counter_ == 1) && ((int)current_time - (int)last_click_time_ < double_click_time_delay)) |
1762 | { |
1763 | double_click = true; |
1764 | double_click_counter_ = 0; |
1765 | @@ -2679,7 +2693,10 @@ |
1766 | if (GetGpuDevice()->GetGpuInfo().Support_EXT_Swap_Control()) |
1767 | { |
1768 | GLXDrawable drawable = glXGetCurrentDrawable(); |
1769 | - glXSwapIntervalEXT(m_X11Display, drawable, 0); |
1770 | + if (drawable != None) |
1771 | + { |
1772 | + glXSwapIntervalEXT(m_X11Display, drawable, 0); |
1773 | + } |
1774 | } |
1775 | #endif |
1776 | } |
1777 | |
1778 | === modified file 'NuxGraphics/GraphicsEngine.h' |
1779 | --- NuxGraphics/GraphicsEngine.h 2011-10-21 22:06:35 +0000 |
1780 | +++ NuxGraphics/GraphicsEngine.h 2012-01-03 03:15:27 +0000 |
1781 | @@ -102,6 +102,9 @@ |
1782 | }; |
1783 | |
1784 | //! Rendering engine class |
1785 | + /*! |
1786 | + This is the object that renders the graphics primitives. |
1787 | + */ |
1788 | class GraphicsEngine |
1789 | { |
1790 | public: |
1791 | |
1792 | === modified file 'NuxImage/CairoGraphics.cpp' |
1793 | --- NuxImage/CairoGraphics.cpp 2011-10-20 19:55:31 +0000 |
1794 | +++ NuxImage/CairoGraphics.cpp 2012-01-03 03:15:27 +0000 |
1795 | @@ -257,6 +257,12 @@ |
1796 | return true; |
1797 | } |
1798 | |
1799 | + void CairoGraphics::TranslateCoordinates(double tx, double ty) |
1800 | + { |
1801 | + nuxAssert(_cr); |
1802 | + cairo_translate(_cr, tx, ty); |
1803 | + } |
1804 | + |
1805 | bool CairoGraphics::DrawFilledRect(double x, double y, double w, double h, |
1806 | const Color &c) |
1807 | { |
1808 | |
1809 | === modified file 'NuxImage/CairoGraphics.h' |
1810 | --- NuxImage/CairoGraphics.h 2011-10-19 20:32:38 +0000 |
1811 | +++ NuxImage/CairoGraphics.h 2012-01-03 03:15:27 +0000 |
1812 | @@ -97,6 +97,8 @@ |
1813 | |
1814 | bool DrawLine(double x0, double y0, double x1, double y1, double width, const Color &c); |
1815 | |
1816 | + void TranslateCoordinates(double dx, double dy); |
1817 | + |
1818 | bool DrawFilledRect(double x, double y, double w, double h, const Color &c); |
1819 | |
1820 | bool DrawCanvas(double x, double y, CairoGraphics *cg); |
1821 | |
1822 | === modified file 'configure.ac' |
1823 | --- configure.ac 2012-01-03 01:10:30 +0000 |
1824 | +++ configure.ac 2012-01-03 03:15:27 +0000 |
1825 | @@ -22,7 +22,7 @@ |
1826 | # The number format is : year/month/day |
1827 | # e.g.: december 5th, 2011 is: 20111205 |
1828 | # So far there is no provision for more than one break in a day. |
1829 | -m4_define([nux_abi_version], [20111210]) |
1830 | +m4_define([nux_abi_version], [20111211]) |
1831 | |
1832 | m4_define([nux_version], |
1833 | [nux_major_version.nux_minor_version.nux_micro_version]) |
1834 | |
1835 | === modified file 'tests/Makefile.am' |
1836 | --- tests/Makefile.am 2011-12-19 18:59:56 +0000 |
1837 | +++ tests/Makefile.am 2012-01-03 03:15:27 +0000 |
1838 | @@ -1,6 +1,7 @@ |
1839 | if BUILD_TESTS |
1840 | check_PROGRAMS = \ |
1841 | test-nux \ |
1842 | + gtest-nux \ |
1843 | gtest-nux-core \ |
1844 | test-graphics-display \ |
1845 | test-empty-window \ |
1846 | @@ -75,6 +76,35 @@ |
1847 | -lpthread -lgtest -lgmock \ |
1848 | -lboost_filesystem -lboost_system |
1849 | |
1850 | +gtest_nux_SOURCES = \ |
1851 | + test-nux-main.cpp \ |
1852 | + test-nux-statictext.cpp \ |
1853 | + test-nux-windowthread.cpp |
1854 | + |
1855 | +gtest_nux_CPPFLAGS = \ |
1856 | + -I$(srcdir) \ |
1857 | + -I$(top_srcdir) \ |
1858 | + -DPREFIX=\""$(prefix)"\" \ |
1859 | + -DLIBDIR=\""$(libdir)"\" \ |
1860 | + -DDATADIR=\""$(datadir)"\" \ |
1861 | + -DG_LOG_DOMAIN=\"NuxTests\" \ |
1862 | + -DTESTDIR=\""$(top_srcdir)/tests"\" \ |
1863 | + $(GCC_FLAGS) \ |
1864 | + $(NUX_CORE_CFLAGS) \ |
1865 | + $(NUX_EXAMPLES_CFLAGS) \ |
1866 | + $(NUX_CFLAGS) \ |
1867 | + $(MAINTAINER_CFLAGS) |
1868 | + |
1869 | +gtest_nux_LDADD = \ |
1870 | + $(top_builddir)/NuxCore/libnux-core-@NUX_API_VERSION@.la \ |
1871 | + $(top_builddir)/NuxImage/libnux-image-@NUX_API_VERSION@.la \ |
1872 | + $(top_builddir)/NuxGraphics/libnux-graphics-@NUX_API_VERSION@.la \ |
1873 | + $(top_builddir)/Nux/libnux-@NUX_API_VERSION@.la \ |
1874 | + $(NUX_LIBS) |
1875 | + |
1876 | +gtest_nux_LDFLAGS = \ |
1877 | + -lpthread -lgtest -lgmock \ |
1878 | + -lboost_filesystem -lboost_system |
1879 | |
1880 | TestFlags = -I$(srcdir) \ |
1881 | -I$(top_srcdir) \ |
1882 | @@ -200,8 +230,9 @@ |
1883 | test: |
1884 | @gtester --verbose -k -o=test-nux-results.xml ./test-nux |
1885 | |
1886 | -gtest: gtest-nux-core |
1887 | +gtest: gtest-nux-core gtest-nux |
1888 | ./gtest-nux-core |
1889 | + ./gtest-nux |
1890 | |
1891 | test-apps: test-graphics-display test-empty-window button-xtest mouse-events-test mouse-buttons-test hgrid-key-navigation-test hlayout-key-navigation-test vlayout-key-navigation-test scrollbar-test |
1892 | ./test-graphics-display |
1893 | |
1894 | === modified file 'tests/nux_automated_test_framework.cpp' |
1895 | --- tests/nux_automated_test_framework.cpp 2011-11-23 04:42:44 +0000 |
1896 | +++ tests/nux_automated_test_framework.cpp 2012-01-03 03:15:27 +0000 |
1897 | @@ -59,7 +59,7 @@ |
1898 | void NuxAutomatedTestFramework::Startup() |
1899 | { |
1900 | display_ = XOpenDisplay(NULL); |
1901 | - nux::Geometry rect = window_thread_->GetWindow().GetWindowGeometry(); |
1902 | + nux::Geometry rect = window_thread_->GetGraphicsDisplay().GetWindowGeometry(); |
1903 | //nuxDebugMsg("Window geometry: (%d, %d, %d, %d)", rect.x, rect.y, rect.width, rect.height); |
1904 | |
1905 | window_x_ = rect.x; |
1906 | @@ -78,7 +78,7 @@ |
1907 | } |
1908 | else |
1909 | { |
1910 | - r = window_thread_->GetWindow().GetWindowGeometry(); |
1911 | + r = window_thread_->GetGraphicsDisplay().GetWindowGeometry(); |
1912 | r.OffsetPosition(r.width/2, r.height/2); |
1913 | } |
1914 | |
1915 | @@ -101,7 +101,7 @@ |
1916 | } |
1917 | else |
1918 | { |
1919 | - r = window_thread_->GetWindow().GetWindowGeometry(); |
1920 | + r = window_thread_->GetGraphicsDisplay().GetWindowGeometry(); |
1921 | r.OffsetPosition(r.width/2, r.height/2); |
1922 | } |
1923 | |
1924 | @@ -191,7 +191,7 @@ |
1925 | } |
1926 | else |
1927 | { |
1928 | - r = window_thread_->GetWindow().GetWindowGeometry(); |
1929 | + r = window_thread_->GetGraphicsDisplay().GetWindowGeometry(); |
1930 | r.OffsetPosition(x, y); |
1931 | } |
1932 | |
1933 | @@ -208,7 +208,7 @@ |
1934 | } |
1935 | else |
1936 | { |
1937 | - r = window_thread_->GetWindow().GetWindowGeometry(); |
1938 | + r = window_thread_->GetGraphicsDisplay().GetWindowGeometry(); |
1939 | } |
1940 | |
1941 | int view_center_x = r.x + r.width/2; |
1942 | |
1943 | === added file 'tests/test-nux-main.cpp' |
1944 | --- tests/test-nux-main.cpp 1970-01-01 00:00:00 +0000 |
1945 | +++ tests/test-nux-main.cpp 2012-01-03 03:15:27 +0000 |
1946 | @@ -0,0 +1,13 @@ |
1947 | +#include <gtest/gtest.h> |
1948 | +#include <glib-object.h> |
1949 | + |
1950 | +#include "Nux/Nux.h" |
1951 | + |
1952 | +int main(int argc, char **argv) |
1953 | +{ |
1954 | + ::testing::InitGoogleTest(&argc, argv); |
1955 | + g_type_init(); |
1956 | + nux::NuxInitialize (0); |
1957 | + |
1958 | + return RUN_ALL_TESTS(); |
1959 | +} |
1960 | |
1961 | === added file 'tests/test-nux-statictext.cpp' |
1962 | --- tests/test-nux-statictext.cpp 1970-01-01 00:00:00 +0000 |
1963 | +++ tests/test-nux-statictext.cpp 2012-01-03 03:15:27 +0000 |
1964 | @@ -0,0 +1,52 @@ |
1965 | +#include <string> |
1966 | +#include <fstream> |
1967 | + |
1968 | +#include <iostream> |
1969 | +#include <gmock/gmock.h> |
1970 | +#include <boost/filesystem.hpp> |
1971 | +#include <glib.h> |
1972 | + |
1973 | +#include "Nux/Nux.h" |
1974 | +#include "Nux/StaticText.h" |
1975 | + |
1976 | + |
1977 | +using namespace testing; |
1978 | + |
1979 | +namespace { |
1980 | + |
1981 | +TEST(TestStaticText, TestCreate) |
1982 | +{ |
1983 | + nux::NuxInitialize(0); |
1984 | + nux::WindowThread *wnd_thread = nux::CreateNuxWindow("Nux Window", 300, 200, |
1985 | + nux::WINDOWSTYLE_NORMAL, NULL, false, NULL, NULL); |
1986 | + |
1987 | + nux::StaticText *statictext = new nux::StaticText(""); |
1988 | + |
1989 | + EXPECT_EQ(statictext->GetText(), std::string("")); |
1990 | + |
1991 | + // Test the default color. Should be white. |
1992 | + EXPECT_EQ(statictext->GetTextColor(), nux::color::White); |
1993 | + |
1994 | + // Test random color. |
1995 | + nux::Color random_color = nux::color::RandomColor(); |
1996 | + statictext->SetTextColor(random_color); |
1997 | + EXPECT_EQ(statictext->GetTextColor(), random_color); |
1998 | + |
1999 | + // Test default font. Should be "Ubuntu". |
2000 | + EXPECT_EQ(statictext->GetFontName(), std::string("Ubuntu")); |
2001 | + |
2002 | + // Test random font. |
2003 | + statictext->SetFontName("Courrier"); |
2004 | + EXPECT_EQ(statictext->GetFontName(), std::string("Courrier")); |
2005 | + |
2006 | + // Test default font point size; |
2007 | + EXPECT_EQ(statictext->GetTextPointSize(), 10); |
2008 | + |
2009 | + statictext->SetTextPointSize(20); |
2010 | + EXPECT_EQ(statictext->GetTextPointSize(), 20); |
2011 | + |
2012 | + statictext->UnReference(); |
2013 | + delete wnd_thread; |
2014 | +} |
2015 | + |
2016 | +} |
2017 | |
2018 | === added file 'tests/test-nux-windowthread.cpp' |
2019 | --- tests/test-nux-windowthread.cpp 1970-01-01 00:00:00 +0000 |
2020 | +++ tests/test-nux-windowthread.cpp 2012-01-03 03:15:27 +0000 |
2021 | @@ -0,0 +1,33 @@ |
2022 | +#include <string> |
2023 | +#include <fstream> |
2024 | + |
2025 | +#include <iostream> |
2026 | +#include <gmock/gmock.h> |
2027 | +#include <boost/filesystem.hpp> |
2028 | +#include <glib.h> |
2029 | + |
2030 | +#include "Nux/Nux.h" |
2031 | + |
2032 | + |
2033 | +using namespace testing; |
2034 | + |
2035 | +namespace { |
2036 | + |
2037 | +TEST(TestWindowThread, TestCreate) |
2038 | +{ |
2039 | + nux::NuxInitialize(0); |
2040 | + nux::WindowThread *wnd_thread = nux::CreateNuxWindow("Nux Window", 300, 200, |
2041 | + nux::WINDOWSTYLE_NORMAL, NULL, false, NULL, NULL); |
2042 | + |
2043 | + ASSERT_TRUE(wnd_thread != NULL); |
2044 | + EXPECT_EQ(wnd_thread->GetWindowTitle(), std::string("Nux Window")); |
2045 | + EXPECT_EQ(wnd_thread->IsModalWindow(), false); |
2046 | + |
2047 | + EXPECT_EQ(wnd_thread->IsComputingLayout(), false); |
2048 | + EXPECT_EQ(wnd_thread->IsInsideLayoutCycle(), false); |
2049 | + |
2050 | + delete wnd_thread; |
2051 | +} |
2052 | + |
2053 | + |
2054 | +} |