Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .hdoc.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "ekg"
version = "1.0.0"
version = "2.0.0"

git_repo_url = "https://github.com/vokegpu/ekg-ui-library/"
git_default_branch = "version-core"
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ target_compile_options(
#-g
)

target_compile_definitions(
ekg PRIVATE
EKG_VERSION="${EKG_VERSION}"
)

set_target_properties(
ekg PROPERTIES
CXX_STANDARD 17
Expand Down
2 changes: 1 addition & 1 deletion cmake/properties.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(EKG_VERSION 2.0.0)
set(EKG_VERSION 2.1.0)
set(EKG_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include")

if(CMAKE_TOOLCHAIN_FILE)
Expand Down
7 changes: 4 additions & 3 deletions include/ekg/core/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ namespace ekg {
extern struct dpi_t {
public:
ekg::rect_t<float> viewport {};
ekg::rect_t<float> scale {0.0f, 0.0f, 1080.0f, 1920.0f};
bool auto_scale {};
ekg::rect_t<float> scale {0.0f, 0.0f, 1920.0f, 1080.0f};
bool auto_scale {true};
float scale_interval {25.0f};
float factor_scale {};
float font_scale {};
float font_scale {18.0f};
float min_sizes {10.0f};
ekg::vec2_t<uint32_t> font_offset {4, 6};
} dpi;
Expand All @@ -66,6 +66,7 @@ namespace ekg {
ekg::at_t pressed_at {ekg::at_t::not_found};
ekg::type released_type {};
ekg::at_t released_at {ekg::at_t::not_found};
int64_t frequency {500};
float dt {};
bool redraw {};
};
Expand Down
11 changes: 8 additions & 3 deletions include/ekg/core/pools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,18 @@ namespace ekg::core {
} \
\
ekg::property_t &parent {ekg::query<ekg::property_t>(ekg::gui.bind.parent_at)}; \
if (parent != ekg::property_t::not_found && is_container) { \
if (widget.dock != ekg::dock::none) { \
if (is_container) { \
if (parent != ekg::property_t::not_found && widget.dock != ekg::dock::none) { \
parent.children.push_back(widget.at); \
property.parent_at = ekg::gui.bind.parent_at; \
property.abs_parent_at = parent.abs_parent_at; \
} else { \
ekg::gui.bind.parent_at = widget.at; \
ekg::gui.bind.parent_at = property.at; \
property.abs_parent_at = property.at; \
} \
} else if (parent != ekg::property_t::not_found) { \
property.parent_at = ekg::gui.bind.parent_at; \
property.abs_parent_at = parent.abs_parent_at; \
parent.children.push_back(widget.at); \
} \
\
Expand Down
26 changes: 21 additions & 5 deletions include/ekg/draw/allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,23 @@
* This macro prevent from dispatching any GPU-data under a render section
* if the content is not visible to the parent rect_scissor.
**/
#define ekg_assert_scissor(rect_scissor, rect_child, rect_parent, is_parented) \
#define ekg_draw_allocator_assert_scissor(rect_scissor, rect_child, rect_parent, is_parented) \
if (!ekg::p_core->draw_allocator.sync_scissor(rect_scissor, rect_child, rect_parent, is_parented)) return;

#define ekg_draw_allocator_bind_local(p_geometry_buffer, p_gpu_data_buffer) \
ekg::p_core->draw_allocator.bind_local(p_geometry_buffer, p_gpu_data_buffer);

#define ekg_draw_allocator_pass() \
ekg::p_core->draw_allocator.pass(); \
return;

namespace ekg::draw {
class allocator {
public:
static bool enable_high_priority;
static bool is_simple_shape;
protected:
size_t global_data_instance {};
size_t data_instance {};
ekg::vec2_t<size_t> stride_instance {};
size_t simple_shape_instance {};
Expand All @@ -53,7 +61,12 @@ namespace ekg::draw {
std::vector<ekg::gpu::data_t> gpu_data_buffer {};
std::vector<ekg::gpu::data_t> high_priority_gpu_data_buffer {};
std::vector<float> geometry_buffer {};

std::vector<float> *p_local_geometry_buffer {};
std::vector<ekg::gpu::data_t> *p_local_gpu_data_buffer {};

size_t last_geometry_buffer_size {};
size_t memory_block_offset_counter {};

bool was_hash_changed {};
int32_t previous_hash {};
Expand All @@ -65,12 +78,15 @@ namespace ekg::draw {
void revoke();
void to_gpu();

void bind_texture(ekg::sampler_t &sampler);
void bind_texture(ekg::at_t &sampler_at);
void bind_local(
std::vector<float> *p_geometry_buffer,
std::vector<ekg::gpu::data_t> *p_gpu_data_buffer
);

ekg::gpu::data_t &bind_current_data();
size_t get_current_data_id();
ekg::gpu::data_t &get_data_by_index(size_t index);
void clear_current_data();
void dispatch();
void pass();

bool sync_scissor(
ekg::rect_t<float> &rect_scissor,
Expand Down
4 changes: 2 additions & 2 deletions include/ekg/draw/shape/shape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ namespace ekg::draw {
const ekg::rect_t<float> &rect,
const ekg::rgba_t<uint8_t> &color,
ekg::pixel_thickness_t line_thicnkess,
ekg::sampler_t &sampler
ekg::at_t &sampler_at
);

void rect(
float x, float y, float w, float h,
const ekg::rgba_t<uint8_t> &color,
ekg::pixel_thickness_t line_thicnkess,
ekg::sampler_t &sampler
ekg::at_t &sampler_at
);

void scissor(
Expand Down
2 changes: 1 addition & 1 deletion include/ekg/gpu/api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ namespace ekg::gpu {
) { return ekg::result::failed_not_implemented; };

virtual ekg::at_t &bind_sampler(
ekg::sampler_t &sampler
ekg::at_t &sampler_at
) { return ekg::at_t::not_found; };
};
}
Expand Down
6 changes: 5 additions & 1 deletion include/ekg/gpu/data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ namespace ekg::gpu {
public:
static ekg::gpu::data_t not_found;
public:
float buffer[12] {};
ekg::at_t sampler_at {ekg::at_t::not_found};
public:
float buffer[12] {};
int8_t line_thickness {};
int32_t begin_stride {};
int32_t end_stride {};
// int32_t prev_mem_block_size {};
// int32_t mem_block_offset {};
bool is_new {};
ekg::hash_t hash {};
int32_t scissor_id {-1};
public:
Expand Down
2 changes: 1 addition & 1 deletion include/ekg/gpu/opengl/gl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace ekg {
) override;

ekg::at_t &bind_sampler(
ekg::sampler_t &sampler
ekg::at_t &sampler_at
) override;
};
}
Expand Down
4 changes: 2 additions & 2 deletions include/ekg/gpu/sampler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace ekg {
static constexpr ekg::type type {ekg::type::sampler};
static ekg::sampler_t not_found;
public:
const char *p_tag {};
std::string tag {};
uint32_t w {};
uint32_t h {};
uint32_t channel {};
Expand All @@ -47,7 +47,7 @@ namespace ekg {

struct sampler_info_t {
public:
const char *p_tag {};
std::string tag {};
int32_t offset[2] {};
int32_t w {};
int32_t h {};
Expand Down
2 changes: 1 addition & 1 deletion include/ekg/handler/theme.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace ekg {
std::string description {};
public:
float layout_offset {};
ekg::pixel_t layout_margin_thickness {};
ekg::pixel_t layout_margin_thickness {2};
ekg::button_color_scheme_t button_color_scheme {};
ekg::frame_color_scheme_t frame_color_scheme {};
};
Expand Down
46 changes: 44 additions & 2 deletions include/ekg/io/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,49 @@
#define EKG_IO_EVENT_HPP

#include "ekg/handler/input.hpp"
#include "ekg/handler/callback.hpp"
#include "ekg/core/context.hpp"

#include <array>

namespace ekg {
enum behavior : ekg::flags_t {
no_auto_set_viewport_when_resize = 2 << 1
};

constexpr size_t enum_layer_size {8};
enum class layer {
bg,
outline,
highlight_bg,
highlight_fg,
active_bg,
active_outline,
text_fg,
text_outline
};

constexpr size_t enum_action_size {8};
enum class action {
hover,
active,
press,
release
};

template<typename t, size_t s>
struct at_array_t {
protected:
std::array<ekg::at_t, s> ats {};
public:
ekg::at_t &operator[](t item) {
return this->ats[static_cast<size_t>(item)];
}

ekg::at_t &operator[](size_t index) {
return this->ats[index];
}
};
}

namespace ekg::io {
Expand All @@ -46,6 +84,10 @@ namespace ekg::io {
ekg::at_t &property_at = ekg::at_t::not_found
);

void dispatch(
ekg::at_t &callback_at
);

enum class stage {
pre,
process,
Expand Down Expand Up @@ -91,8 +133,8 @@ namespace ekg::io {
};
}

namespace ekg::io {

}
#define ekg_action(actions, action, state) if (state) ekg::io::dispatch(actions[action]);
#define ekg_set(should_rebuffering, state, new_state) ((state != new_state) && (ekg::gui.ui.redraw = true) && (should_rebuffering = true) && ((state = new_state) || true))

#endif
18 changes: 13 additions & 5 deletions include/ekg/io/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
/**
* A low-level assert used in risks cases where virtual-address should be warned.
**/
#define ekg_assert_low_level(state, alarm, end) if (state) alarm; end;
#define ekg_assert_low_level(state, alarm, end) if (state) { alarm; end; }

/**
* A dev-purpose log level untracked for EKG.
Expand All @@ -58,7 +58,7 @@ namespace ekg {

template<typename t>
constexpr bool has(ekg::flags_t bits, t bit) {
return (bits & bit) == bit;
return (bits & bit) >= bit;
}

template<typename t>
Expand Down Expand Up @@ -166,7 +166,7 @@ namespace ekg {
class value {
protected:
t val {};
t *p {};
t *p {nullptr};
t previous {};
bool changed {};
public:
Expand All @@ -189,9 +189,10 @@ namespace ekg {
this->changed = true;
}

void set(const t &val) {
this->get() = p;
bool set(const t &val) {
this->get() = val;
this->changed = true;
return true;
}

t &get() {
Expand Down Expand Up @@ -220,6 +221,13 @@ namespace ekg {

return false;
}
public:
template<typename s>
ekg::value<t> &operator = (const s &val) {
this->get() = val;
this->changed = true;
return *this;
}
};

struct mapped_address_sign_info_t {
Expand Down
15 changes: 12 additions & 3 deletions include/ekg/ui/button/button.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ekg/io/descriptor.hpp"
#include "ekg/io/font.hpp"
#include "ekg/math/geometry.hpp"
#include "ekg/io/event.hpp"

namespace ekg {
struct button_color_scheme_t {
Expand All @@ -36,6 +37,7 @@ namespace ekg {
ekg::rgba_t<uint8_t> background {};
ekg::rgba_t<uint8_t> outline {};
ekg::rgba_t<uint8_t> highlight {};
ekg::rgba_t<uint8_t> active {};

ekg::rgba_t<uint8_t> box_background {};
ekg::rgba_t<uint8_t> box_outline {};
Expand All @@ -49,15 +51,20 @@ namespace ekg {
public:
struct widget_t {
public:
bool is_highlight {};
bool is_active {};
ekg::rect_t<float> rect_text {};
ekg::rect_t<float> rect_box {};
};
public:
ekg::value<std::string> text {};
ekg::value<bool> value {};
ekg::font font_size {ekg::font::medium};
bool is_check_box {};
ekg::flags_t dock {};
ekg::flags_t box {ekg::dock::none};
ekg::flags_t dock {ekg::dock::left};
ekg::button_t::check_t::widget_t widget {};
ekg::at_array_t<ekg::layer, 12> layers {};
ekg::at_array_t<ekg::action, 12> actions {};
};

static ekg::button_t not_found;
Expand All @@ -66,8 +73,10 @@ namespace ekg {
ekg::at_t property_at {};
public:
std::string tag {};
ekg::flags_t dock {};
ekg::flags_t dock {ekg::dock::left | ekg::dock::fill};
ekg::rect_t<float> rect {};
ekg::at_array_t<ekg::layer, 12> layers {};
ekg::at_array_t<ekg::action, 12> actions {};
std::vector<ekg::button_t::check_t> checks {};
ekg::button_color_scheme_t color_scheme {};
public:
Expand Down
Loading
Loading