diff --git a/bin/assets/layouts/test_widgets.xml b/bin/assets/layouts/test_widgets.xml
index 642e1f664..0a227a0ee 100644
--- a/bin/assets/layouts/test_widgets.xml
+++ b/bin/assets/layouts/test_widgets.xml
@@ -30,9 +30,9 @@
- Test 3
- Test 4
- Test 5
- Test 6
- Test 7
- Test 8
-
+
-
+
diff --git a/include/eepp/scene/eventdispatcher.hpp b/include/eepp/scene/eventdispatcher.hpp
index 9b270ca75..5c18e7af4 100644
--- a/include/eepp/scene/eventdispatcher.hpp
+++ b/include/eepp/scene/eventdispatcher.hpp
@@ -92,6 +92,7 @@ class EE_API EventDispatcher {
Vector2i mMousePosi;
Vector2f mLastMousePos;
Vector2i mMouseDownPos;
+ Vector2i mClickPos;
Int32 mCbId;
bool mFirstPress;
Node* mNodeDragging;
diff --git a/include/eepp/window/input.hpp b/include/eepp/window/input.hpp
index 9e1c2c17d..93749b6d8 100644
--- a/include/eepp/window/input.hpp
+++ b/include/eepp/window/input.hpp
@@ -151,10 +151,10 @@ class EE_API Input {
const Uint32& getDoubleClickTrigger() const;
/** @return The double click interval in milliseconds ( default 500 ms ) */
- const Uint32& getDoubleClickInterval() const;
+ const Time& getDoubleClickInterval() const;
/** Set the double click interval in milliseconds */
- void setDoubleClickInterval( const Uint32& Interval );
+ void setDoubleClickInterval( const Time& Interval );
/** Clean the keyboard and mouse states */
void cleanStates();
@@ -197,8 +197,8 @@ class EE_API Input {
Uint32 mClickTrigger;
Uint32 mDoubleClickTrigger;
Uint32 mInputMod;
- Uint32 mDoubleClickInterval; //!< Determine the double click inverval in milliseconds ( default
- //!< 500 ms )
+ Time mDoubleClickInterval; /// Determine the double click inverval in milliseconds ( default 400
+ /// ms )
Uint32 mLastButtonLeftClicked;
Uint32 mLastButtonRightClicked;
Uint32 mLastButtonMiddleClicked;
diff --git a/include/eepp/window/inputevent.hpp b/include/eepp/window/inputevent.hpp
index db629f3c8..a7353039a 100644
--- a/include/eepp/window/inputevent.hpp
+++ b/include/eepp/window/inputevent.hpp
@@ -141,6 +141,16 @@ class InputEvent {
Uint8 type;
};
+ /** File dropped event */
+ struct FileDroppedEvent {
+ char* file;
+ };
+
+ /** Text dropped event */
+ struct TextDroppedEvent {
+ char* text;
+ };
+
/** The "quit requested" event */
struct QuitEvent {
Uint8 type;
@@ -182,6 +192,8 @@ class InputEvent {
SysWM,
VideoResize,
VideoExpose,
+ FileDropped,
+ TextDropped,
EventUser,
EventCount = EventUser - 1
};
@@ -203,6 +215,8 @@ class InputEvent {
JoyButtonEvent jbutton;
ResizeEvent resize;
ExposeEvent expose;
+ FileDroppedEvent file;
+ TextDroppedEvent textdrop;
QuitEvent quit;
UserEvent user;
SysWMEvent syswm;
diff --git a/src/eepp/scene/eventdispatcher.cpp b/src/eepp/scene/eventdispatcher.cpp
index 2eb0f3120..60a845faa 100644
--- a/src/eepp/scene/eventdispatcher.cpp
+++ b/src/eepp/scene/eventdispatcher.cpp
@@ -128,12 +128,15 @@ void EventDispatcher::update( const Time& time ) {
lastFocusControl->onMouseClick( mMousePosi, mInput->getClickTrigger() );
sendMsg( lastFocusControl, NodeMessage::Click, mInput->getClickTrigger() );
- if ( mInput->getDoubleClickTrigger() ) {
+ if ( mInput->getDoubleClickTrigger() &&
+ mClickPos.distance( mMousePosi ) < 10 ) {
lastFocusControl->onMouseDoubleClick( mMousePosi,
mInput->getDoubleClickTrigger() );
sendMsg( lastFocusControl, NodeMessage::DoubleClick,
mInput->getDoubleClickTrigger() );
}
+
+ mClickPos = mMousePosi;
}
}
}
diff --git a/src/eepp/ui/uibackgrounddrawable.cpp b/src/eepp/ui/uibackgrounddrawable.cpp
index 7e8856f7d..7b2a28df8 100644
--- a/src/eepp/ui/uibackgrounddrawable.cpp
+++ b/src/eepp/ui/uibackgrounddrawable.cpp
@@ -12,7 +12,7 @@ UIBackgroundDrawable* UIBackgroundDrawable::New( UINode* owner ) {
UIBackgroundDrawable::UIBackgroundDrawable( UINode* owner ) :
Drawable( UIBACKGROUNDDRAWABLE ),
mOwner( owner ),
- mVertexBuffer( VertexBuffer::NewVertexArray( VERTEX_FLAGS_PRIMITIVE, PRIMITIVE_TRIANGLE_FAN ) ),
+ mVertexBuffer( nullptr ),
mNeedsUpdate( false ),
mNeedsRadiusUpdate( false ),
mColorNeedsUpdate( false ) {}
@@ -44,7 +44,7 @@ void UIBackgroundDrawable::draw( const Vector2f& position, const Sizef& size ) {
update();
}
- if ( hasRadius() ) {
+ if ( hasRadius() && mVertexBuffer ) {
mVertexBuffer->bind();
mVertexBuffer->draw();
mVertexBuffer->unbind();
@@ -152,7 +152,13 @@ void UIBackgroundDrawable::onPositionChange() {
void UIBackgroundDrawable::update() {
updateRadiuses();
- Borders::createBackground( mVertexBuffer, mRadiuses, mPosition, mSize, mColor );
+ if ( hasRadius() ) {
+ if ( nullptr == mVertexBuffer ) {
+ mVertexBuffer =
+ VertexBuffer::NewVertexArray( VERTEX_FLAGS_PRIMITIVE, PRIMITIVE_TRIANGLE_FAN );
+ }
+ Borders::createBackground( mVertexBuffer, mRadiuses, mPosition, mSize, mColor );
+ }
mColorNeedsUpdate = false;
mNeedsRadiusUpdate = false;
mNeedsUpdate = false;
diff --git a/src/eepp/window/backend/SDL2/inputsdl2.cpp b/src/eepp/window/backend/SDL2/inputsdl2.cpp
index a94d2a843..a6495c697 100644
--- a/src/eepp/window/backend/SDL2/inputsdl2.cpp
+++ b/src/eepp/window/backend/SDL2/inputsdl2.cpp
@@ -308,6 +308,16 @@ void InputSDL::update() {
EEEvent.syswm.msg = (InputEvent::SysWMmsg*)SDLEvent.syswm.msg;
break;
}
+ case SDL_DROPFILE: {
+ EEEvent.Type = InputEvent::FileDropped;
+ EEEvent.file.file = SDLEvent.drop.file;
+ break;
+ }
+ case SDL_DROPTEXT: {
+ EEEvent.Type = InputEvent::TextDropped;
+ EEEvent.textdrop.text = SDLEvent.drop.file;
+ break;
+ }
default: {
if ( SDLEvent.type >= SDL_USEREVENT && SDLEvent.type < SDL_LASTEVENT ) {
EEEvent.Type = InputEvent::EventUser + SDLEvent.type - SDL_USEREVENT;
@@ -324,6 +334,10 @@ void InputSDL::update() {
if ( InputEvent::NoEvent != EEEvent.Type ) {
processEvent( &EEEvent );
}
+
+ if ( InputEvent::FileDropped == EEEvent.Type || InputEvent::TextDropped == EEEvent.Type ) {
+ SDL_free( SDLEvent.drop.file );
+ }
}
InputEvent endProcessingEvent;
diff --git a/src/eepp/window/input.cpp b/src/eepp/window/input.cpp
index 6e816cfd7..11a3f4ee3 100644
--- a/src/eepp/window/input.cpp
+++ b/src/eepp/window/input.cpp
@@ -11,7 +11,7 @@ Input::Input( EE::Window::Window* window, JoystickManager* joystickmanager ) :
mClickTrigger( 0 ),
mDoubleClickTrigger( 0 ),
mInputMod( 0 ),
- mDoubleClickInterval( 400 ),
+ mDoubleClickInterval( Milliseconds( 400 ) ),
mLastButtonLeftClicked( 0 ),
mLastButtonRightClicked( 0 ),
mLastButtonMiddleClicked( 0 ),
@@ -116,7 +116,7 @@ void Input::processEvent( InputEvent* Event ) {
mTClick = mLastButtonLeftClick - mLastButtonLeftClicked;
- if ( mTClick < mDoubleClickInterval && mTClick > 0 ) {
+ if ( mTClick < mDoubleClickInterval.asMilliseconds() && mTClick > 0 ) {
mDoubleClickTrigger |= EE_BUTTON_MASK( EE_BUTTON_LEFT );
mLastButtonLeftClick = 0;
mLastButtonLeftClicked = 0;
@@ -127,7 +127,7 @@ void Input::processEvent( InputEvent* Event ) {
mTClick = mLastButtonRightClick - mLastButtonRightClicked;
- if ( mTClick < mDoubleClickInterval && mTClick > 0 ) {
+ if ( mTClick < mDoubleClickInterval.asMilliseconds() && mTClick > 0 ) {
mDoubleClickTrigger |= EE_BUTTON_MASK( EE_BUTTON_RIGHT );
mLastButtonRightClick = 0;
mLastButtonRightClicked = 0;
@@ -138,7 +138,7 @@ void Input::processEvent( InputEvent* Event ) {
mTClick = mLastButtonMiddleClick - mLastButtonMiddleClicked;
- if ( mTClick < mDoubleClickInterval && mTClick > 0 ) {
+ if ( mTClick < mDoubleClickInterval.asMilliseconds() && mTClick > 0 ) {
mDoubleClickTrigger |= EE_BUTTON_MASK( EE_BUTTON_MIDDLE );
mLastButtonMiddleClick = 0;
mLastButtonMiddleClicked = 0;
@@ -400,11 +400,11 @@ const Uint32& Input::getDoubleClickTrigger() const {
return mDoubleClickTrigger;
}
-const Uint32& Input::getDoubleClickInterval() const {
+const Time& Input::getDoubleClickInterval() const {
return mDoubleClickInterval;
}
-void Input::setDoubleClickInterval( const Uint32& Interval ) {
+void Input::setDoubleClickInterval( const Time& Interval ) {
mDoubleClickInterval = Interval;
}
diff --git a/src/eepp/window/inputtextbuffer.cpp b/src/eepp/window/inputtextbuffer.cpp
index d17b3230b..d937709de 100644
--- a/src/eepp/window/inputtextbuffer.cpp
+++ b/src/eepp/window/inputtextbuffer.cpp
@@ -319,7 +319,6 @@ void InputTextBuffer::update( InputEvent* Event ) {
Event->key.keysym.sym == KEY_DELETE ) ||
keyChar == KEY_BACKSPACE ) {
removeSelection();
- break;
}
}