2 * Copyright (C) 2012 Samsung Electronics
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
28 #if ENABLE(TIZEN_DRAG_SUPPORT)
29 #include "DragHandle.h"
33 using namespace WebCore;
37 DragHandle::DragHandle(Evas_Object* object, const String& theme, const String& path, Drag* drag)
41 m_icon = edje_object_add(evas_object_evas_get(object));
45 if (!edje_object_file_set(m_icon, theme.utf8().data(), path.utf8().data()))
48 edje_object_signal_emit(m_icon, "dragndrop,drop,out", "dragndrop");
49 evas_object_smart_member_add(m_icon, object);
51 evas_object_propagate_events_set(m_icon, false);
52 evas_object_event_callback_add(m_icon, EVAS_CALLBACK_MOUSE_DOWN, mouseDown, this);
53 evas_object_event_callback_add(m_icon, EVAS_CALLBACK_MOUSE_MOVE, mouseMove, this);
54 evas_object_event_callback_add(m_icon, EVAS_CALLBACK_MOUSE_UP, mouseUp, this);
57 DragHandle::~DragHandle()
60 ecore_job_del(m_dragJob);
65 evas_object_event_callback_del(m_icon, EVAS_CALLBACK_MOUSE_DOWN, mouseDown);
66 evas_object_event_callback_del(m_icon, EVAS_CALLBACK_MOUSE_MOVE, mouseMove);
67 evas_object_event_callback_del(m_icon, EVAS_CALLBACK_MOUSE_UP, mouseUp);
68 evas_object_del(m_icon);
72 void DragHandle::move(const IntPoint& point)
75 evas_object_move(m_icon, point.x(), point.y());
78 void DragHandle::show()
81 evas_object_show(m_icon);
84 void DragHandle::hide()
87 evas_object_hide(m_icon);
88 edje_object_signal_emit(m_icon, "dragndrop,drop,out", "dragndrop");
92 void DragHandle::updateHandleIcon(bool isDropAble)
98 edje_object_signal_emit(m_icon, "dragndrop,drop,in", "dragndrop");
100 edje_object_signal_emit(m_icon, "dragndrop,drop,out", "dragndrop");
104 void DragHandle::mouseDown(void* data, Evas*, Evas_Object*, void* eventInfo)
106 Evas_Event_Mouse_Down* event = static_cast<Evas_Event_Mouse_Down*>(eventInfo);
107 DragHandle* handle = static_cast<DragHandle*>(data);
109 handle->setMousePosition(IntPoint(event->canvas.x, event->canvas.y));
112 void DragHandle::mouseMove(void* data, Evas*, Evas_Object*, void* eventInfo)
114 Evas_Event_Mouse_Move* event = static_cast<Evas_Event_Mouse_Move*>(eventInfo);
115 DragHandle* handle = static_cast<DragHandle*>(data);
117 handle->setMousePosition(IntPoint(event->cur.canvas.x, event->cur.canvas.y));
119 if (!handle->m_dragJob)
120 handle->m_dragJob = ecore_job_add(update, data);
123 void DragHandle::mouseUp(void* data, Evas*, Evas_Object*, void* eventInfo)
125 DragHandle* handle = static_cast<DragHandle*>(data);
126 handle->m_drag->handleMouseUp(handle);
130 void DragHandle::update(void* data)
132 DragHandle* handle = static_cast<DragHandle*>(data);
133 handle->m_drag->handleMouseMove(handle);
134 handle->m_dragJob = 0;
137 } // namespace WebKit
139 #endif // TIZEN_DRAG_SUPPORT