Code Monkey home page Code Monkey logo

libwtk-sdl2's Introduction

Provides a framework for hierarchic widgets based on SDL2. Most of the event handling and drawing is however abstracted away and should be easily replacable. The original purpose of this library is to supersede my quick and dirty immediate GUI implementation in my touchscreen GUI and at the same time provide GUI support for a remote control.

Installation

Run autoreconf -vfi to generate the configure script. Then build as usual with ./configure, make, and make install.

Features

  • Clean and easy to use (mostly declarative) GUI building with modern C++.
  • Simple widget hierarchy with useful base classes. New widgets can be created by deriving.
  • Flexible widget containers: (h/v)box and table.
  • Support for widget selection. In addition selectable widgets can be navigated in 2 dimensions. The intention was to support faster and more intuitive keyboard or infra-red remote navigation.
  • Optional dirty-based drawing: Only dirty widgets will be redrawn.

Documentation

I uploaded an early snapshot of the API here.

Current Shortcomings

  • Only a basic dark hard-coded theme is provided.
  • Missing widget to enter text.
  • Keyboard events are not handled by widgets.
  • Widgets do not get a new size when their content changes. There are several desirable behaviors how this could work.
  • Containers do not have interfaces to add or remove children. This would also require redoing the allocation.
  • The drawing primitives are lacking (should probably be refactored into low-level and design-based drawing).
  • The font renderer is optimized on reoccuring words. Rendering arbitrary text with it might use a lot of memory (although it will trade off with rerendering).
  • Backgrounds can not easily redrawn if a child is dirty (although no widgets need that yet).
  • Widgets can't unselect themselves or others (bad if a selection gets covered).

Examples

widget test min

libwtk-sdl2's People

Contributors

mklein-de avatar muesli4 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

libwtk-sdl2's Issues

Add and propagate events for scrolling

  • Add scrolling events.
  • Find a clever way to propagate scrolling events to widgets. Picking the active widget may not be good enough. For example, one could first try to propagate it to the active widget, if it is supported by it, and otherwise try some hierarchy-based heuristic (bottom-up from active widget, top-down from root widget to visible widgets).

Add new event to reset widgets

In some cases in event handling widgets have to be reset to their initial state (i.e. only state related to user input).

List entry won't draw most entries with sdl-2.0.10

The list entry widget doesn't draw some of the text to display. It seems like it only draws the first list entry and even that one is strangely limited.

This may be related to how basic rendering works and how SDL_RenderSetViewport and SDL_RenderSetClipRect are used. See:

void draw_context::draw_entry_text(std::string text, rect abs_rect, int texture_x_offset, int texture_y_offset)

Duplicate touch and mouse events are not filtered

A newer version of SDL2 has the annoying behavior of producing additional mouse button events for touch devices. This leads to issues on some widgets (e.g., swipe_area gets triggered twice even though it was hit once).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.