mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 14:03:26 +02:00
side panel splitter
This commit is contained in:
@@ -116,8 +116,11 @@ void UIManager::inputEvent(const InputEvent& event)
|
||||
}
|
||||
case Fw::MouseMoveInputEvent: {
|
||||
// start dragging when moving a pressed widget
|
||||
if(m_pressedWidget && m_pressedWidget->isDragable() && m_draggingWidget != m_pressedWidget)
|
||||
updateDraggingWidget(m_pressedWidget, event.mousePos - event.mouseMoved);
|
||||
if(m_pressedWidget && m_pressedWidget->isDragable() && m_draggingWidget != m_pressedWidget) {
|
||||
// only drags when moving more than 4 pixels
|
||||
if((event.mousePos - m_pressedWidget->getLastClickPosition()).length() >= 4)
|
||||
updateDraggingWidget(m_pressedWidget, event.mousePos - event.mouseMoved);
|
||||
}
|
||||
|
||||
// mouse move can change hovered widgets
|
||||
updateHoveredWidget();
|
||||
|
@@ -1323,6 +1323,7 @@ bool UIWidget::onMousePress(const Point& mousePos, Fw::MouseButton button)
|
||||
m_clickTimer.stop();
|
||||
} else
|
||||
m_clickTimer.restart();
|
||||
m_lastClickPosition = mousePos;
|
||||
}
|
||||
|
||||
if(hasLuaField("onMousePress"))
|
||||
|
@@ -43,6 +43,7 @@ struct EdgeGroup {
|
||||
|
||||
// generate lua bindings for this class running:
|
||||
// ./tools/lua-binding-generator/generate_lua_bindings.lua src/framework/ui/uiwidget.h
|
||||
|
||||
class UIWidget : public LuaObject
|
||||
{
|
||||
// widget core
|
||||
@@ -253,6 +254,7 @@ public:
|
||||
int getAutoRepeatDelay() { return m_autoRepeatDelay; }
|
||||
Point getVirtualOffset() { return m_virtualOffset; }
|
||||
std::string getStyleName() { return m_style->tag(); }
|
||||
Point getLastClickPosition() { return m_lastClickPosition; }
|
||||
|
||||
|
||||
// base style
|
||||
@@ -277,6 +279,7 @@ protected:
|
||||
EdgeGroup<int> m_padding;
|
||||
float m_opacity;
|
||||
int m_autoRepeatDelay;
|
||||
Point m_lastClickPosition;
|
||||
|
||||
public:
|
||||
void setX(int x) { move(x, getY()); }
|
||||
|
@@ -50,7 +50,12 @@ void UIWidget::updateText()
|
||||
newSize.setHeight(textSize.height());
|
||||
setSize(newSize);
|
||||
} else if(m_textAutoResize) {
|
||||
setSize(getTextSize());
|
||||
Size textSize = getTextSize();
|
||||
Size size = getSize();
|
||||
if(textSize.width() > size.width())
|
||||
size.setWidth(textSize.width());
|
||||
size.setHeight(textSize.height());
|
||||
setSize(size);
|
||||
}
|
||||
|
||||
m_textMustRecache = true;
|
||||
|
Reference in New Issue
Block a user