applied Drag&Drop code (Feature Disabled)
authorChulheon <ch.jeong47@samsung.com>
Thu, 22 Aug 2013 06:17:53 +0000 (15:17 +0900)
committerChulheon <ch.jeong47@samsung.com>
Thu, 22 Aug 2013 06:24:40 +0000 (15:24 +0900)
Change-Id: Ie276d2bce7cfc857771b3f566a1eb2a5567be796

src/ui/controls/FUiCtrl_Edit.cpp
src/ui/controls/FUiCtrl_EditPresenter.cpp
src/ui/inc/FUiCtrl_Edit.h
src/ui/inc/FUiCtrl_EditPresenter.h
src/ui/inc/FUi_ResourceEditConfig.h
src/ui/resource/FUi_ResourceEditConfig.cpp

index fcb4519..89da773 100755 (executable)
@@ -3409,6 +3409,41 @@ _Edit::OnDrawFocus(void)
        return;
 }
 
+_Window*
+_Edit::OnDragAndDropBeginning(void)
+{
+       return _pEditPresenter->OnDragAndDropBeginning();
+}
+void
+_Edit::OnDragAndDropDropping(void)
+{
+       return _pEditPresenter->OnDragAndDropDropping();
+}
+
+void
+_Edit::OnDragAndDropEntered(void)
+{
+       return _pEditPresenter->OnDragAndDropEntered();
+}
+
+void
+_Edit::OnDragAndDropMoved(const Tizen::Graphics::FloatPoint& position)
+{
+       return _pEditPresenter->OnDragAndDropMoved(position);
+}
+
+void
+_Edit::OnDragAndDropLeft(void)
+{
+       return _pEditPresenter->OnDragAndDropLeft();
+}
+
+void
+_Edit::OnDragAndDropDropped(const _DragAndDropItem& dragAndDropItem)
+{
+       return _pEditPresenter->OnDragAndDropDropped(dragAndDropItem);
+}
+
 _AccessibilityElement*
 _Edit::GetTextAccessibilityElement(void) const
 {
index 92822c5..89f2392 100644 (file)
@@ -69,6 +69,7 @@
 #include "FUiCtrl_TableView.h"
 #include "FUi_Window.h"
 
+#define EDIT_DRAG_AND_DROP_ENABLED 0
 
 using namespace Tizen::Base::Runtime;
 using namespace Tizen::Base::Utility;
@@ -131,6 +132,48 @@ _EditAnimationProvider::CreateAnimationForProperty(VisualElement& source, const
        return pAnimation;
 }
 
+class _EditDragAndDropWindow
+       : public Tizen::Ui::_Window
+{
+public:
+       _EditDragAndDropWindow(void);
+       virtual ~_EditDragAndDropWindow(void);
+
+       virtual result OnAttachedToMainTree(void);
+       void SetLabel(_Label* pLabel);
+private:
+       _Label* __pLabel;
+}; // _EditDragAndDropWindow
+
+_EditDragAndDropWindow::_EditDragAndDropWindow(void)
+: __pLabel(null)
+{
+}
+
+_EditDragAndDropWindow::~_EditDragAndDropWindow(void)
+{
+       if (__pLabel)
+       {
+               DetachChild(*__pLabel);
+               delete __pLabel;
+               __pLabel = null;
+       }
+}
+
+result
+_EditDragAndDropWindow::OnAttachedToMainTree(void)
+{
+       AcquireHandle();
+
+       return E_SUCCESS;
+}
+
+void
+_EditDragAndDropWindow::SetLabel(_Label* pLabel)
+{
+       __pLabel = pLabel;
+}
+
 _EditPresenter::_EditPresenter(void)
        : __pTitleSlidingTimer(null)
        , __pEdit(null)
@@ -241,6 +284,8 @@ _EditPresenter::_EditPresenter(void)
        , __isPasswordVisible(false)
        , __needToCreateCopyPastePopup(false)
        , __calculatedCursorBounds(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
+       , __dragAndDropStarted(false)
+       , __dragAndDropString("")
 {
 }
 
@@ -3307,6 +3352,14 @@ _EditPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchi
 bool
 _EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
 {
+       if (__dragAndDropStarted)
+       {
+               __dragAndDropStarted = false;
+               __pEdit->DragAndDropDrop();
+
+               return true;
+       }
+
        if (__isCopyPasteManagerExist)
        {
                if (__isTouchPressed && !__isCopyPastePopupMoving)
@@ -3599,6 +3652,19 @@ _EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchI
 bool
 _EditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
 {
+       if (__dragAndDropStarted)
+       {
+               _Window* pDragWindow = __pEdit->GetDragWindow();
+               if (pDragWindow)
+               {
+                       FloatPoint dragPoint = touchInfo.GetCurrentPosition();
+                       dragPoint.x += __pEdit->GetAbsoluteBoundsF(true).x;
+                       dragPoint.y += __pEdit->GetAbsoluteBoundsF(true).y;
+                       pDragWindow->SetPosition(FloatPoint(dragPoint.x - pDragWindow->GetBoundsF().width/2.0f, dragPoint.y - pDragWindow->GetBoundsF().height/2.0f));
+               }
+               return true;
+       }
+
        if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
        {
                return false;
@@ -4684,6 +4750,24 @@ _EditPresenter::OnLongPressGestureDetected(void)
 
        if (__isCopyPasteManagerExist)
        {
+
+#if EDIT_DRAG_AND_DROP_ENABLED
+               if (IsBlocked())
+               {
+                       int start = -1;
+                       int end = -1;
+                       GetBlockRange(start, end);
+                       __dragAndDropString = GetText(start, end-1);
+                       _DragAndDropItem* pDragAndDropItem = _DragAndDropItem::CreateInstanceN(_DRAG_AND_DROP_TYPE_TEXT, __dragAndDropString);
+                       SysTryReturn(NID_UI_CTRL, pDragAndDropItem, false, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+                       __pEdit->DragAndDropBegin(*pDragAndDropItem);
+                       delete pDragAndDropItem;
+
+                       __dragAndDropStarted = true;
+                       InitializeCopyPasteManager();
+               }
+#endif
                return true;
        }
        else if (IsCurrentFocused() == false)
@@ -11769,4 +11853,155 @@ CATCH:
        return r;
 }
 
+_Window*
+_EditPresenter::OnDragAndDropBeginning(void)
+{
+       SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
+
+       result r = E_SUCCESS;
+       _Label* pLabel = null;
+       FloatDimension dragWindowDimension;
+       _ControlOrientation orientation = __pEdit->GetOrientation();
+
+       GET_SHAPE_CONFIG(EDIT::DRAG_AND_DROP_WINDOW_WIDTH, orientation, dragWindowDimension.width);
+       GET_SHAPE_CONFIG(EDIT::DRAG_AND_DROP_WINDOW_HEIGHT, orientation, dragWindowDimension.height);
+
+       FloatRectangle bounds(__pressedAbsolutePoint.x-dragWindowDimension.width/2.0f, __pressedAbsolutePoint.y-dragWindowDimension.height/2.0f, dragWindowDimension.width, dragWindowDimension.height);
+
+       _EditDragAndDropWindow* pDragWindow = new (std::nothrow) _EditDragAndDropWindow();
+       SysTryReturn(NID_UI_CTRL, pDragWindow, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
+
+       r = pDragWindow->CreateRootVisualElement(_WINDOW_TYPE_SUB);
+       SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pDragWindow->SetBackgroundColor(Color(0, 0, 0, 0));
+       pDragWindow->SetActivationEnabled(false);
+       pDragWindow->SetBounds(bounds);
+
+       pLabel = _Label::CreateLabelN();
+       SysTryCatch(NID_UI_CTRL, pLabel, , E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(r));
+
+       pLabel->SetBackgroundColor(Color(0, 0, 0, 0));
+       pLabel->SetBounds(FloatRectangle(0, 0, bounds.width, bounds.height));
+       pLabel->SetText(__dragAndDropString);
+       pLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
+
+       pDragWindow->AttachChild(*pLabel);
+       pDragWindow->SetLabel(pLabel);
+
+       pDragWindow->SetZOrderGroup(WINDOW_Z_ORDER_GROUP_HIGH);
+       pDragWindow->Open();
+
+       return pDragWindow;
+
+CATCH:
+       delete pDragWindow;
+
+       return null;
+}
+
+void
+_EditPresenter::OnDragAndDropDropping(void)
+{
+       SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
+
+       _Window* pDragWindow = __pEdit->GetDragWindow();
+       if (pDragWindow)
+       {
+               pDragWindow->Close();
+               delete pDragWindow;
+       }
+       return;
+}
+
+void
+_EditPresenter::OnDragAndDropEntered(void)
+{
+       SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
+       if (!IsViewModeEnabled() && !IsCurrentFocused())
+       {
+               _Window* pWindow = null;
+               _ControlManager* pControlManager = _ControlManager::GetInstance();
+               SysTryReturnVoidResult(NID_UI, pControlManager, E_SYSTEM, "[E_SYSTEM] System error occurred.");
+
+               pWindow = pControlManager->GetCurrentFrame();
+               if (pWindow)
+               {
+                       _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
+                       SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] System error occurred.");
+
+                       bool visible = pEcoreEvas->IsWindowVisible(*pWindow);
+                       bool activationEnabled = pEcoreEvas->IsWindowActivationEnabled(*pWindow);
+
+                       if ((visible == true) && (activationEnabled == true))
+                       {
+                               pEcoreEvas->ActivateWindow(*pWindow);
+                       }
+               }
+               __pEdit->SetFocused();
+       }
+       return;
+}
+
+void
+_EditPresenter::OnDragAndDropMoved(const Tizen::Graphics::FloatPoint& position)
+{
+       SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
+
+       if (IsViewModeEnabled())
+       {
+               return;
+       }
+
+       FloatRectangle clientBounds = __pEdit->GetBoundsF();
+       clientBounds.x = 0.0f;
+       clientBounds.y = 0.0f;
+       if (clientBounds.Contains(position))
+       {
+               int rowIndex;
+               int columnIndex;
+               int cursorPos = GetCursorPositionAt(position, rowIndex,columnIndex);
+               if (cursorPos != -1)
+               {
+                       SetCursorPosition(cursorPos, rowIndex, columnIndex);
+               }
+               else
+               {
+                       if ((__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) == false)
+                       {
+                               SetCursorPosition(GetTextLength());
+                       }
+               }
+               InitializeCursor();
+       }
+       return;
+}
+
+void
+_EditPresenter::OnDragAndDropLeft(void)
+{
+       SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
+       return;
+}
+
+void
+_EditPresenter::OnDragAndDropDropped(const _DragAndDropItem& dragAndDropItem)
+{
+       SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
+
+       if (IsViewModeEnabled())
+       {
+               return;
+       }
+
+       if (IsUnsupportedChracterExist(GetKeypadStyle(), dragAndDropItem.GetData()))
+       {
+               return;
+       }
+
+       InsertTextAt(__cursorPos, dragAndDropItem.GetData());
+       DrawText();
+       return;
+}
+
 }}} // Tizen::Ui::Controls
index 004a3ca..6b39e0f 100755 (executable)
@@ -43,6 +43,7 @@
 #include <FUiIClipboardPopupEventListener.h>
 #include <FUiITextEventListener.h>
 #include "FUi_Control.h"
+#include "FUi_DragAndDropItem.h"
 #include "FUi_ITouchFlickGestureEventListener.h"
 #include "FUi_ITouchLongPressGestureEventListener.h"
 #include "FUi_ITouchTapGestureEventListener.h"
@@ -499,9 +500,17 @@ public:
        virtual void OnAncestorEnableStateChanged(const _Control& control);
        virtual void OnAncestorVisibleStateChanged(const _Control& control);
        virtual void OnSettingChanged(Tizen::Base::String& key);
-
        virtual void OnDrawFocus(void);
 
+       virtual _Window* OnDragAndDropBeginning(void);
+       virtual void OnDragAndDropDropping(void);
+
+       virtual void OnDragAndDropEntered(void);
+       virtual void OnDragAndDropMoved(const Tizen::Graphics::FloatPoint& position);
+       virtual void OnDragAndDropLeft(void);
+       virtual void OnDragAndDropDropped(const _DragAndDropItem& dragAndDropItem);
+
+
        _EditPresenter* GetPresenter(void) const;
        Tizen::Graphics::FloatDimension GetContentSizeInternalF(bool horizontalMode, bool verticalMode) const;
        bool IsInternalFocused(void) const;
index d4f90b2..0f9bfd9 100755 (executable)
@@ -348,6 +348,14 @@ public:
        bool IsClearIconPressed(void) const;
        result DrawFocusRing(Tizen::Graphics::Canvas& canvas);
 
+       virtual _Window* OnDragAndDropBeginning(void);
+       virtual void OnDragAndDropDropping(void);
+
+       virtual void OnDragAndDropEntered(void);
+       virtual void OnDragAndDropMoved(const Tizen::Graphics::FloatPoint& position);
+       virtual void OnDragAndDropLeft(void);
+       virtual void OnDragAndDropDropped(const _DragAndDropItem& dragAndDropItem);
+
 protected:
        void StopTitleSlidingTimer(void);
        result StartTitleSlidingTimer(void);
@@ -598,7 +606,8 @@ private:
        bool __isPasswordVisible;
        bool __needToCreateCopyPastePopup;
        FloatRectangle __calculatedCursorBounds;
-
+       bool __dragAndDropStarted;
+       Tizen::Base::String __dragAndDropString;
 }; // _EditPresenter
 
 }}} // Tizen::Ui::Controls
index 426240b..276376d 100644 (file)
@@ -124,6 +124,9 @@ DECLARE_UI_CONFIG(EDIT);
        DECLARE_SHAPE_CONFIG(COPYPASTE_MAGNIFIER_CAPTURE_HEIGHT, 43)
        DECLARE_SHAPE_CONFIG(COPYPASTE_MAGNIFIER_CAPTURE_POSITION_X, 44)
        DECLARE_SHAPE_CONFIG(COPYPASTE_MAGNIFIER_CAPTURE_POSITION_Y, 45)
+       DECLARE_SHAPE_CONFIG(DRAG_AND_DROP_WINDOW_WIDTH, 46)
+       DECLARE_SHAPE_CONFIG(DRAG_AND_DROP_WINDOW_HEIGHT, 47)
+
 DECLARE_END_UI_CONFIG(EDIT);
 
 #endif //_FUI_RESOURCE_EDIT_CONFIG_H_
index e7ada32..42ba43f 100644 (file)
@@ -135,6 +135,8 @@ START_UI_CONFIG(EDIT);
        ADD_SHAPE_CONFIG(COPYPASTE_MAGNIFIER_CAPTURE_HEIGHT, 70);
        ADD_SHAPE_CONFIG(COPYPASTE_MAGNIFIER_CAPTURE_POSITION_X, 18);
        ADD_SHAPE_CONFIG(COPYPASTE_MAGNIFIER_CAPTURE_POSITION_Y, 18);
+       ADD_SHAPE_CONFIG(DRAG_AND_DROP_WINDOW_WIDTH, 300);
+       ADD_SHAPE_CONFIG(DRAG_AND_DROP_WINDOW_HEIGHT, 40);
 
        ADD_DIMENSION_CONFIG(MIN_SIZE, 48, 60);
        ADD_DIMENSION_CONFIG(TITLE_STYLE_MIN_SIZE, 48, 102);