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
1
src/core/RenderCall.cpp
Normal file
1
src/core/RenderCall.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
|
72
src/main.cpp
72
src/main.cpp
|
@ -1,72 +0,0 @@
|
|||
//
|
||||
// Created by n0ffie on 08/04/25.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <cigui.hpp>
|
||||
|
||||
// WIP - not working yet
|
||||
// Layout unsupported
|
||||
struct HStack final : cig::View {
|
||||
using Stack = cig::utils::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](const 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;
|
||||
}
|
0
src/utils/List.cpp
Normal file
0
src/utils/List.cpp
Normal file
23
src/utils/Vectors.cpp
Normal file
23
src/utils/Vectors.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <cigui/utils/Vectors.hpp>
|
||||
|
||||
#define VECTOR_TEMPLATE_INSTANTIATION(N, T) \
|
||||
template union Vector##N<T>;
|
||||
|
||||
#define VECTOR_TEMPLATE_IMPLEMENTATION(N) \
|
||||
VECTOR_TEMPLATE_INSTANTIATION(N, int) \
|
||||
VECTOR_TEMPLATE_INSTANTIATION(N, float) \
|
||||
VECTOR_TEMPLATE_INSTANTIATION(N, double)\
|
||||
VECTOR_TEMPLATE_INSTANTIATION(N, unsigned int) \
|
||||
VECTOR_TEMPLATE_INSTANTIATION(N, unsigned long) \
|
||||
VECTOR_TEMPLATE_INSTANTIATION(N, long) \
|
||||
VECTOR_TEMPLATE_INSTANTIATION(N, unsigned long long) \
|
||||
VECTOR_TEMPLATE_INSTANTIATION(N, long long) \
|
||||
VECTOR_TEMPLATE_INSTANTIATION(N, short) \
|
||||
VECTOR_TEMPLATE_INSTANTIATION(N, unsigned short) \
|
||||
VECTOR_TEMPLATE_INSTANTIATION(N, bool)
|
||||
|
||||
namespace cig {
|
||||
VECTOR_TEMPLATE_IMPLEMENTATION(2)
|
||||
VECTOR_TEMPLATE_IMPLEMENTATION(3)
|
||||
VECTOR_TEMPLATE_IMPLEMENTATION(4)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue