47 KiB
Knowledge Base
Guidance
The following data types are preferred:
- For any code interops with Windows API, use Windows API specific types.
- Use signed integer type
vintor unsigned integer typevuintfor general purpose. It always has the size of a pointer. - Use signed integer types when the size is critical:
vint8_t,vint16_t,vint32_t,vint64_t. - Use unsigned integer types when the size is critical:
vuint8_t,vuint16_t,vuint32_t,vuint64_t. - Use
atomic_vintfor atomic integers, it is a rename ofstd::atomic<vint>. - Use
DateTimefor date times.
Vlpp
Files from Import:
- Vlpp.h
- Vlpp.cpp
- Vlpp.Windows.cpp
- Vlpp.Linux.cpp
Online documentation: https://gaclib.net/doc/current/vlpp/home.html
Vlpp is the foundational library that provides STL replacements and basic utilities.
It is the cornerstone of the entire framework, offering string handling, collections, lambda expressions, memory management, and primitive data types.
Use this when you need basic data structures without depending on STL.
This project prefers wchar_t over other char types and provides immutable string types, smart pointers, collection classes, and LINQ-like operations.
Choosing APIs
String Types and Handling
Immutable string types for text processing across different encodings with UTF conversion capabilities.
- Use
WStringfor general purpose wide character strings (UTF-16 on Windows, UTF-32 on other platforms) - Use
AStringfor ASCII string operations - Use
U8Stringfor UTF-8 string handling - Use
U16StringandU32Stringfor specific UTF encoding requirements - Use
ObjectString<T>template when you need custom character types - Use
Unmanaged,CopyFrom,TakeOverstatic functions for string initialization - Use
wtoi,wtoi64,wtou,wtou64for string to integer conversion - Use
itow,i64tou,utow,u64towfor integer to string conversion - Use
ftow,wtoffor double and string conversion - Use
wupper,wlowerfor case conversion - Use
ConvertUtfString<From, To>for template-based UTF string conversion - Use
AtoBfunctions (likewtou8,u8tow) for direct UTF encoding conversion
Exception Handling
Error reporting and exception management for fatal errors and recoverable conditions.
- Use
Errorbase class for fatal errors that should never happen - Use
Exceptionbase class for recoverable errors and control flow - Use
CHECK_ERROR(condition, message)to raise errors on assertion failures - Use
CHECK_FAIL(message)to raise errors without conditions
Object Model and Memory Management
Reference counting smart pointers and object lifecycle management following specific inheritance patterns.
- Use
Objectbase class for all reference types - Use
Interfacebase class for all interface types with virtual inheritance - Use
Ptr<T>for shared ownership of reference types instead of raw pointers - Use
ComPtr<T>for COM objects on Windows API - Use
Nullable<T>to add nullptr semantics to value types - Use
structfor value types andclassfor reference types
Lambda Expressions and Callable Types
Function objects and event handling with type-safe callable containers.
- Use
Func<T(TArgs...)>for function objects similar to std::function - Use
Event<void(TArgs...)>for multi-subscriber event handling - Use lambda expressions for callbacks instead of native functions when possible
- Use
Func(callable-object)for automatic type inference
Primitive Value Types
Container types for organizing and manipulating related data values.
- Use
Pair<Key, Value>for two-value tuples with key and value fields - Use
Tuple<T...>for multiple value organization without defining structs - Use
Variant<T...>for type-safe unions that can hold one of several types - Use
Pair(k, v)andTuple(a, b, c...)for type inference - Use
get<0>method for tuple value access - Use
Get<T>(),TryGet<T>()for variant value access - Use
ApplywithOverloadingfor variant type-specific handling
Date and Time Operations
Cross-platform date and time handling with timezone conversions and arithmetic operations.
- Use
DateTime::LocalTime()andDateTime::UtcTime()for current time retrieval - Use
DateTime::FromDateTime()for creating specific date/time instances - Use
ToLocalTime()andToUtcTime()for timezone conversions - Use
Forward()andBackward()for time arithmetic operations - Use
InjectDateTimeImplto replace implementation for testing and customization - Use
EjectDateTimeImplto remove injected implementations and restore previous ones
Collection Types
Dynamic containers implementing IEnumerable interface with comprehensive manipulation capabilities.
- Use
Array<T>for fixed-size collections with random access - Use
List<T>for dynamic arrays with insertion and removal operations - Use
SortedList<T>for automatically ordered collections - Use
Dictionary<Key, Value>for one-to-one key-value mappings - Use
Group<Key, Value>for one-to-many key-value relationships - Use
Count(),Get(index),Contains(value),IndexOf(value)for common operations - Use
Add(),Insert(),Remove(),RemoveAt(),Clear()for modification operations - Use
Keys(),Values()for dictionary access patterns
LINQ Operations
Functional programming operations on collections with lazy evaluation and method chaining.
Check out comments before #ifndef VCZH_COLLECTIONS_OPERATION for a full list of operators.
- Use
LazyList<T>for LINQ-style operations on any IEnumerable collection - Use
From(collection)to create LazyList from collections - Use method chaining with
Skip(),Reverse(),Where(),Select()for data transformation - Use
indexedfunction for enumeration with index access - Use range-based for loops with any IEnumerable implementation
Sorting and Ordering
Algorithms for arranging data with support for both total and partial ordering relationships.
- Use
Sort(T*, vint)for quick sort on raw pointer ranges - Use lambda expressions returning
std::strong_orderingorstd::weak_orderingas comparators - Use
PartialOrderingProcessorfor partial ordering scenarios where Sort doesn't work - Use
<=>operator to obtain ordering values for comparators
Console Operations
Basic input/output operations for console applications.
- Use
Console::WriteandConsole::WriteLinefor console output in CLI applications
Memory Leak Detection
Global storage management and memory leak detection for debugging and testing.
- Use
BEGIN_GLOBAL_STORAGE_CLASS,INITIALIZE_GLOBAL_STORAGE_CLASS,FINALIZE_GLOBAL_STORAGE_CLASS,END_GLOBAL_STORAGE_CLASSfor global variable management - Use
FinalizeGlobalStorage()before memory leak detection - Use
GetStorageName().IsInitialized()to check availability - Use
_CrtDumpMemoryLeaks()on Windows for leak detection
Unit Testing Framework
Testing infrastructure with hierarchical test organization and assertion capabilities.
- Use
TEST_FILEto define test file scope - Use
TEST_CATEGORY(name)for grouping related tests - Use
TEST_CASE(name)for individual test implementations - Use
TEST_ASSERT(expression)for test assertions - Use nested
TEST_CATEGORYfor hierarchical organization - Use
TEST_PRINTfor logging information to CLI in tests
Design Explanation
VlppOS
Files from Import:
- VlppOS.h
- VlppOS.cpp
- VlppOS.Windows.cpp
- VlppOS.Linux.cpp
Online documentation: https://gaclib.net/doc/current/vlppos/home.html
VlppOS provides cross-platform OS abstraction for file system operations, streams, locale support, and multi-threading. Use this when you need to interact with the operating system in a portable way. It offers locale-aware string manipulation, file system access, various stream types with encoding/decoding capabilities, and comprehensive multi-threading support with synchronization primitives.
Choosing APIs
Locale Support
Cross-platform localization and globalization with culture-aware string operations and formatting.
- Use
Locale::Invariant()orINVLOCmacro for culture-invariant operations - Use
Locale::SystemDefault()for OS code page interpretation - Use
Locale::UserDefault()for user language and location settings - Use
Locale::Enumerate(locales)to get all supported locales - Use
Get*Formatsmethods for date-time format enumeration - Use
FormatDateandFormatTimefor locale-aware date/time formatting - Use
Get*Namemethods for localized week day and month names - Use
FormatNumberandFormatCurrencyfor locale-aware number formatting - Use
Compare,CompareOrdinal,CompareOrdinalIgnoreCasefor locale-aware string comparison - Use
FindFirst,FindLast,StartsWith,EndsWithfor normalized string searching - Use
InjectLocaleImplto replaceLocaleimplementation for testing and customization - Use
EjectLocaleImplto remove specific injected implementations or reset to default - Use
EnUsLocaleImplclass as platform-independent en-US fallback implementation
File System Operations
Cross-platform file and directory manipulation with path handling and content access.
- Use
FilePathfor path representation and manipulation - Use
GetName,GetFolder,GetFullPath,GetRelativePathForfor path operations - Use
IsFile,IsFolder,IsRootto determine path object types - Use
Fileclass for file operations whenFilePath::IsFilereturns true - Use
ReadAllTextWithEncodingTesting,ReadAllTextByBom,ReadAllLinesByBomfor text reading - Use
WriteAllText,WriteAllLinesfor text writing - Use
Exists,Delete,Renamefor file operations - Use
Folderclass for directory operations whenFilePath::IsFolderorFilePath::IsRootreturns true - Use
GetFolders,GetFilesfor directory content enumeration - Use
Createfor creating new folders - Use
InjectFileSystemImplto replace file system implementation for testing and customization - Use
EjectFileSystemImplto remove specific injected implementations or reset to default
Stream Operations
Unified stream interface for file, memory, and data transformation operations with encoding support.
- Use
IStreaminterface for all stream operations - Use
FileStreamfor file I/O withReadOnly,WriteOnly,ReadWritemodes - Use
MemoryStreamfor in-memory buffer operations - Use
MemoryWrapperStreamfor operating on existing memory buffers - Use
EncoderStreamandDecoderStreamfor data transformation pipelines - Use
IsAvailable,CanRead,CanWrite,CanSeek,IsLimitedfor capability checking - Use
Read,Write,Peek,Seek,Position,Sizefor stream operations - Use
Closefor resource cleanup (automatic on destruction)
Encoding and Decoding
Text encoding conversion between different UTF formats with BOM support and binary data encoding.
- Use
BomEncoderandBomDecoderfor UTF encoding with BOM support - Use
UtfGeneralEncoder<Native, Expect>andUtfGeneralDecoder<Native, Expect>for UTF conversion without BOM - Use
Utf8Encoder,Utf8Decoder,Utf16Encoder,Utf16Decoder,Utf16BEEncoder,Utf16BEDecoder,Utf32Encoder,Utf32Decoderfor specific UTF conversions - Use
MbcsEncoderandMbcsDecoderfor ASCII/MBCS conversion - Use
TestEncodingfor automatic encoding detection - Use
Utf8Base64EncoderandUtf8Base64Decoderfor Base64 encoding in UTF-8 - Use
LzwEncoderandLzwDecoderfor data compression - Use
CopyStream,CompressStream,DecompressStreamhelper functions
Additional Streams
Specialized stream types for caching, recording, and broadcasting data operations.
- Use
CacheStreamfor performance optimization with non-random accessed data, although it supports random accessing if the underlying stream does - Use
RecorderStreamfor copying data from one stream to another during reading - Use
BroadcastStreamfor writing the same data to multiple target streams - Use
Targets()method to manage BroadcastStream destinations
Multi-threading
Cross-platform threading primitives and synchronization mechanisms for concurrent programming.
- Use
ThreadPoolLite::QueueandThreadPoolLite::QueueLambdafor thread pool execution - Use
Thread::Sleepfor thread pausing - Use
Thread::GetCurrentThreadIdfor thread identification - Use
Thread::CreateAndStartonly when thread pool is insufficient
Synchronization Primitives
Non-waitable synchronization objects for protecting shared resources in multi-threaded environments.
- Use
SpinLockfor protecting very fast code sections - Use
CriticalSectionfor protecting time-consuming code sections - Use
ReaderWriterLockfor multiple reader, single writer scenarios - Use
Enter,TryEnter,Leavefor manual lock management - Use
SPIN_LOCK,CS_LOCK,READER_LOCK,WRITER_LOCKmacros for exception-safe automatic locking - Use
ConditionVariablewithSleepWith,SleepWithForTimefor conditional waiting - Use
WakeOnePending,WaitAllPendingsfor condition variable signaling
Waitable Objects
Cross-process synchronization objects that support waiting operations with timeout capabilities.
- Use
Mutexfor cross-process mutual exclusion - Use
Semaphorefor counting semaphore operations across processes - Use
EventObjectfor event signaling across processes - Use
CreateandOpenmethods for establishing named synchronization objects - Use
Wait,WaitForTimefor blocking operations with optional timeout - Use
WaitAll,WaitAllForTime,WaitAny,WaitAnyForTimefor multiple object synchronization - Use
Signal,Unsignalfor event object state management - Use
Releasefor releasing mutex and semaphore ownership
Design Explanation
Implementing an Injectable Feature
- Linked-list based dependency injection mechanism enabling runtime replacement and extension of feature implementations while maintaining delegation capabilities
- Three core components:
IFeatureImplbase interface,FeatureImpl<TImpl>template for type-safe delegation, andFeatureInjection<TImpl>manager for chain operations - Standard implementation pattern with interface definition, default implementation, global management functions using static local variables for thread-safe singleton behavior
- Delegation mechanism through
Previous()method allowing partial overrides and full delegation with LIFO injection structure and cascading ejection behavior - Critical lifecycle guarantees where
EndInjectiononly called during explicit operations, and restriction of injection/ejection to application-level code for proper ordering - Real-world implementation demonstrated through DateTime system with platform-specific implementations and testing integration using mock implementations
VlppRegex
Files from Import:
- VlppRegex.h
- VlppRegex.cpp
Online documentation: https://gaclib.net/doc/current/vlppregex/home.html
VlppRegex provides regular expression functionality with .NET-like syntax but with important differences. Use this when you need pattern matching and text processing capabilities.
Pattern definition with .NET-like syntax but specific escaping and character matching rules.
Check out comments before class Regex_ for a full syntax description.
The regular expression syntax is mostly compatible with .NET but has important differences:
- Both
/and\perform escaping (prefer/to avoid C++ string literal conflicts) .matches literal '.' character, while/.or\.matches all characters- DFA incompatible features significantly impact performance
- Detailed syntax description is available in
Regex_<T>class comments
Choosing APIs
Pattern Matching Operations
Text pattern matching and searching operations with support for different UTF encodings.
- Use
Regex_<T>for pattern definition withObjectString<T>encoding - Use
MatchHead<U>for finding longest prefix matching the pattern - Use
Match<U>for finding earliest substring matching the pattern - Use
TestHead<U>for boolean prefix matching without detailed results - Use
Test<U>for boolean substring matching without detailed results - Use
Search<U>for finding all non-overlapping matches - Use
Split<U>for using pattern as delimiter to split text - Use
Cut<U>for combined search and split operations
Type Aliases
Convenient type aliases for common character encodings to simplify regex usage.
- Use
RegexStringinstead ofRegexString_<wchar_t> - Use
RegexMatchinstead ofRegexMatch_<wchar_t> - Use
Regexinstead ofRegex_<wchar_t> - Use
RegexTokeninstead ofRegexToken_<wchar_t> - Use
RegexProcinstead ofRegexProc_<wchar_t> - Use
RegexTokensinstead ofRegexTokens_<wchar_t> - Use
RegexLexerWalkerinstead ofRegexLexerWalker_<wchar_t> - Use
RegexLexerColorizerinstead ofRegexLexerColorizer_<wchar_t> - Use
RegexLexerinstead ofRegexLexer_<wchar_t>
Design Explanation
VlppReflection
Files from Import:
- VlppReflection.h
- VlppReflection.cpp
Online documentation: https://gaclib.net/doc/current/vlppreflection/home.html
VlppReflection provides runtime reflection capabilities for C++ classes and functions. Use this when you need to work with type metadata, register classes for scripting, or implement dynamic behavior. It supports three compilation levels: full reflection, metadata-only, and no reflection. Registration must happen in dedicated files and follows specific patterns for enums, structs, classes, and interfaces.
Choosing APIs
Reflection Compilation Levels
Three different compilation modes for reflection support with varying runtime capabilities.
The reflection system supports three compilation levels:
- Full reflection: Complete metadata and runtime support for type registration and function calls
- Metadata-only (
VCZH_DESCRIPTABLEOBJECT_WITH_METADATA): Type metadata without runtime support - No reflection (
VCZH_DEBUG_NO_REFLECTION): Reflection disabled entirely Always prefer code compatible withVCZH_DEBUG_NO_REFLECTIONwhen possible.
Type Metadata Access
Runtime type information retrieval and manipulation through the reflection system.
- Use
vl::reflection::description::GetTypeDescriptor<T>for type metadata access when reflection is enabled - Use
vl::reflection::description::Valuefor boxing any value type similar to C# object or std::any - Use
Description<T>base class for making classes reflectable - Use
AggregatableDescription<T>for classes that can be inherited in Workflow scripts - Use
IDescriptableinterface for reflectable interfaces without other base interfaces
Type Registration Structure
Organized approach for registering types with proper file organization and macro usage.
All type registration must occur in vl::reflection::description namespace with specific file organization:
- Type lists and interface proxies in
.hfiles - Type metadata registration in
.cppfiles - Registration code in dedicated files
- Follow established patterns from existing source code examples
Enum Registration
Registration patterns for enumeration types with support for simple lists and combinable flags.
- Use
BEGIN_ENUM_ITEMandEND_ENUM_ITEMfor simple enumeration lists - Use
BEGIN_ENUM_ITEM_MERGABLEandEND_ENUM_ITEMfor combinable flag enumerations - Use
ENUM_CLASS_ITEMfor enum class members - Use
ENUM_ITEMfor enum members - Use
ENUM_ITEM_NAMESPACEandENUM_NAMESPACE_ITEMfor enums defined inside other types
Struct Registration
Registration patterns for structure types with field access capabilities.
- Use
BEGIN_STRUCT_MEMBERandEND_STRUCT_MEMBERfor struct registration - Use
STRUCT_MEMBERto register each accessible field
Class and Interface Registration
Comprehensive registration system for classes and interfaces with methods, properties, and events.
- Use
BEGIN_CLASS_MEMBERandEND_CLASS_MEMBERfor class registration - Use
BEGIN_INTERFACE_MEMBERandEND_INTERFACE_MEMBERfor inheritable interfaces - Use
BEGIN_INTERFACE_MEMBER_NOPROXYandEND_INTERFACE_MEMBERfor non-inheritable interfaces - Use
CLASS_MEMBER_BASEfor reflectable base class declaration - Use
CLASS_MEMBER_FIELDfor member field registration - Use
CLASS_MEMBER_CONSTRUCTORfor constructor registration withPtr<Class>(types...)orClass*(types...) - Use
CLASS_MEMBER_EXTERNALCTORfor external function constructors - Use
CLASS_MEMBER_METHODfor method registration with parameter names - Use
CLASS_MEMBER_METHOD_OVERLOADfor overloaded method registration - Use
CLASS_MEMBER_EXTERNALMETHODfor external function methods - Use
CLASS_MEMBER_STATIC_METHODfor static method registration - Use
CLASS_MEMBER_EVENTfor event registration - Use
CLASS_MEMBER_PROPERTY_READONLY,CLASS_MEMBER_PROPERTYfor property registration - Use
CLASS_MEMBER_PROPERTY_READONLY_FAST,CLASS_MEMBER_PROPERTY_FASTfor standard getter/setter patterns - Use
CLASS_MEMBER_PROPERTY_EVENT_READONLY_FAST,CLASS_MEMBER_PROPERTY_EVENT_FASTfor properties with change events - Use
NO_PARAMETERfor parameterless functions - Use
{ L"arg1" _ L"arg2" ... }for parameter name lists
Interface Proxy Implementation
Proxy generation for interfaces to enable inheritance in Workflow scripts.
- Use
BEGIN_INTERFACE_PROXY_NOPARENT_RAWPTRfor interfaces without base interfaces using raw pointers - Use
BEGIN_INTERFACE_PROXY_NOPARENT_SHAREDPTRfor interfaces without base interfaces using Ptr - Use
BEGIN_INTERFACE_PROXY_RAWPTRfor interfaces with base interfaces using raw pointers - Use
BEGIN_INTERFACE_PROXY_SHAREDPTRfor interfaces with base interfaces using Ptr - Use
END_INTERFACE_PROXYto complete proxy definition - Use
INVOKE_INTERFACE_PROXY_NOPARAMSfor void methods without parameters - Use
INVOKEGET_INTERFACE_PROXY_NOPARAMSfor return value methods without parameters - Use
INVOKE_INTERFACE_PROXYfor void methods with parameters - Use
INVOKEGET_INTERFACE_PROXYfor return value methods with parameters
Design Explanation
VlppParser2
Files from Import:
- VlppGlrParser.h
- VlppGlrParser.cpp
Online documentation: https://gaclib.net/doc/current/vlppparser2/home.html
VlppParser2 implements GLR parsers based on customized and enhanced EBNF syntax. Use this when you need to parse complex grammars or implement domain-specific languages. The documentation for VlppParser2 is not ready yet.
Choosing APIs
Design Explanation
Workflow
Files from Import:
- VlppWorkflowLibrary.h
- VlppWorkflowLibrary.cpp
- VlppWorkflowCompiler.h
- VlppWorkflowCompiler.cpp
- VlppWorkflowRuntime.h
- VlppWorkflowRuntime.cpp
Online documentation: https://gaclib.net/doc/current/workflow/home.html
Workflow is a script language based on C++ reflection that can execute scripts at runtime or generate equivalent C++ code. Use this when you need scripting capabilities, code generation, or when working with GacUI XML files. It can execute the script if reflection is turned on. It can generate equivalent C++ source files from the the script.
Choosing APIs
Design Explanation
GacUI
Online documentation: https://gaclib.net/doc/current/gacui/home.html
GacUI is a cross-platform GUI library that comes with an XML-based UI definition system and a compiler. Use this when you need to create desktop applications with rich user interfaces. It provides a comprehensive testing framework, XML-to-C++ compilation, and integrates with the Workflow script language for event handling and data binding.
Choosing APIs
Design Explanation
Platform Initialization and Multi-Platform Architecture
- GacUI implements a sophisticated multi-platform initialization system that provides consistent API across different operating systems and rendering backends while maintaining platform-specific optimizations.
- The initialization process follows a layered architecture from platform entry points through renderer setup to application framework. It supports:
- Windows Direct2D/GDI
- Linux GTK
- macOS Cocoa
- remote rendering for testing
- hosted mode for embedded applications.
- The system uses a consistent naming pattern
Setup[Platform][Renderer][Mode]()with standard mode providing full application framework, hosted mode running within a single native window, and raw mode bypassing GuiApplication entirely. - Key features include hardware acceleration fallbacks, comprehensive error handling, frame-based unit testing through remote mode, and systematic service registration with proper dependency management.
Main Window and Modal Window Management
- GacUI provides a sophisticated multi-layered window management architecture that enables consistent main window and modal window behavior across all supported platforms while maintaining platform-specific optimizations.
- The application loop operates through hierarchical delegation from
GuiApplicationlayer down to platform-specificINativeWindowServiceimplementations, supporting Windows native, hosted mode, and remote mode environments. - Modal windows achieve apparent "blocking" behavior without actually blocking the underlying event processing system through an event-driven callback architecture that maintains full user interaction capabilities.
- The system supports three modal window variants:
ShowModalfor basic modal behavior,ShowModalAndDeletefor automatic cleanup, andShowModalAsyncfor modern async/await integration patterns. - Cross-platform consistency is maintained through unified modal APIs, continuous message loop processing, and platform-optimized implementations that abstract differences while providing rich windowing capabilities.
Implementing IGuiGraphicsElement
- Defines element lifecycle via
IGuiGraphicsElement,IGuiGraphicsRenderer, renderer factories, and render targets. - Uses
GuiElementBase<T>pattern with property change notifications throughInvokeOnElementStateChangedfor invalidation and size recalculation. - Renderer abstraction supplies hooks (
InitializeInternal,FinalizeInternal,RenderTargetChangedInternal,Render,OnElementStateChanged,GetMinSize) and caches platform resources. - Parallel renderer families per backend (Direct2D, GDI, Remote/Hosted) registered in backend initialization via static
Register(). - Composition + host rendering pipeline traverses compositions, applies clippers, calls element renderers; invalidation chain from property setter to
GuiGraphicsHost::Render. - Provides checklist, lifecycle summary, common pitfalls, and distinction from complex
GuiDocumentElementmodel-based rendering architecture.
Layout and GuiGraphicsComposition
- Core layout system centered on
GuiGraphicsCompositionwith measurement (Layout_CalculateMinSize) and arrangement (Layout_CalculateBounds) passes driven only by host render loop invalidation. - Three subclass archetypes (
_Trivial,_Controlled,_Specialized) define ownership of size calculation and parent-child constraint propagation. - Eight predefined layout families (Bounds, Table, Stack, Flow, Shared Size, Side Aligned, Partial View, Window Root) plus responsive (
GuiResponsive*) adaptive level-based system. - Bidirectional constraints: parent supplies space; children optionally enlarge parent via
Layout_CalculateMinClientSizeForParent; controlled items receive bounds from parent setters. - Invalidation via
InvokeOnCompositionStateChanged;GuiGraphicsHost::Renderiteratively recalculates until stable;ForceCalculateSizeImmediatelyonly for interactive latency. - Responsive compositions add multi-level adaptive switching with aggregation strategies (View, Stack, Group, Fixed) and automatic container adjustment.
Control Focus Switching and TAB/ALT Handling
- Three-layered architecture from composition focus (
GuiGraphicsHost) through control focus (GuiControl) to automatic clearing on state changes. - TAB navigation managed by
GuiTabActionManagerwithIGuiTabActionservice, prioritized control list building, wrapping navigation logic, and character suppression. - ALT navigation managed by
GuiAltActionManagerwithIGuiAltActionservice, nested ALT host hierarchy (IGuiAltActionHost), visual label creation, and prefix-based key filtering. - Critical
continuebarrier inCollectAltActionsFromControlblocks children from parent-level collection when control has ALT action, enabling nested context pattern. - Custom
GetActivatingAltHostimplementations handle non-child relationships (menu popups), intentional blocking (combo boxes), dynamic content (grid editors), and scoped navigation (ribbon groups, date pickers). - Event flow integration processes ALT before TAB in key event chain, with character suppression for both managers in character event chain.
List Control Architecture
- Three-layer architecture separates data management (
IItemProviderwith view system), layout arrangement (IItemArrangerwith virtual repeat composition), and visual rendering (item templates with background wrapping). - Item lifecycle from creation (
InstallStyle) through property updates to destruction (UninstallStyle) with event translation from compositions to item-level events viaItemCallback. - Virtual repeat composition system delegates to
GuiVirtualRepeatCompositionBasewith four arranger types (free height, fixed height, fixed size multi-column, fixed height multi-column) supporting efficient virtualization. - Provider hierarchy includes concrete providers (holding actual data), bindable providers (wrapping observable data sources via reflection), and converter providers (transforming tree to list via
NodeItemProvider). - Selection management in
GuiSelectableListControlhandles multi-selection with ctrl/shift modifiers, synchronizes with item templates, and provides keyboard navigation with special right-click behavior. - Specialized controls (
GuiVirtualTextList,GuiVirtualListView,GuiVirtualTreeView,GuiVirtualDataGrid, combo boxes, ribbon galleries) with view-specific templates and default implementations. - Scroll view integration with size calculation (
QueryFullSize), view updates (UpdateView), adopted size for responsive layouts, and lifecycle management (OnRenderTargetChanged). - Template and arranger coordination through
SetStyleAndArrangerprocess with detach/clear/update/attach phases,PredefinedListItemTemplatepattern, and display item background wrapping. - Data grid advanced features with visualizer system (cell rendering customization via decorator pattern), editor system (in-place editing with keyboard/mouse integration), sorter system (multi-level sorting with stable ordering), and filter system (row filtering with AND/OR/NOT composition).
Adding a New Control
- Coordinated changes across control class definition, template system, theme management, reflection registration, and XML compiler integration.
- Control class inherits from
GuiControlandDescription<T>, specifies template type via macro, overrides lifecycle methods, attaches event handlers toboundsComposition, and defines events/properties. - Template system with declaration in
GuiControlTemplates.husing macro expansion, property definition macros, auto-generated implementations including getters/setters/change events. - Inheritance pattern for derived controls using parent template as base, selective lifecycle override, and attachment to parent events instead of re-implementing handlers.
- Reflection registration in three steps: type list addition, control class registration with base/constructor/members, automatic template registration.
- XML loader registration via
ADD_TEMPLATE_CONTROLorADD_VIRTUAL_CONTROLfor themed variants. - Theme integration through
GUI_CONTROL_TEMPLATE_TYPESmacro generatingThemeNameenum values. - Minimal working example demonstrates complete lifecycle from class definition through template, theme, reflection, to XML loader registration.
- File modification checklist covers 10+ files across Controls, Templates, Application, Reflection, and Compiler directories.
- Header organization requires updates to
IncludeForward.handIncludeAll.hfor proper compilation order.
Experiences and Learnings
Copy of Online Manual
Vlpp OS
Workflow Script
- Running a Script
- Syntax
- Runtime Instructions
- C++ Code Generation
GacUI
- Knowledge Base
- GacUI XML Resource
- GacUI Components
- Elements
- Compositions
- Controls
- Control Templates
- Item Templates
- Components
- Advanced Topics