Back with clickable button.

This commit is contained in:
James Grogan 2022-11-16 17:00:55 +00:00
parent 3e53bd9e00
commit 70891ce7b4
20 changed files with 107 additions and 50 deletions

View file

@ -9,7 +9,6 @@ DesktopManager::DesktopManager(AbstractDesktopApp* application)
mWindowManager(WindowManager::Create()),
mKeyboard(Keyboard::Create()),
mUiApplication(application),
mModified(false),
mEventManager(EventManager::Create())
{
@ -45,14 +44,8 @@ void DesktopManager::onMouseEvent(const MouseEvent* event)
mWindowManager->onMouseEvent(event);
}
bool DesktopManager::isModified() const
{
return mModified;
}
void DesktopManager::onUiEvent(UiEventUPtr eventUPtr)
{
mModified = false;
const auto event = mEventManager->AddEvent(std::move(eventUPtr));
switch (event->GetType())
{
@ -64,28 +57,18 @@ void DesktopManager::onUiEvent(UiEventUPtr eventUPtr)
case (UiEvent::Type::Keyboard):
{
onKeyboardEvent(dynamic_cast<const KeyboardEvent*>(event));
mModified = true;
break;
}
case (UiEvent::Type::Resize):
{
auto resize_event = dynamic_cast<const ResizeEvent*>(event);
mWindowManager->onResizeEvent(resize_event);
mModified = true;
break;
}
case (UiEvent::Type::Mouse):
{
auto mouseEvent = dynamic_cast<const MouseEvent*>(event);
onMouseEvent(mouseEvent);
if (mouseEvent->GetAction() == MouseEvent::Action::Pressed)
{
mModified = true;
}
else if(mouseEvent->GetAction() == MouseEvent::Action::Released)
{
mModified = true;
}
break;
}
default:
@ -93,11 +76,6 @@ void DesktopManager::onUiEvent(UiEventUPtr eventUPtr)
}
}
void DesktopManager::setIsModified(bool modified)
{
mModified = modified;
}
Keyboard* DesktopManager::getKeyboard() const
{
return mKeyboard.get();
@ -136,3 +114,10 @@ WindowManager* DesktopManager::getWindowManager() const
{
return mWindowManager.get();
}
void DesktopManager::onLoopIteration()
{
auto defaultScreen = getDefaultScreen();
mWindowManager->onLoopIteration(defaultScreen);
}

View file

@ -37,10 +37,6 @@ public:
mt::Screen* getDefaultScreen() const;
bool isModified() const;
void setIsModified(bool modified);
void setKeyboard(KeyboardUPtr keyboard);
void onUiEvent(UiEventUPtr event);
@ -53,13 +49,14 @@ public:
void clearEvents();
void onLoopIteration();
private:
std::vector<ScreenPtr> mScreens;
WindowManagerUPtr mWindowManager;
KeyboardUPtr mKeyboard;
EventManagerUPtr mEventManager;
AbstractDesktopApp* mUiApplication;
bool mModified;
};
using DesktopManagerUPtr = std::unique_ptr<DesktopManager>;

View file

@ -1,5 +1,7 @@
#include "WindowManager.h"
#include <iostream>
WindowManager::WindowManager()
: mWindows()
{
@ -60,3 +62,15 @@ mt::Window* WindowManager::getMainWindow() const
return nullptr;
}
}
void WindowManager::onLoopIteration(mt::Screen* screen)
{
for (auto& window : mWindows)
{
if (window->isDirty())
{
window->onPaint(nullptr);
window->doPaint(screen);
}
}
}

View file

@ -42,6 +42,8 @@ public:
return mWindows[idx].get();
}
void onLoopIteration(mt::Screen* screen);
private:
std::vector<WindowUPtr> mWindows;
};

View file

@ -239,6 +239,7 @@ void XcbInterface::loop()
break;
}
free(event);
mDesktopManager->onLoopIteration();
}
}