Nux

Merge lp:~gordallott/nux/keynav-fixes-11-03-10 into lp:nux

Proposed by Gord Allott
Status: Merged
Merged at revision: 265
Proposed branch: lp:~gordallott/nux/keynav-fixes-11-03-10
Merge into: lp:nux
Diff against target: 1303 lines (+694/-136)
19 files modified
Nux/Area.cpp (+2/-6)
Nux/Area.h (+2/-1)
Nux/Focusable.cpp (+11/-0)
Nux/GridHLayout.cpp (+93/-0)
Nux/GridHLayout.h (+8/-0)
Nux/HLayout.cpp (+22/-0)
Nux/HLayout.h (+4/-0)
Nux/InputArea.cpp (+0/-1)
Nux/LayeredLayout.cpp (+71/-12)
Nux/LayeredLayout.h (+6/-0)
Nux/Layout.cpp (+197/-49)
Nux/Layout.h (+15/-4)
Nux/TextEntry.cpp (+82/-2)
Nux/TextEntry.h (+3/-0)
Nux/VLayout.cpp (+21/-0)
Nux/VLayout.h (+4/-0)
Nux/View.cpp (+37/-5)
Nux/View.h (+2/-0)
examples/focus.cpp (+114/-56)
To merge this branch: bzr merge lp:~gordallott/nux/keynav-fixes-11-03-10
Reviewer Review Type Date Requested Status
Jay Taoko (community) Approve
Review via email: mp+52842@code.launchpad.net

Description of the change

Bunch of key-nav fixes for unity key-nav - paired with lp:~gordallott/unity/keynav-fixes-11-03-10

To post a comment you must log in.
Revision history for this message
Jay Taoko (jaytaoko) wrote :

Approved

review: Approve

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-02-28 17:37:41 +0000
3+++ Nux/Area.cpp 2011-03-10 13:09:13 +0000
4@@ -827,7 +827,7 @@
5 return;
6
7 _is_focused = focused;
8- FocusChanged (this);
9+ FocusChanged.emit (this);
10 }
11
12 bool Area::DoCanFocus ()
13@@ -838,6 +838,7 @@
14 /* override me! */
15 void Area::DoActivateFocus ()
16 {
17+ FocusActivated.emit (this);
18 }
19
20 void Area::QueueRelayout ()
21@@ -845,9 +846,4 @@
22 nux::GetWindowThread ()->QueueObjectLayout (this);
23 }
24
25-// bool Area::AddSecondaryChild (Area *child)
26-// {
27-// NUX_RETURN_IF_NULL (child, false);
28-//
29-// }
30 }
31
32=== modified file 'Nux/Area.h'
33--- Nux/Area.h 2011-03-01 04:25:39 +0000
34+++ Nux/Area.h 2011-03-10 13:09:13 +0000
35@@ -296,7 +296,8 @@
36 virtual void DoSetFocused (bool focused);
37 virtual bool DoCanFocus ();
38 virtual void DoActivateFocus ();
39-
40+
41+ sigc::signal <void, Area *> FocusActivated;
42 sigc::signal <void, Area *> FocusChanged;
43 //! Queue a relayout
44 /*!
45
46=== modified file 'Nux/Focusable.cpp'
47--- Nux/Focusable.cpp 2011-02-28 17:32:57 +0000
48+++ Nux/Focusable.cpp 2011-03-10 13:09:13 +0000
49@@ -54,22 +54,27 @@
50 {
51 case NUX_VK_ENTER:
52 type = FOCUS_EVENT_ACTIVATE;
53+ //g_debug ("focus key activated");
54 break;
55 case NUX_KP_UP:
56 type = FOCUS_EVENT_DIRECTION;
57 *direction = FOCUS_DIRECTION_UP;
58+ //g_debug ("direction up");
59 break;
60 case NUX_KP_DOWN:
61 type = FOCUS_EVENT_DIRECTION;
62 *direction = FOCUS_DIRECTION_DOWN;
63+ //g_debug ("direction down");
64 break;
65 case NUX_KP_LEFT:
66 type = FOCUS_EVENT_DIRECTION;
67 *direction = FOCUS_DIRECTION_LEFT;
68+ //g_debug ("direction left");
69 break;
70 case NUX_KP_RIGHT:
71 type = FOCUS_EVENT_DIRECTION;
72 *direction = FOCUS_DIRECTION_RIGHT;
73+ //g_debug ("direction right");
74 break;
75 case NUX_VK_TAB:
76 type = FOCUS_EVENT_DIRECTION;
77@@ -77,6 +82,11 @@
78 if (keysym & NUX_STATE_SHIFT)
79 {
80 *direction = FOCUS_DIRECTION_PREV;
81+ //g_debug ("direction_prev");
82+ }
83+ else
84+ {
85+ //g_debug ("direction next");
86 }
87 break;
88 default:
89@@ -100,6 +110,7 @@
90
91 bool Focusable::DoCanFocus ()
92 {
93+ g_debug ("Focusable DoCanFocus");
94 return false;
95 }
96
97
98=== modified file 'Nux/GridHLayout.cpp'
99--- Nux/GridHLayout.cpp 2011-02-27 00:34:59 +0000
100+++ Nux/GridHLayout.cpp 2011-03-10 13:09:13 +0000
101@@ -61,6 +61,99 @@
102
103 }
104
105+ int GridHLayout::GetChildPos (Area *child)
106+ {
107+ int position = 0;
108+ std::list<Area *>::const_iterator it;
109+ for (it = GetChildren ().begin(); it != GetChildren ().end(); it++)
110+ {
111+ if ((*it) == child)
112+ break;
113+
114+ if ((*it)->CanFocus ())
115+ {
116+ position++;
117+ }
118+ }
119+
120+ return position;
121+ }
122+
123+ Area* GridHLayout::GetChildAtPosition (int pos)
124+ {
125+ int position = 0;
126+ std::list<Area *>::const_iterator it;
127+ for (it = GetChildren ().begin(); it != GetChildren ().end(); it++)
128+ {
129+ if (position == pos)
130+ return (*it);
131+
132+ if ((*it)->CanFocus ())
133+ {
134+ position++;
135+ }
136+ }
137+
138+ return NULL;
139+ }
140+
141+ //up and down should pass event to parent
142+ long GridHLayout::DoFocusUp (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
143+ {
144+ Area* focused_child = GetFocusedChild ();
145+ int position = GetChildPos (focused_child);
146+
147+ if (focused_child == NULL || position < GetNumColumn ())
148+ {
149+ Area *parent = GetParentObject ();
150+ if (parent != NULL)
151+ return SendEventToArea (parent, ievent, TraverseInfo, ProcessEventInfo);
152+
153+ }
154+ else
155+ {
156+ // so hacky, but its cheap!
157+ // just focus the child position - numcolumns
158+ focused_child->SetFocused (false);
159+ focused_child = GetChildAtPosition (position - GetNumColumn ());
160+ if (focused_child)
161+ focused_child->SetFocused (true);
162+ }
163+
164+ return TraverseInfo;
165+ }
166+ long GridHLayout::DoFocusDown (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
167+ {
168+ Area* focused_child = GetFocusedChild ();
169+ int position = GetChildPos (focused_child);
170+
171+ if (focused_child == NULL || position > GetNumColumn () * (GetNumRow () - 1))
172+ {
173+ Area *parent = GetParentObject ();
174+ if (parent != NULL)
175+ {
176+ return SendEventToArea (parent, ievent, TraverseInfo, ProcessEventInfo);
177+ }
178+ }
179+ else
180+ {
181+ // so hacky, but its cheap!
182+ // just focus the child position - numcolumns
183+ focused_child->SetFocused (false);
184+ focused_child = GetChildAtPosition (position + GetNumColumn ());
185+ if (focused_child)
186+ {
187+ focused_child->SetFocused (true);
188+ }
189+ else
190+ {
191+ FocusLastChild ();
192+ }
193+ }
194+
195+ return TraverseInfo;
196+ }
197+
198 void GridHLayout::EnablePartialVisibility (bool partial_visibility)
199 {
200 _partial_visibility = partial_visibility;
201
202=== modified file 'Nux/GridHLayout.h'
203--- Nux/GridHLayout.h 2011-02-23 14:14:29 +0000
204+++ Nux/GridHLayout.h 2011-03-10 13:09:13 +0000
205@@ -104,6 +104,14 @@
206 */
207 virtual void ProcessDraw (GraphicsEngine &GfxContext, bool force_draw);
208
209+ protected:
210+ int GetChildPos (Area *child);
211+ Area* GetChildAtPosition (int pos);
212+ virtual long DoFocusUp (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
213+ virtual long DoFocusDown (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
214+ //virtual long DoFocusLeft (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
215+ //virtual long DoFocusRight (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
216+
217 private:
218 Size _children_size;
219 bool _dynamic_column;
220
221=== modified file 'Nux/HLayout.cpp'
222--- Nux/HLayout.cpp 2011-02-23 14:14:29 +0000
223+++ Nux/HLayout.cpp 2011-03-10 13:09:13 +0000
224@@ -64,6 +64,28 @@
225 {
226 }
227
228+ //up and down should pass event to parent
229+ long HLayout::DoFocusUp (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
230+ {
231+ Area *parent = GetParentObject ();
232+ if (parent != NULL)
233+ return SendEventToArea (parent, ievent, TraverseInfo, ProcessEventInfo);
234+ else
235+ FocusFirstChild ();
236+
237+ return TraverseInfo;
238+ }
239+ long HLayout::DoFocusDown (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
240+ {
241+
242+ Area *parent = GetParentObject ();
243+ if (parent != NULL)
244+ return SendEventToArea (parent, ievent, TraverseInfo, ProcessEventInfo);
245+ else
246+ FocusFirstChild ();
247+ return TraverseInfo;
248+ }
249+
250 void HLayout::GetCompositeList (std::list<Area *> *ViewList)
251 {
252 std::list<Area *>::iterator it;
253
254=== modified file 'Nux/HLayout.h'
255--- Nux/HLayout.h 2011-02-17 06:49:43 +0000
256+++ Nux/HLayout.h 2011-03-10 13:09:13 +0000
257@@ -50,6 +50,10 @@
258 @param element_margin The margin between elements.
259 */
260 void ComputeStacking (t_s32 remaining_width, t_s32 &offset_space, t_s32 &element_margin);
261+
262+ protected:
263+ virtual long DoFocusUp (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
264+ virtual long DoFocusDown (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
265 };
266 }
267
268
269=== modified file 'Nux/InputArea.cpp'
270--- Nux/InputArea.cpp 2011-03-09 13:04:39 +0000
271+++ Nux/InputArea.cpp 2011-03-10 13:09:13 +0000
272@@ -814,7 +814,6 @@
273 void InputArea::DoSetFocused (bool focused)
274 {
275 Area::DoSetFocused (focused);
276- CaptureMouseDownAnyWhereElse (focused);
277 SetKeyboardFocus (focused);
278 }
279
280
281=== modified file 'Nux/LayeredLayout.cpp'
282--- Nux/LayeredLayout.cpp 2011-02-28 16:24:11 +0000
283+++ Nux/LayeredLayout.cpp 2011-03-10 13:09:13 +0000
284@@ -82,6 +82,37 @@
285 {
286 }
287
288+ long LayeredLayout::DoFocusPrev (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
289+ {
290+ if (GetInputMode () == INPUT_MODE_ACTIVE)
291+ {
292+ Area *parent = GetParentObject ();
293+ if (parent != NULL)
294+ return SendEventToArea (parent, ievent, TraverseInfo, ProcessEventInfo);
295+ }
296+ else
297+ {
298+ return Layout::DoFocusPrev (ievent, TraverseInfo, ProcessEventInfo);
299+ }
300+
301+ return TraverseInfo;
302+ }
303+
304+ long LayeredLayout::DoFocusNext (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
305+ {
306+ if (GetInputMode () == INPUT_MODE_ACTIVE)
307+ {
308+ Area *parent = GetParentObject ();
309+ if (parent != NULL)
310+ return SendEventToArea (parent, ievent, TraverseInfo, ProcessEventInfo);
311+ }
312+ else
313+ {
314+ return Layout::DoFocusNext (ievent, TraverseInfo, ProcessEventInfo);
315+ }
316+
317+ return TraverseInfo;
318+ }
319 void LayeredLayout::GetCompositeList (std::list<Area *> *ViewList)
320 {
321 std::list<Area *>::iterator it;
322@@ -392,21 +423,25 @@
323
324 m_active_index = index_;
325 m_active_area = NULL;
326+ bool is_focused = GetFocused ();
327
328 // first unset focused on all elements
329- for (it = _layout_element_list.begin (); it != eit; ++it)
330+ if (is_focused)
331 {
332- if ((*it)->GetFocused ())
333+ for (it = _layout_element_list.begin (); it != eit; ++it)
334 {
335- if ((*it)->IsView ())
336- static_cast<View *> (*it)->SetFocused (false);
337- else if ((*it)->IsLayout ())
338- static_cast<Layout *> (*it)->SetFocused (false);
339- else
340- (*it)->SetFocused (false);
341+ if ((*it)->GetFocused ())
342+ {
343+ if ((*it)->IsView ())
344+ static_cast<View *> (*it)->SetFocused (false);
345+ else if ((*it)->IsLayout ())
346+ static_cast<Layout *> (*it)->SetFocused (false);
347+ else
348+ (*it)->SetFocused (false);
349+ }
350 }
351 }
352-
353+
354 for (it = _layout_element_list.begin (); it != eit; ++it)
355 {
356 if (i == m_active_index && !m_active_area)
357@@ -417,12 +452,14 @@
358 if ((*it)->IsView ())
359 {
360 static_cast<View *> (*it)->QueueDraw ();
361- static_cast<View *> (*it)->SetFocused (true);
362- }
363+ if (is_focused)
364+ static_cast<View *> (*it)->SetFocused (true);
365+ }
366 else if ((*it)->IsLayout ())
367 {
368 static_cast<Layout *> (*it)->QueueDraw ();
369- static_cast<Layout *> (*it)->SetFocused (true);
370+ if (is_focused);
371+ static_cast<Layout *> (*it)->SetFocused (true);
372 }
373
374 i++;
375@@ -595,4 +632,26 @@
376 _layout_element_list.erase (area_it);
377 _layout_element_list.insert (_layout_element_list.begin (), area);
378 }
379+
380+ bool LayeredLayout::FocusFirstChild ()
381+ {
382+ if (m_input_mode == INPUT_MODE_ACTIVE)
383+ {
384+ m_active_area->SetFocused (true);
385+ return true;
386+ }
387+ else
388+ return Layout::FocusFirstChild ();
389+ }
390+
391+ bool LayeredLayout::FocusLastChild ()
392+ {
393+ if (m_input_mode == INPUT_MODE_ACTIVE)
394+ {
395+ m_active_area->SetFocused (true);
396+ return true;
397+ }
398+ else
399+ return Layout::FocusLastChild ();
400+ }
401 }
402
403=== modified file 'Nux/LayeredLayout.h'
404--- Nux/LayeredLayout.h 2011-02-07 10:05:22 +0000
405+++ Nux/LayeredLayout.h 2011-03-10 13:09:13 +0000
406@@ -198,6 +198,12 @@
407 void RemoveChildObject (Area *area);
408 void Clear ();
409
410+ protected:
411+ virtual long DoFocusPrev (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
412+ virtual long DoFocusNext (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
413+ virtual bool FocusFirstChild ();
414+ virtual bool FocusLastChild ();
415+
416 private:
417 void PaintOne (Area *area, GraphicsEngine &GfxContext, bool force_draw);
418 long ProcessOne (Area *_area, IEvent &ievent, long traverse_info, long process_event_info);
419
420=== modified file 'Nux/Layout.cpp'
421--- Nux/Layout.cpp 2011-02-28 17:32:57 +0000
422+++ Nux/Layout.cpp 2011-03-10 13:09:13 +0000
423@@ -40,6 +40,7 @@
424 m_ContentStacking = eStackExpand;
425 _has_focus_control = false;
426 _queued_draw = false;
427+ _ignore_focus = false;
428
429 SetMinimumSize(1, 1);
430 }
431@@ -421,6 +422,22 @@
432 return false;
433 }
434
435+ bool Layout::FocusLastChild ()
436+ {
437+ std::list<Area *>::reverse_iterator it;
438+ for (it = _layout_element_list.rbegin(); it != _layout_element_list.rend(); it++)
439+ {
440+ if ((*it)->CanFocus ())
441+ {
442+ (*it)->SetFocused (true);
443+ ChildFocusChanged (this, (*it));
444+ return true;
445+ }
446+ }
447+
448+ return false;
449+ }
450+
451
452 bool Layout::FocusNextChild (Area *child)
453 {
454@@ -491,7 +508,9 @@
455 {
456 // if parent is null return, thats a valid usecase so no warnings.
457 if (area == NULL)
458+ {
459 return 0;
460+ }
461
462
463 long ret = 0;
464@@ -511,10 +530,80 @@
465 return ret;
466 }
467
468+ Area* Layout::GetFocusedChild ()
469+ {
470+ std::list<Area *>::iterator it;
471+ for (it = _layout_element_list.begin(); it != _layout_element_list.end(); it++)
472+ {
473+ if ((*it)->GetFocused ())
474+ {
475+ return (*it);
476+ }
477+ }
478+
479+ return NULL;
480+ }
481+
482+ long Layout::DoFocusPrev (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
483+ {
484+ Area *focused_child = GetFocusedChild ();
485+ if (focused_child == NULL) return ProcessEventInfo;
486+ bool success = FocusPreviousChild (focused_child);
487+ focused_child->SetFocused (false);
488+
489+ if (success == false)
490+ {
491+ Area *parent = GetParentObject ();
492+ if (parent != NULL)
493+ return SendEventToArea (parent, ievent, TraverseInfo, ProcessEventInfo);
494+ else
495+ FocusFirstChild ();
496+ }
497+
498+ return ProcessEventInfo;
499+ }
500+
501+ long Layout::DoFocusNext (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
502+ {
503+ Area *focused_child = GetFocusedChild ();
504+ if (focused_child == NULL) return ProcessEventInfo;
505+ bool success = FocusNextChild(focused_child);
506+ focused_child->SetFocused (false);
507+
508+ if (success == false)
509+ {
510+ Area *parent = GetParentObject ();
511+ if (parent != NULL)
512+ return SendEventToArea (parent, ievent, TraverseInfo, ProcessEventInfo);
513+ else
514+ FocusFirstChild ();
515+ }
516+
517+ return ProcessEventInfo;
518+ }
519+
520+ long Layout::DoFocusUp (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
521+ {
522+ return DoFocusPrev (ievent, TraverseInfo, ProcessEventInfo);
523+ }
524+ long Layout::DoFocusDown (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
525+ {
526+ return DoFocusNext (ievent, TraverseInfo, ProcessEventInfo);
527+ }
528+ long Layout::DoFocusLeft (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
529+ {
530+ return DoFocusPrev (ievent, TraverseInfo, ProcessEventInfo);
531+ }
532+ long Layout::DoFocusRight (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
533+ {
534+ return DoFocusNext (ievent, TraverseInfo, ProcessEventInfo);
535+ }
536+
537+
538 long Layout::ProcessFocusEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
539 {
540 long ret = TraverseInfo;
541- std::list<Area *>::iterator it;
542+
543
544 if (GetFocused () && ievent.e_event == NUX_KEYDOWN)
545 {
546@@ -532,15 +621,8 @@
547
548 if (type == FOCUS_EVENT_DIRECTION && direction != FOCUS_DIRECTION_NONE)
549 {
550- for (it = _layout_element_list.begin(); it != _layout_element_list.end(); it++)
551- {
552- if ((*it)->GetFocused ())
553- {
554- focused_child = (*it);
555- break;
556- }
557- }
558-
559+ focused_child = GetFocusedChild ();
560+
561 /* if nothing is focused, focus the first child else send the event to the parent */
562
563 if (focused_child == NULL)
564@@ -566,7 +648,16 @@
565 {
566 if (focused_child == _layout_element_list.front ())
567 {
568- ret |= SendEventToArea (parent, ievent, ret, ProcessEventInfo);
569+ if (parent != NULL)
570+ {
571+ ret |= SendEventToArea (parent, ievent, ret, ProcessEventInfo);
572+ }
573+ else
574+ {
575+ bool success = FocusLastChild ();
576+ if (success)
577+ focused_child->SetFocused (false);
578+ }
579 return ret;
580 }
581 }
582@@ -574,40 +665,70 @@
583 {
584 if (focused_child == _layout_element_list.back ())
585 {
586- ret |= SendEventToArea (parent, ievent, ret, ProcessEventInfo);
587- return ret;
588- }
589- }
590-
591- if (direction == FOCUS_DIRECTION_NEXT // we don't support RTL yet, for shame!
592- || direction == FOCUS_DIRECTION_RIGHT
593- || direction == FOCUS_DIRECTION_DOWN)
594- {
595- bool success = FocusNextChild(focused_child);
596-
597- if (success)
598- {
599- focused_child->SetFocused (false);
600- return ret;
601- }
602-
603- //~ if (success == false)
604- //~ // no next focused, thats weird. lets propagate up
605- //~ return SendEventToArea (parent, ievent, ret, ProcessEventInfo);
606- }
607-
608- if (direction == FOCUS_DIRECTION_PREV // we don't support RTL yet, for shame!
609- || direction == FOCUS_DIRECTION_LEFT
610- || direction == FOCUS_DIRECTION_UP)
611- {
612- bool success = FocusPreviousChild(focused_child);
613-
614- if (success)
615- {
616- focused_child->SetFocused (false);
617- return ret;
618- }
619- }
620+ if (parent != NULL)
621+ {
622+ ret |= SendEventToArea (parent, ievent, ret, ProcessEventInfo);
623+ }
624+ else
625+ {
626+ bool success = FocusFirstChild ();
627+ if (success)
628+ focused_child->SetFocused (false);
629+ }
630+ return ret;
631+ }
632+ }
633+
634+ switch (direction)
635+ {
636+ case FOCUS_DIRECTION_NEXT:
637+ ret |= DoFocusNext (ievent, ret, ProcessEventInfo);
638+ break;
639+ case FOCUS_DIRECTION_PREV:
640+ ret |= DoFocusPrev (ievent, ret, ProcessEventInfo);
641+ break;
642+ case FOCUS_DIRECTION_UP:
643+ ret |= DoFocusUp (ievent, ret, ProcessEventInfo);
644+ break;
645+ case FOCUS_DIRECTION_DOWN:
646+ ret |= DoFocusDown (ievent, ret, ProcessEventInfo);
647+ break;
648+ case FOCUS_DIRECTION_LEFT:
649+ ret |= DoFocusLeft (ievent, ret, ProcessEventInfo);
650+ break;
651+ case FOCUS_DIRECTION_RIGHT:
652+ ret |= DoFocusRight (ievent, ret, ProcessEventInfo);
653+ break;
654+ default:
655+ break;
656+ }
657+
658+ return ret;
659+
660+
661+// if (direction == FOCUS_DIRECTION_NEXT // we don't support RTL yet, for shame!
662+// || direction == FOCUS_DIRECTION_RIGHT
663+// || direction == FOCUS_DIRECTION_DOWN)
664+// {
665+//
666+//
667+// //~ if (success == false)
668+// //~ // no next focused, thats weird. lets propagate up
669+// //~ return SendEventToArea (parent, ievent, ret, ProcessEventInfo);
670+// }
671+//
672+// if (direction == FOCUS_DIRECTION_PREV // we don't support RTL yet, for shame!
673+// || direction == FOCUS_DIRECTION_LEFT
674+// || direction == FOCUS_DIRECTION_UP)
675+// {
676+// bool success = FocusPreviousChild(focused_child);
677+//
678+// if (success)
679+// {
680+// focused_child->SetFocused (false);
681+// return ret;
682+// }
683+// }
684
685 }
686 }
687@@ -650,8 +771,14 @@
688 }
689
690 /* must do focus processing after sending events to children */
691- if (ievent.e_event == NUX_KEYDOWN && HasFocusControl ())
692- ret |= ProcessFocusEvent (ievent, ret, ProcessEventInfo);
693+ if (ievent.e_event == NUX_KEYDOWN && HasFocusControl () && _ignore_focus == false)
694+ {
695+ ret |= ProcessFocusEvent (ievent, ret, ProcessEventInfo);
696+ }
697+
698+ if (_ignore_focus)
699+ _ignore_focus = false;
700+
701 return ret;
702 }
703
704@@ -815,7 +942,21 @@
705 else
706 {
707 SetFocusControl (true);
708- FocusFirstChild ();
709+ bool has_focused_child = false;
710+ std::list<Area *>::iterator it;
711+ for (it = _layout_element_list.begin(); it != _layout_element_list.end(); it++)
712+ {
713+ if ((*it)->GetFocused ())
714+ has_focused_child = true;
715+ }
716+
717+ if (has_focused_child == false)
718+ {
719+ FocusFirstChild ();
720+ _ignore_focus = true;
721+ }
722+
723+ // we need to chain up
724 Area *_parent = GetParentObject();
725 if (_parent == NULL)
726 return;
727@@ -823,15 +964,22 @@
728 if (_parent->IsView ())
729 {
730 View *parent = (View*)_parent;
731+ if (parent->GetFocused () == false)
732+ {
733+ parent->SetFocused (true);
734+ }
735 parent->SetFocusControl (false);
736 }
737 else if (_parent->IsLayout ())
738 {
739 Layout *parent = (Layout *)_parent;
740+ if (parent->GetFocused () == false)
741+ {
742+ parent->SetFocused (true);
743+ }
744 parent->SetFocusControl (false);
745 }
746
747-
748 }
749 }
750
751
752=== modified file 'Nux/Layout.h'
753--- Nux/Layout.h 2011-03-01 04:25:39 +0000
754+++ Nux/Layout.h 2011-03-10 13:09:13 +0000
755@@ -229,10 +229,6 @@
756 virtual bool DoCanFocus ();
757 virtual void DoActivateFocus ();
758
759- bool FocusFirstChild ();
760- bool FocusNextChild (Area *child);
761- bool FocusPreviousChild (Area *child);
762-
763 bool HasFocusableEntries ();
764
765 sigc::signal <void, Layout *, Area*> ChildFocusChanged;
766@@ -242,8 +238,23 @@
767 bool _has_focus_control;
768 void SetFocusControl (bool focus_control);
769 bool HasFocusControl ();
770+ bool _ignore_focus;
771
772 protected:
773+ Area*GetFocusedChild ();
774+ virtual long DoFocusPrev (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
775+ virtual long DoFocusNext (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
776+ virtual long DoFocusUp (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
777+ virtual long DoFocusDown (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
778+ virtual long DoFocusLeft (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
779+ virtual long DoFocusRight (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
780+ virtual bool FocusFirstChild ();
781+ virtual bool FocusLastChild ();
782+ virtual bool FocusNextChild (Area *child);
783+ virtual bool FocusPreviousChild (Area *child);
784+
785+
786+
787 bool _queued_draw; //<! The rendering of the layout needs to be refreshed.
788
789 Size m_ContentSize;
790
791=== modified file 'Nux/TextEntry.cpp'
792--- Nux/TextEntry.cpp 2011-03-08 15:48:35 +0000
793+++ Nux/TextEntry.cpp 2011-03-10 13:09:13 +0000
794@@ -200,13 +200,91 @@
795 return result;
796 }
797
798+ void TextEntry::DoSetFocused (bool focused)
799+ {
800+
801+ View::DoSetFocused (focused);
802+ if (focused == true)
803+ {
804+ SetCursor(0);
805+ QueueRefresh(false, true);
806+
807+ Area *_parent = GetParentObject();
808+ if (_parent == NULL)
809+ return;
810+
811+ if (_parent->IsView ())
812+ {
813+ View *parent = (View*)_parent;
814+ parent->SetFocusControl (false);
815+ }
816+ else if (_parent->IsLayout ())
817+ {
818+ Layout *parent = (Layout *)_parent;
819+ parent->SetFocusControl (false);
820+ }
821+ }
822+ }
823+
824 long TextEntry::ProcessEvent (IEvent& event,
825 long traverseInfo,
826 long processEventInfo)
827 {
828 long ret = traverseInfo;
829-
830- ret = PostProcessEvent2 (event, ret, processEventInfo);
831+ /* must do focus processing after sending events to children */
832+ if (event.e_event == NUX_KEYDOWN && GetFocused ())
833+ {
834+ FocusDirection direction;
835+ FocusEventType type;
836+
837+ direction = FOCUS_DIRECTION_NONE;
838+
839+ type = Focusable::GetFocusableEventType (event.e_event,
840+ event.GetKeySym(),
841+ event.GetText(),
842+ &direction);
843+ if (type == FOCUS_EVENT_DIRECTION)
844+ {
845+ if (direction == FOCUS_DIRECTION_PREV || direction == FOCUS_DIRECTION_NEXT ||
846+ direction == FOCUS_DIRECTION_UP || direction == FOCUS_DIRECTION_DOWN)
847+ {
848+ Area *area = GetParentObject ();
849+ // if parent is null return, thats a valid usecase so no warnings.
850+ if (area)
851+ {
852+ long ret = 0;
853+ if ( area->IsView() )
854+ {
855+ View *ic = NUX_STATIC_CAST (View *, area );
856+ ret = ic->ProcessFocusEvent (event, ret, processEventInfo);
857+ }
858+ else if ( area->IsLayout() )
859+ {
860+ Layout *layout = NUX_STATIC_CAST (Layout *, area );
861+ layout->SetFocusControl (true);
862+ ret = layout->ProcessFocusEvent (event, ret, processEventInfo);
863+ }
864+ }
865+ }
866+ else
867+ {
868+ OnKeyEvent.emit (GetWindowThread ()->GetGraphicsEngine(),
869+ event.e_event, event.GetKeySym(),
870+ event.GetKeyState(), event.GetText(),
871+ event.GetKeyRepeatCount());
872+ //ret = PostProcessEvent2 (event, ret, processEventInfo);
873+ }
874+ }
875+ else
876+ {
877+ OnKeyEvent.emit (GetWindowThread ()->GetGraphicsEngine(),
878+ event.e_event, event.GetKeySym(),
879+ event.GetKeyState(), event.GetText(),
880+ event.GetKeyRepeatCount());
881+ }
882+ }
883+
884+
885 return ret;
886 }
887
888@@ -522,6 +600,7 @@
889 if (_text_color != text_color)
890 {
891 _text_color = text_color;
892+ QueueRefresh(true, true);
893 }
894 }
895
896@@ -1301,6 +1380,7 @@
897 if (end > str)
898 {
899 size_t len = end - str;
900+
901 _text.insert(cursor_, str, len);
902 cursor_ += static_cast<int>(len);
903 selection_bound_ += static_cast<int>(len);
904
905=== modified file 'Nux/TextEntry.h'
906--- Nux/TextEntry.h 2011-03-08 14:22:45 +0000
907+++ Nux/TextEntry.h 2011-03-10 13:09:13 +0000
908@@ -173,6 +173,9 @@
909 CairoGraphics::Alignment GetAlign() const;
910 void SetAlign(CairoGraphics::Alignment align);
911
912+ protected:
913+ virtual void DoSetFocused (bool focused);
914+
915 private:
916 /**
917 * Enum used to specify different motion types.
918
919=== modified file 'Nux/VLayout.cpp'
920--- Nux/VLayout.cpp 2011-02-23 14:14:29 +0000
921+++ Nux/VLayout.cpp 2011-03-10 13:09:13 +0000
922@@ -65,6 +65,27 @@
923 {
924 }
925
926+ //left and right in a vlayout should pass event to parent
927+ long VLayout::DoFocusLeft (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
928+ {
929+ Area *parent = GetParentObject ();
930+ if (parent != NULL)
931+ return SendEventToArea (parent, ievent, TraverseInfo, ProcessEventInfo);
932+ else
933+ FocusFirstChild ();
934+
935+ return TraverseInfo;
936+ }
937+ long VLayout::DoFocusRight (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
938+ {
939+ Area *parent = GetParentObject ();
940+ if (parent != NULL)
941+ return SendEventToArea (parent, ievent, TraverseInfo, ProcessEventInfo);
942+ else
943+ FocusLastChild ();
944+ return TraverseInfo;
945+ }
946+
947 void VLayout::GetCompositeList (std::list<Area *> *ViewList)
948 {
949 std::list<Area *>::iterator it;
950
951=== modified file 'Nux/VLayout.h'
952--- Nux/VLayout.h 2011-02-17 06:49:43 +0000
953+++ Nux/VLayout.h 2011-03-10 13:09:13 +0000
954@@ -50,6 +50,10 @@
955 @param element_margin The margin between elements.
956 */
957 void ComputeStacking (t_s32 length, t_s32 &offset_space, t_s32 &element_margin);
958+
959+ protected:
960+ virtual long DoFocusLeft (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
961+ virtual long DoFocusRight (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
962 };
963 }
964
965
966=== modified file 'Nux/View.cpp'
967--- Nux/View.cpp 2011-02-28 17:32:57 +0000
968+++ Nux/View.cpp 2011-03-10 13:09:13 +0000
969@@ -40,6 +40,7 @@
970 m_UseStyleDrawing = true;
971 m_TextColor = Color (1.0f, 1.0f, 1.0f, 1.0f);
972 _can_pass_focus_to_composite_layout = true;
973+ _can_focus = true;
974
975 // Set widget default size;
976 SetMinimumSize (DEFAULT_WIDGET_WIDTH, PRACTICAL_WIDGET_HEIGHT);
977@@ -261,6 +262,17 @@
978 }
979 }
980
981+// if (GetFocused () && _can_pass_focus_to_composite_layout == false)
982+// {
983+// GetPainter ().Paint2DQuadColor (GfxContext, GetGeometry (), nux::Color (0.2, 1.0, 0.2, 1.0));
984+// }
985+
986+// if (GetFocused () && _can_pass_focus_to_composite_layout == true)
987+// {
988+// GetPainter ().Paint2DQuadColor (GfxContext, GetGeometry (), nux::Color (1.0, 0.2, 0.2, 1.0));
989+// }
990+
991+
992 GfxContext.PopModelViewMatrix ();
993
994 _need_redraw = false;
995@@ -269,7 +281,7 @@
996
997 void View::DrawContent (GraphicsEngine &GfxContext, bool force_draw)
998 {
999-
1000+
1001 }
1002
1003 void View::PostDraw (GraphicsEngine &GfxContext, bool force_draw)
1004@@ -462,6 +474,7 @@
1005
1006 void View::DoSetFocused (bool focused)
1007 {
1008+ QueueDraw ();
1009 if (_can_pass_focus_to_composite_layout)
1010 {
1011 Layout *layout = GetLayout ();
1012@@ -473,6 +486,7 @@
1013 }
1014 else
1015 {
1016+ InputArea::DoSetFocused (focused);
1017 }
1018 }
1019 else
1020@@ -494,20 +508,38 @@
1021 SetFocusControl (false);
1022
1023 }
1024+ else
1025+ {
1026+ InputArea::DoSetFocused (focused);
1027+ }
1028 }
1029
1030 bool View::DoCanFocus ()
1031 {
1032+ if (IsVisible () == false)
1033+ return false;
1034+
1035+ if (_can_focus == false)
1036+ return false;
1037+
1038 if (_can_pass_focus_to_composite_layout)
1039 {
1040 if (GetLayout () != NULL)
1041 {
1042 return GetLayout ()->CanFocus ();
1043 }
1044- return true;
1045- }
1046-
1047- return true;
1048+ }
1049+
1050+ return _can_focus;
1051+ }
1052+
1053+ void View::SetCanFocus (bool can_focus)
1054+ {
1055+ _can_focus = can_focus;
1056+ if (_can_focus == False && GetFocused ())
1057+ {
1058+ SetFocused (false);
1059+ }
1060 }
1061
1062 void View::SetFocusControl (bool focus_control)
1063
1064=== modified file 'Nux/View.h'
1065--- Nux/View.h 2011-03-01 04:25:39 +0000
1066+++ Nux/View.h 2011-03-10 13:09:13 +0000
1067@@ -176,10 +176,12 @@
1068 virtual long ProcessFocusEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
1069 virtual void DoSetFocused (bool focused);
1070 virtual bool DoCanFocus ();
1071+ void SetCanFocus (bool can_focus);
1072 void SetFocusControl (bool focus_control);
1073 bool HasFocusControl ();
1074
1075 protected:
1076+ bool _can_focus;
1077
1078 virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo) = 0;
1079 virtual void Draw (GraphicsEngine &GfxContext, bool force_draw) = 0;
1080
1081=== modified file 'examples/focus.cpp'
1082--- examples/focus.cpp 2011-02-28 11:14:50 +0000
1083+++ examples/focus.cpp 2011-03-10 13:09:13 +0000
1084@@ -23,21 +23,28 @@
1085 #include "Nux/WindowThread.h"
1086 #include "NuxGraphics/GraphicsEngine.h"
1087 #include "Nux/TextureArea.h"
1088+#include "Nux/TextEntry.h"
1089
1090 #include "Nux/VLayout.h"
1091 #include "Nux/HLayout.h"
1092+#include "Nux/GridHLayout.h"
1093 #include "Nux/ScrollView.h"
1094 #include "Nux/PushButton.h"
1095 #include "Nux/TextureArea.h"
1096
1097+float frand ()
1098+{
1099+ return ((float)rand ()) / RAND_MAX;
1100+}
1101+
1102 static void OnFocusChildChanged (nux::Layout *layout, nux::Area *view)
1103 {
1104- g_debug ("focus has changed, woo");
1105+ g_debug ("focus has changed, woo %i", rand ());
1106 }
1107
1108 static void OnFocusChanged (nux::Area *view)
1109 {
1110- g_debug ("focus on a specific child has changed");
1111+ g_debug ("focus on a specific child has changed %i", rand ());
1112 nux::TextureArea *texarea = (nux::TextureArea *)view;
1113
1114 if (view->GetFocused ())
1115@@ -47,7 +54,7 @@
1116 }
1117 else
1118 {
1119- nux::ColorLayer color (nux::Color (1.0, 0.2, 0.2, 1.0));
1120+ nux::ColorLayer color (nux::Color (0.6, 0.+ frand ()*0.3, 0.2+ frand ()*0.3, 1.0));
1121 texarea->SetPaintLayer (&color);
1122 }
1123
1124@@ -57,66 +64,117 @@
1125 void UserInterfaceInitialization(nux::NThread* thread, void* init_data)
1126 {
1127 // Create a vertical Layout
1128- nux::VLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION);
1129- nux::HLayout* layout_top = new nux::HLayout(NUX_TRACKER_LOCATION);
1130-
1131- nux::ScrollView *layout_scroll = new nux::ScrollView (NUX_TRACKER_LOCATION);
1132- nux::HLayout* layout_bottom = new nux::HLayout(NUX_TRACKER_LOCATION);
1133- layout->AddLayout (layout_top, 0, nux::MINOR_POSITION_TOP);
1134-
1135- layout_scroll->SetLayout (layout_bottom);
1136- layout->AddView (layout_scroll, 0, nux::MINOR_POSITION_TOP);
1137+ nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION);
1138+ nux::VLayout* layout_left = new nux::VLayout (NUX_TRACKER_LOCATION);
1139+ nux::HLayout* content_layout = new nux::HLayout (NUX_TRACKER_LOCATION);
1140+ nux::VLayout* layout_right = new nux::VLayout (NUX_TRACKER_LOCATION);
1141+
1142+ //nux::HLayout* layout_top = new nux::HLayout(NUX_TRACKER_LOCATION);
1143+ nux::TextEntry* text_entry = new nux::TextEntry ("This is some text", NUX_TRACKER_LOCATION);
1144+ text_entry->SetTextColor (nux::Color (1.0, 1.0, 1.0, 1.0));
1145+
1146+ //nux::ScrollView *layout_scroll = new nux::ScrollView (NUX_TRACKER_LOCATION);
1147+ nux::VLayout* layout_scroll_container = new nux::VLayout (NUX_TRACKER_LOCATION);
1148+
1149+ nux::VLayout* layout_scroll_1 = new nux::VLayout(NUX_TRACKER_LOCATION);
1150+ nux::HLayout* layout_scroll_11 = new nux::HLayout(NUX_TRACKER_LOCATION);
1151+ nux::GridHLayout* layout_scroll_12 = new nux::GridHLayout (NUX_TRACKER_LOCATION);
1152+
1153+ layout_scroll_1->AddLayout (layout_scroll_11, 0, nux::MINOR_POSITION_TOP);
1154+ layout_scroll_1->AddLayout (layout_scroll_12, 1, nux::MINOR_POSITION_TOP);
1155+
1156+ nux::VLayout* layout_scroll_2 = new nux::VLayout(NUX_TRACKER_LOCATION);
1157+ nux::HLayout* layout_scroll_21 = new nux::HLayout(NUX_TRACKER_LOCATION);
1158+ nux::GridHLayout* layout_scroll_22 = new nux::GridHLayout (NUX_TRACKER_LOCATION);
1159+
1160+ layout_scroll_2->AddLayout (layout_scroll_21, 0, nux::MINOR_POSITION_TOP);
1161+ layout_scroll_2->AddLayout (layout_scroll_22, 1, nux::MINOR_POSITION_TOP);
1162+
1163+ layout_scroll_container->AddView (text_entry, 0, nux::MINOR_POSITION_TOP);
1164+
1165+ //layout_scroll->SetLayout (layout_scroll_container);
1166+ layout_scroll_container->AddLayout (layout_scroll_1, 1, nux::MINOR_POSITION_TOP);
1167+ layout_scroll_container->AddLayout (layout_scroll_2, 1, nux::MINOR_POSITION_TOP);
1168+
1169+ content_layout->AddLayout (layout_scroll_container, 1, nux::MINOR_POSITION_TOP);
1170+ layout->AddLayout (layout_left, 0);
1171+ layout->AddLayout (content_layout, 1);
1172+ layout->AddLayout (layout_right, 0);
1173+
1174 layout->ChildFocusChanged.connect (sigc::ptr_fun(&OnFocusChildChanged));
1175
1176- //~ //Create a button of type PushButton
1177- //~ nux::PushButton* button = new nux::PushButton (TEXT ("Hello World!"), NUX_TRACKER_LOCATION);
1178-//~
1179- //~ // Set the button maximum width/height
1180- //~ button->SetMaximumWidth (80);
1181- //~ button->SetMaximumHeight (40);
1182-//~
1183- //~ // Add the button to the layout
1184- //~ layout->AddView (button, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
1185-//~
1186- //~ //Create a button of type PushButton
1187- //~ button = new nux::PushButton (TEXT ("Button2"), NUX_TRACKER_LOCATION);
1188-//~
1189- //~ // Set the button maximum width/height
1190- //~ button->SetMaximumWidth (80);
1191- //~ button->SetMaximumHeight (40);
1192-//~
1193- //~ // Add the button to the layout
1194- //~ layout->AddView (button, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
1195-//~
1196- //~ //Create a button of type PushButton
1197- //~ button = new nux::PushButton( TEXT ("Button 3"), NUX_TRACKER_LOCATION);
1198-//~
1199- //~ // Set the button maximum width/height
1200- //~ button->SetMaximumWidth (80);
1201- //~ button->SetMaximumHeight (40);
1202-//~
1203- //~ // Add the button to the layout
1204- //~ layout->AddView (button, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
1205+
1206+// for (int i = 0; i < 6; i++)
1207+// {
1208+// nux::ColorLayer color (nux::Color (0.2, 0.2, 0.2+ frand ()*0.3, 1.0));
1209+// nux::TextureArea* texture_area = new nux::TextureArea ();
1210+// texture_area->SetPaintLayer (&color);
1211+// texture_area->FocusChanged.connect (sigc::ptr_fun (&OnFocusChanged));
1212+//
1213+// layout_top->AddView (texture_area, 1, nux::eLeft, nux::eFull);
1214+// }
1215
1216 for (int i = 0; i < 6; i++)
1217 {
1218- nux::ColorLayer color (nux::Color (0.2, 0.2, 0.2, 1.0));
1219- nux::TextureArea* texture_area = new nux::TextureArea ();
1220- texture_area->SetPaintLayer (&color);
1221- texture_area->FocusChanged.connect (sigc::ptr_fun (&OnFocusChanged));
1222-
1223- layout_top->AddView (texture_area, 1, nux::eLeft, nux::eFull);
1224- }
1225-
1226- for (int i = 0; i < 3; i++)
1227- {
1228- nux::ColorLayer color (nux::Color (0.2, 0.2, 0.4, 1.0));
1229+ nux::ColorLayer color (nux::Color (0.2, 0.2, 0.4+ frand ()*0.3, 1.0));
1230 nux::TextureArea* texture_area = new nux::TextureArea ();
1231 texture_area->SetPaintLayer (&color);
1232 texture_area->FocusChanged.connect (sigc::ptr_fun (&OnFocusChanged));
1233 //~ //~
1234- layout_bottom->AddView (texture_area, 1, nux::eLeft, nux::eFull);
1235- }
1236+ layout_scroll_11->AddView (texture_area, 1, nux::eLeft, nux::eFull);
1237+ }
1238+
1239+ for (int i = 0; i < 16; i++)
1240+ {
1241+ nux::ColorLayer color (nux::Color (0.2, 0.2, 0.4+ frand ()*0.3, 1.0));
1242+ nux::TextureArea* texture_area = new nux::TextureArea ();
1243+ texture_area->SetPaintLayer (&color);
1244+ texture_area->FocusChanged.connect (sigc::ptr_fun (&OnFocusChanged));
1245+ //~ //~
1246+ layout_scroll_12->AddView (texture_area, 1, nux::eLeft, nux::eFull);
1247+ }
1248+
1249+ for (int i = 0; i < 6; i++)
1250+ {
1251+ nux::ColorLayer color (nux::Color (0.2, 0.2, 0.4+ frand ()*0.3, 1.0));
1252+ nux::TextureArea* texture_area = new nux::TextureArea ();
1253+ texture_area->SetPaintLayer (&color);
1254+ texture_area->FocusChanged.connect (sigc::ptr_fun (&OnFocusChanged));
1255+ //~ //~
1256+ layout_scroll_21->AddView (texture_area, 1, nux::eLeft, nux::eFull);
1257+ }
1258+
1259+ for (int i = 0; i < 16; i++)
1260+ {
1261+ nux::ColorLayer color (nux::Color (0.2, 0.2, 0.4+ frand ()*0.3, 1.0));
1262+ nux::TextureArea* texture_area = new nux::TextureArea ();
1263+ texture_area->SetPaintLayer (&color);
1264+ texture_area->FocusChanged.connect (sigc::ptr_fun (&OnFocusChanged));
1265+ //~ //~
1266+ layout_scroll_22->AddView (texture_area, 1, nux::eLeft, nux::eFull);
1267+ }
1268+
1269+
1270+ for (int i = 0; i < 16; i++)
1271+ {
1272+ nux::ColorLayer color (nux::Color (0.2, 0.2, 0.4+ frand ()*0.3, 1.0));
1273+ nux::TextureArea* texture_area = new nux::TextureArea ();
1274+ texture_area->SetPaintLayer (&color);
1275+ texture_area->FocusChanged.connect (sigc::ptr_fun (&OnFocusChanged));
1276+ //~ //~
1277+ layout_left->AddView (texture_area, 1, nux::eLeft, nux::eFull);
1278+ }
1279+
1280+ for (int i = 0; i < 16; i++)
1281+ {
1282+ nux::ColorLayer color (nux::Color (0.2, 0.2, 0.4+ frand ()*0.3, 1.0));
1283+ nux::TextureArea* texture_area = new nux::TextureArea ();
1284+ texture_area->SetPaintLayer (&color);
1285+ texture_area->FocusChanged.connect (sigc::ptr_fun (&OnFocusChanged));
1286+ //~ //~
1287+ layout_right->AddView (texture_area, 1, nux::eLeft, nux::eFull);
1288+ }
1289+
1290
1291
1292 // Control the position of elements inside the layout
1293@@ -140,8 +198,8 @@
1294 // Create a Window thread
1295 nux::WindowThread* wt = nux::CreateGUIThread(
1296 TEXT("Push Button"),
1297- 500,
1298- 500,
1299+ 800,
1300+ 600,
1301 0,
1302 &UserInterfaceInitialization,
1303 0);

Subscribers

People subscribed via source and target branches