Remove unnecessary draw code.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_SplitPanelPresenter.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FUiCtrl_SplitPanelPresenter.cpp
20  * @brief               This is the header file for the _SplitPanelPresenter class.
21  *
22  * This header file contains the declarations of the %_SplitPanelPresenter class.
23  */
24
25 #include <FBaseErrorDefine.h>
26 #include <FGrpCanvas.h>
27 #include <FUiCtrlSplitPanelTypes.h>
28 #include <FBaseSysLog.h>
29 #include <FGrp_BitmapImpl.h>
30 #include "FUi_ResourceManager.h"
31 #include "FUi_UiTouchEvent.h"
32 #include "FUiCtrl_SplitPanelPresenter.h"
33 #include "FUiCtrl_SplitPanel.h"
34 #include "FUiCtrl_SplitPanelImpl.h"
35 #include "FGrp_CoordinateSystemUtils.h"
36
37 using namespace Tizen::Ui;
38 using namespace Tizen::Graphics;
39 using namespace Tizen::Ui::Animations;
40
41 namespace Tizen { namespace Ui { namespace Controls
42 {
43
44 _SplitPanelPresenter::_SplitPanelPresenter(void)
45         : __pSplitPanel(null)
46         , __pSplitPanelModel(null)
47         , __dividerMaximumPosition(0.0f)
48         , __dividerMinimumPosition(0.0f)
49         , __splitPanelDividerPressed(false)
50         , __setFirstDividerPositionChangeEvent(true)
51         , __dividerRectangle(0.0f, 0.0f ,0.0f, 0.0f)
52         , __dividerThumbRectangle(0.0f, 0.0f, 0.0f, 0.0f)
53         , __pDividerPressedBackgroundBitmap(null)
54         , __pDividerBackgroundBitmap(null)
55         , __pDividerBackgroundEffectBitmap(null)
56         , __pDividerThumbBitmap(null)
57         , __transactionIdMaximize(0)
58         , __transactionIdRestore(0)
59         , __controlAnimatorAnimationInterpolator(ANIMATION_INTERPOLATOR_LINEAR)
60         , __visualElementAnimationInterpolator(L"Linear")
61 {
62         GET_COLOR_CONFIG(SPLITPANEL::DIVIDER_BG_NORMAL, __dividerBackgroundColor);
63         GET_COLOR_CONFIG(SPLITPANEL::DIVIDER_BG_PRESSED, __dividerPressedBackgroundColor);
64 }
65
66 _SplitPanelPresenter::~_SplitPanelPresenter(void)
67 {
68         delete __pSplitPanelModel;
69         __pSplitPanelModel = null;
70
71         delete __pDividerPressedBackgroundBitmap;
72         __pDividerPressedBackgroundBitmap = null;
73
74         delete __pDividerBackgroundBitmap;
75         __pDividerBackgroundBitmap = null;
76
77         delete __pDividerThumbBitmap;
78         __pDividerThumbBitmap = null;
79
80         delete __pDividerBackgroundEffectBitmap;
81         __pDividerBackgroundEffectBitmap = null;
82 }
83
84 result
85 _SplitPanelPresenter::Construct(const _SplitPanel& splitPanel, SplitPanelDividerStyle splitPanelDividerStyle, SplitPanelDividerDirection splitPanelDividerDirection)
86 {
87         result r = E_SUCCESS;
88         _SplitPanelModel* pModel = null;
89
90         pModel = new (std::nothrow) _SplitPanelModel;
91         SysTryReturnResult(NID_UI_CTRL, pModel, E_OUT_OF_MEMORY, "Memory allocation failed.");
92
93         r = SetModel(*pModel);
94         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to set the model.");
95
96         r = pModel->Construct();
97         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to construct _SplitPanelModel instance.");
98
99         __pSplitPanel = const_cast <_SplitPanel*>(&splitPanel);
100         SysTryCatch(NID_UI_CTRL, __pSplitPanel != null, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. _SplitPanel instance is null.");
101
102         __pSplitPanelModel->SetDividerStyle(splitPanelDividerStyle);
103
104         r = LoadBitmap(splitPanelDividerDirection);
105         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to load bitmap.", GetErrorMessage(r));
106
107         AdjustDividerRectangle();
108
109         __controlAnimatorAnimationInterpolator = ANIMATION_INTERPOLATOR_EASE_IN;
110         __visualElementAnimationInterpolator = L"EaseIn";
111
112         return E_SUCCESS;
113
114 CATCH:
115         delete pModel;
116         pModel = null;
117
118         return r;
119 }
120
121 bool
122 _SplitPanelPresenter::CheckDividerTouchRegion(float positionX, float positionY)
123 {
124         float dividerPosition = 0.0f;
125         Bitmap* pThumbBitmap = null;
126
127         dividerPosition = __pSplitPanel->GetDividerPosition();
128
129         if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
130         {
131                 pThumbBitmap = __pDividerThumbBitmap;
132                 if ((positionX >= dividerPosition)
133                         && (positionX <= dividerPosition + pThumbBitmap->GetWidthF()))
134                 {
135                         return true;
136                 }
137         }
138         else
139         {
140                 pThumbBitmap = __pDividerThumbBitmap;
141                 if ((positionY >= dividerPosition)
142                         && (positionY <= dividerPosition + pThumbBitmap->GetHeightF()))
143                 {
144                         return true;
145                 }
146         }
147
148         return false;
149 }
150
151 bool
152 _SplitPanelPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
153 {
154         FloatPoint point(0.0f, 0.0f);
155
156         point = touchinfo.GetCurrentPosition();
157
158         if (CheckDividerTouchRegion(point.x, point.y) == true)
159         {
160                 __splitPanelDividerPressed = true;
161         }
162
163         Draw();
164
165         return E_SUCCESS;
166 }
167
168 bool
169 _SplitPanelPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
170 {
171         if (__splitPanelDividerPressed == true)
172         {
173                 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
174                 __splitPanelDividerPressed = false;
175                 Draw();
176         }
177
178         return E_SUCCESS;
179 }
180
181 bool
182 _SplitPanelPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
183 {
184         FloatPoint point(0.0f, 0.0f);
185         Bitmap* pThumbBitmap = null;
186
187         if (__pSplitPanel != &source || __splitPanelDividerPressed == false )
188         {
189                 return false;
190         }
191
192         if (__pSplitPanelModel->GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_FIXED)
193         {
194                 return false;
195         }
196
197         point = touchinfo.GetCurrentPosition();
198
199         if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
200         {
201                 // Min, Max Position Check.
202                 if ((__pSplitPanel->GetMinimumDividerPosition() > point.x)
203                         || (__pSplitPanel->GetMaximumDividerPosition() < point.x))
204                 {
205                         return false;
206                 }
207
208                 pThumbBitmap = __pDividerThumbBitmap;
209
210                 if (point.x <= __pSplitPanel->GetBoundsF().width - pThumbBitmap->GetWidthF())
211                 {
212                         __pSplitPanel->SetDividerPosition(point.x);
213                 }
214         }
215         else
216         {
217                 // Min, Max Position Check.
218                 if ((__pSplitPanel->GetMinimumDividerPosition() > point.y)
219                         || (__pSplitPanel->GetMaximumDividerPosition() < point.y))
220                 {
221                         return false;
222                 }
223
224                 pThumbBitmap = __pDividerThumbBitmap;
225
226                 if (point.y <= __pSplitPanel->GetBoundsF().height - pThumbBitmap->GetHeightF())
227                 {
228                         __pSplitPanel->SetDividerPosition(point.y);
229                 }
230         }
231
232         __pSplitPanel->SendSplitPanelEvent(_SPLIT_PANEL_EVENT_DIVIDER_POSITION_CHANGE);
233
234         Draw();
235
236         return true;
237 }
238
239 bool
240 _SplitPanelPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
241 {
242         if (__splitPanelDividerPressed == true)
243         {
244                 __splitPanelDividerPressed = false;
245                 Draw();
246         }
247
248         return E_SUCCESS;
249 }
250
251 bool
252 _SplitPanelPresenter::OnTapGestureDetected(_TouchTapGestureDetector& gesture)
253 {
254         if (__pSplitPanelModel->GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_FIXED)
255         {
256                 return false;
257         }
258
259         __pSplitPanel->SendSplitPanelEvent(_SPLIT_PANEL_EVENT_DIVIDER_DOUBLE_PRESSED);
260
261         return true;
262 }
263
264 bool
265 _SplitPanelPresenter::OnTapGestureCanceled(_TouchTapGestureDetector& gesture)
266 {
267         return false;
268 }
269
270 result
271 _SplitPanelPresenter::SetDividerStyle(SplitPanelDividerStyle splitPanelDividerStyle)
272 {
273         __pSplitPanelModel->SetDividerStyle(splitPanelDividerStyle);
274
275         return E_SUCCESS;
276 }
277
278 SplitPanelDividerStyle
279 _SplitPanelPresenter::GetDividerStyle(void) const
280 {
281         return __pSplitPanelModel->GetDividerStyle();
282 }
283
284 FloatRectangle
285 _SplitPanelPresenter::GetDividerRectangle(void) const
286 {
287         return __dividerRectangle;
288 }
289
290 result
291 _SplitPanelPresenter::MaximizePane(SplitPanelPaneOrder paneOrder)
292 {
293         result r = E_SUCCESS;
294
295         if (IsPaneMaximized(paneOrder))
296         {
297                 return E_SUCCESS;
298         }
299         else if (GetAnimationStatus() == ANIMATOR_STATUS_PLAYING)
300         {
301                 AnimationTransaction::Stop(__transactionIdMaximize);
302                 AnimationTransaction::Stop(__transactionIdRestore);
303         }
304
305         RecalcSplitPanel();
306
307         ChangePaneOrder(paneOrder);
308
309         AnimationTransaction::Begin(__transactionIdMaximize);
310
311         if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
312         {
313                 if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST)
314                 {
315                         r = AnimateDivider(_SPLIT_PANEL_ANIMATION_RIGHT);
316                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
317
318                         r = AnimatePane(_SPLIT_PANEL_ANIMATION_RIGHT);
319                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
320                 }
321                 else
322                 {
323                         r = AnimateDivider(_SPLIT_PANEL_ANIMATION_LEFT);
324                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
325
326                         r = AnimatePane(_SPLIT_PANEL_ANIMATION_LEFT);
327                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
328                 }
329         }
330         else
331         {
332                 if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST)
333                 {
334                         r = AnimateDivider(_SPLIT_PANEL_ANIMATION_BOTTOM);
335                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
336
337                         r = AnimatePane(_SPLIT_PANEL_ANIMATION_BOTTOM);
338                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
339                 }
340                 else
341                 {
342                         r = AnimateDivider(_SPLIT_PANEL_ANIMATION_TOP);
343                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
344
345                         r = AnimatePane(_SPLIT_PANEL_ANIMATION_TOP);
346                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
347                 }
348         }
349
350         AnimationTransaction::Commit();
351
352         __pSplitPanelModel->SetPaneMaximumState(true);
353         __pSplitPanelModel->SetMaximizedPaneOrder(paneOrder);
354
355         return E_SUCCESS;
356
357 CATCH:
358         AnimationTransaction::Discard();
359
360         return r;
361 }
362
363 bool
364 _SplitPanelPresenter::IsPaneMaximized(SplitPanelPaneOrder paneOrder) const
365 {
366         if ((__pSplitPanelModel->GetPaneMaximumState() == true)
367                 && (__pSplitPanelModel->GetMaximizedPaneOrder() == paneOrder))
368         {
369                 return true;
370         }
371
372         return false;
373 }
374
375 result
376 _SplitPanelPresenter::RestorePane(void)
377 {
378         result r = E_SUCCESS;
379
380         if (__pSplitPanelModel->GetPaneMaximumState() == false)
381         {
382                 return E_SUCCESS;
383         }
384         else if (GetAnimationStatus() == ANIMATOR_STATUS_PLAYING)
385         {
386                 AnimationTransaction::Stop(__transactionIdMaximize);
387                 AnimationTransaction::Stop(__transactionIdRestore);
388         }
389
390         RecalcSplitPanel();
391
392         AnimationTransaction::Begin(__transactionIdRestore);
393
394         if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
395         {
396                 r = AnimateDivider(_SPLIT_PANEL_ANIMATION_RESTORE_VERTICAL);
397                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
398
399                 r = AnimatePane(_SPLIT_PANEL_ANIMATION_RESTORE_VERTICAL);
400                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
401         }
402         else
403         {
404                 r = AnimateDivider(_SPLIT_PANEL_ANIMATION_RESTORE_HORIZONTAL);
405                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
406
407                 r = AnimatePane(_SPLIT_PANEL_ANIMATION_RESTORE_HORIZONTAL);
408                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
409         }
410
411         AnimationTransaction::Commit();
412
413         __pSplitPanelModel->SetPaneMaximumState(false);
414
415         return E_SUCCESS;
416
417 CATCH:
418         AnimationTransaction::Discard();
419
420         return r;
421 }
422
423 result
424 _SplitPanelPresenter::Draw(void)
425 {
426         if (__pSplitPanelModel->GetPaneMaximumState() == false && GetAnimationStatus() == ANIMATOR_STATUS_STOPPED)
427         {
428                 FloatRectangle dividerBounds(0.0f, 0.0f, 0.0f, 0.0f);
429                 FloatRectangle dividerThumbBounds(0.0f, 0.0f, 0.0f, 0.0f);
430
431                 //adjust divider rectangle
432                 AdjustDividerRectangle();
433
434                 Canvas* pCanvas = __pSplitPanel->GetDividerVisualElement()->GetCanvasN();
435                 SysTryReturnResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "Propagating.");
436
437                 pCanvas->Clear();
438
439                 //resize pane
440                 SetPaneBounds();
441
442                 dividerBounds = __dividerRectangle;
443                 dividerBounds.x = 0.0f;
444                 dividerBounds.y = 0.0f;
445
446                 if (__splitPanelDividerPressed == true)
447                 {
448                         pCanvas->DrawNinePatchedBitmap(dividerBounds, *__pDividerPressedBackgroundBitmap);
449                 }
450                 else
451                 {
452                         pCanvas->DrawNinePatchedBitmap(dividerBounds, *__pDividerBackgroundBitmap);
453                 }
454
455                 //draw divider
456                 pCanvas->DrawNinePatchedBitmap(dividerBounds, *__pDividerBackgroundEffectBitmap);
457
458                 //draw divider thumb
459                 if (__pSplitPanelModel->GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
460                 {
461                         dividerThumbBounds = __dividerThumbRectangle;
462                         if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
463                         {
464                                 dividerThumbBounds.x = 0.0f;
465                         }
466                         else
467                         {
468                                 dividerThumbBounds.y = 0.0f;
469                         }
470
471                         pCanvas->DrawBitmap(dividerThumbBounds, *__pDividerThumbBitmap);
472                 }
473
474                 delete pCanvas;
475         }
476
477         return E_SUCCESS;
478 }
479
480 result
481 _SplitPanelPresenter::LoadBitmap(SplitPanelDividerDirection splitPanelDividerDirection)
482 {
483         result r = E_SUCCESS;
484         Bitmap *pDividerBackgroundBitmap = null;
485
486         // Modified - Changeable Color / Resource ( Fixed Style )
487         r = GET_BITMAP_CONFIG_N(SPLITPANEL::DIVIDER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pDividerBackgroundBitmap);
488         SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Failed to load bitmap.");
489
490         if (splitPanelDividerDirection == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
491         {
492                 r = GET_BITMAP_CONFIG_N(SPLITPANEL::VERTICAL_DIVIDER_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pDividerBackgroundEffectBitmap);
493                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Failed to load bitmap.", GetErrorMessage(r));
494                 r = GET_BITMAP_CONFIG_N(SPLITPANEL::VERTICAL_DIVIDER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDividerThumbBitmap);
495                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Failed to load bitmap.", GetErrorMessage(r));
496         }
497         else
498         {
499                 r = GET_BITMAP_CONFIG_N(SPLITPANEL::HORIZONTAL_DIVIDER_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pDividerBackgroundEffectBitmap);
500                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Failed to load bitmap.", GetErrorMessage(r));
501                 r = GET_BITMAP_CONFIG_N(SPLITPANEL::HORIZONTAL_DIVIDER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDividerThumbBitmap);
502                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Failed to load bitmap.", GetErrorMessage(r));
503         }
504
505         __pDividerPressedBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pDividerBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), __dividerPressedBackgroundColor);
506         r = GetLastResult();
507         SysTryCatch(NID_UI_CTRL, (__pDividerPressedBackgroundBitmap != null), , r, "[%s] Failed to get replacement color bitmap.", GetErrorMessage(r));
508
509         __pDividerBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pDividerBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), __dividerBackgroundColor);
510         r = GetLastResult();
511         SysTryCatch(NID_UI_CTRL, (__pDividerBackgroundBitmap != null), , r, "[%s] Failed to get replacement color bitmap.", GetErrorMessage(r));
512
513         delete pDividerBackgroundBitmap;
514
515         return r;
516
517 CATCH:
518         delete pDividerBackgroundBitmap;
519         delete __pDividerBackgroundEffectBitmap;
520         delete __pDividerPressedBackgroundBitmap;
521         delete __pDividerThumbBitmap;
522
523         return r;
524 }
525
526 void
527 _SplitPanelPresenter::RecalcSplitPanel(void)
528 {
529         //adjust divider rectangle
530         AdjustDividerRectangle();
531
532         //resize pane
533         SetPaneBounds();
534
535         return;
536 }
537
538 void
539 _SplitPanelPresenter::OnChangeLayout(_ControlOrientation orientation)
540 {
541         AnimationTransaction::Stop(__transactionIdMaximize);
542         AnimationTransaction::Stop(__transactionIdRestore);
543
544         return;
545 }
546
547 void
548 _SplitPanelPresenter::OnBoundsChanged(void)
549 {
550         RecalcSplitPanel();
551         return;
552 }
553
554 result
555 _SplitPanelPresenter::SetModel(const _SplitPanelModel& splitPanelModel)
556 {
557         __pSplitPanelModel = const_cast<_SplitPanelModel*>(&splitPanelModel);
558
559         return E_SUCCESS;
560 }
561
562 result
563 _SplitPanelPresenter::SetPaneBounds(void)
564 {
565         result r = E_SUCCESS;
566         FloatRectangle clientBounds(0.0f, 0.0f, 0.0f, 0.0f);
567         FloatRectangle firstPaneBounds(0.0f, 0.0f, 0.0f, 0.0f);
568         FloatRectangle secondPaneBounds(0.0f, 0.0f, 0.0f, 0.0f);
569         FloatPoint panePostion(0.0f, 0.0f);
570         _Control* pFirstPane = null;
571         _Control* pSecondPane = null;
572
573         clientBounds = __pSplitPanel->GetBoundsF();
574
575         pFirstPane = __pSplitPanel->GetPane(SPLIT_PANEL_PANE_ORDER_FIRST);
576
577         pSecondPane = __pSplitPanel->GetPane(SPLIT_PANEL_PANE_ORDER_SECOND);
578
579         clientBounds.x = clientBounds.y = 0.0f;
580
581         if (IsPaneMaximized(SPLIT_PANEL_PANE_ORDER_FIRST))
582         {
583                 firstPaneBounds = clientBounds;
584
585                 if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
586                 {
587                         secondPaneBounds = FloatRectangle(clientBounds.width + __dividerRectangle.width, 0.0f, clientBounds.width - __dividerRectangle.x - __dividerRectangle.width, clientBounds.height);
588                 }
589                 else
590                 {
591                         secondPaneBounds = FloatRectangle(0.0f, clientBounds.height + __dividerRectangle.height, clientBounds.width, clientBounds.height - __dividerRectangle.y - __dividerRectangle.height);
592                 }
593         }
594         else if (IsPaneMaximized(SPLIT_PANEL_PANE_ORDER_SECOND))
595         {
596                 secondPaneBounds = clientBounds;
597
598                 if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
599                 {
600                         firstPaneBounds = FloatRectangle(clientBounds.x -__dividerRectangle.x - __dividerRectangle.width, 0.0f, __dividerRectangle.x, clientBounds.height);
601                 }
602                 else
603                 {
604                         firstPaneBounds = FloatRectangle(0.0f, clientBounds.y -__dividerRectangle.y - __dividerRectangle.height, clientBounds.width, __dividerRectangle.y);
605                 }
606         }
607         else
608         {
609                 if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
610                 {
611                         firstPaneBounds = FloatRectangle(0.0f, 0.0f, __dividerRectangle.x, clientBounds.height);
612                         secondPaneBounds = FloatRectangle(__dividerRectangle.x + __dividerRectangle.width, 0.0f, clientBounds.width - __dividerRectangle.x - __dividerRectangle.width,clientBounds.height);
613                 }
614                 else
615                 {
616                         firstPaneBounds  = FloatRectangle(0.0f, 0.0f, clientBounds.width, __dividerRectangle.y);
617                         secondPaneBounds = FloatRectangle(0.0f, __dividerRectangle.y + __dividerRectangle.height, clientBounds.width, clientBounds.height - __dividerRectangle.y - __dividerRectangle.height);
618                 }
619         }
620
621         //set Pane bounds
622         if (pFirstPane != null)
623         {
624                 r = pFirstPane->SetBounds(firstPaneBounds);
625
626                 if (r != E_SUCCESS)
627                 {
628                         panePostion.x = firstPaneBounds.x;
629                         panePostion.y = firstPaneBounds.y;
630                         
631                         r = pFirstPane->SetPosition(panePostion);
632                 }
633                 
634                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
635         }
636
637         if (pSecondPane != null)
638         {
639                 r = pSecondPane->SetBounds(secondPaneBounds);
640
641                 if (r != E_SUCCESS)
642                 {
643                         panePostion.x = secondPaneBounds.x;
644                         panePostion.y = secondPaneBounds.y;
645
646                         r = pSecondPane->SetPosition(panePostion);
647                 }
648                                 
649                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
650         }
651
652         if ((pFirstPane != null) && (pSecondPane != null))
653         {
654                 if (__setFirstDividerPositionChangeEvent == true)
655                 {
656                         __setFirstDividerPositionChangeEvent = false;
657                         __pSplitPanel->SendSplitPanelEvent(_SPLIT_PANEL_EVENT_DIVIDER_POSITION_CHANGE);
658                 }
659         }
660
661         return r;
662 }
663
664 void
665 _SplitPanelPresenter::AdjustDividerRectangle(void)
666 {
667         float dividerPosition = 0.0f;
668         float width = 0.0f;
669         float height = 0.0f;
670         FloatRectangle clientBounds(0.0f, 0.0f, 0.0f, 0.0f);
671         _ControlOrientation orientation = _CONTROL_ORIENTATION_PORTRAIT;
672         Bitmap* pThumbBitmap = null;
673
674         orientation = _ControlManager::GetInstance()->GetOrientation();
675
676         dividerPosition = __pSplitPanel->GetDividerPosition();
677         clientBounds = __pSplitPanel->GetBoundsF();
678
679         if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
680         {
681                 pThumbBitmap = __pDividerThumbBitmap;
682
683                 if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
684                 {
685                         GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, width);
686                 }
687                 else
688                 {
689                         GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, width);
690                 }
691
692                 height = clientBounds.height;
693
694                 if (height > 0)
695                 {
696                         __dividerRectangle = FloatRectangle(dividerPosition, 0.0f, width, height);
697                         __dividerThumbRectangle = FloatRectangle(dividerPosition, ((height - pThumbBitmap->GetHeightF()) / 2.0f), pThumbBitmap->GetWidthF(), pThumbBitmap->GetHeightF());
698                 }
699         }
700         else
701         {
702                 pThumbBitmap = __pDividerThumbBitmap;
703
704                 if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
705                 {
706                         GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, height);
707                 }
708                 else
709                 {
710                         GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, height);
711                 }
712
713                 width = clientBounds.width;
714
715                 if (width > 0.0f)
716                 {
717                         __dividerRectangle = FloatRectangle(0.0f, dividerPosition, width, height);
718                         __dividerThumbRectangle = FloatRectangle(((width - pThumbBitmap->GetWidth()) / 2.0f), dividerPosition, pThumbBitmap->GetWidthF(), pThumbBitmap->GetHeightF());
719                 }
720         }
721
722         __pSplitPanel->SetDividerVisualElementBounds(__dividerRectangle);
723 }
724
725 void
726 _SplitPanelPresenter::ChangePaneOrder(SplitPanelPaneOrder paneOrder)
727 {
728         result r = E_SUCCESS;
729         _Control* pFirstPane = null;
730         _Control* pSecondPane = null;
731
732         if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST)
733         {
734                 pFirstPane = __pSplitPanel->GetPane(SPLIT_PANEL_PANE_ORDER_FIRST);
735                 SysTryReturnVoidResult(NID_UI_CTRL, pFirstPane != null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
736
737                 r = __pSplitPanel->DetachChild(*pFirstPane);
738                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
739
740                 r = __pSplitPanel->AttachChild(*pFirstPane);
741                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
742         }
743         else
744         {
745                 pSecondPane = __pSplitPanel->GetPane(SPLIT_PANEL_PANE_ORDER_SECOND);
746                 SysTryReturnVoidResult(NID_UI_CTRL, pSecondPane != null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
747
748                 r = __pSplitPanel->DetachChild(*pSecondPane);
749                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
750
751                 r = __pSplitPanel->AttachChild(*pSecondPane);
752                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
753         }
754
755         return;
756 }
757
758 result
759 _SplitPanelPresenter::AnimateDivider(int destination)
760 {
761         result r = E_SUCCESS;
762         FloatRectangle dividerBoundsStart(0.0f, 0.0f, 0.0f, 0.0f);
763         FloatRectangle dividerBoundsEnd(0.0f, 0.0f, 0.0f, 0.0f);
764         FloatRectangle dividerBounds(0, 0, 0, 0);
765         FloatRectangle clientBounds(0, 0, 0, 0);
766         FloatRectangle firstPaneBounds(0, 0, 0, 0);
767         Control* pFirstPanelControl = null;
768         VisualElement* pVisualElementDivider = null;
769         VisualElementPropertyAnimation* pAnimationDivider = null;
770
771         const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(__visualElementAnimationInterpolator);
772         r = GetLastResult();
773         SysTryReturnResult(NID_UI_CTRL, pTimingFunction != null, r, "Propagating.");
774
775         pFirstPanelControl = GetPaneControl(SPLIT_PANEL_PANE_ORDER_FIRST);
776         r = GetLastResult();
777         SysTryReturnResult(NID_UI_CTRL, pFirstPanelControl != null, r, "Propagating.");
778
779         pVisualElementDivider = __pSplitPanel->GetDividerVisualElement();
780         r = GetLastResult();
781         SysTryReturnResult(NID_UI_CTRL, pVisualElementDivider != null, r, "Propagating.");
782
783         pVisualElementDivider->RemoveAllAnimations();
784         r = GetLastResult();
785         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
786
787         pAnimationDivider = new (std::nothrow) VisualElementPropertyAnimation();
788         SysTryReturnResult(NID_UI_CTRL, pAnimationDivider != null, E_OUT_OF_MEMORY, " Memory allocation failed.")
789
790         r = pAnimationDivider->SetPropertyName(L"bounds");
791         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating.");
792
793         r = pAnimationDivider->SetDuration(ANIMATION_DURATION);
794         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating.");
795
796         pAnimationDivider->SetTimingFunction(pTimingFunction);
797         r = GetLastResult();
798         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating.");
799
800         dividerBounds = pVisualElementDivider->GetBounds();
801         clientBounds = __pSplitPanel->GetBoundsF();
802         firstPaneBounds =  pFirstPanelControl->GetBoundsF();
803         dividerBoundsStart = dividerBounds;
804
805         clientBounds.x = clientBounds.y = 0.0f;
806
807         switch (destination)
808         {
809         case _SPLIT_PANEL_ANIMATION_RIGHT:
810                 {
811                         dividerBoundsStart.x = firstPaneBounds.x + firstPaneBounds.width;
812
813                         dividerBoundsEnd = dividerBounds;
814                         dividerBoundsEnd.x = clientBounds.width;
815                 }
816                 break;
817         case _SPLIT_PANEL_ANIMATION_LEFT:
818                 {
819                         dividerBoundsStart.x = firstPaneBounds.x + firstPaneBounds.width;
820
821                         dividerBoundsEnd = dividerBounds;
822                         dividerBoundsEnd.x = clientBounds.x - dividerBounds.width;
823                 }
824                 break;
825         case _SPLIT_PANEL_ANIMATION_TOP:
826                 {
827                         dividerBoundsStart.y = firstPaneBounds.y + firstPaneBounds.height;
828
829                         dividerBoundsEnd = dividerBounds;
830                         dividerBoundsEnd.y = clientBounds.y - dividerBounds.height;
831                 }
832                 break;
833         case _SPLIT_PANEL_ANIMATION_BOTTOM:
834                 {
835                         dividerBoundsStart.y = firstPaneBounds.y + firstPaneBounds.height;
836
837                         dividerBoundsEnd = dividerBounds;
838                         dividerBoundsEnd.y = clientBounds.height;
839                 }
840                 break;
841         case _SPLIT_PANEL_ANIMATION_RESTORE_HORIZONTAL:
842                 {
843                         dividerBounds = __dividerRectangle;
844
845                         dividerBoundsStart = dividerBounds;
846                         dividerBoundsEnd = dividerBounds;
847
848                         if (__pSplitPanelModel->GetMaximizedPaneOrder() == SPLIT_PANEL_PANE_ORDER_FIRST)
849                         {
850                                 dividerBoundsStart.y = clientBounds.height;
851                         }
852                         else
853                         {
854                                 dividerBoundsStart.y = clientBounds.y - dividerBounds.height;
855                         }
856                 }
857                 break;
858         case _SPLIT_PANEL_ANIMATION_RESTORE_VERTICAL:
859                 {
860                         dividerBounds = __dividerRectangle;
861
862                         dividerBoundsStart = dividerBoundsEnd = dividerBounds;
863
864                         if (__pSplitPanelModel->GetMaximizedPaneOrder() == SPLIT_PANEL_PANE_ORDER_FIRST)
865                         {
866                                 dividerBoundsStart.x = clientBounds.width;
867                         }
868                         else
869                         {
870                                 dividerBoundsStart.x = clientBounds.x - dividerBounds.width;
871                         }
872                 }
873                 break;
874         }
875
876         r = pAnimationDivider->SetStartValue(dividerBoundsStart);
877         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating.");
878
879         r = pAnimationDivider->SetEndValue(dividerBoundsEnd);
880         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating.");
881
882         pVisualElementDivider->AddAnimation(L"Bounds", *pAnimationDivider);
883         r = GetLastResult();
884         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating.");
885
886 CATCH:
887
888         delete pAnimationDivider;
889         return r;
890
891 }
892
893 result
894 _SplitPanelPresenter::AnimatePane(int destination)
895 {
896         result r = E_SUCCESS;
897         Rectangle clientBounds(0, 0, 0, 0);
898         Rectangle firstPaneBounds(0, 0, 0, 0);
899         Rectangle secondPaneBounds(0, 0, 0, 0);
900         Rectangle dividerRectangle(0, 0, 0, 0);
901         Control* pFirstPanelControl = null;
902         Control* pSecondPanelControl = null;
903         ControlAnimator* pControlAnimatorFirstPane = null;
904         ControlAnimator* pControlAnimatorSecondPane = null;
905
906         FloatAnimation animationHidePane = FloatAnimation(ANIMATION_ALPHA_SHOW, ANIMATION_ALPHA_HIDE, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
907         FloatAnimation animationShowPane = FloatAnimation(ANIMATION_ALPHA_HIDE, ANIMATION_ALPHA_SHOW, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
908
909         pFirstPanelControl = GetPaneControl(SPLIT_PANEL_PANE_ORDER_FIRST);
910         r = GetLastResult();
911         SysTryReturnResult(NID_UI_CTRL, pFirstPanelControl != null, r, "Propagating.");
912
913         pSecondPanelControl = GetPaneControl(SPLIT_PANEL_PANE_ORDER_SECOND);
914         r = GetLastResult();
915         SysTryReturnResult(NID_UI_CTRL, pSecondPanelControl != null, r, "Propagating.");
916
917         pControlAnimatorFirstPane = pFirstPanelControl->GetControlAnimator();
918         r = GetLastResult();
919         SysTryReturnResult(NID_UI_CTRL, pControlAnimatorFirstPane != null, r, "Propagating.");
920
921         pControlAnimatorSecondPane = pSecondPanelControl->GetControlAnimator();
922         r = GetLastResult();
923         SysTryReturnResult(NID_UI_CTRL, pControlAnimatorSecondPane != null, r, "Propagating.");
924
925         clientBounds = __pSplitPanel->GetBounds();
926         firstPaneBounds = pFirstPanelControl->GetBounds();
927         secondPaneBounds = pSecondPanelControl->GetBounds();
928
929         clientBounds.x = clientBounds.y = 0;
930
931         dividerRectangle = _CoordinateSystemUtils::ConvertToInteger(__dividerRectangle);
932
933         switch (destination)
934         {
935         case _SPLIT_PANEL_ANIMATION_RIGHT:
936                 {
937                         Rectangle secondPaneEndBounds = secondPaneBounds;
938                         secondPaneEndBounds.x = clientBounds.x + clientBounds.width + dividerRectangle.width;
939
940                         RectangleAnimation animationMaximizeFirstPane = RectangleAnimation(firstPaneBounds, clientBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
941                         RectangleAnimation animationMinimizeSecondPane = RectangleAnimation(secondPaneBounds, secondPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
942
943                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMaximizeFirstPane);
944                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
945
946                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationMaximizeFirstPane);
947                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
948
949                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMinimizeSecondPane);
950                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
951
952                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationHidePane);
953                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
954
955                         if (pFirstPanelControl->GetShowState() == false)
956                         {
957                                 r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane);
958                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
959                         }
960                 }
961                 break;
962         case _SPLIT_PANEL_ANIMATION_LEFT:
963                 {
964                         Rectangle firstPaneEndBounds = firstPaneBounds;
965                         firstPaneEndBounds.x = clientBounds.x - firstPaneBounds.width - dividerRectangle.width;
966
967                         RectangleAnimation animationMaximizeSecondPane = RectangleAnimation(secondPaneBounds, clientBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
968                         RectangleAnimation animationMinimizeFirstPane = RectangleAnimation(firstPaneBounds, firstPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
969
970                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMaximizeSecondPane);
971                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
972
973                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationMaximizeSecondPane);
974                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
975
976                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMinimizeFirstPane);
977                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
978
979                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationHidePane);
980                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
981
982                         if (pSecondPanelControl->GetShowState() == false)
983                         {
984                                 r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane);
985                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
986                         }
987                 }
988                 break;
989         case _SPLIT_PANEL_ANIMATION_TOP:
990                 {
991                         Rectangle firstPaneEndBounds = firstPaneBounds;
992                         firstPaneEndBounds.y = clientBounds.y - firstPaneBounds.height - dividerRectangle.height;
993
994                         RectangleAnimation animationMaximizeSecondPane = RectangleAnimation(secondPaneBounds, clientBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
995                         RectangleAnimation animationMinimizeFirstPane = RectangleAnimation(firstPaneBounds, firstPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
996
997                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMaximizeSecondPane);
998                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
999
1000                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationMaximizeSecondPane);
1001                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1002
1003                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMinimizeFirstPane);
1004                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1005
1006                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationHidePane);
1007                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1008
1009                         if (pSecondPanelControl->GetShowState() == false)
1010                         {
1011                                 r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane);
1012                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1013                         }
1014                 }
1015                 break;
1016         case _SPLIT_PANEL_ANIMATION_BOTTOM:
1017                 {
1018                         Rectangle secondPaneEndBounds = secondPaneBounds;
1019                         secondPaneEndBounds.y = clientBounds.y + clientBounds.height + dividerRectangle.height;
1020
1021                         RectangleAnimation animationMaximizeFirstPane = RectangleAnimation(firstPaneBounds, clientBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
1022                         RectangleAnimation animationMinimizeSecondPane = RectangleAnimation(secondPaneBounds, secondPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
1023
1024                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMaximizeFirstPane);
1025                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1026
1027                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationMaximizeFirstPane);
1028                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1029
1030                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMinimizeSecondPane);
1031                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1032
1033                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationHidePane);
1034                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1035
1036                         if (pFirstPanelControl->GetShowState() == false)
1037                         {
1038                                 r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane);
1039                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1040                         }
1041                 }
1042                 break;
1043         case _SPLIT_PANEL_ANIMATION_RESTORE_HORIZONTAL:
1044                 {
1045                         Rectangle firstPaneEndBounds = _CoordinateSystemUtils::ConvertToInteger(GetRestorePaneBounds(SPLIT_PANEL_PANE_ORDER_FIRST));
1046                         Rectangle secondPaneEndBounds = _CoordinateSystemUtils::ConvertToInteger(GetRestorePaneBounds(SPLIT_PANEL_PANE_ORDER_SECOND));
1047
1048                         RectangleAnimation animationRestoreFirstPane = RectangleAnimation(firstPaneBounds, firstPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
1049                         RectangleAnimation animationRestoreSecondPane = RectangleAnimation(secondPaneBounds, secondPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
1050
1051                         // Restore Pane 1
1052                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationRestoreFirstPane);
1053                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1054
1055                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationRestoreFirstPane);
1056                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1057
1058                         // Restore Pane 2
1059                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationRestoreSecondPane);
1060                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1061
1062                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationRestoreSecondPane);
1063                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1064
1065                         if (__pSplitPanelModel->GetMaximizedPaneOrder() == SPLIT_PANEL_PANE_ORDER_FIRST)
1066                         {
1067                                 r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane);
1068                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1069                         }
1070                         else
1071                         {
1072                                 r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane);
1073                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1074                         }
1075                 }
1076                 break;
1077         case _SPLIT_PANEL_ANIMATION_RESTORE_VERTICAL:
1078                 {
1079                         Rectangle firstPaneEndBounds = _CoordinateSystemUtils::ConvertToInteger(GetRestorePaneBounds(SPLIT_PANEL_PANE_ORDER_FIRST));
1080                         Rectangle secondPaneEndBounds = _CoordinateSystemUtils::ConvertToInteger(GetRestorePaneBounds(SPLIT_PANEL_PANE_ORDER_SECOND));
1081
1082                         RectangleAnimation animationRestoreFirstPane = RectangleAnimation(firstPaneBounds, firstPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
1083                         RectangleAnimation animationRestoreSecondPane = RectangleAnimation(secondPaneBounds, secondPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
1084
1085                         // Restore Pane 1
1086                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationRestoreFirstPane);
1087                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1088
1089                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationRestoreFirstPane);
1090                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1091
1092                         // Restore Pane 2
1093                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationRestoreSecondPane);
1094                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1095
1096                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationRestoreSecondPane);
1097                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1098
1099                         if (__pSplitPanelModel->GetMaximizedPaneOrder() == SPLIT_PANEL_PANE_ORDER_FIRST)
1100                         {
1101                                 r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane);
1102                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1103                         }
1104                         else
1105                         {
1106                                 r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane);
1107                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1108                         }
1109                 }
1110                 break;
1111         }
1112
1113         return E_SUCCESS;
1114 }
1115
1116 Control*
1117 _SplitPanelPresenter::GetPaneControl(SplitPanelPaneOrder paneOrder)
1118 {
1119         _ControlImpl* pControlImpl = null;
1120         _SplitPanelImpl* pSplitPanelImpl = null;
1121         Control* pControl = null;
1122
1123         pControlImpl = static_cast<_ControlImpl*>(__pSplitPanel->GetUserData());
1124         SysTryReturn(NID_UI_CTRL, pControlImpl != null, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. _ControlImpl is null.");
1125
1126         pSplitPanelImpl = dynamic_cast<_SplitPanelImpl*>(pControlImpl);
1127         SysTryReturn(NID_UI_CTRL, pSplitPanelImpl != null, null, E_SYSTEM, "[E_SYSTEM]A system error has occurred. _SplitPanelImpl is null.");
1128
1129         SplitPanel& splitPanelPublic = pSplitPanelImpl->GetPublic();
1130
1131         pControl = splitPanelPublic.GetPane(paneOrder);
1132         SysTryReturn(NID_UI_CTRL, pControl != null, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1133
1134         return pControl;
1135 }
1136
1137 AnimatorStatus
1138 _SplitPanelPresenter::GetAnimationStatus(void)
1139 {
1140         result r = E_SUCCESS;
1141
1142         Control* pFirstPanelControl = GetPaneControl(SPLIT_PANEL_PANE_ORDER_FIRST);
1143         r = GetLastResult();
1144         SysTryReturn(NID_UI_CTRL, pFirstPanelControl != null, ANIMATOR_STATUS_STOPPED, r, "[%s] Propagating.", GetErrorMessage(r));
1145
1146         Control* pSecondPanelControl = GetPaneControl(SPLIT_PANEL_PANE_ORDER_SECOND);
1147         r = GetLastResult();
1148         SysTryReturn(NID_UI_CTRL, pSecondPanelControl != null, ANIMATOR_STATUS_STOPPED, r, "[%s] Propagating.", GetErrorMessage(r));
1149
1150         ControlAnimator* pControlAnimatorFirstPane = pFirstPanelControl->GetControlAnimator();
1151         r = GetLastResult();
1152         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, ANIMATOR_STATUS_STOPPED, r, "[%s] Propagating.", GetErrorMessage(r));
1153
1154         ControlAnimator* pControlAnimatorSecondPane = pSecondPanelControl->GetControlAnimator();
1155         r = GetLastResult();
1156         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, ANIMATOR_STATUS_STOPPED, r, "[%s] Propagating.", GetErrorMessage(r));
1157
1158         if (pControlAnimatorFirstPane->GetStatus() == ANIMATOR_STATUS_STOPPED && pControlAnimatorSecondPane->GetStatus() == ANIMATOR_STATUS_STOPPED)
1159         {
1160                 return ANIMATOR_STATUS_STOPPED;
1161         }
1162
1163         return ANIMATOR_STATUS_PLAYING;
1164 }
1165
1166 FloatRectangle
1167 _SplitPanelPresenter::GetRestorePaneBounds(SplitPanelPaneOrder paneOrder)
1168 {
1169         float width = 0.0f;
1170         float height = 0.0f;
1171
1172         FloatRectangle firstPaneBounds(0.0f, 0.0f, 0.0f, 0.0f);
1173         FloatRectangle secondPaneBounds(0.0f, 0.0f, 0.0f, 0.0f);
1174
1175         float dividerPosition = __pSplitPanel->GetDividerPosition();
1176
1177         FloatRectangle clientBounds = __pSplitPanel->GetBoundsF();
1178
1179         _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
1180
1181         if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
1182         {
1183                 if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
1184                 {
1185                         GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, width);
1186                 }
1187                 else
1188                 {
1189                         GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, width);
1190                 }
1191
1192                 height = clientBounds.height;
1193
1194                 if (height > 0.0f)
1195                 {
1196                         __dividerRectangle = FloatRectangle(dividerPosition, 0.0f, width, height);
1197                 }
1198         }
1199         else
1200         {
1201                 if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
1202                 {
1203                         GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, height);
1204                 }
1205                 else
1206                 {
1207                         GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, height);
1208                 }
1209
1210                 width = clientBounds.width;
1211
1212                 if (width > 0.0f)
1213                 {
1214                         __dividerRectangle = FloatRectangle(0.0f, dividerPosition, width, height);
1215                 }
1216         }
1217
1218         if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
1219         {
1220                 firstPaneBounds = FloatRectangle(0.0f, 0.0f, __dividerRectangle.x, clientBounds.height);
1221                 secondPaneBounds = FloatRectangle(__dividerRectangle.x + __dividerRectangle.width, 0.0f, clientBounds.width - __dividerRectangle.x - __dividerRectangle.width, clientBounds.height);
1222         }
1223         else
1224         {
1225                 firstPaneBounds  = FloatRectangle(0.0f, 0.0f, clientBounds.width, __dividerRectangle.y);
1226                 secondPaneBounds = FloatRectangle(0.0f, __dividerRectangle.y + __dividerRectangle.height, clientBounds.width, clientBounds.height - __dividerRectangle.y - __dividerRectangle.height);
1227         }
1228
1229         if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST)
1230         {
1231                 return firstPaneBounds;
1232         }
1233
1234         return secondPaneBounds;
1235 }
1236
1237 }}} // Tizen::Ui::Controls