Major Restructuring
N0ffie switched to mingw (fixing linux warnings)
This commit is contained in:
parent
384c758295
commit
8e0e9ceb7c
26 changed files with 1016 additions and 2921 deletions
26
examples/CMakeLists.txt
Normal file
26
examples/CMakeLists.txt
Normal file
|
@ -0,0 +1,26 @@
|
|||
# Examples CMakeLists.txt
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
# Function to easily add examples
|
||||
function(add_cigui_example NAME)
|
||||
find_files(EXAMPLE_${NAME}_SOURCES "${NAME}/src" cpp c cxx hpp h hxx inl)
|
||||
add_executable(EXAMPLE_${NAME} ${EXAMPLE_${NAME}_SOURCES})
|
||||
target_link_libraries(EXAMPLE_${NAME} PRIVATE cigui)
|
||||
|
||||
set_target_properties(EXAMPLE_${NAME} PROPERTIES OUTPUT_NAME "${NAME}")
|
||||
|
||||
# Copy SFML DLLs to output directory on Windows when building shared
|
||||
if(WIN32 AND CIGUI_BUILD_SHARED)
|
||||
add_custom_command(TARGET EXAMPLE_${NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
$<TARGET_FILE:sfml-graphics>
|
||||
$<TARGET_FILE:sfml-window>
|
||||
$<TARGET_FILE:sfml-system>
|
||||
$<TARGET_FILE:cigui>
|
||||
$<TARGET_FILE_DIR:EXAMPLE_${NAME}>
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Basic example
|
||||
add_subdirectory(Full)
|
2
examples/Full/CMakeLists.txt
Normal file
2
examples/Full/CMakeLists.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
add_cigui_example(General)
|
||||
add_cigui_example(TicTacToe)
|
73
examples/Full/General/src/main.cpp
Normal file
73
examples/Full/General/src/main.cpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
//
|
||||
// Created by n0ffie on 08/04/25.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <cigui/cigui.hpp>
|
||||
#include <cigui/utils/List.hpp>
|
||||
|
||||
// WIP - not working yet
|
||||
// Layout unsupported
|
||||
struct HStack final : cig::View {
|
||||
using Stack = cig::List<View*>;
|
||||
Stack views;
|
||||
|
||||
void append(View* view) { views.push_back(view); }
|
||||
|
||||
bool update() override {
|
||||
bool needs_redraw = false;
|
||||
views.iterate([this, &needs_redraw](View*& view) { if (view->update()) needs_redraw = true; });
|
||||
return needs_redraw;
|
||||
}
|
||||
|
||||
View* body() override {
|
||||
views.iterate<>([this](View*& view) { view->draw(); });
|
||||
views.iterate([this](View*& view) {
|
||||
this->m_RenderCalls.expand(view->renderCalls());
|
||||
});
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
struct NewView final : cig::View {
|
||||
View* body() override {
|
||||
auto List = new HStack();
|
||||
|
||||
auto view = new cig::Rectangle({400, 400});
|
||||
view->setBorderColor(sf::Color::Red)->setBorderThickness(5)->setColor(sf::Color::Green);
|
||||
List->append(view);
|
||||
|
||||
view = new cig::Rectangle({100, 100});
|
||||
view->setBorderColor(sf::Color::Blue)->setBorderThickness(5)->setColor(sf::Color::Yellow);
|
||||
List->append(view);
|
||||
|
||||
return List;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
sf::RenderWindow window(sf::VideoMode({800, 600}), "Hello World!");
|
||||
|
||||
const auto view = new NewView();
|
||||
const cig::Renderer renderer(view);
|
||||
|
||||
while (window.isOpen()) {
|
||||
|
||||
while (const std::optional event = window.pollEvent())
|
||||
{
|
||||
if (event->is<sf::Event::Closed>())
|
||||
{
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
renderer.update();
|
||||
|
||||
window.clear();
|
||||
renderer.render(window, sf::RenderStates());
|
||||
window.display();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
6
examples/Full/TicTacToe/src/main.cpp
Normal file
6
examples/Full/TicTacToe/src/main.cpp
Normal file
|
@ -0,0 +1,6 @@
|
|||
#include <iosteam>
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello World" << std::endl;
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue