commit 8b04e4ded8e23b9399a7ff14e2754807abf0dafb
parent 00bb998e4b557ed62e82a5ee39e8743f5851e4f2
Author: cfillion <cfillion@users.noreply.github.com>
Date: Fri, 26 May 2017 16:54:24 -0400
about: fix positionning of link buttons on resize
Position was wrong if the window has been resized prior to loading the contents.
Diffstat:
3 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/src/about.cpp b/src/about.cpp
@@ -214,18 +214,19 @@ void About::setMetadata(const Metadata *metadata, const bool substitution)
if(!m_links.count(control)) {
HWND handle = getControl(control);
-
- SetWindowPos(handle, nullptr, rect.left, rect.top, 0, 0,
- SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
-
+ setAnchorPos(handle, &rect.left, nullptr, &rect.right);
show(handle);
- setAnchor(handle, AnchorTop | AnchorBottom);
+
rect.left += shift;
+ rect.right += shift;
+
m_links[control] = {};
}
m_links[control].push_back(&pair.second);
}
+
+ onResize(); // update the position of link buttons
}
void About::setAction(const string &label)
diff --git a/src/dialog.cpp b/src/dialog.cpp
@@ -367,10 +367,29 @@ void Dialog::setAnchor(HWND handle, const int flags)
const float right = (float)min(1, flags & AnchorRight);
const float bottom = (float)min(1, flags & AnchorBottom);
- m_resizer.remove_itemhwnd(handle);
m_resizer.init_itemhwnd(handle, left, top, right, bottom);
}
+void Dialog::setAnchorPos(HWND handle,
+ const LONG *left, const LONG *top, const LONG *right, const LONG *bottom)
+{
+ auto *item = m_resizer.get_itembywnd(handle);
+
+ if(!item)
+ return;
+
+ RECT *rect = &item->orig;
+
+ if(left)
+ rect->left = *left;
+ if(top)
+ rect->top = *top;
+ if(right)
+ rect->right = *right;
+ if(bottom)
+ rect->bottom = *bottom;
+}
+
void Dialog::restoreState(Serializer::Data &data)
{
if(data.size() < 2)
diff --git a/src/dialog.hpp b/src/dialog.hpp
@@ -103,6 +103,8 @@ public:
HWND getControl(int idc);
std::string getText(HWND);
void setAnchor(HWND, int flags);
+ void setAnchorPos(HWND, const LONG *left = nullptr, const LONG *top = nullptr,
+ const LONG *right = nullptr, const LONG *bottom = nullptr);
void setMinimumSize(const POINT &p) { m_minimumSize = p; }
void restoreState(Serializer::Data &);