Prep for image support in windows.
This commit is contained in:
parent
53c98a227d
commit
e7683cd94e
13 changed files with 172 additions and 135 deletions
|
@ -33,7 +33,7 @@ target_include_directories(ui_elements PUBLIC
|
|||
"${CMAKE_CURRENT_SOURCE_DIR}/ui_events"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/desktop_elements"
|
||||
)
|
||||
target_link_libraries(ui_elements PUBLIC core geometry visual_elements)
|
||||
target_link_libraries(ui_elements PUBLIC core geometry visual_elements image)
|
||||
|
||||
set_property(TARGET ui_elements PROPERTY FOLDER src)
|
||||
|
||||
|
|
|
@ -2,10 +2,23 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
namespace mt
|
||||
{
|
||||
class Screen;
|
||||
}
|
||||
|
||||
class IPlatformWindow
|
||||
{
|
||||
public:
|
||||
virtual ~IPlatformWindow() = default;
|
||||
|
||||
virtual void show() const = 0;
|
||||
|
||||
virtual void map() const = 0;
|
||||
|
||||
virtual void clear() const = 0;
|
||||
|
||||
virtual void paint(mt::Screen* screen) const = 0;
|
||||
};
|
||||
|
||||
using IPlatformWindowPtr = std::unique_ptr<IPlatformWindow>;
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include "MouseEvent.h"
|
||||
#include "VisualLayer.h"
|
||||
#include "KeyboardEvent.h"
|
||||
#include "Image.h"
|
||||
#include "Screen.h"
|
||||
|
||||
namespace mt
|
||||
{
|
||||
|
@ -12,6 +14,7 @@ namespace mt
|
|||
Window::Window()
|
||||
:mWidth(800),
|
||||
mHeight(600),
|
||||
mBackingImage(std::make_unique<Image>(mWidth, mHeight)),
|
||||
mWidget(Widget::Create())
|
||||
{
|
||||
mWidget->setBounds(mWidth, mHeight);
|
||||
|
@ -93,4 +96,41 @@ void Window::SetPlatformWindow(IPlatformWindowPtr window)
|
|||
mPlatformWindow = std::move(window);
|
||||
}
|
||||
|
||||
Image* Window::getBackingImage() const
|
||||
{
|
||||
return mBackingImage.get();
|
||||
}
|
||||
|
||||
void Window::map()
|
||||
{
|
||||
if (mPlatformWindow)
|
||||
{
|
||||
mPlatformWindow->map();
|
||||
}
|
||||
}
|
||||
|
||||
void Window::show()
|
||||
{
|
||||
if (mPlatformWindow)
|
||||
{
|
||||
mPlatformWindow->show();
|
||||
}
|
||||
}
|
||||
|
||||
void Window::doPaint(mt::Screen* screen)
|
||||
{
|
||||
if (mPlatformWindow)
|
||||
{
|
||||
mPlatformWindow->paint(screen);
|
||||
}
|
||||
}
|
||||
|
||||
void Window::clear()
|
||||
{
|
||||
if (mPlatformWindow)
|
||||
{
|
||||
mPlatformWindow->clear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,12 +9,15 @@ class PaintEvent;
|
|||
class MouseEvent;
|
||||
class KeyboardEvent;
|
||||
class VisualLayer;
|
||||
class Image;
|
||||
class IPlatformWindow;
|
||||
using IPlatformWindowPtr = std::unique_ptr<IPlatformWindow>;
|
||||
|
||||
namespace mt
|
||||
{
|
||||
|
||||
class Screen;
|
||||
|
||||
class Window
|
||||
{
|
||||
|
||||
|
@ -48,12 +51,23 @@ public:
|
|||
|
||||
void SetPlatformWindow(IPlatformWindowPtr window);
|
||||
|
||||
Image* getBackingImage() const;
|
||||
|
||||
void map();
|
||||
|
||||
void show();
|
||||
|
||||
void doPaint(mt::Screen* screen);
|
||||
|
||||
void clear();
|
||||
|
||||
private:
|
||||
int mHandle {-1};
|
||||
WidgetUPtr mWidget {nullptr};
|
||||
unsigned mWidth {800};
|
||||
unsigned mHeight {600};
|
||||
IPlatformWindowPtr mPlatformWindow {nullptr};
|
||||
std::unique_ptr<Image> mBackingImage;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue