Nux

Merge lp:~azzar1/nux/nux-layout-nvi into lp:nux

Proposed by Andrea Azzarone
Status: Needs review
Proposed branch: lp:~azzar1/nux/nux-layout-nvi
Merge into: lp:nux
Diff against target: 653 lines (+171/-294)
7 files modified
Nux/LayeredLayout.cpp (+15/-13)
Nux/LayeredLayout.h (+14/-11)
Nux/Layout.cpp (+71/-57)
Nux/Layout.h (+70/-26)
Nux/LinearLayout.cpp (+0/-156)
Nux/LinearLayout.h (+0/-30)
configure.ac (+1/-1)
To merge this branch: bzr merge lp:~azzar1/nux/nux-layout-nvi
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Francis Ginther Abstain
Unity Team Pending
Review via email: mp+117236@code.launchpad.net

Commit message

Use NVI for AddLayout/AddView/AddSpace to avoid to redefine a function's inherited default parameter value.

Description of the change

== Problem ==
nux::LinearLayout and nux::LayeredLayout redefine nux::Layout functions with default parameters. This is not advisable because default values are statically bound.

== Fix ==
Use NVI (no virtual implementation).

== Test ==
Not applicable.

To post a comment you must log in.
Revision history for this message
Francis Ginther (fginther) wrote :

Review was claimed by accident, please ignore.

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

640. By Andrea Azzarone

Minor changes.

639. By Andrea Azzarone

Use NVI for AddLayout/AddView/AddSpace to avoid to redefine a function's inherited default parameter value.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nux/LayeredLayout.cpp'
2--- Nux/LayeredLayout.cpp 2012-04-10 00:58:09 +0000
3+++ Nux/LayeredLayout.cpp 2012-07-30 10:42:05 +0000
4@@ -240,22 +240,24 @@
5 return NULL;
6 }
7
8- void LayeredLayout::AddLayout(Layout *layout,
9- unsigned int stretch_factor,
10- MinorDimensionPosition positioning,
11- MinorDimensionSize extend,
12- float percentage)
13+ void LayeredLayout::DoAddLayout(Layout* layout,
14+ unsigned int stretch_factor,
15+ MinorDimensionPosition minor_position,
16+ MinorDimensionSize minor_size,
17+ float percentage,
18+ LayoutPosition index)
19 {
20 AddLayer(layout);
21 }
22
23- void LayeredLayout::AddView(Area *view,
24- unsigned int stretch_factor,
25- MinorDimensionPosition positioning,
26- MinorDimensionSize extend,
27- float percentage)
28+ void LayeredLayout::DoAddView(Area* baseobject,
29+ unsigned int stretch_factor,
30+ MinorDimensionPosition minor_position,
31+ MinorDimensionSize minor_size,
32+ float percentage,
33+ LayoutPosition index)
34 {
35- AddLayer(view);
36+ AddLayer(baseobject);
37 }
38
39 void LayeredLayout::RemoveChildObject(Area *area)
40@@ -308,9 +310,9 @@
41 props->m_vis_it = area->OnVisibleChanged.connect(sigc::mem_fun(this, &LayeredLayout::ChildVisibilityChanged));
42
43 if (area->IsLayout())
44- Layout::AddLayout(static_cast<Layout *> (area));
45+ Layout::DoAddLayout(static_cast<Layout *> (area), 1, eAbove, eFull, 100, NUX_LAYOUT_END);
46 else
47- Layout::AddView(area);
48+ Layout::DoAddView(area, 1, eAbove, eFull, 100.0f, NUX_LAYOUT_END);
49
50 QueueDraw();
51 }
52
53=== modified file 'Nux/LayeredLayout.h'
54--- Nux/LayeredLayout.h 2012-04-10 00:58:09 +0000
55+++ Nux/LayeredLayout.h 2012-07-30 10:42:05 +0000
56@@ -208,16 +208,6 @@
57 // */
58 // LayoutProperties * GetLayoutProperties();
59
60- void AddLayout(Layout *layouy,
61- unsigned int stretch_factor = 1,
62- MinorDimensionPosition position = eAbove,
63- MinorDimensionSize extend = eFull,
64- float percentage = 100.0f);
65- void AddView(Area *view,
66- unsigned int stretch_factor = 1,
67- MinorDimensionPosition positioning = eAbove,
68- MinorDimensionSize extend = eFull,
69- float percentage = 100.0f);
70 void RemoveChildObject(Area *area);
71 void Clear();
72
73@@ -234,7 +224,20 @@
74 virtual Area* KeyNavIteration(KeyNavDirection direction);
75 void OnLayerGeometryChanged(Area* area, Geometry geo);
76
77- private:
78+ /*override*/ void DoAddLayout(Layout* layout,
79+ unsigned int stretch_factor,
80+ MinorDimensionPosition minor_position,
81+ MinorDimensionSize minor_size,
82+ float percentage,
83+ LayoutPosition index);
84+
85+ /*override*/ void DoAddView(Area* baseobject,
86+ unsigned int stretch_factor,
87+ MinorDimensionPosition minor_position,
88+ MinorDimensionSize minor_size,
89+ float percentage,
90+ LayoutPosition index);
91+
92 void PaintOne(Area *area, GraphicsEngine &graphics_engine, bool force_draw);
93 void ChildQueueDraw(Area *area);
94 void ChildVisibilityChanged(Area *area, bool visible);
95
96=== modified file 'Nux/Layout.cpp'
97--- Nux/Layout.cpp 2011-11-25 04:59:29 +0000
98+++ Nux/Layout.cpp 2012-07-30 10:42:05 +0000
99@@ -193,24 +193,60 @@
100 return (_layout_element_list.size() == 0);
101 }
102
103-// If(stretchfactor == 0): the WidgetLayout geometry will be set to SetGeometry(0,0,1,1);
104+ /*
105+ * Use non-virtual interface idiom (NVI) to avoid to redefine a function's
106+ * inherited default parameter value.
107+ */
108+ void Layout::AddLayout(Layout* layout,
109+ unsigned int stretch_factor,
110+ MinorDimensionPosition positioning,
111+ MinorDimensionSize extend,
112+ float percentage,
113+ LayoutPosition index)
114+ {
115+ DoAddLayout(layout, stretch_factor, positioning, extend, percentage, index);
116+ }
117+
118+ void Layout::AddView(Area* baseobject,
119+ unsigned int stretch_factor,
120+ MinorDimensionPosition positioning,
121+ MinorDimensionSize extend,
122+ float percentage,
123+ LayoutPosition index)
124+ {
125+ DoAddView(baseobject, stretch_factor, positioning, extend, percentage, index);
126+ }
127+
128+ void Layout::AddSpace(unsigned int width,
129+ unsigned int stretch_factor,
130+ LayoutPosition index)
131+ {
132+ DoAddSpace(width, stretch_factor, index);
133+ }
134+
135+// If(stretch_factor == 0): the WidgetLayout geometry will be set to SetGeometry(0,0,1,1);
136 // and the children will take their natural size by expending WidgetLayout.
137 // If the parent of WidgetLayout offers more space, it won't be used by WidgetLayout.
138- void Layout::AddLayout(Layout *layout, unsigned int stretchFactor, MinorDimensionPosition minor_position, MinorDimensionSize minor_size, float percentage, LayoutPosition index)
139+ void Layout::DoAddLayout(Layout* layout,
140+ unsigned int stretch_factor,
141+ MinorDimensionPosition minor_position,
142+ MinorDimensionSize minor_size,
143+ float percentage,
144+ LayoutPosition index)
145 {
146- nuxAssertMsg(layout != 0, "[Layout::AddView] Invalid parameter.");
147+ nuxAssertMsg(layout != 0, "[Layout::DoAddLayout] Invalid parameter.");
148 NUX_RETURN_IF_TRUE(layout == 0);
149 // Should never happen
150- nuxAssertMsg(layout != this, "[Layout::AddLayout] Error: Trying to add a layout to itself.");
151+ nuxAssertMsg(layout != this, "[Layout::DoAddLayout] Error: Trying to add a layout to itself.");
152 NUX_RETURN_IF_FALSE(layout != 0);
153
154 Area *parent = layout->GetParentObject();
155- nuxAssertMsg(parent == 0, "[Layout::AddLayout] Trying to add an object that already has a parent.");
156+ nuxAssertMsg(parent == 0, "[Layout::DoAddLayout] Trying to add an object that already has a parent.");
157 NUX_RETURN_IF_TRUE(parent != 0);
158
159- nuxAssertMsg(index >= 0, "[Layout::AddLayout] Invalid index position. Adding at the beginning of the list..");
160+ nuxAssertMsg(index >= 0, "[Layout::DoAddLayout] Invalid index position. Adding at the beginning of the list..");
161
162- layout->SetScaleFactor(stretchFactor);
163+ layout->SetScaleFactor(stretch_factor);
164 layout->SetPositioning(minor_position);
165 layout->SetExtend(minor_size);
166
167@@ -253,63 +289,43 @@
168
169 }
170
171-//! Add an object to the layout.
172- /*! Add an object to the layout.
173- A baseobject minor dimension with respect to a layout object is the dimension opposite to the layout flow.
174- A baseobject major dimension with respect to a layout object is the dimension aligned with the layout flow.
175- A layout object minor dimension is the dimension opposite to the layout flow.
176- A layout object major dimension is the dimension aligned with the layout flow.
177-
178- Add an object to the layout. The added object get its size and position managed by the layout.
179- When a baseobject is added with a stretches factor equal to 0, its major dimension assumes its minimum value.
180- For instance, if the layout is a vertical layout and the added object has a stretch factor equal 0, then during the layout,
181- the added object height will be set to its minimum value using ApplyMinHeight().
182-
183- The minor_position parameter controls how the layout will place the object within itself. A vertical layout object controls the horizontal positioning
184- of its children baseobjects, While an horizontal layout object controls the vertical positioning of its children baseobjects.
185-
186- The minor_size parameter controls how much size the baseobject minor dimension gets from the layout minor dimension. See MinorDimensionSize.
187-
188- /param baseobject The object that is being added.
189- /param stretchFactor This value controls how the layout object share space between its children baseobject.
190- /param minor_position Controls how the layout position the object.
191- /param minor_size Controls the object minor dimension size.
192- /param percentage Controls the object minor dimension size in percentage of the layout minor dimension size.
193- /param index Controls the object position in the layout children.
194- */
195-
196- void Layout::AddView(Area *bo, unsigned int stretchFactor, MinorDimensionPosition minor_position, MinorDimensionSize minor_size, float percentage, LayoutPosition index)
197+ void Layout::DoAddView(Area* baseobject,
198+ unsigned int stretch_factor,
199+ MinorDimensionPosition minor_position,
200+ MinorDimensionSize minor_size,
201+ float percentage,
202+ LayoutPosition index)
203 {
204- nuxAssertMsg(bo != 0, "[Layout::AddView] Invalid parameter.");
205- NUX_RETURN_IF_TRUE(bo == 0);
206+ nuxAssertMsg(baseobject != 0, "[Layout::DoAddView] Invalid parameter.");
207+ NUX_RETURN_IF_TRUE(baseobject == 0);
208
209- Area *parent = bo->GetParentObject();
210- nuxAssertMsg(parent == 0, "[Layout::AddView] Trying to add an object that already has a parent.");
211+ Area *parent = baseobject->GetParentObject();
212+ nuxAssertMsg(parent == 0, "[Layout::DoAddView] Trying to add an object that already has a parent.");
213 NUX_RETURN_IF_TRUE(parent != 0);
214
215- nuxAssertMsg(index >= 0, "[Layout::AddView] Invalid index position. Adding at the beginning of the list..");
216+ nuxAssertMsg(index >= 0, "[Layout::DoAddView] Invalid index position. Adding at the beginning of the list..");
217
218- bo->SetScaleFactor(stretchFactor);
219- bo->SetPositioning(minor_position);
220- bo->SetExtend(minor_size);
221+ baseobject->SetScaleFactor(stretch_factor);
222+ baseobject->SetPositioning(minor_position);
223+ baseobject->SetExtend(minor_size);
224
225 if (percentage < 1.0f)
226 {
227- bo->SetPercentage(1.0f);
228+ baseobject->SetPercentage(1.0f);
229 }
230 else if (percentage > 100.0f)
231 {
232- bo->SetPercentage(100.0f);
233+ baseobject->SetPercentage(100.0f);
234 }
235 else
236 {
237- bo->SetPercentage(percentage);
238+ baseobject->SetPercentage(percentage);
239 }
240
241- bo->SetParentObject(this);
242+ baseobject->SetParentObject(this);
243
244- if (bo->IsView())
245- static_cast<View *> (bo)->OnQueueDraw.connect(sigc::mem_fun(this, &Layout::ChildViewQueuedDraw));
246+ if (baseobject->IsView())
247+ static_cast<View *> (baseobject)->OnQueueDraw.connect(sigc::mem_fun(this, &Layout::ChildViewQueuedDraw));
248
249 //if(HasFocusControl() && HasFocusableEntries() == false)
250 //{
251@@ -322,31 +338,29 @@
252
253 if (index == NUX_LAYOUT_END || index >= _layout_element_list.size())
254 {
255- _layout_element_list.push_back(bo);
256+ _layout_element_list.push_back(baseobject);
257 }
258 else
259 {
260-#if defined(NUX_OS_WINDOWS) && !defined(NUX_VISUAL_STUDIO_2010)
261- std::list<Area *>::iterator pos = _layout_element_list.begin();
262-#else
263- auto pos = _layout_element_list.begin();
264-#endif
265+ std::list<Area*>::iterator pos = _layout_element_list.begin();
266 int idx = index;
267 while (pos != _layout_element_list.end() && idx > 0)
268 {
269 idx--;
270 pos++;
271 }
272- _layout_element_list.insert(pos, bo);
273+ _layout_element_list.insert(pos, baseobject);
274 }
275
276- ViewAdded.emit(this, bo);
277+ ViewAdded.emit(this, baseobject);
278 //--->> Removed because it cause problem with The splitter widget: ComputeContentSize();
279 }
280
281- void Layout::AddSpace(unsigned int width, unsigned int stretchFactor, LayoutPosition index)
282+ void Layout::DoAddSpace(unsigned int width,
283+ unsigned int stretch_factor,
284+ LayoutPosition index)
285 {
286- AddLayout(new SpaceLayout(), stretchFactor);
287+ AddLayout(new SpaceLayout(), stretch_factor);
288 }
289
290 void Layout::Clear()
291
292=== modified file 'Nux/Layout.h'
293--- Nux/Layout.h 2011-11-24 17:54:41 +0000
294+++ Nux/Layout.h 2012-07-30 10:42:05 +0000
295@@ -42,7 +42,12 @@
296 Layout(NUX_FILE_LINE_PROTO);
297 virtual ~Layout();
298
299- virtual void AddLayout(Layout *, unsigned int stretchFactor = 1, MinorDimensionPosition = eAbove, MinorDimensionSize extend = eFull, float percentage = 100.0f, LayoutPosition = NUX_LAYOUT_END);
300+ void AddLayout(Layout* layout,
301+ unsigned int stretch_factor = 1,
302+ MinorDimensionPosition minor_position = eAbove,
303+ MinorDimensionSize minor_size = eFull,
304+ float percentage = 100.0f,
305+ LayoutPosition index = NUX_LAYOUT_END);
306
307 //! Add an object to the layout.
308 /*! Add an object to the layout.
309@@ -56,20 +61,28 @@
310 For instance, if the layout is a vertical layout and the added object has a stretch factor equal 0, then during the layout,
311 the added object height will be set to its minimum value using ApplyMinHeight().
312
313- The positioning parameter controls how the layout will place the object within itself. A vertical layout object controls the horizontal positioning
314+ The minor_position parameter controls how the layout will place the object within itself. A vertical layout object controls the horizontal positioning
315 of its children baseobject, While an horizontal layout object controls the vertical positioning of its children baseobject.
316
317- The extend parameter controls how much size the baseobject minor dimension gets from the layout minor dimension. See MinorDimensionSize.
318+ The minor_size parameter controls how much size the baseobject minor dimension gets from the layout minor dimension. See MinorDimensionSize.
319
320 /param baseobject The object that is being added.
321- /param stretchFactor This value controls how the layout object share space between its children baseobject.
322- /param positioning Controls how the layout position the object.
323- /param extend Controls the object minor dimension size.
324+ /param stretch_factor This value controls how the layout object share space between its children baseobject.
325+ /param minor_position Controls how the layout position the object.
326+ /param minor_size Controls the object minor dimension size.
327 /param percentage Controls the object minor dimension size in percentage of the layout minor dimension size.
328 /param index Controls the object position in the layout.
329 */
330- virtual void AddView(Area *baseobject, unsigned int stretchFactor = 1, MinorDimensionPosition positioning = eAbove, MinorDimensionSize extend = eFull, float percentage = 100.0f, LayoutPosition index = NUX_LAYOUT_END);
331- virtual void AddSpace(unsigned int width, unsigned int stretchFactor = 0, LayoutPosition index = NUX_LAYOUT_END);
332+ void AddView(Area* baseobject,
333+ unsigned int stretch_factor = 1,
334+ MinorDimensionPosition minor_position = eAbove,
335+ MinorDimensionSize minor_size = eFull,
336+ float percentage = 100.0f,
337+ LayoutPosition index = NUX_LAYOUT_END);
338+
339+ void AddSpace(unsigned int width,
340+ unsigned int stretch_factor = 0,
341+ LayoutPosition index = NUX_LAYOUT_END);
342
343 virtual void Clear();
344
345@@ -251,6 +264,24 @@
346
347 protected:
348 virtual bool AcceptKeyNavFocus();
349+
350+ virtual void DoAddLayout(Layout* layout,
351+ unsigned int stretch_factor,
352+ MinorDimensionPosition minor_position,
353+ MinorDimensionSize minor_size,
354+ float percentage,
355+ LayoutPosition index);
356+
357+ virtual void DoAddView(Area* baseobject,
358+ unsigned int stretch_factor,
359+ MinorDimensionPosition minor_position,
360+ MinorDimensionSize minor_size,
361+ float percentage,
362+ LayoutPosition index);
363+
364+ virtual void DoAddSpace(unsigned int width,
365+ unsigned int stretch_factor,
366+ LayoutPosition index);
367
368 bool _queued_draw; //<! The rendering of the layout needs to be refreshed.
369
370@@ -309,22 +340,37 @@
371 return true;
372 }
373
374-
375- virtual void AddLayout(Layout *, unsigned int stretchFactor = 1, MinorDimensionPosition minor_position = eAbove, MinorDimensionSize minor_size = eFull, float percentage = 100.0f, LayoutPosition index = NUX_LAYOUT_END)
376- {
377- // Do not allow a WidgetLayout to encapsulate an object of type layout
378- }
379-
380- virtual void AddView(Area *baseobject, unsigned int stretchFactor = 1, MinorDimensionPosition positioning = eAbove, MinorDimensionSize extend = eFull, float percentage = 100.0f, LayoutPosition index = NUX_LAYOUT_END)
381- {
382- // the baseObject is provided via the constructor.
383- };
384-
385- virtual void AddSpace(unsigned int width, unsigned int stretchFactor = 0, LayoutPosition index = NUX_LAYOUT_END)
386- {
387- // Do not allow a WidgetLayout to encapsulate an object of type layout
388- }
389-
390+ protected:
391+ /*override*/ void DoAddLayout(Layout* layout,
392+ unsigned int stretch_factor,
393+ MinorDimensionPosition minor_position,
394+ MinorDimensionSize minor_size,
395+ float percentage,
396+ LayoutPosition index)
397+ {
398+ // Do not allow a SpaceLayout to encapsulate an object of type layout
399+ }
400+
401+ /*override*/ void DoAddView(Area* baseobject,
402+ unsigned int stretch_factor,
403+ MinorDimensionPosition minor_position,
404+ MinorDimensionSize minor_size,
405+ float percentage,
406+ LayoutPosition index)
407+ {
408+ // The baseobject is provided via the constructor.
409+ }
410+
411+ /*override*/ void DoAddSpace(unsigned int width,
412+ unsigned int stretch_factor,
413+ LayoutPosition index)
414+ {
415+ // Do not allow a SpaceLayout to encapsulate an object of type layout
416+ }
417+
418+ Area* Find(long handle);
419+
420+ private:
421 virtual bool CanFocus()
422 {
423 return false;
424@@ -340,8 +386,6 @@
425 }
426 // End: Abstract virtual function member(inherited from class Layout) that must be implemented
427
428- protected:
429- Area *Find(long handle);
430 };
431 }
432
433
434=== modified file 'Nux/LinearLayout.cpp'
435--- Nux/LinearLayout.cpp 2011-10-17 20:57:35 +0000
436+++ Nux/LinearLayout.cpp 2012-07-30 10:42:05 +0000
437@@ -37,162 +37,6 @@
438 {
439 }
440
441-// If(stretchfactor == 0): the WidgetLayout geometry will be set to SetGeometry(0,0,1,1);
442-// and the children will take their natural size by expending WidgetLayout.
443-// If the parent of WidgetLayout offers more space, it won't be used by WidgetLayout.
444- void LinearLayout::AddLayout(Layout *layout, unsigned int stretchFactor, MinorDimensionPosition minor_position, MinorDimensionSize minor_size, float percentage, LayoutPosition index)
445- {
446- nuxAssertMsg(layout != 0, "[Layout::AddView] Invalid parameter.");
447- NUX_RETURN_IF_TRUE(layout == 0);
448- // Should never happen
449- nuxAssertMsg(layout != this, "[Layout::AddLayout] Error: Trying to add a layout to itself.");
450- NUX_RETURN_IF_FALSE(layout != 0);
451-
452- Area *parent = layout->GetParentObject();
453- nuxAssertMsg(parent == 0, "[Layout::AddLayout] Trying to add an object that already has a parent.");
454- NUX_RETURN_IF_TRUE(parent != 0);
455-
456- nuxAssertMsg(index >= 0, "[Layout::AddLayout] Invalid index position. Adding at the beginning of the list..");
457-
458- layout->SetScaleFactor(stretchFactor);
459- layout->SetPositioning(minor_position);
460- layout->SetExtend(minor_size);
461-
462- if (percentage < 1.0f)
463- {
464- layout->SetPercentage(1.0f);
465- }
466- else if (percentage > 100.0f)
467- {
468- layout->SetPercentage(100.0f);
469- }
470- else
471- {
472- layout->SetPercentage(percentage);
473- }
474-
475- layout->SetParentObject(this);
476-
477- layout->OnChildQueueDraw.connect(sigc::mem_fun(this, &Layout::ChildLayoutChildQueuedDraw));
478- layout->OnQueueDraw.connect(sigc::mem_fun(this, &Layout::ChildLayoutQueuedDraw));
479-
480- if (index < 0)
481- index = NUX_LAYOUT_BEGIN;
482-
483- if (index == NUX_LAYOUT_END || index >= _layout_element_list.size())
484- {
485- _layout_element_list.push_back(layout);
486- }
487- else
488- {
489- std::list<Area *>::iterator pos = _layout_element_list.begin();
490- int idx = index;
491- while (pos != _layout_element_list.end() && idx > 0)
492- {
493- idx--;
494- pos++;
495- }
496- _layout_element_list.insert(pos, layout);
497- }
498-
499- }
500-
501-//! Add an object to the layout.
502- /*! Add an object to the layout.
503- A baseobject minor dimension with respect to a layout object is the dimension opposite to the layout flow.
504- A baseobject major dimension with respect to a layout object is the dimension aligned with the layout flow.
505- A layout object minor dimension is the dimension opposite to the layout flow.
506- A layout object major dimension is the dimension aligned with the layout flow.
507-
508- Add an object to the layout. The added object get its size and position managed by the layout.
509- When a baseobject is added with a stretches factor equal to 0, its major dimension assumes its minimum value.
510- For instance, if the layout is a vertical layout and the added object has a stretch factor equal 0, then during the layout,
511- the added object height will be set to its minimum value using ApplyMinHeight().
512-
513- The minor_position parameter controls how the layout will place the object within itself. A vertical layout object controls the horizontal positioning
514- of its children baseobjects, While an horizontal layout object controls the vertical positioning of its children baseobjects.
515-
516- The minor_size parameter controls how much size the baseobject minor dimension gets from the layout minor dimension. See MinorDimensionSize.
517-
518- /param baseobject The object that is being added.
519- /param stretchFactor This value controls how the layout object share space between its children baseobject.
520- /param minor_position Controls how the layout position the object.
521- /param minor_size Controls the object minor dimension size.
522- /param percentage Controls the object minor dimension size in percentage of the layout minor dimension size.
523- /param index Controls the object position in the layout children.
524- */
525-
526- void LinearLayout::AddView(Area *bo, unsigned int stretchFactor, MinorDimensionPosition minor_position, MinorDimensionSize minor_size, float percentage, LayoutPosition index)
527- {
528- nuxAssertMsg(bo != 0, "[Layout::AddView] Invalid parameter.");
529- NUX_RETURN_IF_TRUE(bo == 0);
530-
531- Area *parent = bo->GetParentObject();
532- nuxAssertMsg(parent == 0, "[Layout::AddView] Trying to add an object that already has a parent.");
533- NUX_RETURN_IF_TRUE(parent != 0);
534-
535- nuxAssertMsg(index >= 0, "[Layout::AddView] Invalid index position. Adding at the beginning of the list..");
536-
537- bo->SetScaleFactor(stretchFactor);
538- bo->SetPositioning(minor_position);
539- bo->SetExtend(minor_size);
540-
541- if (percentage < 1.0f)
542- {
543- bo->SetPercentage(1.0f);
544- }
545- else if (percentage > 100.0f)
546- {
547- bo->SetPercentage(100.0f);
548- }
549- else
550- {
551- bo->SetPercentage(percentage);
552- }
553-
554- bo->SetParentObject(this);
555-
556- if (bo->IsView())
557- static_cast<View *> (bo)->OnQueueDraw.connect(sigc::mem_fun(this, &Layout::ChildViewQueuedDraw));
558-
559- //if(HasFocusControl() && HasFocusableEntries() == false)
560- //{
561- //bo->SetFocused(true);
562- //ChildFocusChanged(this, bo);
563- //}
564-
565- if (index < 0)
566- index = NUX_LAYOUT_BEGIN;
567-
568- if (index == NUX_LAYOUT_END || index >= _layout_element_list.size())
569- {
570- _layout_element_list.push_back(bo);
571- }
572- else
573- {
574-#if defined(NUX_OS_WINDOWS) && !defined(NUX_VISUAL_STUDIO_2010)
575- std::list<Area *>::iterator pos = _layout_element_list.begin();
576-#else
577- auto pos = _layout_element_list.begin();
578-#endif
579- int idx = index;
580- while (pos != _layout_element_list.end() && idx > 0)
581- {
582- idx--;
583- pos++;
584- }
585- _layout_element_list.insert(pos, bo);
586- }
587-
588- ViewAdded.emit(this, bo);
589- //--->> Removed because it cause problem with The splitter widget: ComputeContentSize();
590- }
591-
592- void LinearLayout::AddSpace(unsigned int width, unsigned int stretchFactor, LayoutPosition index)
593- {
594- AddLayout(new SpaceLayout(), stretchFactor);
595- }
596-
597 void LinearLayout::SetHorizontalInternalMargin(int space)
598 {
599 SetSpaceBetweenChildren(space);
600
601=== modified file 'Nux/LinearLayout.h'
602--- Nux/LinearLayout.h 2011-10-11 13:55:55 +0000
603+++ Nux/LinearLayout.h 2012-07-30 10:42:05 +0000
604@@ -32,36 +32,6 @@
605 {
606 NUX_DECLARE_OBJECT_TYPE(LinearLayout, Layout);
607 public:
608- virtual void AddLayout(Layout *, unsigned int stretchFactor = 1, MinorDimensionPosition = eAbove, MinorDimensionSize extend = eFull, float percentage = 100.0f, LayoutPosition = NUX_LAYOUT_END);
609-
610- //! Add an object to the layout.
611- /*! Add an object to the layout.
612- A baseobject minor dimension with respect to a layout object is the dimension opposite to the layout flow.
613- A baseobject major dimension with respect to a layout object is the dimension aligned with the layout flow.
614- A layout object minor dimension is the dimension opposite to the layout flow.
615- A layout object major dimension is the dimension aligned with the layout flow.
616-
617- Add an object to the layout. The added object get its size and position managed by the layout.
618- When a baseobject is added with a stretches factor equal to 0, its major dimension assumes its minimum value.
619- For instance, if the layout is a vertical layout and the added object has a stretch factor equal 0, then during the layout,
620- the added object height will be set to its minimum value using ApplyMinHeight().
621-
622- The positioning parameter controls how the layout will place the object within itself. A vertical layout object controls the horizontal positioning
623- of its children baseobject, While an horizontal layout object controls the vertical positioning of its children baseobject.
624-
625- The extend parameter controls how much size the baseobject minor dimension gets from the layout minor dimension. See MinorDimensionSize.
626-
627- /param baseobject The object that is being added.
628- /param stretchFactor This value controls how the layout object share space between its children baseobject.
629- /param positioning Controls how the layout position the object.
630- /param extend Controls the object minor dimension size.
631- /param percentage Controls the object minor dimension size in percentage of the layout minor dimension size.
632- /param index Controls the object position in the layout.
633- */
634- virtual void AddView(Area *baseobject, unsigned int stretchFactor = 1, MinorDimensionPosition positioning = eAbove, MinorDimensionSize extend = eFull, float percentage = 100.0f, LayoutPosition index = NUX_LAYOUT_END);
635- virtual void AddSpace(unsigned int width, unsigned int stretchFactor = 0, LayoutPosition index = NUX_LAYOUT_END);
636-
637-
638 //! Deprecated. Use SetSpaceBetweenChildren;
639 void SetHorizontalInternalMargin(int space);
640 //! Deprecated. Use SetSpaceBetweenChildren;
641
642=== modified file 'configure.ac'
643--- configure.ac 2012-07-26 00:50:33 +0000
644+++ configure.ac 2012-07-30 10:42:05 +0000
645@@ -22,7 +22,7 @@
646 # The number format is : year/month/day
647 # e.g.: december 5th, 2011 is: 20111205
648 # To make more than one API change in a day, add a number to the date. Like 20111205.xx
649-m4_define([nux_abi_version], [20120725.01])
650+m4_define([nux_abi_version], [20120730.01])
651
652 m4_define([nux_version],
653 [nux_major_version.nux_minor_version.nux_micro_version])

Subscribers

People subscribed via source and target branches