Minor fixes and add auto resize for images
This commit is contained in:
parent
a3a65d40ce
commit
b43a196eac
|
@ -257,11 +257,14 @@ function flushLines()
|
||||||
for _,line in pairs(cachedLines) do
|
for _,line in pairs(cachedLines) do
|
||||||
-- delete old lines if needed
|
-- delete old lines if needed
|
||||||
if numLines > MaxLogLines then
|
if numLines > MaxLogLines then
|
||||||
local len = #terminalBuffer:getChildByIndex(1):getText()
|
local firstChild = terminalBuffer:getChildByIndex(1)
|
||||||
terminalBuffer:getChildByIndex(1):destroy()
|
if firstChild then
|
||||||
|
local len = #firstChild:getText()
|
||||||
|
firstChild:destroy()
|
||||||
table.remove(allLines, 1)
|
table.remove(allLines, 1)
|
||||||
fulltext = string.sub(fulltext, len)
|
fulltext = string.sub(fulltext, len)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local label = g_ui.createWidget('TerminalLabel', terminalBuffer)
|
local label = g_ui.createWidget('TerminalLabel', terminalBuffer)
|
||||||
label:setId('terminalLabel' .. numLines)
|
label:setId('terminalLabel' .. numLines)
|
||||||
|
|
|
@ -110,7 +110,9 @@ function UITabBar:selectTab(tab)
|
||||||
tab:setOn(false)
|
tab:setOn(false)
|
||||||
|
|
||||||
local parent = tab:getParent()
|
local parent = tab:getParent()
|
||||||
|
if parent then
|
||||||
parent:focusChild(tab, MouseFocusReason)
|
parent:focusChild(tab, MouseFocusReason)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function UITabBar:selectNextTab()
|
function UITabBar:selectNextTab()
|
||||||
|
|
|
@ -569,6 +569,7 @@ void Application::registerLuaFunctions()
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("setImageFixedRatio", &UIWidget::setImageFixedRatio);
|
g_lua.bindClassMemberFunction<UIWidget>("setImageFixedRatio", &UIWidget::setImageFixedRatio);
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("setImageRepeated", &UIWidget::setImageRepeated);
|
g_lua.bindClassMemberFunction<UIWidget>("setImageRepeated", &UIWidget::setImageRepeated);
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("setImageSmooth", &UIWidget::setImageSmooth);
|
g_lua.bindClassMemberFunction<UIWidget>("setImageSmooth", &UIWidget::setImageSmooth);
|
||||||
|
g_lua.bindClassMemberFunction<UIWidget>("setImageAutoResize", &UIWidget::setImageAutoResize);
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("setImageBorderTop", &UIWidget::setImageBorderTop);
|
g_lua.bindClassMemberFunction<UIWidget>("setImageBorderTop", &UIWidget::setImageBorderTop);
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("setImageBorderRight", &UIWidget::setImageBorderRight);
|
g_lua.bindClassMemberFunction<UIWidget>("setImageBorderRight", &UIWidget::setImageBorderRight);
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("setImageBorderBottom", &UIWidget::setImageBorderBottom);
|
g_lua.bindClassMemberFunction<UIWidget>("setImageBorderBottom", &UIWidget::setImageBorderBottom);
|
||||||
|
@ -585,6 +586,7 @@ void Application::registerLuaFunctions()
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("getImageColor", &UIWidget::getImageColor);
|
g_lua.bindClassMemberFunction<UIWidget>("getImageColor", &UIWidget::getImageColor);
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("isImageFixedRatio", &UIWidget::isImageFixedRatio);
|
g_lua.bindClassMemberFunction<UIWidget>("isImageFixedRatio", &UIWidget::isImageFixedRatio);
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("isImageSmooth", &UIWidget::isImageSmooth);
|
g_lua.bindClassMemberFunction<UIWidget>("isImageSmooth", &UIWidget::isImageSmooth);
|
||||||
|
g_lua.bindClassMemberFunction<UIWidget>("isImageAutoResize", &UIWidget::isImageAutoResize);
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("getImageBorderTop", &UIWidget::getImageBorderTop);
|
g_lua.bindClassMemberFunction<UIWidget>("getImageBorderTop", &UIWidget::getImageBorderTop);
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("getImageBorderRight", &UIWidget::getImageBorderRight);
|
g_lua.bindClassMemberFunction<UIWidget>("getImageBorderRight", &UIWidget::getImageBorderRight);
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("getImageBorderBottom", &UIWidget::getImageBorderBottom);
|
g_lua.bindClassMemberFunction<UIWidget>("getImageBorderBottom", &UIWidget::getImageBorderBottom);
|
||||||
|
|
|
@ -98,9 +98,9 @@ void UIWidget::drawSelf(Fw::DrawPane drawPane)
|
||||||
}
|
}
|
||||||
|
|
||||||
drawImage(m_rect);
|
drawImage(m_rect);
|
||||||
drawBorder(m_rect);
|
|
||||||
drawIcon(m_rect);
|
drawIcon(m_rect);
|
||||||
drawText(m_rect);
|
drawText(m_rect);
|
||||||
|
drawBorder(m_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIWidget::drawChildren(const Rect& visibleRect, Fw::DrawPane drawPane)
|
void UIWidget::drawChildren(const Rect& visibleRect, Fw::DrawPane drawPane)
|
||||||
|
|
|
@ -419,6 +419,7 @@ protected:
|
||||||
stdext::boolean<false> m_imageFixedRatio;
|
stdext::boolean<false> m_imageFixedRatio;
|
||||||
stdext::boolean<false> m_imageRepeated;
|
stdext::boolean<false> m_imageRepeated;
|
||||||
stdext::boolean<false> m_imageSmooth;
|
stdext::boolean<false> m_imageSmooth;
|
||||||
|
stdext::boolean<false> m_imageAutoResize;
|
||||||
EdgeGroup<int> m_imageBorder;
|
EdgeGroup<int> m_imageBorder;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -435,6 +436,7 @@ public:
|
||||||
void setImageFixedRatio(bool fixedRatio) { m_imageFixedRatio = fixedRatio; updateImageCache(); }
|
void setImageFixedRatio(bool fixedRatio) { m_imageFixedRatio = fixedRatio; updateImageCache(); }
|
||||||
void setImageRepeated(bool repeated) { m_imageRepeated = repeated; updateImageCache(); }
|
void setImageRepeated(bool repeated) { m_imageRepeated = repeated; updateImageCache(); }
|
||||||
void setImageSmooth(bool smooth) { m_imageSmooth = smooth; }
|
void setImageSmooth(bool smooth) { m_imageSmooth = smooth; }
|
||||||
|
void setImageAutoResize(bool autoResize) { m_imageAutoResize = autoResize; }
|
||||||
void setImageBorderTop(int border) { m_imageBorder.top = border; configureBorderImage(); }
|
void setImageBorderTop(int border) { m_imageBorder.top = border; configureBorderImage(); }
|
||||||
void setImageBorderRight(int border) { m_imageBorder.right = border; configureBorderImage(); }
|
void setImageBorderRight(int border) { m_imageBorder.right = border; configureBorderImage(); }
|
||||||
void setImageBorderBottom(int border) { m_imageBorder.bottom = border; configureBorderImage(); }
|
void setImageBorderBottom(int border) { m_imageBorder.bottom = border; configureBorderImage(); }
|
||||||
|
@ -452,6 +454,7 @@ public:
|
||||||
Color getImageColor() { return m_imageColor; }
|
Color getImageColor() { return m_imageColor; }
|
||||||
bool isImageFixedRatio() { return m_imageFixedRatio; }
|
bool isImageFixedRatio() { return m_imageFixedRatio; }
|
||||||
bool isImageSmooth() { return m_imageSmooth; }
|
bool isImageSmooth() { return m_imageSmooth; }
|
||||||
|
bool isImageAutoResize() { return m_imageAutoResize; }
|
||||||
int getImageBorderTop() { return m_imageBorder.top; }
|
int getImageBorderTop() { return m_imageBorder.top; }
|
||||||
int getImageBorderRight() { return m_imageBorder.right; }
|
int getImageBorderRight() { return m_imageBorder.right; }
|
||||||
int getImageBorderBottom() { return m_imageBorder.bottom; }
|
int getImageBorderBottom() { return m_imageBorder.bottom; }
|
||||||
|
|
|
@ -68,9 +68,10 @@ void UIWidget::parseImageStyle(const OTMLNodePtr& styleNode)
|
||||||
setImageBorderBottom(node->value<int>());
|
setImageBorderBottom(node->value<int>());
|
||||||
else if(node->tag() == "image-border-left")
|
else if(node->tag() == "image-border-left")
|
||||||
setImageBorderLeft(node->value<int>());
|
setImageBorderLeft(node->value<int>());
|
||||||
else if(node->tag() == "image-border") {
|
else if(node->tag() == "image-border")
|
||||||
setImageBorder(node->value<int>());
|
setImageBorder(node->value<int>());
|
||||||
}
|
else if(node->tag() == "image-auto-resize")
|
||||||
|
setImageAutoResize(node->value<bool>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,5 +181,16 @@ void UIWidget::setImageSource(const std::string& source)
|
||||||
m_imageTexture = nullptr;
|
m_imageTexture = nullptr;
|
||||||
else
|
else
|
||||||
m_imageTexture = g_textures.getTexture(source);
|
m_imageTexture = g_textures.getTexture(source);
|
||||||
|
|
||||||
|
if(m_imageTexture && (!m_rect.isValid() || m_imageAutoResize)) {
|
||||||
|
Size size = getSize();
|
||||||
|
Size imageSize = m_imageTexture->getSize();
|
||||||
|
if(size.width() <= 0 || m_imageAutoResize)
|
||||||
|
size.setWidth(imageSize.width());
|
||||||
|
if(size.height() <= 0 || m_imageAutoResize)
|
||||||
|
size.setHeight(imageSize.height());
|
||||||
|
setSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
m_imageMustRecache = true;
|
m_imageMustRecache = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue