0581c7b3192493ad38297da2195b9b58af6661df
[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                 pFirstPane->Invalidate(true);
660                 pSecondPane->Invalidate(true);
661         }
662
663         return r;
664 }
665
666 void
667 _SplitPanelPresenter::AdjustDividerRectangle(void)
668 {
669         float dividerPosition = 0.0f;
670         float width = 0.0f;
671         float height = 0.0f;
672         FloatRectangle clientBounds(0.0f, 0.0f, 0.0f, 0.0f);
673         _ControlOrientation orientation = _CONTROL_ORIENTATION_PORTRAIT;
674         Bitmap* pThumbBitmap = null;
675
676         orientation = _ControlManager::GetInstance()->GetOrientation();
677
678         dividerPosition = __pSplitPanel->GetDividerPosition();
679         clientBounds = __pSplitPanel->GetBoundsF();
680
681         if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
682         {
683                 pThumbBitmap = __pDividerThumbBitmap;
684
685                 if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
686                 {
687                         GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, width);
688                 }
689                 else
690                 {
691                         GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, width);
692                 }
693
694                 height = clientBounds.height;
695
696                 if (height > 0)
697                 {
698                         __dividerRectangle = FloatRectangle(dividerPosition, 0.0f, width, height);
699                         __dividerThumbRectangle = FloatRectangle(dividerPosition, ((height - pThumbBitmap->GetHeightF()) / 2.0f), pThumbBitmap->GetWidthF(), pThumbBitmap->GetHeightF());
700                 }
701         }
702         else
703         {
704                 pThumbBitmap = __pDividerThumbBitmap;
705
706                 if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
707                 {
708                         GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, height);
709                 }
710                 else
711                 {
712                         GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, height);
713                 }
714
715                 width = clientBounds.width;
716
717                 if (width > 0.0f)
718                 {
719                         __dividerRectangle = FloatRectangle(0.0f, dividerPosition, width, height);
720                         __dividerThumbRectangle = FloatRectangle(((width - pThumbBitmap->GetWidth()) / 2.0f), dividerPosition, pThumbBitmap->GetWidthF(), pThumbBitmap->GetHeightF());
721                 }
722         }
723
724         __pSplitPanel->SetDividerVisualElementBounds(__dividerRectangle);
725 }
726
727 void
728 _SplitPanelPresenter::ChangePaneOrder(SplitPanelPaneOrder paneOrder)
729 {
730         result r = E_SUCCESS;
731         _Control* pFirstPane = null;
732         _Control* pSecondPane = null;
733
734         if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST)
735         {
736                 pFirstPane = __pSplitPanel->GetPane(SPLIT_PANEL_PANE_ORDER_FIRST);
737                 SysTryReturnVoidResult(NID_UI_CTRL, pFirstPane != null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
738
739                 r = __pSplitPanel->DetachChild(*pFirstPane);
740                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
741
742                 r = __pSplitPanel->AttachChild(*pFirstPane);
743                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
744         }
745         else
746         {
747                 pSecondPane = __pSplitPanel->GetPane(SPLIT_PANEL_PANE_ORDER_SECOND);
748                 SysTryReturnVoidResult(NID_UI_CTRL, pSecondPane != null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
749
750                 r = __pSplitPanel->DetachChild(*pSecondPane);
751                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
752
753                 r = __pSplitPanel->AttachChild(*pSecondPane);
754                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
755         }
756
757         return;
758 }
759
760 result
761 _SplitPanelPresenter::AnimateDivider(int destination)
762 {
763         result r = E_SUCCESS;
764         FloatRectangle dividerBoundsStart(0.0f, 0.0f, 0.0f, 0.0f);
765         FloatRectangle dividerBoundsEnd(0.0f, 0.0f, 0.0f, 0.0f);
766         FloatRectangle dividerBounds(0, 0, 0, 0);
767         FloatRectangle clientBounds(0, 0, 0, 0);
768         FloatRectangle firstPaneBounds(0, 0, 0, 0);
769         Control* pFirstPanelControl = null;
770         VisualElement* pVisualElementDivider = null;
771         VisualElementPropertyAnimation* pAnimationDivider = null;
772
773         const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(__visualElementAnimationInterpolator);
774         r = GetLastResult();
775         SysTryReturnResult(NID_UI_CTRL, pTimingFunction != null, r, "Propagating.");
776
777         pFirstPanelControl = GetPaneControl(SPLIT_PANEL_PANE_ORDER_FIRST);
778         r = GetLastResult();
779         SysTryReturnResult(NID_UI_CTRL, pFirstPanelControl != null, r, "Propagating.");
780
781         pVisualElementDivider = __pSplitPanel->GetDividerVisualElement();
782         r = GetLastResult();
783         SysTryReturnResult(NID_UI_CTRL, pVisualElementDivider != null, r, "Propagating.");
784
785         pVisualElementDivider->RemoveAllAnimations();
786         r = GetLastResult();
787         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
788
789         pAnimationDivider = new (std::nothrow) VisualElementPropertyAnimation();
790         SysTryReturnResult(NID_UI_CTRL, pAnimationDivider != null, E_OUT_OF_MEMORY, " Memory allocation failed.")
791
792         r = pAnimationDivider->SetPropertyName(L"bounds");
793         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating.");
794
795         r = pAnimationDivider->SetDuration(ANIMATION_DURATION);
796         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating.");
797
798         pAnimationDivider->SetTimingFunction(pTimingFunction);
799         r = GetLastResult();
800         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating.");
801
802         dividerBounds = pVisualElementDivider->GetBounds();
803         clientBounds = __pSplitPanel->GetBoundsF();
804         firstPaneBounds =  pFirstPanelControl->GetBoundsF();
805         dividerBoundsStart = dividerBounds;
806
807         clientBounds.x = clientBounds.y = 0.0f;
808
809         switch (destination)
810         {
811         case _SPLIT_PANEL_ANIMATION_RIGHT:
812                 {
813                         dividerBoundsStart.x = firstPaneBounds.x + firstPaneBounds.width;
814
815                         dividerBoundsEnd = dividerBounds;
816                         dividerBoundsEnd.x = clientBounds.width;
817                 }
818                 break;
819         case _SPLIT_PANEL_ANIMATION_LEFT:
820                 {
821                         dividerBoundsStart.x = firstPaneBounds.x + firstPaneBounds.width;
822
823                         dividerBoundsEnd = dividerBounds;
824                         dividerBoundsEnd.x = clientBounds.x - dividerBounds.width;
825                 }
826                 break;
827         case _SPLIT_PANEL_ANIMATION_TOP:
828                 {
829                         dividerBoundsStart.y = firstPaneBounds.y + firstPaneBounds.height;
830
831                         dividerBoundsEnd = dividerBounds;
832                         dividerBoundsEnd.y = clientBounds.y - dividerBounds.height;
833                 }
834                 break;
835         case _SPLIT_PANEL_ANIMATION_BOTTOM:
836                 {
837                         dividerBoundsStart.y = firstPaneBounds.y + firstPaneBounds.height;
838
839                         dividerBoundsEnd = dividerBounds;
840                         dividerBoundsEnd.y = clientBounds.height;
841                 }
842                 break;
843         case _SPLIT_PANEL_ANIMATION_RESTORE_HORIZONTAL:
844                 {
845                         dividerBounds = __dividerRectangle;
846
847                         dividerBoundsStart = dividerBounds;
848                         dividerBoundsEnd = dividerBounds;
849
850                         if (__pSplitPanelModel->GetMaximizedPaneOrder() == SPLIT_PANEL_PANE_ORDER_FIRST)
851                         {
852                                 dividerBoundsStart.y = clientBounds.height;
853                         }
854                         else
855                         {
856                                 dividerBoundsStart.y = clientBounds.y - dividerBounds.height;
857                         }
858                 }
859                 break;
860         case _SPLIT_PANEL_ANIMATION_RESTORE_VERTICAL:
861                 {
862                         dividerBounds = __dividerRectangle;
863
864                         dividerBoundsStart = dividerBoundsEnd = dividerBounds;
865
866                         if (__pSplitPanelModel->GetMaximizedPaneOrder() == SPLIT_PANEL_PANE_ORDER_FIRST)
867                         {
868                                 dividerBoundsStart.x = clientBounds.width;
869                         }
870                         else
871                         {
872                                 dividerBoundsStart.x = clientBounds.x - dividerBounds.width;
873                         }
874                 }
875                 break;
876         }
877
878         r = pAnimationDivider->SetStartValue(dividerBoundsStart);
879         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating.");
880
881         r = pAnimationDivider->SetEndValue(dividerBoundsEnd);
882         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating.");
883
884         pVisualElementDivider->AddAnimation(L"Bounds", *pAnimationDivider);
885         r = GetLastResult();
886         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating.");
887
888 CATCH:
889
890         delete pAnimationDivider;
891         return r;
892
893 }
894
895 result
896 _SplitPanelPresenter::AnimatePane(int destination)
897 {
898         result r = E_SUCCESS;
899         Rectangle clientBounds(0, 0, 0, 0);
900         Rectangle firstPaneBounds(0, 0, 0, 0);
901         Rectangle secondPaneBounds(0, 0, 0, 0);
902         Rectangle dividerRectangle(0, 0, 0, 0);
903         Control* pFirstPanelControl = null;
904         Control* pSecondPanelControl = null;
905         ControlAnimator* pControlAnimatorFirstPane = null;
906         ControlAnimator* pControlAnimatorSecondPane = null;
907
908         FloatAnimation animationHidePane = FloatAnimation(ANIMATION_ALPHA_SHOW, ANIMATION_ALPHA_HIDE, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
909         FloatAnimation animationShowPane = FloatAnimation(ANIMATION_ALPHA_HIDE, ANIMATION_ALPHA_SHOW, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
910
911         pFirstPanelControl = GetPaneControl(SPLIT_PANEL_PANE_ORDER_FIRST);
912         r = GetLastResult();
913         SysTryReturnResult(NID_UI_CTRL, pFirstPanelControl != null, r, "Propagating.");
914
915         pSecondPanelControl = GetPaneControl(SPLIT_PANEL_PANE_ORDER_SECOND);
916         r = GetLastResult();
917         SysTryReturnResult(NID_UI_CTRL, pSecondPanelControl != null, r, "Propagating.");
918
919         pControlAnimatorFirstPane = pFirstPanelControl->GetControlAnimator();
920         r = GetLastResult();
921         SysTryReturnResult(NID_UI_CTRL, pControlAnimatorFirstPane != null, r, "Propagating.");
922
923         pControlAnimatorSecondPane = pSecondPanelControl->GetControlAnimator();
924         r = GetLastResult();
925         SysTryReturnResult(NID_UI_CTRL, pControlAnimatorSecondPane != null, r, "Propagating.");
926
927         clientBounds = __pSplitPanel->GetBounds();
928         firstPaneBounds = pFirstPanelControl->GetBounds();
929         secondPaneBounds = pSecondPanelControl->GetBounds();
930
931         clientBounds.x = clientBounds.y = 0;
932
933         dividerRectangle = _CoordinateSystemUtils::ConvertToInteger(__dividerRectangle);
934
935         switch (destination)
936         {
937         case _SPLIT_PANEL_ANIMATION_RIGHT:
938                 {
939                         Rectangle secondPaneEndBounds = secondPaneBounds;
940                         secondPaneEndBounds.x = clientBounds.x + clientBounds.width + dividerRectangle.width;
941
942                         RectangleAnimation animationMaximizeFirstPane = RectangleAnimation(firstPaneBounds, clientBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
943                         RectangleAnimation animationMinimizeSecondPane = RectangleAnimation(secondPaneBounds, secondPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
944
945                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMaximizeFirstPane);
946                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
947
948                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationMaximizeFirstPane);
949                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
950
951                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMinimizeSecondPane);
952                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
953
954                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationHidePane);
955                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
956
957                         if (pFirstPanelControl->GetShowState() == false)
958                         {
959                                 r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane);
960                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
961                         }
962                 }
963                 break;
964         case _SPLIT_PANEL_ANIMATION_LEFT:
965                 {
966                         Rectangle firstPaneEndBounds = firstPaneBounds;
967                         firstPaneEndBounds.x = clientBounds.x - firstPaneBounds.width - dividerRectangle.width;
968
969                         RectangleAnimation animationMaximizeSecondPane = RectangleAnimation(secondPaneBounds, clientBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
970                         RectangleAnimation animationMinimizeFirstPane = RectangleAnimation(firstPaneBounds, firstPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
971
972                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMaximizeSecondPane);
973                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
974
975                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationMaximizeSecondPane);
976                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
977
978                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMinimizeFirstPane);
979                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
980
981                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationHidePane);
982                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
983
984                         if (pSecondPanelControl->GetShowState() == false)
985                         {
986                                 r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane);
987                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
988                         }
989                 }
990                 break;
991         case _SPLIT_PANEL_ANIMATION_TOP:
992                 {
993                         Rectangle firstPaneEndBounds = firstPaneBounds;
994                         firstPaneEndBounds.y = clientBounds.y - firstPaneBounds.height - dividerRectangle.height;
995
996                         RectangleAnimation animationMaximizeSecondPane = RectangleAnimation(secondPaneBounds, clientBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
997                         RectangleAnimation animationMinimizeFirstPane = RectangleAnimation(firstPaneBounds, firstPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
998
999                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMaximizeSecondPane);
1000                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1001
1002                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationMaximizeSecondPane);
1003                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1004
1005                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMinimizeFirstPane);
1006                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1007
1008                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationHidePane);
1009                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1010
1011                         if (pSecondPanelControl->GetShowState() == false)
1012                         {
1013                                 r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane);
1014                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1015                         }
1016                 }
1017                 break;
1018         case _SPLIT_PANEL_ANIMATION_BOTTOM:
1019                 {
1020                         Rectangle secondPaneEndBounds = secondPaneBounds;
1021                         secondPaneEndBounds.y = clientBounds.y + clientBounds.height + dividerRectangle.height;
1022
1023                         RectangleAnimation animationMaximizeFirstPane = RectangleAnimation(firstPaneBounds, clientBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
1024                         RectangleAnimation animationMinimizeSecondPane = RectangleAnimation(secondPaneBounds, secondPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
1025
1026                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMaximizeFirstPane);
1027                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1028
1029                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationMaximizeFirstPane);
1030                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1031
1032                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMinimizeSecondPane);
1033                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1034
1035                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationHidePane);
1036                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1037
1038                         if (pFirstPanelControl->GetShowState() == false)
1039                         {
1040                                 r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane);
1041                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1042                         }
1043                 }
1044                 break;
1045         case _SPLIT_PANEL_ANIMATION_RESTORE_HORIZONTAL:
1046                 {
1047                         Rectangle firstPaneEndBounds = _CoordinateSystemUtils::ConvertToInteger(GetRestorePaneBounds(SPLIT_PANEL_PANE_ORDER_FIRST));
1048                         Rectangle secondPaneEndBounds = _CoordinateSystemUtils::ConvertToInteger(GetRestorePaneBounds(SPLIT_PANEL_PANE_ORDER_SECOND));
1049
1050                         RectangleAnimation animationRestoreFirstPane = RectangleAnimation(firstPaneBounds, firstPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
1051                         RectangleAnimation animationRestoreSecondPane = RectangleAnimation(secondPaneBounds, secondPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
1052
1053                         // Restore Pane 1
1054                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationRestoreFirstPane);
1055                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1056
1057                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationRestoreFirstPane);
1058                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1059
1060                         // Restore Pane 2
1061                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationRestoreSecondPane);
1062                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1063
1064                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationRestoreSecondPane);
1065                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1066
1067                         if (__pSplitPanelModel->GetMaximizedPaneOrder() == SPLIT_PANEL_PANE_ORDER_FIRST)
1068                         {
1069                                 r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane);
1070                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1071                         }
1072                         else
1073                         {
1074                                 r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane);
1075                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1076                         }
1077                 }
1078                 break;
1079         case _SPLIT_PANEL_ANIMATION_RESTORE_VERTICAL:
1080                 {
1081                         Rectangle firstPaneEndBounds = _CoordinateSystemUtils::ConvertToInteger(GetRestorePaneBounds(SPLIT_PANEL_PANE_ORDER_FIRST));
1082                         Rectangle secondPaneEndBounds = _CoordinateSystemUtils::ConvertToInteger(GetRestorePaneBounds(SPLIT_PANEL_PANE_ORDER_SECOND));
1083
1084                         RectangleAnimation animationRestoreFirstPane = RectangleAnimation(firstPaneBounds, firstPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
1085                         RectangleAnimation animationRestoreSecondPane = RectangleAnimation(secondPaneBounds, secondPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator);
1086
1087                         // Restore Pane 1
1088                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationRestoreFirstPane);
1089                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1090
1091                         r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationRestoreFirstPane);
1092                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1093
1094                         // Restore Pane 2
1095                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationRestoreSecondPane);
1096                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1097
1098                         r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationRestoreSecondPane);
1099                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1100
1101                         if (__pSplitPanelModel->GetMaximizedPaneOrder() == SPLIT_PANEL_PANE_ORDER_FIRST)
1102                         {
1103                                 r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane);
1104                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1105                         }
1106                         else
1107                         {
1108                                 r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane);
1109                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1110                         }
1111                 }
1112                 break;
1113         }
1114
1115         return E_SUCCESS;
1116 }
1117
1118 Control*
1119 _SplitPanelPresenter::GetPaneControl(SplitPanelPaneOrder paneOrder)
1120 {
1121         _ControlImpl* pControlImpl = null;
1122         _SplitPanelImpl* pSplitPanelImpl = null;
1123         Control* pControl = null;
1124
1125         pControlImpl = static_cast<_ControlImpl*>(__pSplitPanel->GetUserData());
1126         SysTryReturn(NID_UI_CTRL, pControlImpl != null, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. _ControlImpl is null.");
1127
1128         pSplitPanelImpl = dynamic_cast<_SplitPanelImpl*>(pControlImpl);
1129         SysTryReturn(NID_UI_CTRL, pSplitPanelImpl != null, null, E_SYSTEM, "[E_SYSTEM]A system error has occurred. _SplitPanelImpl is null.");
1130
1131         SplitPanel& splitPanelPublic = pSplitPanelImpl->GetPublic();
1132
1133         pControl = splitPanelPublic.GetPane(paneOrder);
1134         SysTryReturn(NID_UI_CTRL, pControl != null, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1135
1136         return pControl;
1137 }
1138
1139 AnimatorStatus
1140 _SplitPanelPresenter::GetAnimationStatus(void)
1141 {
1142         result r = E_SUCCESS;
1143
1144         Control* pFirstPanelControl = GetPaneControl(SPLIT_PANEL_PANE_ORDER_FIRST);
1145         r = GetLastResult();
1146         SysTryReturn(NID_UI_CTRL, pFirstPanelControl != null, ANIMATOR_STATUS_STOPPED, r, "[%s] Propagating.", GetErrorMessage(r));
1147
1148         Control* pSecondPanelControl = GetPaneControl(SPLIT_PANEL_PANE_ORDER_SECOND);
1149         r = GetLastResult();
1150         SysTryReturn(NID_UI_CTRL, pSecondPanelControl != null, ANIMATOR_STATUS_STOPPED, r, "[%s] Propagating.", GetErrorMessage(r));
1151
1152         ControlAnimator* pControlAnimatorFirstPane = pFirstPanelControl->GetControlAnimator();
1153         r = GetLastResult();
1154         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, ANIMATOR_STATUS_STOPPED, r, "[%s] Propagating.", GetErrorMessage(r));
1155
1156         ControlAnimator* pControlAnimatorSecondPane = pSecondPanelControl->GetControlAnimator();
1157         r = GetLastResult();
1158         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, ANIMATOR_STATUS_STOPPED, r, "[%s] Propagating.", GetErrorMessage(r));
1159
1160         if (pControlAnimatorFirstPane->GetStatus() == ANIMATOR_STATUS_STOPPED && pControlAnimatorSecondPane->GetStatus() == ANIMATOR_STATUS_STOPPED)
1161         {
1162                 return ANIMATOR_STATUS_STOPPED;
1163         }
1164
1165         return ANIMATOR_STATUS_PLAYING;
1166 }
1167
1168 FloatRectangle
1169 _SplitPanelPresenter::GetRestorePaneBounds(SplitPanelPaneOrder paneOrder)
1170 {
1171         float width = 0.0f;
1172         float height = 0.0f;
1173
1174         FloatRectangle firstPaneBounds(0.0f, 0.0f, 0.0f, 0.0f);
1175         FloatRectangle secondPaneBounds(0.0f, 0.0f, 0.0f, 0.0f);
1176
1177         float dividerPosition = __pSplitPanel->GetDividerPosition();
1178
1179         FloatRectangle clientBounds = __pSplitPanel->GetBoundsF();
1180
1181         _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
1182
1183         if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
1184         {
1185                 if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
1186                 {
1187                         GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, width);
1188                 }
1189                 else
1190                 {
1191                         GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, width);
1192                 }
1193
1194                 height = clientBounds.height;
1195
1196                 if (height > 0.0f)
1197                 {
1198                         __dividerRectangle = FloatRectangle(dividerPosition, 0.0f, width, height);
1199                 }
1200         }
1201         else
1202         {
1203                 if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
1204                 {
1205                         GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, height);
1206                 }
1207                 else
1208                 {
1209                         GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, height);
1210                 }
1211
1212                 width = clientBounds.width;
1213
1214                 if (width > 0.0f)
1215                 {
1216                         __dividerRectangle = FloatRectangle(0.0f, dividerPosition, width, height);
1217                 }
1218         }
1219
1220         if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
1221         {
1222                 firstPaneBounds = FloatRectangle(0.0f, 0.0f, __dividerRectangle.x, clientBounds.height);
1223                 secondPaneBounds = FloatRectangle(__dividerRectangle.x + __dividerRectangle.width, 0.0f, clientBounds.width - __dividerRectangle.x - __dividerRectangle.width, clientBounds.height);
1224         }
1225         else
1226         {
1227                 firstPaneBounds  = FloatRectangle(0.0f, 0.0f, clientBounds.width, __dividerRectangle.y);
1228                 secondPaneBounds = FloatRectangle(0.0f, __dividerRectangle.y + __dividerRectangle.height, clientBounds.width, clientBounds.height - __dividerRectangle.y - __dividerRectangle.height);
1229         }
1230
1231         if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST)
1232         {
1233                 return firstPaneBounds;
1234         }
1235
1236         return secondPaneBounds;
1237 }
1238
1239 }}} // Tizen::Ui::Controls