Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b243ae6
[build] fixed trash \t
mrsrina May 27, 2025
cdd2963
[update] package-pattern, stuff unfinshed
mrsrina May 27, 2025
f685625
[git] new model architecture readme
mrsrina May 27, 2025
70e48c4
[git] removed useuless specifications topic from readme
mrsrina May 27, 2025
6b8163e
[git] improved readme
mrsrina May 27, 2025
2a125af
[feature] callback-handler and query function for descriptors
mrsrina May 28, 2025
c144ef4
[update] sampler
mrsrina May 29, 2025
48cfb4a
[ref] gl and allocator
mrsrina May 30, 2025
617805a
[ref] license on header
mrsrina May 30, 2025
babbbcb
[ref] font, gl, draw, allocator, init etc
mrsrina May 31, 2025
6d2f3ea
[update][git] font-rendering, allocator, commit
mrsrina May 31, 2025
8080ee9
[update] utf text io
mrsrina May 31, 2025
9be76cc
[update] added context extern to be intilialized on 'ekg.hpp'
mrsrina May 31, 2025
0ac6169
[update] swap, property, and button
mrsrina May 31, 2025
4c48382
[update] layout docknize, some states, button etc
mrsrina Jun 2, 2025
d9bf15f
[update] layout model
mrsrina Jun 3, 2025
7d6c21e
[fix] layoutnizatio, docknization and scalenization
mrsrina Jun 3, 2025
75e6966
[update] runtime events, callbacks, operations, et c
mrsrina Jun 4, 2025
6c8c8b3
[update] button widget impl.
mrsrina Jun 4, 2025
def188c
[ref] button reload done, fixed some errors, unbuidable yet
mrsrina Jun 5, 2025
e4ae314
[update] buildable
mrsrina Jun 6, 2025
4bc4795
[update] frame
mrsrina Jun 6, 2025
06970e6
[update] frame update, stuff and stuff idk
mrsrina Jun 6, 2025
ef1ed84
[fix] memory-swap
mrsrina Jun 7, 2025
865b047
[fix] interact and stuff
mrsrina Jun 7, 2025
24ee43d
[version] commit updates
mrsrina Jun 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ test/cmake-build-cache
lib/
.sublime-project.sublime-workspace
*.sublime-workspace

ekg-ui-library.sublime-workspace
ekg-sandbox
ekg-docs
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ find_package(Freetype REQUIRED)
file(GLOB_RECURSE HEADER_FILES "include/*.hpp")
file(GLOB_RECURSE SOURCE_FILES "src/*.cpp")

exclude_files_by_regex(SOURCE_FILES "/ui_|/util/")
# exclude_files_by_regex(SOURCE_FILES /* regex */)

add_library(
ekg STATIC
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022-2024 Rina Wilk / [email protected]
Copyright (c) 2022-2025 Rina Wilk / [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
88 changes: 7 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,14 @@
# 🐄 EKG 🐈

EKG is a descriptor-based low-latency UI-toolkit for desktop-apps, mobile-apps, and high-performance apps. Offers multi-support for platforms and graphics API(s).
EKG is a descriptor-based low-latency modular UI-toolkit for desktop-apps, mobile-apps, and high-performance apps.

**Note: EKG is not stable yet.**

Contributing for EKG is nicely welcome, just take a look on [Vokegpu standard](https://github.com/vokegpu/standard), thanks.

### GUIs with EKG

Creating a simple frame:

```C++
ekg::make(
ekg::frame_t {
.tag = "first frame",
.rect = {20.0f, 20.0f, 200.0f, 200.0f},
.drag_dock = ekg::dock::top,
.resize_dock = ekg::dock::left | ekg::dock::bottom | ekg::dock::right
}
);
```

![image](https://github.com/user-attachments/assets/1629c5ae-fa50-47f4-8900-65d11479df64)

Adding buttons:

```C++
ekg::button_t button {};

button.tag = "bt-1";
button.text = "moo moo";
button.text_dock = ekg::dock::left;
button.dock = ekg::dock::left;
ekg::make(button);

button.tag = "bt-2";
button.text = "owlf olwf";
button.text_dock = ekg::dock::center;
button.dock = ekg::dock::next | ekg::dock::fill;
ekg::make(button);

button.tag = "bt-3";
button.text = "oi amo gatinhos";
ekg::make(button);
```
Platforms: SDL2, GLFW.
GPU APIs: OpenGL3+, OpenGLES3.

![image](https://github.com/user-attachments/assets/5f510ef6-e51b-4ca0-a5fc-1d36582bb055)

You can dynamic change the value, text or any display output via safety-reference:

```C++
button.tag = "bt-3";
button.text = "oi amo gatinhos";
ekg::button_t &bla = ekg::make(button);
```

And then dynamic trigger/set value from fields.

```C++
bla.value = true; // set button trigger value forced
bla.text = "clicked here times: " + std::to_string(button_click_times); // set the text dynamically
```

Others widgets are being re-implemented in this new memory-model, also new future widgets.

May you want to know about this new memory-model or about EKG more, go here.
[EKG Docs](https://github.com/vokegpu/ekg-docs)

### Initializing EKG

EKG is a modular library, which does not necessary have one unique base, for example the platform used, supporting SDL2, GLFW and soon others.

```cpp
ekg::runtime_property_t ekg_runtime_property {
.font_path = "default.ttf",
.font_path_emoji = "default-emoji.ttf",
.p_gpu_api = new ekg::opengl(),
.p_os_platform = new ekg::sdl(p_win_sdl)
};
**Note: EKG is not stable yet.**

ekg::runtime ekg_runtime {};
ekg::init(&ekg_runtime, &ekg_runtime_property);
```
## GUIs with EKG

Supported GPU API(s): OpenGL3+, OpenGLES3.
## Contributing

Supported platform(s): SDL2, GLFW.
Contributing for EKG is nicely welcome, please confer [EKG docs and read the model architecture](https://github.com/vokegpu/ekg-docs?tab=readme-ov-file#ekg-technical-details) for prevent ~useless~ pull requests.
120 changes: 60 additions & 60 deletions ekg-ui-library.sublime-project
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
{
"folders":
[
{
"path": ".",
}
],
"settings":
{
"tab_size": 2,
"translate_tabs_to_spaces": true,
"LSP":
{
"binary": "clang++",
"clangd":
{
"initializationOptions":
{
"clangd.compile-commands-dir": "$folder/cmake-build",
},
},
},
},
"build_systems":
[
{
"name": "Build Linux GNU",
"shell_cmd":
"cd $folder && EKG_BUILD_MODE=build-only EKG_BUILD_COMPILER=/usr/bin/g++ sh ./linux.sh"
},
{
"name": "Build-&-Test Linux GNU",
"shell_cmd":
"cd $folder && EKG_BUILD_MODE=build-and-test EKG_BUILD_COMPILER=/usr/bin/g++ sh ./linux.sh"
},
{
"name": "Build Linux Clang",
"shell_cmd":
"cd $folder && EKG_BUILD_MODE=build-only EKG_BUILD_COMPILER=/usr/bin/g++ sh ./linux.sh"
},
{
"name": "Build-&-Test Linux Clang",
"shell_cmd":
"cd $folder && EKG_BUILD_MODE=build-and-test EKG_BUILD_COMPILER=/usr/bin/clang++ sh ./linux.sh"
},
{
"name": "Build Linux WASM/emscripten",
"shell_cmd":
"cd $folder && EKG_BUILD_MODE=build-only EKG_BUILD_COMPILER=emscripten sh ./linux.sh"
},
{
"name": "Build Windows GNU",
"shell_cmd":
"cd $folder && cmake -S . -B ./cmake-build/ -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1 && cmake --build ./cmake-build/"
},
{
"name": "Build-&-Test Windows GNU",
"shell_cmd":
"cd $folder && cmake -S . -B ./cmake-build/ -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1 && cmake --build ./cmake-build/ && cd ./ekg-sandbox && cmake -S . -B ./cmake-build -G Ninja -DEKG_DEVELOPER_MODE=1 && cmake --build ./cmake-build && cd ./bin && ./ekg-showcase",
},
],
"folders":
[
{
"path": ".",
}
],
"settings":
{
"tab_size": 2,
"translate_tabs_to_spaces": true,
"LSP":
{
"clangd":
{
"system_binary": "clangd",
"initializationOptions":
{
"clangd.compile-commands-dir": "$folder/cmake-build"
}
},
},
},
"build_systems":
[
{
"name": "Build Linux GNU",
"shell_cmd":
"cd $folder && EKG_BUILD_MODE=build-only EKG_BUILD_COMPILER=/usr/bin/g++ sh ./linux.sh"
},
{
"name": "Build-&-Test Linux GNU",
"shell_cmd":
"cd $folder && EKG_BUILD_MODE=build-and-test EKG_BUILD_COMPILER=/usr/bin/g++ sh ./linux.sh"
},
{
"name": "Build Linux Clang",
"shell_cmd":
"cd $folder && EKG_BUILD_MODE=build-only EKG_BUILD_COMPILER=/usr/bin/g++ sh ./linux.sh"
},
{
"name": "Build-&-Test Linux Clang",
"shell_cmd":
"cd $folder && EKG_BUILD_MODE=build-and-test EKG_BUILD_COMPILER=/usr/bin/clang++ sh ./linux.sh"
},
{
"name": "Build Linux WASM/emscripten",
"shell_cmd":
"cd $folder && EKG_BUILD_MODE=build-only EKG_BUILD_COMPILER=emscripten sh ./linux.sh"
},
{
"name": "Build Windows GNU",
"shell_cmd":
"cd $folder && cmake -S . -B ./cmake-build/ -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1 && cmake --build ./cmake-build/"
},
{
"name": "Build-&-Test Windows GNU",
"shell_cmd":
"cd $folder && cmake -S . -B ./cmake-build/ -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1 && cmake --build ./cmake-build/ && cd ./ekg-sandbox && cmake -S . -B ./cmake-build -G Ninja -DEKG_DEVELOPER_MODE=1 && cmake --build ./cmake-build && cd ./bin && ./ekg-showcase",
},
],
}
94 changes: 62 additions & 32 deletions include/ekg/core/context.hpp
Original file line number Diff line number Diff line change
@@ -1,48 +1,78 @@
/**
* MIT License
*
* Copyright (c) 2022-2025 Rina Wilk / [email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef EKG_CORE_CONTEXT_HPP
#define EKG_CORE_CONTEXT_HPP

#include "ekg/io/typography.hpp"
#include "ekg/math/geometry.hpp"
#include "ekg/ui/types.hpp"
#include "ekg/io/descriptor.hpp"

namespace ekg {
extern FT_Library freetype_library;

extern struct viewport_t {
float x {};
float y {};
float w {};
float h {};
float dt {};
float minimum_possible_size {10.0f};
bool redraw {};
} viewport;
extern struct metrics_t {
public:
size_t gpu_data_count {};
} metrics;

extern struct dpi_t {
ekg::rect_t<float> scale {0.0f, 0.0f, 1920.0f, 1080.0f};
public:
ekg::rect_t<float> viewport {};
ekg::rect_t<float> scale {0.0f, 0.0f, 1080.0f, 1920.0f};
bool auto_scale {};
float scale_interval {25.0f};

float font_scale {18.0f};
float factor_scale {};

float font_scale {};
float min_sizes {10.0f};
ekg::vec2_t<uint32_t> font_offset {4, 6};
bool auto_scale {true};
} dpi;

extern struct current_t {
ekg::id_t pressed {};
ekg::type pressed_type {};
ekg::id_t released {};
ekg::type released_type {};
ekg::id_t last {};
ekg::id_t unique_id {};
ekg::type type {};
} current;

extern struct tweaks_t {
int64_t task_latency {500};
int64_t debug {};
} tweaks;
extern struct gui_t {
public:
struct bind_t {
public:
ekg::at_t stack_at {ekg::at_t::not_found};
ekg::at_t swap_at {ekg::at_t::not_found};
ekg::at_t parent_at {ekg::at_t::not_found};
};

// @TODO: add last for press, release and hover

struct ui_t {
public:
ekg::at_t abs_widget_at {ekg::at_t::not_found};
ekg::type hovered_type {};
ekg::at_t hovered_at {ekg::at_t::not_found};
ekg::at_t last_hovered_at {ekg::at_t::not_found};
ekg::type pressed_type {};
ekg::at_t pressed_at {ekg::at_t::not_found};
ekg::type released_type {};
ekg::at_t released_at {ekg::at_t::not_found};
float dt {};
bool redraw {};
};
public:
ekg::gui_t::bind_t bind {};
ekg::gui_t::ui_t ui {};
} gui;

constexpr uint32_t minimum_small_font_height {4};
constexpr uint32_t minimum_font_height {8};
Expand Down
Loading
Loading