|
ObjectivelyMVC
Object oriented MVC framework for SDL3 and GNU C
|
A tour of building user interfaces with ObjectivelyMVC.
ObjectivelyMVC is built on Objectively, a lightweight object oriented framework for C. ObjectivelyMVC delivers the elegance of OO / MVC without imposing C++ on your project. If you are using C++, ObjectivelyMVC is perfectly happy to coexist with it.
ObjectivelyMVC is purpose-built for video games. Unlike Gtk+, Qt, wxWidgets, FLTK, ...ObjectivelyMVC does not hijack the main loop. ObjectivelyMVC does not create a window, claim the GPU device, or originate events. Your game already does that, because it has to. Like your mother, ObjectivelyMVC only asks that you give it a call once in a while. That's it.
ObjectivelyMVC uses SDL_ttf to render TrueType fonts. It also automatically detects High-DPI (Retina, 4K) displays, and scales fonts accordingly. The result is crisp, beautiful vector-based fonts that look native, because they are.
ObjectivelyMVC provides a robust set of containers, views and controls. Stack and arrange components with Box, Panel and StackView. Add Buttons, Checkboxes, Selects, Sliders, editable TextViews and more by simply instantiating them. Display tabular data or a thumbnail gallery with TableView and CollectionView. Split complex interfaces into multiple tabs with TabView and TabViewController. Use the specialized delegate callbacks to respond to events.
ObjectivelyMVC allows you to define your View hierarchy programmatically, via JSON, or using any combination of both. Programmatic layout gives you explicit control over the big picture, while JSON layout allows you to reduce boilerplate and avoid common pitfalls like memory leaks.
ObjectivelyMVC uses a custom CSS3 dialect to manage all aspects of its presentation. Nothing about the look and feel of ObjectivelyMVC is hard-coded, and authoring and attaching new Stylesheets is trivial and straightforward.
ObjectivelyMVC makes loading Fonts, Images, Stylesheets, and Views painless. For direct filesystem access, add directories to its search path with $$(Resource, addResourcePath, "/my/path"). To search your game's filesystem abstraction, implement a custom ResourceProvider function, and register it:
The Hello example creates a window, enters its main loop, and renders a themed menu over a 3D scene using JSON layout:
HelloViewController interfaceHelloViewController implementation