Nux

Merge lp:~azzar1/nux/scrollview-cleanup into lp:nux

Proposed by Andrea Azzarone
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 744
Merged at revision: 754
Proposed branch: lp:~azzar1/nux/scrollview-cleanup
Merge into: lp:nux
Diff against target: 332 lines (+0/-247)
2 files modified
Nux/ScrollView.cpp (+0/-225)
Nux/ScrollView.h (+0/-22)
To merge this branch: bzr merge lp:~azzar1/nux/scrollview-cleanup
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+143183@code.launchpad.net

Commit message

Remove no longer needed code.

Description of the change

Remove no longer needed code:
- commented code
- IsSizeMatchContent/SetSizeMatchContent are no longer used.
- OnChildFocusChanged is not used.

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nux/ScrollView.cpp'
2--- Nux/ScrollView.cpp 2012-11-05 21:31:06 +0000
3+++ Nux/ScrollView.cpp 2013-01-14 20:56:24 +0000
4@@ -59,7 +59,6 @@
5 , m_ViewContentBottomMargin(0)
6 {
7
8- //GetPainter().CreateBackgroundTexture(m_BackgroundTexture);
9 _hscrollbar = new HScrollBar(NUX_TRACKER_LOCATION);
10 _vscrollbar = new VScrollBar(NUX_TRACKER_LOCATION);
11 // _hscrollbar and _vscrollbar have to be parented so they are correctly
12@@ -82,9 +81,6 @@
13 mouse_wheel.connect(sigc::mem_fun(this, &ScrollView::RecvMouseWheel));
14 _vscrollbar->mouse_wheel.connect(sigc::mem_fun(this, &ScrollView::RecvMouseWheel));
15
16- //FIXME disabling until we have better API for this
17- //ChildFocusChanged.connect(sigc::mem_fun(this, &ScrollView::OnChildFocusChanged));
18-
19 FormatContent();
20
21 SetAcceptMouseWheelEvent(true);
22@@ -127,44 +123,6 @@
23 _vscrollbar->UnReference();
24 }
25
26- void ScrollView::OnChildFocusChanged(Area *child)
27- {
28-// if (child->IsView())
29-// {
30-// View *view = (View*)child;
31-// if (view->HasPassiveFocus())
32-// {
33-// return;
34-// }
35-// }
36- if (child->IsLayout())
37- return;
38-
39- int child_y = child->GetGeometry().y - GetGeometry().y;
40- int child_y_diff = child_y - abs(_delta_y);
41-
42-
43- if (child_y_diff + child->GetGeometry().height < GetGeometry().height && child_y_diff >= 0)
44- {
45- return;
46- }
47-
48- if (child_y_diff < 0)
49- {
50- ScrollUp(1, abs(child_y_diff));
51- }
52- else
53- {
54- int size = child_y_diff - GetGeometry().height;
55-
56- // always keeps the top of a view on the screen
57- size += (child->GetGeometry().height, GetGeometry().height) ? child->GetGeometry().height : GetGeometry().height;
58-
59- ScrollDown(1, size);
60- }
61-
62- }
63-
64 Area* ScrollView::FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type)
65 {
66 // Test if the mouse is inside the ScrollView.
67@@ -250,15 +208,7 @@
68 graphics_engine.PushClippingRectangle(Rect(m_ViewX, m_ViewY, m_ViewWidth, m_ViewHeight));
69
70 if (view_layout_)
71- {
72-// graphics_engine.PushClipOffset(_delta_x, _delta_y);
73-// graphics_engine.PushClippingRectangle(view_layout_->GetGeometry());
74-// graphics_engine.Push2DTranslationModelViewMatrix(_delta_x, _delta_y, 0.0f);
75 view_layout_->ProcessDraw(graphics_engine, force_draw);
76-// graphics_engine.PopModelViewMatrix();
77-// graphics_engine.PopClippingRectangle();
78-// graphics_engine.PopClipOffset();
79- }
80
81 graphics_engine.PopClippingRectangle();
82
83@@ -296,13 +246,6 @@
84 ///////////////////////
85 // Internal function //
86 ///////////////////////
87-
88- void ScrollView::SetGeometry(const Geometry &geo)
89- {
90- Area::SetGeometry(geo);
91- //ComputeContentSize();
92- }
93-
94 void ScrollView::FormatContent()
95 {
96 Geometry geo;
97@@ -423,9 +366,6 @@
98
99 long ScrollView::PostLayoutManagement(long LayoutResult)
100 {
101- if (IsSizeMatchContent())
102- return PostLayoutManagement2(LayoutResult);
103-
104 int ScrollBarWidth = 0;
105 int ScrollBarHeight = 0;
106
107@@ -506,158 +446,6 @@
108 return (eCompliantHeight | eCompliantWidth);
109 }
110
111- long ScrollView::PostLayoutManagement2(long /* LayoutResult */)
112- {
113- // In case IsSizeMatchContent returns True, The scroll view is resized to match its content.
114- int ScrollbarWidth = 0;
115- int ScrollbarHeight = 0;
116-
117- if (m_horizontal_scrollbar_enable)
118- ScrollbarHeight = _hscrollbar->GetBaseHeight();
119-
120- if (m_vertical_scrollbar_enable)
121- ScrollbarWidth = _vscrollbar->GetBaseWidth();
122-
123- // We want the controller to match the size of the content as defined in:
124- // m_ViewContentX
125- // m_ViewContentY
126- // m_ViewContentWidth
127- // m_ViewContentHeight
128- // So we make the composition layout the same size as the content
129- // Note that classes that inherits from ScrollView are responsible for setting the dimension of the ViewContent
130-
131- if (view_layout_)
132- {
133- view_layout_->SetBaseX(m_ViewContentX);
134- view_layout_->SetBaseY(m_ViewContentY);
135- view_layout_->SetBaseWidth(m_ViewContentWidth);
136- view_layout_->SetBaseHeight(m_ViewContentHeight);
137- }
138-
139- Geometry base;
140- // Given the(m_ViewContentWidth, m_ViewContentHeight) compute the size of the ScrollView.
141- // It is possible that the ScrollView size be limited by its min/Max dimension. If this happens, then the scrollbar will reflect that.
142- base.SetX(m_ViewContentX - m_border - m_ViewContentLeftMargin);
143- base.SetY(m_ViewContentY - m_top_border - m_ViewContentTopMargin);
144-
145- if (m_horizontal_scrollbar_enable)
146- base.SetHeight(m_top_border + m_ViewContentTopMargin + m_ViewContentHeight + m_ViewContentBottomMargin + ScrollbarHeight + m_border);
147- else
148- base.SetHeight(m_top_border + m_ViewContentTopMargin + m_ViewContentHeight + m_ViewContentBottomMargin + m_border);
149-
150- if (m_vertical_scrollbar_enable)
151- base.SetWidth(m_border + m_ViewContentLeftMargin + m_ViewContentWidth + m_ViewContentRightMargin + ScrollbarWidth + m_border);
152- else
153- base.SetWidth(m_border + m_ViewContentLeftMargin + m_ViewContentWidth + m_ViewContentRightMargin + m_border);
154-
155- // Set the size so that is is equal to the visible content.
156- Area::SetBaseWidth(base.GetWidth());
157- Area::SetBaseHeight(base.GetHeight());
158- Geometry geo = GetGeometry();
159-
160- // Horizontal scrollbar Geometry
161- if (m_horizontal_scrollbar_enable)
162- {
163- if (m_vertical_scrollbar_enable == false)
164- _hscrollbar->SetBaseWidth(GetBaseWidth() - 2 * m_border);
165- else
166- _hscrollbar->SetBaseWidth(GetBaseWidth() - ScrollbarWidth - 2 * m_border);
167-
168- _hscrollbar->SetBaseX(geo.x + m_border);
169- _hscrollbar->SetBaseY(geo.y + geo.GetHeight() - _hscrollbar->GetBaseHeight() - m_border);
170- _hscrollbar->ComputeContentSize();
171-
172- //---
173- _hscrollbar->SetContainerSize(GetBaseX() + m_border + m_ViewContentLeftMargin,
174- GetBaseY() + m_top_border + m_ViewContentTopMargin,
175- GetBaseWidth() - ScrollbarWidth - 2 * m_border - m_ViewContentRightMargin - m_ViewContentLeftMargin,
176- GetBaseHeight() - ScrollbarHeight - m_top_border - m_border - m_ViewContentBottomMargin - m_ViewContentTopMargin);
177-
178- if (view_layout_)
179- {
180- _hscrollbar->SetContentSize(view_layout_->GetBaseX(), view_layout_->GetBaseY(),
181- view_layout_->GetBaseWidth(), view_layout_->GetBaseHeight());
182- }
183- else
184- {
185- _hscrollbar->SetContentSize(GetBaseX() + m_border + m_ViewContentLeftMargin,
186- GetBaseY() + m_top_border + m_ViewContentTopMargin, 0, 0);
187- }
188-
189- _hscrollbar->SetContentOffset(_delta_x, _delta_y);
190- }
191- else
192- {
193- _hscrollbar->SetBaseWidth(GetBaseWidth() - ScrollbarWidth - 2 * m_border);
194- _hscrollbar->SetBaseX(geo.x + m_border);
195- _hscrollbar->SetBaseY(geo.y + geo.GetHeight() - _hscrollbar->GetBaseHeight() - m_border);
196- _hscrollbar->ComputeContentSize();
197-
198- //---
199- _hscrollbar->SetContainerSize(GetBaseX() + m_border + m_ViewContentLeftMargin,
200- GetBaseY() + m_top_border + m_ViewContentTopMargin,
201- GetBaseWidth() - ScrollbarWidth - 2 * m_border - m_ViewContentRightMargin - m_ViewContentLeftMargin,
202- GetBaseHeight() - ScrollbarHeight - m_top_border - m_border - m_ViewContentBottomMargin - m_ViewContentTopMargin);
203- _hscrollbar->SetContentSize(GetBaseX() + m_border + m_ViewContentLeftMargin,
204- GetBaseY() + m_top_border + m_ViewContentTopMargin, 0, 0);
205- _hscrollbar->SetContentOffset(0, 0);
206- }
207-
208-
209- // Vertical scrollbar Geometry
210- if (m_vertical_scrollbar_enable)
211- {
212- if (m_horizontal_scrollbar_enable == false)
213- _vscrollbar->SetBaseHeight(GetBaseHeight() - m_top_border - m_border);
214- else
215- _vscrollbar->SetBaseHeight(GetBaseHeight() - ScrollbarHeight - m_top_border - m_border);
216-
217- _vscrollbar->SetBaseX(geo.x + geo.GetWidth() - ScrollbarWidth - m_border);
218- _vscrollbar->SetBaseY(geo.y + m_top_border);
219- _vscrollbar->ComputeContentSize();
220-
221- //---
222- _vscrollbar->SetContainerSize(GetBaseX() + m_border + m_ViewContentLeftMargin,
223- GetBaseY() + m_top_border + m_ViewContentTopMargin,
224- GetBaseWidth() - ScrollbarWidth - 2 * m_border - m_ViewContentRightMargin - m_ViewContentLeftMargin,
225- GetBaseHeight() - ScrollbarHeight - m_top_border - m_border - m_ViewContentBottomMargin - m_ViewContentTopMargin);
226-
227- if (view_layout_)
228- {
229- _vscrollbar->SetContentSize(view_layout_->GetBaseX(), view_layout_->GetBaseY(),
230- view_layout_->GetBaseWidth(), view_layout_->GetBaseHeight());
231- }
232- else
233- {
234- _vscrollbar->SetContentSize(GetBaseX() + m_border + m_ViewContentLeftMargin,
235- GetBaseY() + m_top_border + m_ViewContentTopMargin, 0, 0);
236- }
237-
238- _vscrollbar->SetContentOffset(_delta_x, _delta_y);
239- }
240- else
241- {
242- _vscrollbar->SetBaseHeight(GetBaseHeight() - ScrollbarHeight - m_top_border - m_border);
243- _vscrollbar->SetBaseX(geo.x + geo.GetWidth() - ScrollbarWidth - m_border);
244- _vscrollbar->SetBaseY(geo.y + m_top_border);
245- _vscrollbar->ComputeContentSize();
246-
247- //---
248- _vscrollbar->SetContainerSize(GetBaseX() + m_border + m_ViewContentLeftMargin,
249- GetBaseY() + m_top_border + m_ViewContentTopMargin,
250- GetBaseWidth() - ScrollbarWidth - 2 * m_border - m_ViewContentRightMargin - m_ViewContentLeftMargin,
251- GetBaseHeight() - ScrollbarHeight - m_top_border - m_border - m_ViewContentBottomMargin - m_ViewContentTopMargin);
252- _vscrollbar->SetContentSize(GetBaseX() + m_border + m_ViewContentLeftMargin,
253- GetBaseY() + m_top_border + m_ViewContentTopMargin, 0, 0);
254- _vscrollbar->SetContentOffset(0, 0);
255- }
256-
257- if (view_layout_)
258- view_layout_->ComputeContentPosition(0, 0);
259-
260- return (eCompliantHeight | eCompliantWidth);
261- }
262-
263 // When the ScrollView is in a Layout object, and that layout call View::ComputeContentPosition
264 // the ScrollView must call its own ComputeContentPosition so it can properly do the positioning of the inner object.
265 // Otherwise, view_layout_->ComputeContentPosition is called but it doesn't know that it may not contain all the
266@@ -852,19 +640,6 @@
267 }
268 }
269
270- void ScrollView::SetSizeMatchContent(bool b)
271- {
272- m_bSizeMatchContent = b;
273-
274- if (view_layout_)
275- view_layout_->ComputeContentSize();
276- }
277-
278- bool ScrollView::IsSizeMatchContent() const
279- {
280- return m_bSizeMatchContent;
281- }
282-
283 void ScrollView::ResetScrollToLeft()
284 {
285 _delta_x = 0;
286
287=== modified file 'Nux/ScrollView.h'
288--- Nux/ScrollView.h 2012-10-26 10:49:31 +0000
289+++ Nux/ScrollView.h 2013-01-14 20:56:24 +0000
290@@ -45,25 +45,6 @@
291 void EnableHorizontalScrollBar(bool b);
292 virtual bool SetLayout(Layout *layout);
293
294- /*!
295- Set the table size to be such that all the content items of the table are visible .
296- The scrollbar will be useless as the content is entirely visible all the time. If the table is empty, then it assume its minimum size.
297- This is needed for table inside ComboBox drop down memu.
298- @param b If b is true, the size of the table is constrained by its content.
299- @see IsSizeMatchLayout()
300- */
301- void SetSizeMatchContent(bool b);
302-
303- /*!
304- Check if the table size is constrained by its content.
305- @return If the return value is true, the table size is constrained by its content.
306- @see SetSizeMatchContent
307- */
308- bool IsSizeMatchContent() const;
309-
310- //! Inherited from Area
311- virtual void SetGeometry(const Geometry &geo);
312-
313 /////////////////
314 // EMITERS //
315 /////////////////
316@@ -162,7 +143,6 @@
317 virtual Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);
318
319 void RecvMouseWheel(int x, int y, int wheel_delta, long button_flags, unsigned long key_flags);
320- void OnChildFocusChanged(Area *child);
321
322 //! Change Vertical Scrollbar in the ScrollView.
323 /*!
324@@ -209,8 +189,6 @@
325 virtual long PostLayoutManagement(long LayoutResult);
326 virtual void ComputeContentPosition(float offsetX, float offsetY);
327
328- virtual long PostLayoutManagement2(long LayoutResult);
329-
330 private:
331
332 virtual bool AcceptKeyNavFocus();

Subscribers

People subscribed via source and target branches