Skip to content

Commit

Permalink
[fix][build] fixed Clang warnings for Clang toolchain support
Browse files Browse the repository at this point in the history
  • Loading branch information
MrsRina committed Oct 25, 2024
1 parent 3484679 commit 0007cf3
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 99 deletions.
35 changes: 17 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,22 @@
cmake_minimum_required(VERSION 3.9)

set(CMAKE_CXX_STANDARD 17)
set(EKG_VERSION 1.1.0)
set(EKG_VERSION 1.2.0)

message("-- Building EKG user interface library version ${EKG_VERSION}")
message(STATUS "Building EKG user interface library version ${EKG_VERSION}")
project(ekg VERSION ${EKG_VERSION} DESCRIPTION "graphical user interface")

# Enable if your base OS is Debian-based (e.g Ubuntu).
# It is a common issue related by the Linux community.
if (EKG_LINUX_NOT_FOUND_FREETYPE)
include_directories(/usr/include/freetype2)
message("-- Using var EKG_LINUX_NOT_FOUND_FREETYPE to include `/usr/include/freetype2` directly")
message(
STATUS
"Using var EKG_LINUX_NOT_FOUND_FREETYPE to direct include `/usr/include/freetype2`"
)
endif()

if (WIN32 OR EKG_FORCE_WINDOWS)
if(WIN32 OR EKG_FORCE_WINDOWS)
set(LIBRARY_OUTPUT_PATH "../lib/windows/")
set(PLATFORM "windows")
elseif(ANDROID OR EKG_FORCE_ANDROID)
Expand All @@ -47,35 +50,31 @@ elseif(LINUX OR EKG_FORCE_LINUX)
set(PLATFORM "linux")
endif()

message("-- Generating EKG ${PLATFORM} native library")

message(STATUS "Generating EKG ${PLATFORM} native library")
file(GLOB_RECURSE SOURCE_FILES "src/*.cpp")

if (EKG_ENABLE_DEBUG)
message("-- EKG debug mode on")
add_compile_options(-g)
add_compile_options(-fsanitize=address)
add_compile_options(-fno-omit-frame-pointer)
add_compile_options(-fcompare-debug-second)
elseif()
if(
CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
)
add_compile_options(-O3)

endif()

include_directories(./include)
add_library(ekg STATIC ${SOURCE_FILES})

message("-- EKG native library building done")
message(STATUS "EKG native library building done")

if(LINUX OR EKG_FORCE_LINUX)
install(
TARGETS ekg
LIBRARY DESTINATION /usr/lib
LIBRARY DESTINATION /usr/local/lib
)

install(
DIRECTORY ./include DESTINATION /usr
DIRECTORY ./include DESTINATION /usr/local
)

message("-- EKG install on Linux ok!")
message(STATUS "EKG install on Linux ok!")
endif()
6 changes: 5 additions & 1 deletion devlog/commit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,8 @@
-- Fixed a glitch where the item hover attr flag was being spammed if scrolling fast.
-- Fixed a glitch where the addresed value was not clamped in slider widget.
-- Added `ekg::dock::bind` feature flag to the Extentnize, which do not increase the dimension and stand stop unless next dock is not `ekg::dock::bind`.
-- Added `ekg::stack::find<t>(std::string_view tag)` for find UI objects in a stack.
-- Added `ekg::stack::find<t>(std::string_view tag)` for find UI objects in a stack.

1.2.0 25/10/24

-- Written a new docknize layout positions, added two sides: `ekg::dock::right` and `ekg::dock::bottom` .
6 changes: 5 additions & 1 deletion devlog/todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ stupid ticking glitch.

rewrite slider
fix listbox issue when scrolling and dragging?
reduce ekg::slider<t> verbose number setting.
reduce ekg::slider<t> verbose number setting.

// Add checkbox

13 changes: 9 additions & 4 deletions ekg-ui-library.sublime-project
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@
"build_systems":
[
{
"name": "Linux Build-&-Test",
"name": "Linux Build-&-Test GNU",
"shell_cmd":
"cd $folder && cmake -S . -B ./cmake-build-debug/ -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DEKG_LINUX_NOT_FOUND_FREETYPE=1 -DEKG_ENABLE_DEBUG=0 && cmake --build ./cmake-build-debug/ && cd ./test && cmake -S . -B ./cmake-build-debug -G Ninja -DEKG_LINUX_NOT_FOUND_FREETYPE=1 && cmake --build ./cmake-build-debug && cd ./bin && ./ekg-gui-showcase-test"
"cd $folder && cmake -S . -B ./cmake-build-debug/ -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DEKG_LINUX_NOT_FOUND_FREETYPE=1 && cmake --build ./cmake-build-debug/ && cd ./test && cmake -S . -B ./cmake-build-debug -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DEKG_LINUX_NOT_FOUND_FREETYPE=1 && cmake --build ./cmake-build-debug && cd ./bin && ./ekg-gui-showcase-test"
},
{
"name": "Windows Build-&-Test",
"shell_cmd":
"cd $folder && cmake -S . -B ./cmake-build-debug/ -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DEKG_LINUX_NOT_FOUND_FREETYPE=1 -DEKG_ENABLE_DEBUG=0 && cmake --build ./cmake-build-debug/ && cd ./test && cmake -S . -B ./cmake-build-debug -G Ninja -DEKG_LINUX_NOT_FOUND_FREETYPE=1 && cmake --build ./cmake-build-debug && cd ./bin && ./ekg-gui-showcase-test"
}
"cd $folder && cmake -S . -B ./cmake-build-debug/ -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DEKG_LINUX_NOT_FOUND_FREETYPE=1 && cmake --build ./cmake-build-debug/ && cd ./test && cmake -S . -B ./cmake-build-debug -G Ninja -DEKG_LINUX_NOT_FOUND_FREETYPE=1 && cmake --build ./cmake-build-debug && cd ./bin && ./ekg-gui-showcase-test"
},
{
"name": "Linux Build-&-Test Clang",
"shell_cmd":
"cd $folder && cmake -S . -B ./cmake-build-debug/ -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DEKG_LINUX_NOT_FOUND_FREETYPE=1 && cmake --build ./cmake-build-debug/ && cd ./test && cmake -S . -B ./cmake-build-debug -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DEKG_LINUX_NOT_FOUND_FREETYPE=1 && cmake --build ./cmake-build-debug && cd ./bin && ./ekg-gui-showcase-test"
},
],
}
2 changes: 1 addition & 1 deletion include/ekg/ekg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include "ekg/ui/listbox/ui_listbox.hpp"
#include "ekg/ui/scrollbar/ui_scrollbar.hpp"

#define EKG_VERSION_ID "1.1.0"
#define EKG_VERSION_ID "1.2.0"
#define EKG_VERSION_STATE "ALPHA"

#define EKG_FONT_SMALL_SIZE(font_size) (ekg_min(font_size - 4, 4))
Expand Down
5 changes: 5 additions & 0 deletions include/ekg/ui/listbox/ui_listbox_widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@

namespace ekg::ui {
class listbox_widget : public ekg::ui::abstract_widget {
public:
enum op_mode {
cached_update,
recursive_tree_update,
};
public:
void render_item(
ekg::item &item_header,
Expand Down
27 changes: 12 additions & 15 deletions src/os/ekg_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,21 +613,18 @@ void ekg::os::opengl::draw(
!ekg_is_sampler_protected(this->bound_sampler_list.at(data.sampler_index)->gl_protected_active_index)
)
) {
ekg::gpu::sampler_t *&p_sampler {
this->bound_sampler_list.at(data.sampler_index)
};

switch (ekg_is_sampler_protected(p_sampler->gl_protected_active_index)) {
case true:
glUniform1i(this->uniform_active_tex_slot, p_sampler->gl_protected_active_index);
glUniform1i(this->uniform_active_texture, EKG_ENABLE_TEXTURE_PROTECTED);
break;
case false:
glBindTexture(GL_TEXTURE_2D, p_sampler->gl_id);

glUniform1i(this->uniform_active_tex_slot, this->protected_texture_active_index);
glUniform1i(this->uniform_active_texture, EKG_ENABLE_TEXTURE);
break;

ekg::gpu::sampler_t *&p_sampler {
this->bound_sampler_list.at(data.sampler_index)
};

if (ekg_is_sampler_protected(p_sampler->gl_protected_active_index)) {
glUniform1i(this->uniform_active_tex_slot, p_sampler->gl_protected_active_index);
glUniform1i(this->uniform_active_texture, EKG_ENABLE_TEXTURE_PROTECTED);
} else {
glBindTexture(GL_TEXTURE_2D, p_sampler->gl_id);
glUniform1i(this->uniform_active_tex_slot, this->protected_texture_active_index);
glUniform1i(this->uniform_active_texture, EKG_ENABLE_TEXTURE);
}

previous_sampler_bound = data.sampler_index;
Expand Down
24 changes: 6 additions & 18 deletions src/os/ekg_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,11 @@ void ekg::os::sdl::get_special_key(io_key &key, ekg::special_key &special_key) {

void ekg::os::sdl_poll_event(SDL_Event &sdl_event) {
ekg::os::io_event_serial &serialized {ekg::core->io_event_serial};

float precise_interval {};

switch (sdl_event.type) {
default:
break;
case SDL_WINDOWEVENT:
switch (sdl_event.window.event) {
case SDL_WINDOWEVENT_SIZE_CHANGED:
Expand All @@ -182,39 +183,32 @@ void ekg::os::sdl_poll_event(SDL_Event &sdl_event) {

break;
}

break;

case SDL_KEYDOWN:
serialized.event_type = ekg::platform_event_type::key_down;
serialized.key.key = static_cast<int32_t>(sdl_event.key.keysym.sym);
ekg::poll_io_event = true;
break;

case SDL_KEYUP:
serialized.event_type = ekg::platform_event_type::key_up;
serialized.key.key = static_cast<int32_t>(sdl_event.key.keysym.sym);
ekg::poll_io_event = true;
break;

case SDL_TEXTINPUT:
serialized.event_type = ekg::platform_event_type::text_input;
serialized.text_input = sdl_event.text.text;
ekg::poll_io_event = true;
break;

case SDL_MOUSEBUTTONUP:
serialized.event_type = ekg::platform_event_type::mouse_button_up;
serialized.mouse_button = sdl_event.button.button;
ekg::poll_io_event = true;
break;

case SDL_MOUSEBUTTONDOWN:
serialized.event_type = ekg::platform_event_type::mouse_button_down;
serialized.mouse_button = sdl_event.button.button;
ekg::poll_io_event = true;
break;

case SDL_MOUSEWHEEL:
serialized.event_type = ekg::platform_event_type::mouse_wheel;
serialized.mouse_wheel_x = sdl_event.wheel.x;
Expand All @@ -223,28 +217,24 @@ void ekg::os::sdl_poll_event(SDL_Event &sdl_event) {
serialized.mouse_wheel_precise_y = sdl_event.wheel.preciseY;
ekg::poll_io_event = true;
break;

case SDL_MOUSEMOTION:
serialized.event_type = ekg::platform_event_type::mouse_motion;
serialized.mouse_motion_x = sdl_event.motion.x;
serialized.mouse_motion_y = sdl_event.motion.y;
ekg::poll_io_event = true;
break;

case SDL_FINGERUP:
serialized.event_type = ekg::platform_event_type::finger_up;
serialized.finger_x = sdl_event.tfinger.x;
serialized.finger_y = sdl_event.tfinger.y;
ekg::poll_io_event = true;
break;

case SDL_FINGERDOWN:
serialized.event_type = ekg::platform_event_type::finger_down;
serialized.finger_x = sdl_event.tfinger.x;
serialized.finger_y = sdl_event.tfinger.y;
ekg::poll_io_event = true;
break;

case SDL_FINGERMOTION:
serialized.event_type = ekg::platform_event_type::finger_motion;
serialized.finger_x = sdl_event.tfinger.x;
Expand All @@ -255,11 +245,9 @@ void ekg::os::sdl_poll_event(SDL_Event &sdl_event) {
break;
}

switch (ekg::poll_io_event) {
case true:
ekg::cursor = ekg::system_cursor::arrow;
ekg::core->process_event();
ekg::poll_io_event = false;
break;
if (ekg::poll_io_event) {
ekg::cursor = ekg::system_cursor::arrow;
ekg::core->process_event();
ekg::poll_io_event = false;
}
}
Loading

0 comments on commit 0007cf3

Please sign in to comment.