[ion/simulator] Add a Window namespace

This commit is contained in:
Romain Goyet
2020-09-03 16:59:34 -04:00
committed by Léa Saviot
parent 784234690c
commit 945a7b8d56
10 changed files with 25 additions and 26 deletions

View File

@@ -21,12 +21,12 @@ ion_src += $(addprefix ion/src/simulator/shared/, \
keyboard_dummy.cpp:+headless \
keyboard_sdl.cpp:-headless \
layout.cpp:-headless \
main_headless.cpp:+headless \
main_sdl.cpp:-headless \
power.cpp \
random.cpp \
timing.cpp \
timing_msleep.cpp:-headless \
window_headless.cpp:+headless \
window_sdl.cpp:-headless \
)
ion_simulator_assets = background.jpg horizontal_arrow.png vertical_arrow.png round.png small_squircle.png large_squircle.png

View File

@@ -1,7 +1,7 @@
#include "main.h"
#include "platform.h"
#include "layout.h"
#include "events.h"
#include "window.h"
#include <assert.h>
#include <ion/events.h>
@@ -183,7 +183,7 @@ Event getPlatformEvent() {
while (SDL_PollEvent(&event)) {
// The while is important: it'll do a fast-pass over all useless SDL events
if (event.type == SDL_WINDOWEVENT) {
Ion::Simulator::Main::relayout();
Ion::Simulator::Window::relayout();
break;
}
if (event.type == SDL_QUIT) {

View File

@@ -1,4 +1,3 @@
#include "main.h"
#include "platform.h"
#include "framebuffer.h"
#include "events.h"

View File

@@ -1,6 +1,6 @@
#include "framebuffer.h"
#include "window.h"
#include <ion/display.h>
#include "main.h"
/* Drawing on an SDL texture
* In SDL2, drawing bitmap data happens through textures, whose data lives in
@@ -23,14 +23,14 @@ static KDFrameBuffer sFrameBuffer = KDFrameBuffer(sPixels, KDSize(Ion::Display::
void pushRect(KDRect r, const KDColor * pixels) {
if (sFrameBufferActive) {
Simulator::Main::setNeedsRefresh();
Simulator::Window::setNeedsRefresh();
sFrameBuffer.pushRect(r, pixels);
}
}
void pushRectUniform(KDRect r, KDColor c) {
if (sFrameBufferActive) {
Simulator::Main::setNeedsRefresh();
Simulator::Window::setNeedsRefresh();
sFrameBuffer.pushRectUniform(r, c);
}
}

View File

@@ -1,6 +1,6 @@
#include "main.h"
#include "platform.h"
#include "layout.h"
#include "platform.h"
#include "window.h"
#include <ion/keyboard.h>
#include <SDL.h>
@@ -58,7 +58,7 @@ State scan() {
IonSimulatorCallbackDidScanKeyboard();
// Grab this opportunity to refresh the display if needed
Simulator::Main::refresh();
Simulator::Window::refresh();
// Start with a "clean" state
State state;

View File

@@ -1,5 +1,5 @@
#include "layout.h"
#include "main.h"
#include "window.h"
#include "platform.h"
#include <ion.h>
#include <limits.h>
@@ -239,13 +239,13 @@ void highlightKeyAt(SDL_Point * p) {
}
if (newHighlightedKeyIndex != sHighlightedKeyIndex) {
sHighlightedKeyIndex = newHighlightedKeyIndex;
Main::setNeedsRefresh();
Window::setNeedsRefresh();
}
}
void unhighlightKey() {
sHighlightedKeyIndex = -1;
Main::setNeedsRefresh();
Window::setNeedsRefresh();
}
void drawHighlightedKey(SDL_Renderer * renderer) {

View File

@@ -1,9 +1,9 @@
#ifndef ION_SIMULATOR_MAIN_H
#define ION_SIMULATOR_MAIN_H
#ifndef ION_SIMULATOR_WINDOW_H
#define ION_SIMULATOR_WINDOW_H
namespace Ion {
namespace Simulator {
namespace Main {
namespace Window {
void init();
void quit();

View File

@@ -1,4 +1,4 @@
#include "main.h"
#include "window.h"
#include "display.h"
#include "platform.h"
#include "framebuffer.h"
@@ -52,7 +52,7 @@ int main(int argc, char * argv[]) {
namespace Ion {
namespace Simulator {
namespace Main {
namespace Window {
void init() {
}

View File

@@ -1,4 +1,4 @@
#include "main.h"
#include "window.h"
#include "display.h"
#include "haptics.h"
#include "layout.h"
@@ -25,14 +25,14 @@ int main(int argc, char * argv[]) {
#if EPSILON_TELEMETRY
Ion::Simulator::Telemetry::init();
#endif
Ion::Simulator::Main::init();
Ion::Simulator::Window::init();
Ion::Simulator::Haptics::init();
ion_main(arguments.size(), &arguments[0]);
// Shutdown
Ion::Simulator::Haptics::shutdown();
Ion::Simulator::Main::quit();
Ion::Simulator::Window::quit();
#if EPSILON_TELEMETRY
Ion::Simulator::Telemetry::shutdown();
#endif
@@ -42,7 +42,7 @@ int main(int argc, char * argv[]) {
namespace Ion {
namespace Simulator {
namespace Main {
namespace Window {
static SDL_Window * sWindow = nullptr;
static SDL_Renderer * sRenderer = nullptr;

View File

@@ -1,5 +1,5 @@
#include <ion.h>
#include "../shared/main.h"
#include "../shared/window.h"
extern "C" const char * IonSoftwareVersion() {
return Ion::softwareVersion();
@@ -10,6 +10,6 @@ extern "C" const char * IonPatchLevel() {
}
extern "C" void IonDisplayForceRefresh() {
Ion::Simulator::Main::setNeedsRefresh();
Ion::Simulator::Main::refresh();
Ion::Simulator::Window::setNeedsRefresh();
Ion::Simulator::Window::refresh();
}