some fixes in MainWindow move
This commit is contained in:
parent
876c521d43
commit
37f3f904c7
|
@ -8,13 +8,18 @@ Window < UIWindow
|
||||||
image-source: /core_styles/images/window.png
|
image-source: /core_styles/images/window.png
|
||||||
image-border: 4
|
image-border: 4
|
||||||
image-border-top: 20
|
image-border-top: 20
|
||||||
|
opacity: 1
|
||||||
padding-top: 28
|
padding-top: 28
|
||||||
padding-left: 16
|
padding-left: 16
|
||||||
padding-right: 16
|
padding-right: 16
|
||||||
padding-bottom: 16
|
padding-bottom: 16
|
||||||
|
|
||||||
$disabled:
|
$disabled:
|
||||||
color: #aaaaaa88
|
color: #aaaaaa88
|
||||||
|
|
||||||
|
$pressed:
|
||||||
|
opacity: 0.8
|
||||||
|
|
||||||
MainWindow < Window
|
MainWindow < Window
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
|
||||||
|
|
|
@ -10,5 +10,6 @@ end
|
||||||
function UICheckBox:onMouseRelease(mousePos, mouseButton)
|
function UICheckBox:onMouseRelease(mousePos, mouseButton)
|
||||||
if self:isPressed() and self:containsPoint(mousePos) then
|
if self:isPressed() and self:containsPoint(mousePos) then
|
||||||
self:setChecked(not self:isChecked())
|
self:setChecked(not self:isChecked())
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,7 @@ function UIMiniWindow:onMousePress(mousePos, mouseButton)
|
||||||
if parent:getClassName() ~= 'UIMiniWindowContainer' then
|
if parent:getClassName() ~= 'UIMiniWindowContainer' then
|
||||||
self:raise()
|
self:raise()
|
||||||
end
|
end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function UIMiniWindow:onDragEnter(mousePos)
|
function UIMiniWindow:onDragEnter(mousePos)
|
||||||
|
|
|
@ -51,9 +51,8 @@ function UIPopupMenu:onMousePress(mousePos, mouseButton)
|
||||||
-- clicks outside menu area destroys the menu
|
-- clicks outside menu area destroys the menu
|
||||||
if not self:containsPoint(mousePos) then
|
if not self:containsPoint(mousePos) then
|
||||||
self:destroy()
|
self:destroy()
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
return false
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function UIPopupMenu:onKeyPress(keyCode, keyboardModifiers)
|
function UIPopupMenu:onKeyPress(keyCode, keyboardModifiers)
|
||||||
|
|
|
@ -18,7 +18,8 @@ function UIWindow:onKeyPress(keyCode, keyboardModifiers)
|
||||||
end
|
end
|
||||||
|
|
||||||
function UIWindow:onMousePress(mousePos, mouseButton)
|
function UIWindow:onMousePress(mousePos, mouseButton)
|
||||||
|
self:raise()
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function UIWindow:onDragEnter(mousePos)
|
function UIWindow:onDragEnter(mousePos)
|
||||||
|
|
|
@ -32,6 +32,18 @@ LuaObject::~LuaObject()
|
||||||
releaseLuaFieldsTable();
|
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()
|
void LuaObject::releaseLuaFieldsTable()
|
||||||
{
|
{
|
||||||
if(m_fieldsTableRef != -1) {
|
if(m_fieldsTableRef != -1) {
|
||||||
|
|
|
@ -40,6 +40,8 @@ public:
|
||||||
template<typename R, typename... T>
|
template<typename R, typename... T>
|
||||||
R callLuaField(const std::string& field, const T&... args);
|
R callLuaField(const std::string& field, const T&... args);
|
||||||
|
|
||||||
|
bool hasLuaField(const std::string& field);
|
||||||
|
|
||||||
/// Sets a field in this lua object
|
/// Sets a field in this lua object
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void setLuaField(const std::string& key, const T& value);
|
void setLuaField(const std::string& key, const T& value);
|
||||||
|
|
|
@ -1191,7 +1191,10 @@ bool UIWidget::onMousePress(const Point& mousePos, Fw::MouseButton button)
|
||||||
} else
|
} else
|
||||||
m_clickTimer.restart();
|
m_clickTimer.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(hasLuaField("onMousePress"))
|
||||||
return callLuaField<bool>("onMousePress", mousePos, button);
|
return callLuaField<bool>("onMousePress", mousePos, button);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UIWidget::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
|
bool UIWidget::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
|
||||||
|
|
|
@ -319,7 +319,7 @@ public:
|
||||||
void setPaddingRight(int padding) { m_padding.right = padding; updateLayout(); }
|
void setPaddingRight(int padding) { m_padding.right = padding; updateLayout(); }
|
||||||
void setPaddingBottom(int padding) { m_padding.bottom = padding; updateLayout(); }
|
void setPaddingBottom(int padding) { m_padding.bottom = padding; updateLayout(); }
|
||||||
void setPaddingLeft(int padding) { m_padding.left = 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 getX() { return m_rect.x(); }
|
||||||
int getY() { return m_rect.y(); }
|
int getY() { return m_rect.y(); }
|
||||||
|
|
Loading…
Reference in New Issue