Skip to content

All Controls

WUI library provides a set of standard controls for creating user interfaces.

Standard Controls

Control Description
Button Button for user interaction. Supports text, images, toggles
Image Image display with visual themes support
Input Text input field. Single-line, multi-line, password, read-only
List List of items with columns, scrolling, and custom drawing
Menu Context menu with nested items and icons support
Message Modal dialogs for displaying messages
Panel Container for grouping elements or custom drawing
Progress Progress indicator (horizontal/vertical)
Select Dropdown list for selecting one value
Slider Slider for selecting a value from a range
Splitter Draggable divider for resizing areas
Tooltip Popup hints for interface elements
Tray System tray icon with notifications

Base Interface

All controls implement the i_control interface:

class i_control
{
public:
    virtual void draw(graphic &gr, rect clip) = 0;

    virtual void set_position(rect position) = 0;
    virtual rect position() const = 0;

    virtual void set_parent(std::shared_ptr<window> window_) = 0;
    virtual std::weak_ptr<window> parent() const = 0;
    virtual void clear_parent() = 0;

    virtual void set_topmost(bool yes) = 0;
    virtual bool topmost() const = 0;

    virtual void show() = 0;
    virtual void hide() = 0;
    virtual bool showed() const = 0;

    virtual void enable() = 0;
    virtual void disable() = 0;
    virtual bool enabled() const = 0;

    virtual bool focused() const = 0;
    virtual bool focusing() const = 0;

    virtual error get_error() const = 0;
};

Adding Control to Window

// Create control
auto button = std::make_shared<wui::button>("Click", []() {
    std::cout << "Clicked!" << std::endl;
});

// Add to window with position
window->add_control(button, {10, 10, 100, 30}); // left, top, right, bottom

Theming

All controls support visual themes. Example theme JSON:

{
  "button": {
    "calm": "#06a5df",
    "active": "#1aafe9",
    "disabled": "#a5a5a0"
  },
  "input": {
    "background": "#ffffff",
    "text": "#000000"
  }
}

More about themes

See Also