fix and changes
* win32 compilation fix * add buttons to miniwindow * dispatcher events fixes * ui fixes
This commit is contained in:
parent
060c1cf8e7
commit
8ea154016b
|
@ -61,7 +61,6 @@ TopPanel
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.left: prev.right
|
anchors.left: prev.right
|
||||||
anchors.right: next.left
|
|
||||||
visible: false
|
visible: false
|
||||||
|
|
||||||
TopMenuButtonsPanel
|
TopMenuButtonsPanel
|
||||||
|
|
|
@ -9,6 +9,7 @@ end
|
||||||
|
|
||||||
function UISplitter:onHoverChange(hovered)
|
function UISplitter:onHoverChange(hovered)
|
||||||
if hovered then
|
if hovered then
|
||||||
|
if g_ui.getDraggingWidget() then return end
|
||||||
if self:getWidth() > self:getHeight() then
|
if self:getWidth() > self:getHeight() then
|
||||||
Mouse.setVerticalCursor()
|
Mouse.setVerticalCursor()
|
||||||
self.vertical = true
|
self.vertical = true
|
||||||
|
@ -16,13 +17,15 @@ function UISplitter:onHoverChange(hovered)
|
||||||
Mouse.setHorizontalCursor()
|
Mouse.setHorizontalCursor()
|
||||||
self.vertical = false
|
self.vertical = false
|
||||||
end
|
end
|
||||||
|
self.hovering = true
|
||||||
if not self:isPressed() then
|
if not self:isPressed() then
|
||||||
Effects.fadeIn(self)
|
Effects.fadeIn(self)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if not self:isPressed() then
|
if not self:isPressed() and self.hovering then
|
||||||
Mouse.restoreCursor()
|
Mouse.restoreCursor()
|
||||||
Effects.fadeOut(self)
|
Effects.fadeOut(self)
|
||||||
|
self.hovering = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -63,6 +66,7 @@ function UISplitter:onMouseRelease(mousePos, mouseButton)
|
||||||
if not self:isHovered() then
|
if not self:isHovered() then
|
||||||
Mouse.restoreCursor()
|
Mouse.restoreCursor()
|
||||||
Effects.fadeOut(self)
|
Effects.fadeOut(self)
|
||||||
|
self.hovering = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Binary file not shown.
After Width: | Height: | Size: 551 B |
|
@ -19,14 +19,45 @@ MiniWindow < UIMiniWindow
|
||||||
height: 24
|
height: 24
|
||||||
image-border-bottom: 1
|
image-border-bottom: 1
|
||||||
|
|
||||||
|
UIButton
|
||||||
|
id: closeButton
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.right: parent.right
|
||||||
|
margin-top: 5
|
||||||
|
margin-right: 5
|
||||||
|
size: 14 14
|
||||||
|
image-source: /game/images/miniwindowbuttons.png
|
||||||
|
image-clip: 14 0 14 14
|
||||||
|
|
||||||
|
$hover:
|
||||||
|
image-clip: 14 14 14 14
|
||||||
|
|
||||||
|
$pressed:
|
||||||
|
image-clip: 14 28 14 14
|
||||||
|
|
||||||
|
UIButton
|
||||||
|
id: minimizeButton
|
||||||
|
anchors.top: closeButton.top
|
||||||
|
anchors.right: closeButton.left
|
||||||
|
margin-right: 3
|
||||||
|
size: 14 14
|
||||||
|
image-source: /game/images/miniwindowbuttons.png
|
||||||
|
image-clip: 0 0 14 14
|
||||||
|
|
||||||
|
$hover:
|
||||||
|
image-clip: 0 14 14 14
|
||||||
|
|
||||||
|
$pressed:
|
||||||
|
image-clip: 0 28 14 14
|
||||||
|
|
||||||
ResizeBorder
|
ResizeBorder
|
||||||
id: bottomResizeBorder
|
id: bottomResizeBorder
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
height: 2
|
height: 1
|
||||||
margin-bottom: 1
|
|
||||||
minimum: 70
|
minimum: 70
|
||||||
|
background: #ffffff88
|
||||||
|
|
||||||
VerticalScrollBar
|
VerticalScrollBar
|
||||||
id: miniwindowScrollBar
|
id: miniwindowScrollBar
|
||||||
|
@ -37,7 +68,6 @@ MiniWindow < UIMiniWindow
|
||||||
margin-top: 22
|
margin-top: 22
|
||||||
margin-right: 2
|
margin-right: 2
|
||||||
margin-bottom: 2
|
margin-bottom: 2
|
||||||
fade-effect: false
|
|
||||||
|
|
||||||
MiniWindowContents < ScrollablePanel
|
MiniWindowContents < ScrollablePanel
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
UIMiniWindow = extends(UIWindow)
|
|
||||||
|
|
||||||
function UIMiniWindow.create()
|
|
||||||
local miniwindow = UIMiniWindow.internalCreate()
|
|
||||||
return miniwindow
|
|
||||||
end
|
|
||||||
|
|
||||||
function UIMiniWindow:onDragEnter(mousePos)
|
|
||||||
local parent = self:getParent()
|
|
||||||
if not parent then return false end
|
|
||||||
|
|
||||||
if parent:getClassName() == 'UIMiniWindowContainer' then
|
|
||||||
local containerParent = parent:getParent()
|
|
||||||
parent:removeChild(self)
|
|
||||||
containerParent:addChild(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
local oldPos = self:getPosition()
|
|
||||||
self.movingReference = { x = mousePos.x - oldPos.x, y = mousePos.y - oldPos.y }
|
|
||||||
self:setPosition(oldPos)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function UIMiniWindow:onDragLeave(droppedWidget, mousePos)
|
|
||||||
-- TODO: drop on other interfaces
|
|
||||||
end
|
|
||||||
|
|
||||||
function UIMiniWindow:onFocusChange(focused)
|
|
||||||
-- miniwindows only raises when its outside MiniWindowContainers
|
|
||||||
if not focused then return end
|
|
||||||
local parent = self:getParent()
|
|
||||||
if parent and parent:getClassName() ~= 'UIMiniWindowContainer' then
|
|
||||||
self:raise()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ UIMiniWindow = extends(UIWindow)
|
||||||
|
|
||||||
function UIMiniWindow.create()
|
function UIMiniWindow.create()
|
||||||
local miniwindow = UIMiniWindow.internalCreate()
|
local miniwindow = UIMiniWindow.internalCreate()
|
||||||
|
miniwindow:setFocusable(false)
|
||||||
return miniwindow
|
return miniwindow
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ void Application::run()
|
||||||
if(!m_initialized)
|
if(!m_initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ticks_t lastPollTicks = g_clock.updateTicks();
|
//ticks_t lastPollTicks = g_clock.updateTicks();
|
||||||
m_stopping = false;
|
m_stopping = false;
|
||||||
m_running = true;
|
m_running = true;
|
||||||
|
|
||||||
|
@ -185,10 +185,10 @@ void Application::run()
|
||||||
|
|
||||||
// poll events every POLL_CYCLE_DELAY
|
// poll events every POLL_CYCLE_DELAY
|
||||||
// this delay exists to avoid massive polling thus increasing framerate
|
// this delay exists to avoid massive polling thus increasing framerate
|
||||||
if(g_clock.ticksElapsed(lastPollTicks) >= m_pollCycleDelay) {
|
//if(g_clock.ticksElapsed(lastPollTicks) >= m_pollCycleDelay) {
|
||||||
poll();
|
poll();
|
||||||
lastPollTicks = g_clock.ticks();
|
// lastPollTicks = g_clock.ticks();
|
||||||
}
|
//}
|
||||||
|
|
||||||
if(m_appFlags & Fw::AppEnableGraphics && g_window.isVisible()) {
|
if(m_appFlags & Fw::AppEnableGraphics && g_window.isVisible()) {
|
||||||
g_graphics.beginRender();
|
g_graphics.beginRender();
|
||||||
|
@ -225,6 +225,7 @@ void Application::poll()
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection::poll();
|
Connection::poll();
|
||||||
|
//g_eventDispatcher.poll(true);
|
||||||
g_eventDispatcher.poll();
|
g_eventDispatcher.poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ void EventDispatcher::flush()
|
||||||
m_scheduledEventList.pop();
|
m_scheduledEventList.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::poll()
|
void EventDispatcher::poll(bool allEvents)
|
||||||
{
|
{
|
||||||
while(!m_scheduledEventList.empty()) {
|
while(!m_scheduledEventList.empty()) {
|
||||||
ScheduledEventPtr scheduledEvent = m_scheduledEventList.top();
|
ScheduledEventPtr scheduledEvent = m_scheduledEventList.top();
|
||||||
|
@ -45,12 +45,16 @@ void EventDispatcher::poll()
|
||||||
scheduledEvent->execute();
|
scheduledEvent->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pollEventsSize = m_eventList.size();
|
do {
|
||||||
for(int i=0;i<m_pollEventsSize;++i) {
|
m_pollEventsSize = m_eventList.size();
|
||||||
EventPtr event = m_eventList.front();
|
if(m_pollEventsSize == 0)
|
||||||
m_eventList.pop_front();
|
break;
|
||||||
event->execute();
|
for(int i=0;i<m_pollEventsSize;++i) {
|
||||||
}
|
EventPtr event = m_eventList.front();
|
||||||
|
m_eventList.pop_front();
|
||||||
|
event->execute();
|
||||||
|
}
|
||||||
|
} while(allEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScheduledEventPtr EventDispatcher::scheduleEvent(const SimpleCallback& callback, int delay)
|
ScheduledEventPtr EventDispatcher::scheduleEvent(const SimpleCallback& callback, int delay)
|
||||||
|
|
|
@ -73,7 +73,7 @@ class EventDispatcher
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void flush();
|
void flush();
|
||||||
void poll();
|
void poll(bool allEvents = false);
|
||||||
|
|
||||||
EventPtr addEvent(const SimpleCallback& callback, bool pushFront = false);
|
EventPtr addEvent(const SimpleCallback& callback, bool pushFront = false);
|
||||||
ScheduledEventPtr scheduleEvent(const SimpleCallback& callback, int delay);
|
ScheduledEventPtr scheduleEvent(const SimpleCallback& callback, int delay);
|
||||||
|
|
|
@ -49,7 +49,6 @@ void Graphics::init()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
|
|
||||||
m_emptyTexture = TexturePtr(new Texture);
|
m_emptyTexture = TexturePtr(new Texture);
|
||||||
|
|
||||||
|
@ -112,6 +111,16 @@ void Graphics::beginRender()
|
||||||
|
|
||||||
void Graphics::endRender()
|
void Graphics::endRender()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
// this is a simple blur effect
|
||||||
|
static Timer timer;
|
||||||
|
if(timer.ticksElapsed() >= 20) {
|
||||||
|
glAccum(GL_MULT, 0.8);
|
||||||
|
glAccum(GL_ACCUM, 0.2);
|
||||||
|
timer.restart();
|
||||||
|
}
|
||||||
|
glAccum(GL_RETURN, 1);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::beginClipping(const Rect& clipRect)
|
void Graphics::beginClipping(const Rect& clipRect)
|
||||||
|
@ -126,7 +135,7 @@ void Graphics::beginClipping(const Rect& clipRect)
|
||||||
glColorMask(0, 0, 0, 0);
|
glColorMask(0, 0, 0, 0);
|
||||||
g_painter.drawFilledRect(clipRect);
|
g_painter.drawFilledRect(clipRect);
|
||||||
|
|
||||||
// set stencil buffer for clippig
|
// set stencil buffer for clipping
|
||||||
glColorMask(1, 1, 1, 1);
|
glColorMask(1, 1, 1, 1);
|
||||||
glStencilFunc(GL_EQUAL, 1, 1);
|
glStencilFunc(GL_EQUAL, 1, 1);
|
||||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||||
|
|
|
@ -312,6 +312,7 @@ void WIN32Window::internalChooseGLVisual()
|
||||||
0, // Reserved
|
0, // Reserved
|
||||||
0, 0, 0 }; // Layer Masks Ignored
|
0, 0, 0 }; // Layer Masks Ignored
|
||||||
|
|
||||||
|
pixelFormat = ChoosePixelFormat(m_deviceContext, &pfd);
|
||||||
if(!pixelFormat)
|
if(!pixelFormat)
|
||||||
logFatal("Could not find a suitable pixel format");
|
logFatal("Could not find a suitable pixel format");
|
||||||
|
|
||||||
|
|
|
@ -81,11 +81,11 @@ void UIAnchorLayout::removeWidget(const UIWidgetPtr& widget)
|
||||||
removeAnchors(widget);
|
removeAnchors(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIAnchorLayout::updateWidget(const UIWidgetPtr& widget, UIAnchorGroup& anchorGroup)
|
bool UIAnchorLayout::updateWidget(const UIWidgetPtr& widget, UIAnchorGroup& anchorGroup)
|
||||||
{
|
{
|
||||||
UIWidgetPtr parentWidget = getParentWidget();
|
UIWidgetPtr parentWidget = getParentWidget();
|
||||||
if(!parentWidget)
|
if(!parentWidget)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
Rect newRect = widget->getRect();
|
Rect newRect = widget->getRect();
|
||||||
bool verticalMoved = false;
|
bool verticalMoved = false;
|
||||||
|
@ -214,12 +214,17 @@ void UIAnchorLayout::updateWidget(const UIWidgetPtr& widget, UIAnchorGroup& anch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
widget->setRect(newRect);
|
bool changed = false;
|
||||||
|
if(widget->setRect(newRect))
|
||||||
|
changed = true;
|
||||||
anchorGroup.setUpdated(true);
|
anchorGroup.setUpdated(true);
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIAnchorLayout::internalUpdate()
|
bool UIAnchorLayout::internalUpdate()
|
||||||
{
|
{
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
// reset all anchors groups update state
|
// reset all anchors groups update state
|
||||||
for(auto& it : m_anchorsGroups) {
|
for(auto& it : m_anchorsGroups) {
|
||||||
UIAnchorGroup& anchorGroup = it.second;
|
UIAnchorGroup& anchorGroup = it.second;
|
||||||
|
@ -230,7 +235,11 @@ void UIAnchorLayout::internalUpdate()
|
||||||
for(auto& it : m_anchorsGroups) {
|
for(auto& it : m_anchorsGroups) {
|
||||||
const UIWidgetPtr& widget = it.first;
|
const UIWidgetPtr& widget = it.first;
|
||||||
UIAnchorGroup& anchorGroup = it.second;
|
UIAnchorGroup& anchorGroup = it.second;
|
||||||
if(!anchorGroup.isUpdated())
|
if(!anchorGroup.isUpdated()) {
|
||||||
updateWidget(widget, anchorGroup);
|
if(updateWidget(widget, anchorGroup))
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,10 +75,10 @@ public:
|
||||||
UIAnchorLayoutPtr asUIAnchorLayout() { return std::static_pointer_cast<UIAnchorLayout>(shared_from_this()); }
|
UIAnchorLayoutPtr asUIAnchorLayout() { return std::static_pointer_cast<UIAnchorLayout>(shared_from_this()); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void internalUpdate();
|
bool internalUpdate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateWidget(const UIWidgetPtr& widget, UIAnchorGroup& anchorGroup);
|
bool updateWidget(const UIWidgetPtr& widget, UIAnchorGroup& anchorGroup);
|
||||||
std::map<UIWidgetPtr, UIAnchorGroup> m_anchorsGroups;
|
std::map<UIWidgetPtr, UIAnchorGroup> m_anchorsGroups;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,9 @@ void UIGridLayout::addWidget(const UIWidgetPtr& widget)
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIGridLayout::internalUpdate()
|
bool UIGridLayout::internalUpdate()
|
||||||
{
|
{
|
||||||
|
bool changed = false;
|
||||||
UIWidgetPtr parentWidget = getParentWidget();
|
UIWidgetPtr parentWidget = getParentWidget();
|
||||||
UIWidgetList widgets = parentWidget->getChildren();
|
UIWidgetList widgets = parentWidget->getChildren();
|
||||||
|
|
||||||
|
@ -80,12 +81,15 @@ void UIGridLayout::internalUpdate()
|
||||||
Point virtualPos = Point(column * (m_cellSize.width() + m_cellSpacing), line * (m_cellSize.height() + m_cellSpacing));
|
Point virtualPos = Point(column * (m_cellSize.width() + m_cellSpacing), line * (m_cellSize.height() + m_cellSpacing));
|
||||||
Point pos = topLeft + virtualPos;
|
Point pos = topLeft + virtualPos;
|
||||||
|
|
||||||
widget->setRect(Rect(pos, m_cellSize));
|
if(widget->setRect(Rect(pos, m_cellSize)))
|
||||||
|
changed = true;
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
if(index >= m_numColumns * m_numLines)
|
if(index >= m_numColumns * m_numLines)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
virtual UIGridLayoutPtr asUIGridLayout() { return nullptr; }
|
virtual UIGridLayoutPtr asUIGridLayout() { return nullptr; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void internalUpdate();
|
bool internalUpdate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Size m_cellSize;
|
Size m_cellSize;
|
||||||
|
|
|
@ -35,16 +35,17 @@ void UIHorizontalLayout::applyStyle(const OTMLNodePtr& styleNode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIHorizontalLayout::internalUpdate()
|
bool UIHorizontalLayout::internalUpdate()
|
||||||
{
|
{
|
||||||
UIWidgetPtr parentWidget = getParentWidget();
|
UIWidgetPtr parentWidget = getParentWidget();
|
||||||
if(!parentWidget)
|
if(!parentWidget)
|
||||||
return;
|
return false;
|
||||||
UIWidgetList widgets = parentWidget->getChildren();
|
UIWidgetList widgets = parentWidget->getChildren();
|
||||||
|
|
||||||
if(m_alignRight)
|
if(m_alignRight)
|
||||||
std::reverse(widgets.begin(), widgets.end());
|
std::reverse(widgets.begin(), widgets.end());
|
||||||
|
|
||||||
|
bool changed = false;
|
||||||
Rect clippingRect = parentWidget->getClippingRect();
|
Rect clippingRect = parentWidget->getClippingRect();
|
||||||
Point pos = (m_alignRight) ? clippingRect.topRight() : clippingRect.topLeft();
|
Point pos = (m_alignRight) ? clippingRect.topRight() : clippingRect.topLeft();
|
||||||
int prefferedWidth = 0;
|
int prefferedWidth = 0;
|
||||||
|
@ -70,7 +71,8 @@ void UIHorizontalLayout::internalUpdate()
|
||||||
pos.y = clippingRect.top() + (clippingRect.height() - size.height())/2;
|
pos.y = clippingRect.top() + (clippingRect.height() - size.height())/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
widget->setRect(Rect(pos - parentWidget->getVirtualOffset(), size));
|
if(widget->setRect(Rect(pos - parentWidget->getVirtualOffset(), size)))
|
||||||
|
changed = true;
|
||||||
|
|
||||||
gap = (m_alignRight) ? -widget->getMarginLeft() : (widget->getWidth() + widget->getMarginRight());
|
gap = (m_alignRight) ? -widget->getMarginLeft() : (widget->getWidth() + widget->getMarginRight());
|
||||||
gap += m_spacing;
|
gap += m_spacing;
|
||||||
|
@ -87,4 +89,6 @@ void UIHorizontalLayout::internalUpdate()
|
||||||
parentWidget->setWidth(prefferedWidth);
|
parentWidget->setWidth(prefferedWidth);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
UIHorizontalLayoutPtr asUIHorizontalLayout() { return std::static_pointer_cast<UIHorizontalLayout>(shared_from_this()); }
|
UIHorizontalLayoutPtr asUIHorizontalLayout() { return std::static_pointer_cast<UIHorizontalLayout>(shared_from_this()); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void internalUpdate();
|
bool internalUpdate();
|
||||||
|
|
||||||
Boolean<false> m_alignRight;
|
Boolean<false> m_alignRight;
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,7 +38,7 @@ void UILayout::update()
|
||||||
m_updating = true;
|
m_updating = true;
|
||||||
internalUpdate();
|
internalUpdate();
|
||||||
if(UIWidgetPtr parentWidget = getParentWidget())
|
if(UIWidgetPtr parentWidget = getParentWidget())
|
||||||
parentWidget->onLayoutUpdate();
|
parentWidget->onLayoutUpdate();
|
||||||
m_updating = false;
|
m_updating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ public:
|
||||||
virtual UIGridLayoutPtr asUIGridLayout() { return nullptr; }
|
virtual UIGridLayoutPtr asUIGridLayout() { return nullptr; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void internalUpdate() = 0;
|
virtual bool internalUpdate() = 0;
|
||||||
|
|
||||||
Boolean<false> m_updateDisabled;
|
Boolean<false> m_updateDisabled;
|
||||||
Boolean<false> m_updating;
|
Boolean<false> m_updating;
|
||||||
|
|
|
@ -34,11 +34,13 @@ void UIVerticalLayout::applyStyle(const OTMLNodePtr& styleNode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIVerticalLayout::internalUpdate()
|
bool UIVerticalLayout::internalUpdate()
|
||||||
{
|
{
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
UIWidgetPtr parentWidget = getParentWidget();
|
UIWidgetPtr parentWidget = getParentWidget();
|
||||||
if(!parentWidget)
|
if(!parentWidget)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
UIWidgetList widgets = parentWidget->getChildren();
|
UIWidgetList widgets = parentWidget->getChildren();
|
||||||
|
|
||||||
|
@ -70,7 +72,8 @@ void UIVerticalLayout::internalUpdate()
|
||||||
pos.x = clippingRect.left() + (clippingRect.width() - size.width())/2;
|
pos.x = clippingRect.left() + (clippingRect.width() - size.width())/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
widget->setRect(Rect(pos - parentWidget->getVirtualOffset(), size));
|
if(widget->setRect(Rect(pos - parentWidget->getVirtualOffset(), size)))
|
||||||
|
changed = true;
|
||||||
|
|
||||||
gap = (m_alignBottom) ? -widget->getMarginTop() : (widget->getHeight() + widget->getMarginBottom());
|
gap = (m_alignBottom) ? -widget->getMarginTop() : (widget->getHeight() + widget->getMarginBottom());
|
||||||
gap += m_spacing;
|
gap += m_spacing;
|
||||||
|
@ -87,4 +90,6 @@ void UIVerticalLayout::internalUpdate()
|
||||||
parentWidget->setHeight(prefferedHeight);
|
parentWidget->setHeight(prefferedHeight);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
UIVerticalLayoutPtr asUIVerticalLayout() { return std::static_pointer_cast<UIVerticalLayout>(shared_from_this()); }
|
UIVerticalLayoutPtr asUIVerticalLayout() { return std::static_pointer_cast<UIVerticalLayout>(shared_from_this()); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void internalUpdate();
|
bool internalUpdate();
|
||||||
|
|
||||||
Boolean<false> m_alignBottom;
|
Boolean<false> m_alignBottom;
|
||||||
};
|
};
|
||||||
|
|
|
@ -726,16 +726,16 @@ void UIWidget::setLayout(const UILayoutPtr& layout)
|
||||||
m_layout = layout;
|
m_layout = layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIWidget::setRect(const Rect& rect)
|
bool UIWidget::setRect(const Rect& rect)
|
||||||
{
|
{
|
||||||
if(rect.width() > 8192 || rect.height() > 8192) {
|
if(rect.width() > 8192 || rect.height() > 8192) {
|
||||||
logError("attempt to set huge rect size (", rect,") for ", m_id);
|
logError("attempt to set huge rect size (", rect,") for ", m_id);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
// only update if the rect really changed
|
// only update if the rect really changed
|
||||||
Rect oldRect = m_rect;
|
Rect oldRect = m_rect;
|
||||||
if(rect == oldRect)
|
if(rect == oldRect)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
m_rect = rect;
|
m_rect = rect;
|
||||||
|
|
||||||
|
@ -752,6 +752,8 @@ void UIWidget::setRect(const Rect& rect)
|
||||||
});
|
});
|
||||||
m_updateEventScheduled = true;
|
m_updateEventScheduled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIWidget::setStyle(const std::string& styleName)
|
void UIWidget::setStyle(const std::string& styleName)
|
||||||
|
@ -978,6 +980,9 @@ UIWidgetPtr UIWidget::getChildById(const std::string& childId)
|
||||||
|
|
||||||
UIWidgetPtr UIWidget::getChildByPos(const Point& childPos)
|
UIWidgetPtr UIWidget::getChildByPos(const Point& childPos)
|
||||||
{
|
{
|
||||||
|
if(!containsChildPoint(childPos))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
for(auto it = m_children.rbegin(); it != m_children.rend(); ++it) {
|
for(auto it = m_children.rbegin(); it != m_children.rend(); ++it) {
|
||||||
const UIWidgetPtr& child = (*it);
|
const UIWidgetPtr& child = (*it);
|
||||||
if(child->isExplicitlyVisible() && child->containsPoint(childPos))
|
if(child->isExplicitlyVisible() && child->containsPoint(childPos))
|
||||||
|
@ -1010,6 +1015,9 @@ UIWidgetPtr UIWidget::recursiveGetChildById(const std::string& id)
|
||||||
|
|
||||||
UIWidgetPtr UIWidget::recursiveGetChildByPos(const Point& childPos)
|
UIWidgetPtr UIWidget::recursiveGetChildByPos(const Point& childPos)
|
||||||
{
|
{
|
||||||
|
if(!containsChildPoint(childPos))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
for(auto it = m_children.rbegin(); it != m_children.rend(); ++it) {
|
for(auto it = m_children.rbegin(); it != m_children.rend(); ++it) {
|
||||||
const UIWidgetPtr& child = (*it);
|
const UIWidgetPtr& child = (*it);
|
||||||
if(child->isExplicitlyVisible() && child->containsPoint(childPos)) {
|
if(child->isExplicitlyVisible() && child->containsPoint(childPos)) {
|
||||||
|
@ -1026,6 +1034,9 @@ UIWidgetPtr UIWidget::recursiveGetChildByPos(const Point& childPos)
|
||||||
UIWidgetList UIWidget::recursiveGetChildrenByPos(const Point& childPos)
|
UIWidgetList UIWidget::recursiveGetChildrenByPos(const Point& childPos)
|
||||||
{
|
{
|
||||||
UIWidgetList children;
|
UIWidgetList children;
|
||||||
|
if(!containsChildPoint(childPos))
|
||||||
|
return children;
|
||||||
|
|
||||||
for(auto it = m_children.rbegin(); it != m_children.rend(); ++it) {
|
for(auto it = m_children.rbegin(); it != m_children.rend(); ++it) {
|
||||||
const UIWidgetPtr& child = (*it);
|
const UIWidgetPtr& child = (*it);
|
||||||
if(child->isExplicitlyVisible() && child->containsPoint(childPos)) {
|
if(child->isExplicitlyVisible() && child->containsPoint(childPos)) {
|
||||||
|
@ -1342,8 +1353,9 @@ bool UIWidget::onMousePress(const Point& mousePos, Fw::MouseButton button)
|
||||||
m_lastClickPosition = mousePos;
|
m_lastClickPosition = mousePos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasLuaField("onMousePress"))
|
if(hasLuaField("onMousePress")) {
|
||||||
return callLuaField<bool>("onMousePress", mousePos, button);
|
return callLuaField<bool>("onMousePress", mousePos, button);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ public:
|
||||||
void setId(const std::string& id);
|
void setId(const std::string& id);
|
||||||
void setParent(const UIWidgetPtr& parent);
|
void setParent(const UIWidgetPtr& parent);
|
||||||
void setLayout(const UILayoutPtr& layout);
|
void setLayout(const UILayoutPtr& layout);
|
||||||
void setRect(const Rect& rect);
|
bool setRect(const Rect& rect);
|
||||||
void setStyle(const std::string& styleName);
|
void setStyle(const std::string& styleName);
|
||||||
void setStyleFromNode(const OTMLNodePtr& styleNode);
|
void setStyleFromNode(const OTMLNodePtr& styleNode);
|
||||||
void setEnabled(bool enabled);
|
void setEnabled(bool enabled);
|
||||||
|
@ -240,6 +240,7 @@ public:
|
||||||
bool isDestroyed() { return m_destroyed; }
|
bool isDestroyed() { return m_destroyed; }
|
||||||
|
|
||||||
bool hasChildren() { return m_children.size() > 0; }
|
bool hasChildren() { return m_children.size() > 0; }
|
||||||
|
bool containsChildPoint(const Point& point) { return getClippingRect().contains(point); }
|
||||||
bool containsPoint(const Point& point) { return m_rect.contains(point); }
|
bool containsPoint(const Point& point) { return m_rect.contains(point); }
|
||||||
|
|
||||||
std::string getId() { return m_id; }
|
std::string getId() { return m_id; }
|
||||||
|
|
Loading…
Reference in New Issue