This commit is contained in:
Ilusha 2024-03-19 20:17:47 +03:00
parent 29280949a8
commit 752243c7e9
7 changed files with 40 additions and 40 deletions

View file

@ -6,7 +6,7 @@ file(GLOB HEADERS "./public/*.hpp")
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
target_include_directories(${PROJECT_NAME} PUBLIC ./public/)
target_link_libraries(${PROJECT_NAME} PUBLIC Math Strings)
target_link_libraries(${PROJECT_NAME} PUBLIC Math Graphics Strings)
### -------------------------- Tests -------------------------- ###
enable_testing()

View file

@ -1,32 +1,29 @@
#include "ExampleGUI.hpp"
#include "Graphics.hpp"
#include "GraphicApplication.hpp"
using namespace tp;
void runApp() {
auto window = tp::Window::createWindow({ 800, 600 }, "Window 1");
tp::ComplexWidget<tp::EventHandler, tp::Canvas> gui;
if (window) {
while (!window->shouldClose()) {
window->processEvents();
auto area = window->getCanvas().getAvaliableArea();
gui.proc(window->getEvents(), {}, { area.x, area.y, area.z, area.w });
gui.draw(window->getCanvas());
tp::sleep(20);
window->draw();
}
class ExampleGUI : public Application {
public:
ExampleGUI() {
gGlobalGUIConfig = &mConfig;
}
tp::Window::destroyWindow(window);
}
void processFrame(EventHandler* eventHandler) override {
auto rec = RectF( { 0, 0 }, mWindow->getSize() );
mGui.proc(*eventHandler, rec, rec);
}
void drawFrame(Canvas* canvas) override {
mGui.draw(*canvas);
}
private:
GlobalGUIConfig mConfig;
ComplexWidget<EventHandler, Canvas> mGui;
};
int main() {
@ -38,9 +35,8 @@ int main() {
}
{
tp::GlobalGUIConfig config;
tp::gGlobalGUIConfig = &config;
runApp();
ExampleGUI gui;
gui.run();
}
binModule.deinitialize();

View file

@ -23,9 +23,9 @@ namespace tp {
return;
}
mIsHover = getHandle().isInside(events.getPos());
mIsHover = getHandle().isInside(events.getPointer());
if (events.isPressed() && mIsHover) {
if (events.isPressed(InputID::MOUSE1) && mIsHover) {
mResizeInProcess = true;
} else if (!events.isDown()) {
mResizeInProcess = false;

View file

@ -5,6 +5,8 @@
#include "Rect.hpp"
#include "Strings.hpp"
#include "InputCodes.hpp"
namespace tp {
extern ModuleManifest gModuleWidgets;