Mobile
My iOS apps
Other apps
Open source
  • Bandwidth benchmark
  • RAVM virtual machine
  • Big integer division
  • Prime numbers
  • AntiJOP sanitizer
  • TouchWidgets UI lib
  • Networking utils
  • Documentation
  • x86 instructions ref
  • GIT quick ref
  • GPG quick ref
  • Avoid Ubuntu
  • Android malware risks
  • iOS malware risks
  • OS/X security tips
  • Who blocks Tor
  • Software engineering
  • BASH aliases
  • I.B. pro/con
  • Vocal programming
  • Nutrition
  • Blog
  • Contact
    1 at zsmith dot co

    TouchWidgets

    © by
    All rights reserved. TouchWidgets is my widget library that is animation- and touch-friendly. I originally started TouchWidgets as a C++ project, as I based it on my previous related C++ and C projects, but as of release 0.28, TouchWidgets is an Objective C library. It was not a simple task to convert my C++ code to Objective C, but it was worth it, as Objective C is a better language.

    That said, few people outside of the Mac OS and iOS world know or want to know Objective C, and Apple is transitioning away from it, and the fact is that decent Objective C support is not universal across all platforms, and Objective C has potential security issues. Therefore the next phase of TouchWidgets development will be a move away from Objective C.

    • Release 0.26: TouchWidgetsX11 coded in C++ and based on X-Windows
    • Release 0.28: TouchWidgetsX11 coded in Objective C and based on X-Windows
    • Release 0.29: TouchWidgetsGL coded in Objective C and based on OpenGL

    TouchWidgetsX11: For 2D-only devices

    TouchWidgets 0.28 is the release that sits on top of X Windows. It works but is basically unfinished.

    TouchWidgetsGL: For 3D-capable devices

    TouchWidgets 0.30 is OpenGL-based, and therefore should be more portable across platforms. This change was inspired by GLUI, which I began using in 2008 for the multi-platform Maxilla VRML viewer project.

    GLUI provides a way to create a user interface that only sits on top of OpenGL. It doesn't require anything else. It provides buttons, text fields, and an OpenGL subwindow.

    My aim with TouchWidgets is to produce something similar to GLUI that is original code not borrowing from it (GLUI's source code is less than ideally organized anyway). While TouchWidgets began as a C++ project I've since moved on to Objective C.

    Features

    TouchWidgets uses the Model-View-Controller paradigm, where the model is your data, the views are representations of your data, and the controllers are code that manages views. Responses to inputs are performed by both views and controllers.

    The class hierarchy is as follows, using namespace TouchWidgets:

    UXObject
      +----  UXView
      |       +---- UXLabel, UXButton, UXImageView, UXGraph etc.
      |       +---- UXContainer
      |               +---- UXGrid
      |               +---- UXScroll
      |                       +---- UXVerticalList
      +----  UXController
              +----  UXTabs
              +----  ExampleController
    

    Adding styles to widgets can be done programmatically or it can be done using an external style file. This second method is loosely based the idea of CSS but is far more rudimentary. A view or container object can take styles of four levels:

    • All instances
    • Class e.g. ImageView
    • Style class name e.g. screen2labels
    • Instance name e.g. label3

    Screenshots X-Windows

    Tap to embiggen.

    Running on the Raspberry pi 3


    It had a connected LCD.

    Running on OS/X

    Screenshots OpenGL

    The staticly-linked executable that produced this was about 240kB.

    Download

    The OpenGL-based variant: TouchWidgetsGL-0.30.1.zip.

    The X11-based variant: TouchWidgetsX11-0.29.2.tar.gz.

    There will be no Swift variant.

    Installation

    If you're going to run TouchWidgets on a Mac, you'll need to install XQuartz.

    The Makefile's install target puts libTouchWidgets.a in /usr/local/lib and the header files in /usr/local/include/TouchWidgets.

    The Makefile is currently written for both GNU/Linux and OS/X. Eventually I will add an auto-configuration script.




    © Zack Smith