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;
+}
+
// CLASS HEADER
#include <dali/integration-api/events/point.h>
+#include <dali/public-api/events/mouse-button.h>
namespace Dali
{
mDeviceClass( Device::Class::NONE ),
mDeviceSubclass( Device::Subclass::NONE ),
mPressure( 1.0f ),
- mRadius( 0.0f )
+ mRadius( 0.0f ),
+ mMouseButton( MouseButton::INVALID )
{
}
mDeviceClass( Device::Class::NONE ),
mDeviceSubclass( Device::Subclass::NONE ),
mPressure( 1.0f ),
- mRadius( 0.0f )
+ mRadius( 0.0f ),
+ mMouseButton( MouseButton::INVALID )
{
}
return mDeviceSubclass;
}
+MouseButton::Type Point::GetMouseButton() const
+{
+ return mMouseButton;
+}
+
+void Point::SetMouseButton(MouseButton::Type button)
+{
+ mMouseButton = button;
+}
+
+
} // namespace Integration
} // namespace Dali
#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
{
*/
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
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
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
*/
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
${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
--- /dev/null
+#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__
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 )
{
#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
{
*/
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
$(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 \