Add GetMouseButton to identify right/left mouse button click 19/180419/10
authordongsug.song <dongsug.song@samsung.com>
Tue, 29 May 2018 09:01:20 +0000 (18:01 +0900)
committerdongsug.song <dongsug.song@samsung.com>
Mon, 2 Jul 2018 02:43:54 +0000 (11:43 +0900)
Change-Id: If2e2536851e081fc882786da1ff1595c255efae0
Signed-off-by: dongsug.song <dongsug.song@samsung.com>
automated-tests/src/dali/utc-Dali-TouchDataProcessing.cpp [changed mode: 0644->0755]
dali/integration-api/events/point.cpp [changed mode: 0644->0755]
dali/integration-api/events/point.h [changed mode: 0644->0755]
dali/internal/event/events/touch-data-impl.cpp [changed mode: 0644->0755]
dali/internal/event/events/touch-data-impl.h [changed mode: 0644->0755]
dali/public-api/CMakeLists.txt
dali/public-api/events/mouse-button.h [new file with mode: 0755]
dali/public-api/events/touch-data.cpp [changed mode: 0644->0755]
dali/public-api/events/touch-data.h [changed mode: 0644->0755]
dali/public-api/file.list

old mode 100644 (file)
new mode 100755 (executable)
index 6250198..99c9826
@@ -2010,3 +2010,63 @@ int UtcDaliTouchDataGetDeviceAPINegative(void)
   DALI_TEST_EQUALS( data.GetDeviceSubclass( -1 ), Device::Subclass::NONE, TEST_LOCATION );
   END_TEST;
 }
+
+int UtcDaliTouchDataGetMouseButtonPositive(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  actor.SetSize(100.0f, 100.0f);
+  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+  Stage::GetCurrent().Add(actor);
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Connect to actor's touched signal
+  HandleData handleData;
+  TouchDataHandleFunctor functor( handleData );
+  actor.TouchSignal().Connect( &application, functor );
+
+  // Emit a down signal with MouseButton
+  Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
+  touchEvent.points[ 0 ].SetMouseButton( static_cast< MouseButton::Type >( 3 ) );
+  application.ProcessEvent( touchEvent );
+
+  TouchData data = handleData.touchData;
+  DALI_TEST_EQUALS( data.GetMouseButton( 0 ), MouseButton::SECONDARY, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliTouchDataGetMouseButtonNagative(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  actor.SetSize(100.0f, 100.0f);
+  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+  Stage::GetCurrent().Add(actor);
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Connect to actor's touched signal
+  HandleData handleData;
+  TouchDataHandleFunctor functor( handleData );
+  actor.TouchSignal().Connect( &application, functor );
+
+  // Emit a down signal with MouseButton
+  Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
+  touchEvent.points[ 0 ].SetMouseButton( static_cast< MouseButton::Type >( 2 ) );
+  application.ProcessEvent( touchEvent );
+
+  TouchData data = handleData.touchData;
+  DALI_TEST_EQUALS( data.GetMouseButton( 0 ), MouseButton::TERTIARY, TEST_LOCATION );
+  DALI_TEST_EQUALS( data.GetMouseButton( 3 ), MouseButton::INVALID, TEST_LOCATION );
+
+  END_TEST;
+}
+
old mode 100644 (file)
new mode 100755 (executable)
index 19b44b0..7b52bc3
@@ -17,6 +17,7 @@
 
 // CLASS HEADER
 #include <dali/integration-api/events/point.h>
+#include <dali/public-api/events/mouse-button.h>
 
 namespace Dali
 {
@@ -31,7 +32,8 @@ Point::Point()
   mDeviceClass( Device::Class::NONE ),
   mDeviceSubclass( Device::Subclass::NONE ),
   mPressure( 1.0f ),
-  mRadius( 0.0f )
+  mRadius( 0.0f ),
+  mMouseButton( MouseButton::INVALID )
 {
 }
 
@@ -42,7 +44,8 @@ Point::Point( const TouchPoint& touchPoint )
   mDeviceClass( Device::Class::NONE ),
   mDeviceSubclass( Device::Subclass::NONE ),
   mPressure( 1.0f ),
-  mRadius( 0.0f )
+  mRadius( 0.0f ),
+  mMouseButton( MouseButton::INVALID )
 {
 }
 
@@ -166,6 +169,17 @@ Device::Subclass::Type Point::GetDeviceSubclass() const
   return mDeviceSubclass;
 }
 
+MouseButton::Type Point::GetMouseButton() const
+{
+  return mMouseButton;
+}
+
+void Point::SetMouseButton(MouseButton::Type button)
+{
+  mMouseButton = button;
+}
+
+
 } // namespace Integration
 
 } // namespace Dali
old mode 100644 (file)
new mode 100755 (executable)
index d0c4f0f..9b33ed3
@@ -24,6 +24,7 @@
 #include <dali/public-api/math/vector2.h>
 #include <dali/public-api/events/touch-point.h>
 #include <dali/public-api/events/device.h>
+#include <dali/public-api/events/mouse-button.h>
 
 namespace Dali
 {
@@ -178,6 +179,16 @@ struct DALI_CORE_API Point
    */
   Device::Subclass::Type GetDeviceSubclass() const;
 
+  /**
+   * @brief Get Mouse Button value. (ex: right/left button)
+   * @return The mouse button value.
+   */
+  MouseButton::Type GetMouseButton() const;
+
+  /**
+   * @brief Set Mouse Button value. (ex: right/left button)
+   */
+  void SetMouseButton(MouseButton::Type button);
 
 
 public: // Not intended for Integration API developers
@@ -223,6 +234,7 @@ private:
   Device::Subclass::Type mDeviceSubclass;
   float mPressure; ///< The touch pressure.
   float mRadius; ///< Radius of the press point, an average of the ellipse radius.
+  MouseButton::Type mMouseButton; /// < mouse button value.
 };
 
 } // namespace Integration
old mode 100644 (file)
new mode 100755 (executable)
index 58547ea..481407a
@@ -177,6 +177,15 @@ Device::Subclass::Type TouchData::GetDeviceSubclass( std::size_t point ) const
   return Device::Subclass::NONE;
 }
 
+MouseButton::Type TouchData::GetMouseButton( std::size_t point ) const
+{
+  if( point < mPoints.size() )
+  {
+    return mPoints[ point ].GetMouseButton();
+  }
+  return MouseButton::INVALID;
+}
+
 } // namsespace Internal
 
 } // namespace Dali
old mode 100644 (file)
new mode 100755 (executable)
index 15bfb4f..19e56a2
@@ -172,6 +172,14 @@ public:
    */
   Device::Subclass::Type GetDeviceSubclass( std::size_t point ) const;
 
+  /**
+   * @brief Get mouse's button value (ex: right/left button)
+   *
+   * @return The value of mouse button
+   */
+  MouseButton::Type GetMouseButton( std::size_t point ) const;
+
+
 private:
 
   /// Undefined Copy constructor
index 59b2839..ebd2cbe 100644 (file)
@@ -147,6 +147,7 @@ SET(PUBLIC_API_HEADERS
   ${CMAKE_CURRENT_SOURCE_DIR}/events/touch-point.h
   ${CMAKE_CURRENT_SOURCE_DIR}/events/touch-event.h
   ${CMAKE_CURRENT_SOURCE_DIR}/events/touch-data.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/events/mouse-button.h
 
   ${CMAKE_CURRENT_SOURCE_DIR}/images/buffer-image.h
   ${CMAKE_CURRENT_SOURCE_DIR}/images/encoded-buffer-image.h
diff --git a/dali/public-api/events/mouse-button.h b/dali/public-api/events/mouse-button.h
new file mode 100755 (executable)
index 0000000..e6ec2a8
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef DALI_MOUSE_BUTTON_H
+#define DALI_MOUSE_BUTTON_H
+
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Dali
+{
+/**
+ * @addtogroup dali_core_events
+ * @{
+ */
+
+/**
+ * @brief Mouse Button Type
+ * @SINCE_1_3.31
+ */
+namespace MouseButton
+{
+
+/**
+ * @brief Enumeration for mouse button type.
+ * @SINCE_1_3.31
+ */
+enum Type
+{
+  INVALID = -1, /**< No mouse button event or invalid data */
+  PRIMARY = 1, /**< Primary(Left) mouse button */
+  SECONDARY = 3, /**< Secondary(Right) mouse button */
+  TERTIARY = 2, /**< Center(Wheel) mouse button */
+};
+}
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // __DALI_MOUSE_BUTTON_H__
old mode 100644 (file)
new mode 100755 (executable)
index a18a927..54d9a5e
@@ -112,6 +112,11 @@ Device::Subclass::Type TouchData::GetDeviceSubclass( std::size_t point ) const
   return GetImplementation( *this ).GetDeviceSubclass( point );
 }
 
+MouseButton::Type TouchData::GetMouseButton( std::size_t point ) const
+{
+  return GetImplementation( *this ).GetMouseButton( point );
+}
+
 TouchData::TouchData( Internal::TouchData* internal )
 : BaseHandle( internal )
 {
old mode 100644 (file)
new mode 100755 (executable)
index 9a3dec5..89d00ea
@@ -27,6 +27,7 @@
 #include <dali/public-api/events/point-state.h>
 #include <dali/public-api/object/base-handle.h>
 #include <dali/public-api/math/degree.h>
+#include <dali/public-api/events/mouse-button.h>
 
 namespace Dali
 {
@@ -241,6 +242,17 @@ public:
    */
   Device::Subclass::Type GetDeviceSubclass( std::size_t point ) const;
 
+
+  /**
+   * @brief Get mouse device's button value (ex: right/left button)
+   *
+   * @SINCE_1_3.31
+   * @param[in] point The point required
+   * @return The mouse button value
+   */
+  MouseButton::Type GetMouseButton( std::size_t point ) const;
+
+
 public: // Not intended for application developers
 
   /// @cond internal
index ba9f26b..1e0e443 100644 (file)
@@ -151,7 +151,8 @@ public_api_core_events_header_files = \
   $(public_api_src_dir)/events/tap-gesture-detector.h \
   $(public_api_src_dir)/events/touch-point.h \
   $(public_api_src_dir)/events/touch-event.h \
-  $(public_api_src_dir)/events/touch-data.h
+  $(public_api_src_dir)/events/touch-data.h \
+  $(public_api_src_dir)/events/mouse-button.h
 
 public_api_core_images_header_files = \
   $(public_api_src_dir)/images/buffer-image.h \