some fixes in MainWindow move

This commit is contained in:
Eduardo Bart
2012-02-07 02:55:20 -02:00
parent 876c521d43
commit 37f3f904c7
9 changed files with 29 additions and 5 deletions

View File

@@ -32,6 +32,18 @@ LuaObject::~LuaObject()
releaseLuaFieldsTable();
}
bool LuaObject::hasLuaField(const std::string& field)
{
bool ret = false;
if(m_fieldsTableRef != -1) {
g_lua.getRef(m_fieldsTableRef);
g_lua.getField(field); // push the field value
ret = !g_lua.isNil();
g_lua.pop(2);
}
return ret;
}
void LuaObject::releaseLuaFieldsTable()
{
if(m_fieldsTableRef != -1) {

View File

@@ -40,6 +40,8 @@ public:
template<typename R, typename... T>
R callLuaField(const std::string& field, const T&... args);
bool hasLuaField(const std::string& field);
/// Sets a field in this lua object
template<typename T>
void setLuaField(const std::string& key, const T& value);

View File

@@ -1191,7 +1191,10 @@ bool UIWidget::onMousePress(const Point& mousePos, Fw::MouseButton button)
} else
m_clickTimer.restart();
}
return callLuaField<bool>("onMousePress", mousePos, button);
if(hasLuaField("onMousePress"))
return callLuaField<bool>("onMousePress", mousePos, button);
return true;
}
bool UIWidget::onMouseRelease(const Point& mousePos, Fw::MouseButton button)

View File

@@ -319,7 +319,7 @@ public:
void setPaddingRight(int padding) { m_padding.right = padding; updateLayout(); }
void setPaddingBottom(int padding) { m_padding.bottom = padding; updateLayout(); }
void setPaddingLeft(int padding) { m_padding.left = padding; updateLayout(); }
void setOpacity(float opacity) { m_opacity = opacity; }
void setOpacity(float opacity) { m_opacity = std::min(std::max(opacity, 0.0f), 1.0f); }
int getX() { return m_rect.x(); }
int getY() { return m_rect.y(); }