From 88eee1adf0d2be442255477a6aea51efd20bf78d Mon Sep 17 00:00:00 2001 From: Paul Squires Date: Thu, 12 Sep 2024 02:25:24 -0230 Subject: [PATCH 1/3] Add missing vmax_size functionalities (#424) --- lib/include/elements/element/size.hpp | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/lib/include/elements/element/size.hpp b/lib/include/elements/element/size.hpp index a1b0b3e6..a03af0b7 100644 --- a/lib/include/elements/element/size.hpp +++ b/lib/include/elements/element/size.hpp @@ -483,6 +483,56 @@ namespace cycfi::elements ctx.bounds.width(_size); } + //////////////////////////////////////////////////////////////////////////// + template + class vmax_size_element : public proxy + { + public: + + using base_type = proxy; + + vmax_size_element(float size, Subject subject); + + view_limits limits(basic_context const& ctx) const override; + void prepare_subject(context& ctx) override; + + void vmax_size(float size) { _size = size; } + float vmax_size() const { return _size; } + + private: + + float _size; + }; + + template + inline vmax_size_element::vmax_size_element(float size, Subject subject) + : base_type(std::move(subject)) + , _size(size) + {} + + template + inline vmax_size_element> + vmax_size(float size, Subject&& subject) + { + return {size, std::forward(subject)}; + } + + template + inline view_limits vmax_size_element::limits(basic_context const& ctx) const + { + auto e_limits = this->subject().limits(ctx); + float size_y = _size; + clamp(size_y, e_limits.min.y, e_limits.max.y); + return {{e_limits.min.x, e_limits.min.y}, {size_y, e_limits.max.y}}; + } + + template + inline void vmax_size_element::prepare_subject(context& ctx) + { + if (ctx.bounds.height() > _size) + ctx.bounds.height(_size); + } + //////////////////////////////////////////////////////////////////////////// // Stretch elements //////////////////////////////////////////////////////////////////////////// From b25c7a4cadfecad947c90bd5dd7dd338b767459b Mon Sep 17 00:00:00 2001 From: zhkkjun <50400973+zhkkjun@users.noreply.github.com> Date: Sun, 27 Oct 2024 18:12:51 +0800 Subject: [PATCH 2/3] Fixed a non-resizable window issue[#428] (#429) Non-resizable window appears with white borders when they are created and moved. I found that the reason is that the code does not notify the system when the border style of the window's frame is changed. --- lib/host/windows/window.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/host/windows/window.cpp b/lib/host/windows/window.cpp index e4b67769..5f463ebe 100644 --- a/lib/host/windows/window.cpp +++ b/lib/host/windows/window.cpp @@ -43,20 +43,23 @@ namespace cycfi::elements void disable_minimize(HWND hwnd) { SetWindowLongW(hwnd, GWL_STYLE, - GetWindowLongW(hwnd, GWL_STYLE) & ~WS_MINIMIZEBOX); + GetWindowLongW(hwnd, GWL_STYLE) & ~WS_MINIMIZEBOX); + SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); } + [[maybe_unused]] void disable_maximize(HWND hwnd) { SetWindowLongW(hwnd, GWL_STYLE, - GetWindowLongW(hwnd, GWL_STYLE) & ~WS_MAXIMIZEBOX); + GetWindowLongW(hwnd, GWL_STYLE) & ~WS_MAXIMIZEBOX); + SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); } void disable_resize(HWND hwnd) { SetWindowLongW(hwnd, GWL_STYLE, - GetWindowLongW(hwnd, GWL_STYLE) & ~WS_SIZEBOX); - disable_maximize(hwnd); + GetWindowLongW(hwnd, GWL_STYLE) & ~WS_SIZEBOX & ~WS_MAXIMIZEBOX); + SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); } LRESULT on_close(window* win) From d5000b2ac5d400c982f115a2b90952113b3cfec8 Mon Sep 17 00:00:00 2001 From: djowel Date: Sun, 27 Oct 2024 18:26:00 +0800 Subject: [PATCH 3/3] Format tweaks --- lib/host/windows/window.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/host/windows/window.cpp b/lib/host/windows/window.cpp index 5f463ebe..ba727f40 100644 --- a/lib/host/windows/window.cpp +++ b/lib/host/windows/window.cpp @@ -43,7 +43,7 @@ namespace cycfi::elements void disable_minimize(HWND hwnd) { SetWindowLongW(hwnd, GWL_STYLE, - GetWindowLongW(hwnd, GWL_STYLE) & ~WS_MINIMIZEBOX); + GetWindowLongW(hwnd, GWL_STYLE) & ~WS_MINIMIZEBOX); SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); } @@ -51,14 +51,14 @@ namespace cycfi::elements void disable_maximize(HWND hwnd) { SetWindowLongW(hwnd, GWL_STYLE, - GetWindowLongW(hwnd, GWL_STYLE) & ~WS_MAXIMIZEBOX); + GetWindowLongW(hwnd, GWL_STYLE) & ~WS_MAXIMIZEBOX); SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); } void disable_resize(HWND hwnd) { SetWindowLongW(hwnd, GWL_STYLE, - GetWindowLongW(hwnd, GWL_STYLE) & ~WS_SIZEBOX & ~WS_MAXIMIZEBOX); + GetWindowLongW(hwnd, GWL_STYLE) & ~WS_SIZEBOX & ~WS_MAXIMIZEBOX); SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); }