From 7b087e296a881d23a7c16782bcb59dc7c3fba56d Mon Sep 17 00:00:00 2001 From: Ysm-04 Date: Tue, 4 Nov 2025 16:48:53 +0800 Subject: [PATCH] feat: add a new awesome feature --- CHANGELOG.en.md | 18 +++++ CHANGELOG.md | 21 +++++ README.en.md | 9 ++- README.md | 12 +-- aV2.1.0Realse包地址.txt | 1 - .../新建 文本文档.txt | 1 - .../新建 文本文档.txt | 1 - include/StellarX/Canvas.h | 1 + include/StellarX/Control.h | 11 +-- include/StellarX/Dialog.h | 10 ++- include/StellarX/StellarX.h | 2 +- include/StellarX/TabControl.h | 2 + include/StellarX/label.h | 6 +- include/StellarX/window.h | 2 + src/Button.cpp | 10 +-- src/Canvas.cpp | 20 ++++- src/Control.cpp | 6 +- src/Dialog.cpp | 78 ++++++++++++++----- src/TabControl.cpp | 33 +++++++- src/table.cpp | 2 +- src/textBox.cpp | 2 +- src/window.cpp | 20 ++++- 22 files changed, 210 insertions(+), 58 deletions(-) delete mode 100644 aV2.1.0Realse包地址.txt delete mode 100644 aV2.2.0由于更新了重绘机制和事件传递,所以导致部分控件频闪(平凡重绘)/新建 文本文档.txt delete mode 100644 a正在加急修正,如要使用可先下载V2.1.0的lib文件使用/新建 文本文档.txt diff --git a/CHANGELOG.en.md b/CHANGELOG.en.md index 9cbe808..f9ffb7e 100644 --- a/CHANGELOG.en.md +++ b/CHANGELOG.en.md @@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [中文文档](CHANGELOG.md) +## [v2.2.1] - 2025-11-04 + +==This release is a hotfix for v2.2.0== + +### ✅ Fixed + +- The `TabControl` class overrode the base class's `setDirty` method to ensure synchronized update status between the tab and its page list. +- The `Canvas` container, special container `TabControl`, and dialog `Dialog` overrode the `requestRepaint` method. When control bubbling propagates upward, the parent pointer is passed. Repaint requests now only bubble up one level to the parent and no longer propagate to the root. Furthermore, the entire parent container is no longer repainted; instead, the parent container repaints only the dirtied child controls, avoiding flickering caused by frequent repaints of the entire container. +- The `saveBackground` and `restoreBackground` methods were overridden in `Dialog` to ensure no border remnants remain after the dialog is closed. + +### ⚙️ Changed + +- Completely disabled copy and move semantics for the `Control` class: + `Control(const Control&) = delete;` + `Control& operator=(const Control&) = delete;` + `Control(Control&&) = delete;` + `Control& operator=(Control&&) = delete;` + ## [v2.2.0] - 2025-11-02 **Highlights**: Officially introduces the TabControl, enhances control show/hide and layout responsiveness, and refines the text styling mechanism; fixes several UI details to improve stability. diff --git a/CHANGELOG.md b/CHANGELOG.md index 097a0b3..b0a8cc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,27 @@ StellarX 项目所有显著的变化都将被记录在这个文件中。 [English document](CHANGELOG.en.md) +## [v2.2.1] - 2025 - 11 - 4 + +==此版本为v2.2.0的修复版本== + +### ✅ 修复 + +- `TabControl`类重写了基类的`setDirty`方法保证页签+页列表同步更新 + + 状态 + +- `Canvas`容器和特殊容器`TabControl`以及对话框`Dialog`重写`requestRepaint`方法,控件向上冒泡时传递父指针,请求重绘时只向上到父一级,不再传递到根。并且不再重绘整个父容器,而是由父容器重绘标脏的子控件,避免了频繁真个容器重绘导致的频闪 + +- `Dialog`中重写了`saveBackground`和`restBackground`方法,保证对话框关闭后不会有边框残留 + +### ⚙️ 变更 + +- 彻底禁用`Control`的移动构造`Control(const Control&) = delete;` + `Control& operator=(const Control&) = delete;` + `Control(Control&&) = delete;` + `Control& operator=(Control&&) = delete;` + ## [v2.2.0] - 2025-11-02 **重点**:正式引入选项卡控件(TabControl),增强控件显隐与布局响应能力,并完善文本样式机制;修复若干UI细节问题以提升稳定性。 diff --git a/README.en.md b/README.en.md index cc8cfef..9c07929 100644 --- a/README.en.md +++ b/README.en.md @@ -25,7 +25,14 @@ This is a **teaching-grade and tooling-grade** framework that helps developers u ------ -## 🆕 What’s new in v2.2.0 +## **🆕 v2.2.1 (Hotfix for v2.2.0)** + +- Addressed a flickering issue that occurred when using the Canvas and TabControl containers. +- Fixed issues where border remnants and functional buttons could persist after closing a Dialog. + +For details, please refer to the [CHANGELOG.en](CHANGELOG.en.md). + +## What’s new in v2.2.0 - **New TabControl for multi-page tabbed UIs:** With `TabControl`, it’s easy to create a tabbed layout. Tabs can be arranged on the top, bottom, left, or right, and clicking switches the displayed page. Suitable for settings panels and multi-view switching. - **Enhanced control show/hide and resize responsiveness:** All controls now share a unified interface (`setIsVisible`) to toggle visibility. When a container control is hidden, its child controls automatically hide/show with it. Meanwhile, we introduce `onWindowResize` for controls to respond to window size changes so elements update in sync after resizing, eliminating artifacts or misalignment. diff --git a/README.md b/README.md index 5639883..4eb42cc 100644 --- a/README.md +++ b/README.md @@ -25,15 +25,17 @@ --- -==由于2.2.0更新了重绘机制和事件传递,导致部分控件频闪,正在加急修改,可先使用2.1.0的Releas包== +## 🆕v2.2.1(v2.2.0修复版) -从 [Releases](https://github.com/Ysm-04/StellarX/releases/latest) 获取预编译包。 +- 解决了使用Canvas和TabControl容器时,出现频闪问题 ---- +- 修复了Dialog对话框关闭时概率出边边框残留和功能按钮残留问题 + + 详情参考[更新日志](CHANGELOG.md) -## 🆕 v2.2.0 有何变化 +## V2.2.0 有何变化 - **新增 TabControl 控件,实现多页面选项卡界面:** 通过 `TabControl` 可以轻松创建选项卡式布局,支持页签在上下左右排列、点击切换显示不同内容页面。适用于设置面板、多视图切换等场景。 - **控件显隐与布局响应能力增强:** 现在所有控件都可以使用统一接口动态隐藏或显示(`setIsVisible`),容器控件隐藏时其内部子控件会自动随之隐藏/显示。与此同时,引入控件对窗口尺寸变化的响应机制(`onWindowResize`),窗口拉伸后界面各元素可协调更新,杜绝拉伸过程中出现残影或错位。 @@ -297,5 +299,5 @@ MIT(见 `LICENSE`)。 ## 📞 支持与反馈 - 查看 [examples/](examples/) -- 查阅 [更新日志](CHANGELOG.md / CHANGELOG.en.md) +- 查阅 [更新日志](CHANGELOG.md)[CHANGELOG](CHANGELOG.en.md) - 在 GitHub 提交 Issue \ No newline at end of file diff --git a/aV2.1.0Realse包地址.txt b/aV2.1.0Realse包地址.txt deleted file mode 100644 index 4a838ed..0000000 --- a/aV2.1.0Realse包地址.txt +++ /dev/null @@ -1 +0,0 @@ -https://github.com/Ysm-04/StellarX/releases/tag/v2.1.0%E7%89%88 \ No newline at end of file diff --git a/aV2.2.0由于更新了重绘机制和事件传递,所以导致部分控件频闪(平凡重绘)/新建 文本文档.txt b/aV2.2.0由于更新了重绘机制和事件传递,所以导致部分控件频闪(平凡重绘)/新建 文本文档.txt deleted file mode 100644 index 748099d..0000000 --- a/aV2.2.0由于更新了重绘机制和事件传递,所以导致部分控件频闪(平凡重绘)/新建 文本文档.txt +++ /dev/null @@ -1 +0,0 @@ -11111111 \ No newline at end of file diff --git a/a正在加急修正,如要使用可先下载V2.1.0的lib文件使用/新建 文本文档.txt b/a正在加急修正,如要使用可先下载V2.1.0的lib文件使用/新建 文本文档.txt deleted file mode 100644 index 9d07aa0..0000000 --- a/a正在加急修正,如要使用可先下载V2.1.0的lib文件使用/新建 文本文档.txt +++ /dev/null @@ -1 +0,0 @@ -111 \ No newline at end of file diff --git a/include/StellarX/Canvas.h b/include/StellarX/Canvas.h index 359a87c..0b5003a 100644 --- a/include/StellarX/Canvas.h +++ b/include/StellarX/Canvas.h @@ -60,6 +60,7 @@ public: void setIsVisible(bool visible) override; void setDirty(bool dirty) override; void onWindowResize() override; + void requestRepaint(Control* parent)override; //获取子控件列表 std::vector>& getControls() { return controls; } private: diff --git a/include/StellarX/Control.h b/include/StellarX/Control.h index e09544b..3e13f1e 100644 --- a/include/StellarX/Control.h +++ b/include/StellarX/Control.h @@ -61,8 +61,8 @@ protected: Control(const Control&) = delete; Control& operator=(const Control&) = delete; - Control(Control&&) = default; - Control& operator=(Control&&) = default; + Control(Control&&) = delete; + Control& operator=(Control&&) = delete; Control() : localx(0),x(0), localy(0),y(0), localWidth(100),width(100),height(100), localHeight(100) {} Control(int x, int y, int width, int height) @@ -85,14 +85,15 @@ public: discardBackground(); } protected: - virtual void requestRepaint(); + //向上请求重绘 + virtual void requestRepaint(Control* parent); //根控件/无父时触发重绘 virtual void onRequestRepaintAsRoot(); protected: //保存背景快照 - void saveBackground(int x, int y, int w, int h); + virtual void saveBackground(int x, int y, int w, int h); // putimage 回屏 - void restBackground(); + virtual void restBackground(); // 释放快照(窗口重绘/尺寸变化后必须作废) void discardBackground(); public: diff --git a/include/StellarX/Dialog.h b/include/StellarX/Dialog.h index 3783d27..332bc83 100644 --- a/include/StellarX/Dialog.h +++ b/include/StellarX/Dialog.h @@ -20,7 +20,7 @@ #pragma once #include"StellarX.h" -#define closeButtonWidth 23 //关闭按钮宽度 +#define closeButtonWidth 30 //关闭按钮宽度 #define closeButtonHeight 20 //关闭按钮高度 同时作为对话框标题栏高度 #define functionButtonWidth 70 //按钮宽度 #define functionButtonHeight 30 //按钮高度 @@ -29,7 +29,7 @@ #define buttonAreaHeight 50 //按钮区域高度 #define titleToTextMargin 10 //标题到文本的距离 #define textToBorderMargin 10 //文本到边框的距离 - +#define BorderWidth 3 //边框宽度 class Dialog : public Canvas { Window& hWnd; //窗口引用 @@ -37,7 +37,6 @@ class Dialog : public Canvas int textWidth = 0; //文本宽度 int textHeight = 0; //文本高度 int buttonNum = 0; // 按钮数量 - int BorderWidth = 2; //边框宽度 StellarX::MessageBoxType type = StellarX::MessageBoxType::OK; //对话框类型 std::string titleText = "提示"; //标题文本 @@ -124,11 +123,14 @@ private: void getTextSize(); //初始化对话框尺寸 void initDialogSize(); - + void saveBackground(int x, int y, int w, int h)override; + + void restBackground()override; // 清除所有控件 void clearControls(); //创建对话框按钮 std::unique_ptr