mirror of
https://github.com/edubart/otclient.git
synced 2025-10-20 06:23:26 +02:00
scrollbar, options and widgets changes
* complete scrollbar skin * implement scrollbar functionality (scrolling with mouse) * fix onMouseClick issues * add tabs in options (graphics and general tab) * add new option for limiting frame rate using scrollbar * add new widget property "clipping" that will be used on scrollable areas
This commit is contained in:
@@ -53,20 +53,14 @@ UIWidget::~UIWidget()
|
||||
|
||||
void UIWidget::draw(const Rect& visibleRect)
|
||||
{
|
||||
if(m_clipping)
|
||||
g_graphics.beginClipping(visibleRect);
|
||||
|
||||
drawSelf();
|
||||
if(m_children.size() > 0) {
|
||||
bool clip = true;
|
||||
if(this == g_ui.getRootWidget().get())
|
||||
clip = false;
|
||||
drawChildren(visibleRect);
|
||||
|
||||
if(clip)
|
||||
g_graphics.beginClipping(visibleRect);
|
||||
|
||||
drawChildren(visibleRect);
|
||||
|
||||
if(clip)
|
||||
g_graphics.endClipping();
|
||||
}
|
||||
if(m_clipping)
|
||||
g_graphics.endClipping();
|
||||
}
|
||||
|
||||
void UIWidget::drawSelf()
|
||||
@@ -1325,12 +1319,20 @@ bool UIWidget::onMouseWheel(const Point& mousePos, Fw::MouseWheelDirection direc
|
||||
|
||||
bool UIWidget::onClick(const Point& mousePos)
|
||||
{
|
||||
return callLuaField<bool>("onClick", mousePos);
|
||||
if(hasLuaField("onClick")) {
|
||||
callLuaField("onClick", mousePos);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UIWidget::onDoubleClick(const Point& mousePos)
|
||||
{
|
||||
return callLuaField<bool>("onDoubleClick", mousePos);
|
||||
if(hasLuaField("onDoubleClick")) {
|
||||
callLuaField("onDoubleClick", mousePos);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UIWidget::propagateOnKeyText(const std::string& keyText)
|
||||
|
@@ -41,6 +41,8 @@ struct EdgeGroup {
|
||||
T left;
|
||||
};
|
||||
|
||||
// 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
|
||||
@@ -65,6 +67,7 @@ protected:
|
||||
Boolean<false> m_phantom;
|
||||
Boolean<false> m_dragable;
|
||||
Boolean<false> m_destroyed;
|
||||
Boolean<false> m_clipping;
|
||||
UILayoutPtr m_layout;
|
||||
UIWidgetWeakPtr m_parent;
|
||||
UIWidgetList m_children;
|
||||
@@ -120,6 +123,7 @@ public:
|
||||
void setPhantom(bool phantom);
|
||||
void setDragable(bool dragable);
|
||||
void setFixedSize(bool fixed);
|
||||
void setClipping(bool clipping) { m_clipping = clipping; }
|
||||
void setLastFocusReason(Fw::FocusReason reason);
|
||||
void setAutoRepeatDelay(int delay) { m_autoRepeatDelay = delay; }
|
||||
void setVirtualOffset(const Point& offset);
|
||||
@@ -226,6 +230,7 @@ public:
|
||||
bool isPhantom() { return m_phantom; }
|
||||
bool isDragable() { return m_dragable; }
|
||||
bool isFixedSize() { return m_fixedSize; }
|
||||
bool isClipping() { return m_clipping; }
|
||||
bool isDestroyed() { return m_destroyed; }
|
||||
|
||||
bool hasChildren() { return m_children.size() > 0; }
|
||||
|
@@ -120,6 +120,8 @@ void UIWidget::parseBaseStyle(const OTMLNodePtr& styleNode)
|
||||
setSize(node->value<Size>());
|
||||
else if(node->tag() == "fixed-size")
|
||||
setFixedSize(node->value<bool>());
|
||||
else if(node->tag() == "clipping")
|
||||
setClipping(node->value<bool>());
|
||||
else if(node->tag() == "border") {
|
||||
auto split = Fw::split(node->value(), " ");
|
||||
if(split.size() == 2) {
|
||||
|
Reference in New Issue
Block a user