- Get SDL3 sourcefiles and put it in vendored/SDL* (currently using version 3.2.10)
- Add a /build directory, and do cmake .. to build from CMakeLists.txt
- Run nodemon in terminal during development, or use executable in /build/debug/.
Update 0.0.1
This is what i want it to be after some iterations A lightweight application framework built on top of SDL3, providing a structured approach to building graphical applications.
This framework provides:
- Structured application lifecycle management
- Layout system for UI organization
- Page-based content management
- Basic widget system (shapes, buttons)
- Animation support
- Event handling system
├── include/ # Public header files
│ ├── app/ # Application-level components
│ ├── core/ # Core engine functionality
│ ├── layouts/ # Layout management system
│ └── widgets/ # UI widget components
│
├── src/ # Implementation files
│ ├── app/
│ ├── core/
│ ├── layouts/
│ └── widgets/
│
└── docs/ # Documentation
The project uses CMake as its build system. To build:
cmake -S . -B build
cmake --build build- SDL3
- CMake 3.16 or higher
- C compiler with C11 support
The AppContext struct (in application.h) manages:
- Window and renderer
- Performance timing
- Mouse input state
- Layout tree
- Current page
Provides a tree-based layout management system for organizing UI elements.
Pages encapsulate content and handle:
- Event processing
- Content updates
- Rendering
- Animation
The framework follows a layered architecture:
-
Core Layer (SDL3 Abstraction)
- Application lifecycle
- Event system
- Rendering system
-
Layout Layer
- Tree-based layout management
- Flexible positioning system
- Container management
-
Widget Layer
- Basic UI components
- Event handling
- Visual presentation
-
Page Layer
- Content organization
- State management
- Scene composition
#include "core/application.h"
#include "layouts/app_layout.h"
#include "app/page.h"
int main(int argc, char* argv[]) {
AppContext app_context;
// Initialize the application
if (!initialize_app(&app_context, "My App", 800, 600)) {
return 1;
}
// Create layout structure
app_context.root_layout = create_app_layout_structure(&app_context);
// Create and set active page
app_context.current_page = page_create();
// Run the application
run_main_loop(&app_context);
cleanup_app(&app_context);
return 0;
}- Create header file in
include/widgets/:
typedef struct MyWidget {
// Widget-specific properties
} MyWidget;
MyWidget* my_widget_create(void);
void my_widget_destroy(MyWidget* widget);
void my_widget_handle_event(MyWidget* widget, SDL_Event* event);
void my_widget_update(MyWidget* widget, float delta_time);
void my_widget_render(MyWidget* widget, AppContext* context);- Implement in
src/widgets/:- Follow existing widget patterns (button.c, shape.c)
- Handle lifecycle, events, rendering
- Use animation system if needed
- Create header file in
include/layouts/:
typedef struct MyLayout {
LayoutNode base; // Inherit from base layout
// Layout-specific properties
} MyLayout;
MyLayout* my_layout_create(void);
void my_layout_arrange(MyLayout* layout);- Implement in
src/layouts/:- Inherit from base layout system
- Implement arrangement logic
- Handle child positioning
-
Error Handling
- Add more robust error checking throughout initialization
- Implement error logging system beyond SDL_Log
-
Documentation
- Add inline documentation for public APIs
- Create usage examples for each component
-
Features
- Add resource management system
- Implement more widget types
- Add theming support
- Consider adding scene graph support
-
Testing
- Add unit tests for core components
- Implement integration tests for layout system
- Add performance benchmarks
[Add appropriate license information]
This project uses Git for version control. Here's a basic workflow for managing features or development versions:
-
Start a New Feature/Version:
- Ensure your
mainbranch is up-to-date:git checkout main git pull origin main
- Create a new branch for your work (e.g.,
feature/new-widgetordev/v0.2):git checkout -b feature/new-widget
- Ensure your
-
Work on the Feature Branch:
- Make your code changes.
- Commit your changes frequently:
git add . git commit -m "Implement basic button widget"
- Push your branch to the remote repository to back it up and potentially collaborate:
(The
git push -u origin feature/new-widget
-uflag sets the upstream branch, so futuregit pushcommands from this branch will automatically go toorigin/feature/new-widget)
-
Update Main Branch with Completed Feature:
- Once the feature is complete and tested, switch back to the
mainbranch:git checkout main
- Ensure
mainis still up-to-date:git pull origin main
- Merge your feature branch into
main:(Usinggit merge --no-ff feature/new-widget
--no-ffcreates a merge commit, preserving the history of the feature branch) - Resolve any merge conflicts if they occur.
- Push the updated
mainbranch:(Yourgit push origin main
feature/new-widgetbranch still exists locally and remotely at this point)
- Once the feature is complete and tested, switch back to the
-
Clean Up:
- If you no longer need the feature branch, you can delete it locally:
(Use
git branch -d feature/new-widget
-Dinstead of-dif the branch hasn't been fully merged and you still want to delete it) - You can also delete it from the remote repository:
git push origin --delete feature/new-widget
- If you no longer need the feature branch, you can delete it locally:
-
Moving between branches: git add README.md git commit -m "Update README with development workflow"
git checkout main
or
- This saves the current branch git stash push -m "README workflow edits"
git checkout main
- When back in the branch do: to load the saved state git checkout feature/new-widget git stash pop