NIM Duilib Framework

repository·master·Indexed 25 days ago

https://github.com/netease-im/nim_duilib_framework

A comprehensive desktop application development framework that extends the Duilib UI library. It integrates base utilities for threading and memory management, featuring support for DPI scaling, multi-language styling, GIF animations, and CEF (Chromium Embedded Framework) integration. The framework provides a variety of layout containers (Box, HBox, VBox, etc.), interactive controls, and high-performance list components like VirtualListBox.

Tokens
25.6K
Snippets
32
Records
194
Agent score
80%

What's inside nim_duilib_framework

  1. Overview of NIM Duilib

    master
    NIM Duilib is a UI development framework for Windows designed for building desktop applications. It extends the original Duilib by integrating a Google-based library that provides enhanced support for threads, memory management, and closures. It features an abstract rendering interface, allowing for support of various rendering engines.
  2. Overview of NIM Duilib Controls

    master

    NIM Duilib provides a comprehensive set of UI components (Controls) used to build user interfaces. These controls are organized into a hierarchy where higher-level components (like Window) act as containers for lower-level interactive elements (like Button, CheckBox, or Slider).

    Key component categories include:

    • Containers: Window (the top-level container for all UI elements).
    • Base Components: Control (the base class for all UI elements).
    • Interactive Controls: Button, CheckBox, Option, Slider, ScrollBar.
    • Display Controls: Label, Progress, CircleProgress.
    • Input Controls: RichEdit (for rich text input).
    • Web Integration: CefControl (for embedding CEF/Chromium-based content).
  3. Overview of NIM Duilib features

    master

    NIM Duilib is a desktop application development framework rather than just a UI library. It extends the original Duilib and integrates the Google base library (providing thread, memory, and closure management).

    Key features include:

    • Multi-language support
    • Universal styling support
    • DPI scaling support
    • GIF animation support
    • CEF (Chromium Embedded Framework) control support (CEF 2623 supports Windows XP)
    • Touch device support (e.g., Surface, Wacom)
    • Abstract rendering interface (allows support for other rendering engines)
  4. Available List components in NIM Duilib

    master

    NIM Duilib provides several types of list components designed for different data presentation needs. Depending on whether you need hierarchical data, simple selection, or high-performance rendering for large datasets, you should choose one of the following:

    • Combo: A dropdown-style list component.
    • ListBox: A standard list component for displaying items.
    • TreeView: A hierarchical list component for tree-like data structures.
    • VirtualListBox: A high-performance list component optimized for displaying very large datasets by using virtualization techniques.
  5. NIM Duilib Framework Overview

    master

    NIM Duilib is a UI framework providing a comprehensive set of components for building desktop applications. The framework is organized into several core categories:

    • Containers: Layout management tools like Box, VBox, HBox, TabBox, TileBox, ChildBox, and ScrollableBox.
    • Lists: Data presentation components including Combo (dropdowns), TreeView, ListBox, and VirtualListBox for high-performance rendering.
    • Controls: Standard UI elements such as Button, CheckBox, Option, Label, Progress bars, Slider, ScrollBar, and specialized editors like RichEdit and NumberEdit.
    • ControlBox Elements: Specialized items used within containers, such as ListContainerElement and TreeNode.
    • Utilities: Core framework services including Window Base, Multi-language support, DPI Manager, and Shadow effects.
  6. Use ChildBox to embed sub-layouts via XML

    master

    The ChildBox container allows you to embed a sub-layout into a parent container by specifying an external XML file. ChildBox inherits all properties and methods from the Box container; for a complete list of layout properties, refer to the Box documentation.

    To embed a layout, you must provide the path to an XML file using the xmlfile property or the SetChildLayoutXML method.

  7. Override WindowImplBase methods to handle window events

    master

    To customize window behavior in the Duilib framework, you should inherit from WindowImplBase and override its virtual methods. These methods act as event handlers for various Windows messages and framework-specific events.

    Lifecycle and Initialization

    • InitWindow(): Called when the window is being initialized. Use this for setup tasks.
    • OnCreate(uMsg, wParam, lParam, bHandled): Triggered when the window is created. Note that if you use InitWindow for initialization, OnCreate will be called automatically after it.
    • OnFinalMessage(hWnd): Called when the window is receiving its final messages.
    • OnDestroy(uMsg, wParam, lParam, bHandled): Called when the window is being destroyed.
    • OnClose(uMsg, wParam, lParam, bHandled): Called when the window receives a close message.

    Message Handling Pattern

    Most event handlers follow a standard signature:

    • uMsg: The message ID.
    • wParam / lParam: Message parameters.
    • bHandled: A boolean reference. Set this to true if you have processed the message and want to prevent further processing by the default handler.

    Returns LRESULT (typically 0 if handled).

  8. Understand CefControl vs CefNativeControl

    master

    The framework provides two ways to integrate CEF (Chromium Embedded Framework) as a Control:

    • CefControl: Uses the windowed mode for CEF.
    • CefNativeControl: Uses the native mode for CEF, which allows for more direct integration with native windowing systems.

    Setup Requirements: CEF supports Windows XP and later versions. To use CEF in C++, you must include the third_party\cef_wrapper directory in your project. Ensure that the CEF binary files (from the bin directory, e.g., cef_x64) are placed in the same directory as your application's executable.

  9. Use the ListBox container

    master

    The ListBox is a container component used to manage a list of child items. It inherits all properties and methods from ScrollableBox. Use it to create scrollable lists where items can be added, removed, sorted, or selected.

    Key capabilities include:

    • Adding items to the end (Add) or at a specific index (AddAt).
    • Removing items by pointer (Remove) or by index (RemoveAt).
    • Navigating selection via Next() and Previous().
    • Sorting items using a custom comparison function via SortItems.
  10. Use ControlBox containers to combine layout and event response

    master

    A ControlBox is a specialized hybrid component that combines the layout capabilities of a container with the event response mechanisms of a control. Unlike standard containers, they are designed to hold specific types of controls that behave as a single functional unit.

    For example, if you need a button that contains both an icon and text, you should use a ButtonBox instead of manually positioning a Control and a Label inside a standard Box.

    <ButtonBox width="70" height="30" bkcolor="darkcolor" padding="10,8,8,10">
      <Control width="auto" height="auto" bkimage="save.png" mouse="false"/>
      <Label text="保存" normaltextcolor="white" margin="20" mouse="false"/>
    </ButtonBox>