Skip to content

Commit

Permalink
Adding CI
Browse files Browse the repository at this point in the history
  • Loading branch information
texus committed Apr 21, 2024
1 parent c5a63fe commit f73d908
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 8 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ endif()
ctgui_set_option(CTGUI_LINK_TGUI_STATICALLY ${link_tgui_statically_default} BOOL "TRUE to link to a static version of TGUI, FALSE to link dynamically")

set(TGUI_STATIC_LIBRARIES ${CTGUI_LINK_TGUI_STATICALLY})
find_package(TGUI ${PROJECT_VERSION_MAJOR} REQUIRED CONFIG)
if (NOT TARGET TGUI::TGUI)
find_package(TGUI ${PROJECT_VERSION_MAJOR} REQUIRED CONFIG)
endif()

if(CTGUI_HAS_BACKEND_CSFML_GRAPHICS)
ctgui_set_option(CTGUI_USE_CSFML_VERSION 2 STRING "Select the CSFML version to search and link to")
Expand Down
6 changes: 6 additions & 0 deletions examples/SDL_RENDERER/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
add_executable(example-sdl-renderer example.c)
target_link_libraries(example-sdl-renderer PRIVATE ctgui)

if (CTGUI_USE_SDL_VERSION EQUAL 2)
if (TARGET SDL2::SDL2main) # This target is only required on Windows
target_link_libraries(example-sdl-renderer PRIVATE SDL2::SDL2main)
endif()
endif()
13 changes: 11 additions & 2 deletions examples/SDL_RENDERER/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,31 @@
#include <stdio.h>
#include <stdbool.h>

void func()
#if SDL_MAJOR_VERSION >= 3
#include <SDL3/SDL_main.h>
#endif

void func(void)
{
printf("Button clicked\n");
}

int main(int, char**)
int main(int argc, char* argv[])
{
// SDL and SDL_ttf need to be initialized before using CTGUI
SDL_Init(SDL_INIT_VIDEO);
TTF_Init();

#if SDL_MAJOR_VERSION >= 3
SDL_Window* window = SDL_CreateWindow("CTGUI example (SDL-Renderer)", 400, 300, 0);
SDL_Renderer* renderer = SDL_CreateRenderer(window, NULL, 0);
#else
SDL_Window* window = SDL_CreateWindow("CTGUI example (SDL-Renderer)",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
400, 300,
SDL_WINDOW_SHOWN);
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
#endif

// The tguiGui object should always be the first CTGUI object to create
tguiGui* gui = tguiGuiSDLRenderer_create(window, renderer);
Expand Down
2 changes: 1 addition & 1 deletion include/CTGUI/Widgets/ComboBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CTGUI_API tguiWidget* tguiComboBox_create(void);
CTGUI_API void tguiComboBox_setItemsToDisplay(tguiWidget* widget, size_t itemsToDisplay);
CTGUI_API size_t tguiComboBox_getItemsToDisplay(const tguiWidget* widget);

CTGUI_API tguiBool tguiComboBox_addItem(tguiWidget* widget, tguiUtf32 item, tguiUtf32 id);
CTGUI_API size_t tguiComboBox_addItem(tguiWidget* widget, tguiUtf32 item, tguiUtf32 id);
CTGUI_API tguiUtf32 tguiComboBox_getItemById(const tguiWidget* widget, tguiUtf32 id);

CTGUI_API tguiBool tguiComboBox_setSelectedItem(tguiWidget* widget, tguiUtf32 item);
Expand Down
2 changes: 1 addition & 1 deletion src/CTGUI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ if(CTGUI_HAS_BACKEND_SDL_RENDERER)
if (CTGUI_USE_SDL_VERSION EQUAL 2)
target_link_libraries(ctgui PUBLIC SDL2::SDL2 SDL2_ttf::SDL2_ttf)
elseif(CTGUI_USE_SDL_VERSION EQUAL 3)
target_link_libraries(ctgui PUBLIC SDL3::SDL3 SDL3_ttf::SDL3_ttf)
target_link_libraries(ctgui PUBLIC SDL3::SDL3-shared SDL3_ttf::SDL3_ttf-shared)
endif()
endif()

Expand Down
2 changes: 1 addition & 1 deletion src/CTGUI/TimerStruct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct tguiTimer
std::shared_ptr<tgui::Timer> This;

tguiTimer(void(*callback)(tguiTimer*), tgui::Duration interval, bool enable)
: This{tgui::Timer::create([=]{ callback(this); }, interval, enable)}
: This{tgui::Timer::create([this,callback]{ callback(this); }, interval, enable)}
{
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/CTGUI/Widgets/ComboBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ size_t tguiComboBox_getItemsToDisplay(const tguiWidget* widget)

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

tguiBool tguiComboBox_addItem(tguiWidget* widget, tguiUtf32 item, tguiUtf32 id)
size_t tguiComboBox_addItem(tguiWidget* widget, tguiUtf32 item, tguiUtf32 id)
{
return DOWNCAST(widget->This)->addItem(ctgui::toCppStr(item), ctgui::toCppStr(id));
}
Expand Down
2 changes: 1 addition & 1 deletion src/CTGUI/Widgets/PanelListBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ tguiWidget* tguiPanelListBox_addItem(tguiWidget* widget, tguiUtf32 id)

tguiWidget* tguiPanelListBox_addItemAtIndex(tguiWidget* widget, tguiUtf32 id, size_t index)
{
return ctgui::addWidgetRef(DOWNCAST(widget->This)->addItem(ctgui::toCppStr(id), index));
return ctgui::addWidgetRef(DOWNCAST(widget->This)->addItem(ctgui::toCppStr(id), static_cast<int>(index)));
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit f73d908

Please sign in to comment.