Move SkiaEventQueue to WinEventQueue

Added queueEvent() member function to EventQueue interface.
This commit is contained in:
David Capello 2015-05-22 11:56:07 -03:00
parent 02f8fd7920
commit 41114580ae
7 changed files with 25 additions and 14 deletions

View File

@ -135,7 +135,7 @@ public:
event.setType(Event::None);
}
void queueEvent(const Event& event) {
void queueEvent(const Event& event) override {
m_events.push(event);
}

View File

@ -16,6 +16,7 @@ namespace she {
public:
virtual ~EventQueue() { }
virtual void getEvent(Event& ev, bool canWait) = 0;
virtual void queueEvent(const Event& ev) = 0;
};
} // namespace she

View File

@ -10,10 +10,20 @@
#include "she/skia/skia_display.h"
#ifdef _WIN32
#include "she/win/event_queue.h"
#else
#error Your platform does not have a EventQueue implementation
#endif
namespace she {
SkiaDisplay::SkiaDisplay(int width, int height, int scale)
: m_window(&m_queue, this)
:
#ifdef _WIN32
m_queue(new WinEventQueue)
#endif
, m_window(m_queue, this)
, m_surface(new SkiaSurface)
{
m_surface->create(width, height);
@ -101,7 +111,7 @@ void SkiaDisplay::setTitleBar(const std::string& title)
EventQueue* SkiaDisplay::getEventQueue()
{
return &m_queue;
return m_queue;
}
bool SkiaDisplay::setNativeMouseCursor(NativeCursor cursor)

View File

@ -9,7 +9,6 @@
#pragma once
#include "she/display.h"
#include "she/skia/skia_event_queue.h"
#include "she/skia/skia_window.h"
namespace she {
@ -55,7 +54,7 @@ public:
DisplayHandle nativeHandle() override;
private:
SkiaEventQueue m_queue;
EventQueue* m_queue;
SkiaWindow m_window;
SkiaSurface* m_surface;
bool m_recreated;

View File

@ -10,11 +10,12 @@
#include "she/skia/skia_window.h"
#include "she/event_queue.h"
#include "she/skia/skia_display.h"
namespace she {
SkiaWindow::SkiaWindow(SkiaEventQueue* queue, SkiaDisplay* display)
SkiaWindow::SkiaWindow(EventQueue* queue, SkiaDisplay* display)
: m_queue(queue)
, m_display(display)
{

View File

@ -14,22 +14,22 @@
#error There is no Window implementation
#endif
#include "she/skia/skia_event_queue.h"
#include "she/skia/skia_surface.h"
namespace she {
class EventQueue;
class SkiaDisplay;
class SkiaWindow : public Window<SkiaWindow> {
public:
SkiaWindow(SkiaEventQueue* queue, SkiaDisplay* display);
SkiaWindow(EventQueue* queue, SkiaDisplay* display);
void queueEventImpl(Event& ev);
void paintImpl(HDC hdc);
void resizeImpl(const gfx::Size& size);
private:
SkiaEventQueue* m_queue;
EventQueue* m_queue;
SkiaDisplay* m_display;
};

View File

@ -4,8 +4,8 @@
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef SHE_SKIA_SKIA_EVENT_QUEUE_INCLUDED
#define SHE_SKIA_SKIA_EVENT_QUEUE_INCLUDED
#ifndef SHE_WIN_EVENT_QUEUE_INCLUDED
#define SHE_WIN_EVENT_QUEUE_INCLUDED
#pragma once
#include <queue>
@ -17,9 +17,9 @@
namespace she {
class SkiaEventQueue : public EventQueue {
class WinEventQueue : public EventQueue {
public:
SkiaEventQueue() : m_stop(false) {
WinEventQueue() : m_stop(false) {
}
void getEvent(Event& ev, bool canWait) override {
@ -52,7 +52,7 @@ public:
}
}
void queueEvent(Event& ev) {
void queueEvent(const Event& ev) override {
if (ev.type() == Event::CloseDisplay)
m_stop = true;