From c4852d080fa17b89fdfbcf9c7cdc69f532ec5d05 Mon Sep 17 00:00:00 2001 From: Ysm-04 <3150131407@qq.com> Date: Mon, 27 Oct 2025 16:29:43 +0800 Subject: [PATCH] feat: add a new awesome feature --- ...ocumentation.md => API Documentation.en.md | 0 CHANGELOG.en.md | 5 +- CHANGELOG.md | 3 + README.en.md | 565 +++++++----------- README.md | 565 +++++++----------- 5 files changed, 442 insertions(+), 696 deletions(-) rename English API Documentation.md => API Documentation.en.md (100%) diff --git a/English API Documentation.md b/API Documentation.en.md similarity index 100% rename from English API Documentation.md rename to API Documentation.en.md diff --git a/CHANGELOG.en.md b/CHANGELOG.en.md index 11a335b..4d902dd 100644 --- a/CHANGELOG.en.md +++ b/CHANGELOG.en.md @@ -7,12 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [中文文档](CHANGELOG.md) -## [v2.1.0] - 2025-10-05 +## [v2.1.0] - 2025-10-27 **Focus**: Resizable/maximized window (EasyX reinforced by Win32), first-phase layout manager (HBox/VBox), early Tabs control. We also fixed black borders, maximize “ghosts”, flicker, and the issue where controls only appeared after interaction. Control-level **background snapshot/restore**, **single-line truncation**, and **tooltips** are now standardized. ### ✨ Added +- **Bilingual API Documentation (Chinese and English)** + - The documentation provides a detailed introduction of each class, including API descriptions, functionalities, and points to note, with a comprehensive explanation of each control. + - **Window resize/maximize reinforcement (EasyX + Win32)** - `Window::enableResize(bool enable, int minW, int minH)`; toggle at runtime and set min track size. - Subclassed WndProc for `WM_GETMINMAXINFO / WM_SIZE / WM_EXITSIZEMOVE / WM_ERASEBKGND / WM_PAINT` with `WS_THICKFRAME | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS`. diff --git a/CHANGELOG.md b/CHANGELOG.md index 31f0076..9eb5443 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ StellarX 项目所有显著的变化都将被记录在这个文件中。 ### ✨ 新增 +- **中英文双语 API文档** + - 文档详细介绍了每个类,以及API描述、功能和需要注意的地方,详细介绍了每个控件 + - **窗口拉伸 / 最大化补强(在 EasyX 基础上用 Win32 加固)** - 新增 `Window::enableResize(bool enable, int minW, int minH)`;运行时开关可拉伸并设置最小跟踪尺寸。 - 子类化窗口过程:处理 `WM_GETMINMAXINFO / WM_SIZE / WM_EXITSIZEMOVE / WM_ERASEBKGND / WM_PAINT`,并启用 `WS_THICKFRAME | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS`,解决 EasyX 窗口原生不可拉伸问题。 diff --git a/README.en.md b/README.en.md index 977be5a..abf99fd 100644 --- a/README.en.md +++ b/README.en.md @@ -5,11 +5,10 @@ ------ ![GitHub all releases](https://img.shields.io/github/downloads/Ysm-04/StellarX/total) - [![Star GitHub Repo](https://img.shields.io/github/stars/Ysm-04/StellarX.svg?style=social&label=Star%20This%20Repo)](https://github.com/Ysm-04/StellarX) -![Version](https://img.shields.io/badge/Version-2.0.0-brightgreen.svg) -![Download](https://img.shields.io/badge/Download-2.0.0_Release-blue.svg) +![Version](https://img.shields.io/badge/Version-2.1.0-brightgreen.svg) +![Download](https://img.shields.io/badge/Download-2.1.0_Release-blue.svg) ![C++](https://img.shields.io/badge/C++-17+-00599C?logo=cplusplus&logoColor=white) ![Windows](https://img.shields.io/badge/Platform-Windows-0078D6?logo=windows) @@ -18,434 +17,308 @@ ![Architecture](https://img.shields.io/badge/Architecture-Modular%20OOP-brightgreen) ![CMake](https://img.shields.io/badge/Build-CMake-064F8C?logo=cmake) -> **"Bound by Stars, Light as Dust"** — A native C++ GUI framework for Windows platform, featuring extreme lightweight and high modularity. +> **"Bound by Stars, Light as Dust"** — A native C++ GUI framework for Windows, featuring extreme lightness and high modularity. -`StellarX` was born from resistance against "overly bloated" modern GUI frameworks. It rejects dependencies that often reach hundreds of MB, long compilation times, and steep learning curves, choosing to return to the essence: solving core desktop application development needs with the most concise code, clearest architecture, and highest efficiency. +`StellarX` was born from resistance against bloat. It avoids huge dependencies, long build times, and steep learning curves, returning to the essence: using concise code, clear architecture, and high efficiency to solve desktop GUI needs. -It is a **pure teaching-level, tool-level framework** designed to help developers deeply understand GUI principles and quickly build lightweight Windows tools. +It is a **pure teaching/tool-level framework** that helps developers understand GUI principles and quickly build lightweight Windows tools. --- +## 🆕 What's New in v2.1.0 +**Bilingual API Documentation (Chinese and English)** + +- The documentation provides a detailed introduction of each class, including API descriptions, functionalities, and points to note, with a comprehensive explanation of each control. + +- **Resizable/Maximizable Window (EasyX + Win32 reinforcement)** + Subclassed WndProc with `WM_GETMINMAXINFO / WM_SIZE / WM_EXITSIZEMOVE / WM_ERASEBKGND / WM_PAINT` and window styles `WS_THICKFRAME | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS`. Full-surface background paint in `WM_PAINT` eliminates black borders and maximize “ghosts”. Coalesced resize with one-shot redraw. +- **Layout Manager (Phase 1)** + `Canvas` now supports `LayoutKind::{Absolute, HBox, VBox, Grid(placeholder), Flow(placeholder), Stack(placeholder)}` with `LayoutParams` (`margins`, `fixedW/fixedH`, `weight`, `Align{Start,Center,End,Stretch}`). Implemented **HBox/VBox** auto layout (containers remain absolutely positioned; nesting supported). +- **Tabs (early)** + Tab strip + page container separated; background snapshot avoids trails on transparent themes. +- **Button Single-Line Truncation (MBCS, CN/EN aware)** + Pixel-width based `...` truncation prevents half-glyph artifacts. +- **Hover Tooltip** + Implemented via `Label`, supports delay and auto-hide; per-control background snapshot/restore. + +See details in `CHANGELOG.en.md`. + +--- ## 📦 Project Structure & Design Philosophy -StellarX framework adopts classic **Object-Oriented** and **modular** design with a clear and standardized project structure: +StellarX adopts classic **OOP** and **modular** design with a clear structure: ```markdown - StellarX/ -├── include/ # Header files directory -│ └── StellarX/ # Framework header files -│ ├── StellarX.h # Main include header - one-click import of entire framework -│ ├── CoreTypes.h # ★ Core ★ - Single source of truth for all enums and structs -│ ├── Control.h # Abstract base class - defines unified interface for all controls -│ ├── Button.h # Button control -│ ├── Window.h # Window management -│ ├── Label.h # Label control -│ ├── TextBox.h # Text box control -│ ├── Canvas.h # Canvas container -│ ├── Dialog.h # Dialog control (new in v2.0.0) -│ ├── MessageBox.h # Message box factory (new in v2.0.0) -│ └── Table.h # Table control -├── src/ # Source files directory +├── include/ +│ └── StellarX/ +│ ├── StellarX.h +│ ├── CoreTypes.h # Single source of truth for enums/structs +│ ├── Control.h +│ ├── Button.h +│ ├── Window.h +│ ├── Label.h +│ ├── TextBox.h +│ ├── Canvas.h +│ ├── Dialog.h +│ ├── MessageBox.h +│ └── Table.h +├── src/ │ ├── Control.cpp │ ├── Button.cpp │ ├── Window.cpp │ ├── Label.cpp │ ├── TextBox.cpp │ ├── Canvas.cpp -│ ├── Table.cpp -│ ├── Dialog.cpp # v2.0.0 new -│ └── MessageBox.cpp # v2.0.0 new -├── examples/ # Example code directory -│ └── demo.cpp # Basic demonstration -├── docs/ # Documentation directory -│ └── CODE_OF_CONDUCT.md # Code of Conduct -├── CMakeLists.txt # CMake build configuration -├── CONTRIBUTING.md # Contribution guide -├── CHANGELOG.md # Changelog -├── Doxyfile # Doxygen configuration -├── LICENSE # MIT License -└── README.md # Project description +│ ├── Table.cpp +│ ├── Dialog.cpp +│ └── MessageBox.cpp +├── examples/ +│ └── demo.cpp +├── docs/ +│ └── CODE_OF_CONDUCT.md +├── CMakeLists.txt +├── CONTRIBUTING.md +├── CHANGELOG.en.md +├── CHANGELOG.md +├── Doxyfile +├── LICENSE +├──API 文档.md +├──API Documentation.en.md +└── README.en.md ``` -### **Design Philosophy:** +### Design Philosophy -1. **Single Responsibility Principle (SRP)**: Each class/file is responsible for one thing only. -2. **Dependency Inversion Principle (DIP)**: High-level modules (like `Window`) don't depend on low-level modules (like `Button`), both depend on abstractions (`Control`). -3. **Open/Closed Principle (OCP)**: New controls can be easily extended by inheriting the `Control` base class without modifying existing code. -4. **Consistency**: All controls share unified `draw()` and `handleEvent()` interfaces. +1. **SRP**: each class/file does one thing. +2. **DIP**: high-level modules depend on abstractions (`Control`), not concrete controls. +3. **OCP**: new controls extend `Control` without touching existing code. +4. **Consistency**: all controls expose `draw()` and `handleEvent()`. ## 🚀 Core Features -- **Extreme Lightweight**: Core library compiles to only ~12MB, with zero external dependencies. Generated applications are compact. -- **Clear Modular Architecture**: Uses `CoreTypes.h` to uniformly manage all types, eliminating duplicate definitions and greatly improving maintainability. -- **Native C++ Performance**: Built directly on EasyX and Win32 API, providing near-native execution efficiency with very low memory footprint (typically <10MB). -- **Complete Control System**: Button, Label, TextBox, Canvas, Table, Dialog, and MessageBox factory. -- **Highly Customizable**: From control colors, shapes (rectangle, rounded, circle, ellipse) to fill modes and font styles, all have detailed enum support for easy customization. -- **Simple & Intuitive API**: Uses classic object-oriented design, code as documentation, low learning curve. -- **Standard Project Structure**: Adopts standard include/src separation structure, supports CMake build, easy to integrate and use. -- **Enhanced Event System**: v2.0.0 introduces event consumption mechanism, all `handleEvent` methods return `bool` indicating whether event was consumed, supporting finer-grained event propagation control. -- **Dialog System**: New complete dialog support, including modal and non-modal dialogs, automatically handling background saving and restoration. +- **Extreme Lightweight**: tiny footprint with zero external dependencies beyond EasyX. +- **Clear Modular Architecture**: `CoreTypes.h` centralizes types and enums. +- **Native C++ Performance**: EasyX + Win32 API for near-native speed, low memory (<10MB typical). +- **Complete Control Set**: Button, Label, TextBox, Canvas, Table, Dialog, and MessageBox factory. +- **Highly Customizable**: colors, shapes (rectangle/rounded/circle/ellipse), fill modes, fonts via enums. +- **Simple, Intuitive API**: OOP-oriented, code as documentation. +- **Standard Project Layout**: include/src split, CMake build. +- **Enhanced Event System**: `handleEvent` returns `bool` for consumption (since v2.0.0). +- **Dialog System**: modal and modeless; auto background save/restore. -## ⚡ Quick Start (5 Minutes to Get Started) +------ -> **🎯 Latest Version Download** -> Download pre-compiled library files and header files from [GitHub Releases](https://github.com/Ysm-04/StellarX/releases/latest) for quick integration into your project. +## ⚡ Quick Start (5 Minutes) -### Environment Requirements +> Download prebuilt headers/libs from [Releases](https://github.com/Ysm-04/StellarX/releases/latest). -- **OS**: Windows 10 or higher -- **Compiler**: C++17 supported compiler (e.g., **Visual Studio 2019+**) -- **Graphics Library**: [EasyX](https://easyx.cn/) (2022 version or higher, please select the version matching your compiler during installation) -- **Build Tool**: CMake 3.12+ (optional, recommended) +### Requirements + +- **OS**: Windows 10+ +- **Compiler**: C++17 (e.g., Visual Studio 2019+) +- **Graphics**: [EasyX](https://easyx.cn/) 2022+ (match your compiler) +- **Build**: CMake 3.12+ (optional) ### Install EasyX -1. Visit [EasyX official website](https://easyx.cn/) to download the latest version -2. Run the installer, select the version matching your Visual Studio version -3. After installation, no additional configuration is needed, StellarX framework will automatically link EasyX +1. Download latest EasyX +2. Install matching your Visual Studio +3. No extra configuration needed for StellarX -### Method 1: Using CMake Build (Recommended) +### CMake Build (Recommended) -1. **Clone the project**: +``` +git clone https://github.com/Ysm-04/StellarX.git +cd StellarX +mkdir build && cd build +cmake .. +cmake --build . +./examples/Demo +``` - ```bash - git clone https://github.com/Ysm-04/StellarX.git - cd StellarX - ``` +### Manual Integration -2. **Generate build system**: +- Copy `include` and `src` into your project +- Add include paths for `include/StellarX/` +- Add all `.cpp` files to your build - ```bash - mkdir build - cd build - cmake .. - ``` +### Your First App (now Resizable) -3. **Compile the project**: - - ```bash - cmake --build . - ``` - -4. **Run the example**: - - ```bash - ./examples/Demo - ``` - -### Method 2: Manual Integration into Existing Project - -1. **Copy the include and src directories** to your project -2. **Configure include paths** to ensure the compiler can find the `include/StellarX/` directory -3. **Add all .cpp files** to your project for compilation - -### Create Your First StellarX Application - -```cpp -// Just include this one header to use all features +``` #include "StellarX.h" -// Program entry point (use WinMain for better compatibility) -int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd) -{ - // 1. Create a 640x480 window with white background, titled "My App" - Window mainWindow(640, 480, 0, RGB(255, 255, 255), "My First StellarX App"); - - // 2. Create a button (managed with smart pointer) - auto myButton = std::make_unique