2016-07-26 03:37:48 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
2016-11-29 10:57:41 +08:00
|
|
|
// Our platform support functions for the headless (no OpenGL) test runner.
|
2016-07-26 03:37:48 +08:00
|
|
|
//
|
|
|
|
// Copyright 2016 whitequark
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
#include "solvespace.h"
|
|
|
|
#include <cairo.h>
|
|
|
|
|
|
|
|
namespace SolveSpace {
|
|
|
|
|
2018-07-13 03:29:44 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Rendering
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
std::shared_ptr<ViewportCanvas> CreateRenderer() {
|
|
|
|
return std::make_shared<CairoPixmapRenderer>();
|
|
|
|
}
|
|
|
|
|
2018-07-11 13:35:31 +08:00
|
|
|
namespace Platform {
|
|
|
|
|
2018-07-16 18:37:41 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Settings
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class SettingsImplDummy : public Settings {
|
|
|
|
public:
|
|
|
|
void FreezeInt(const std::string &key, uint32_t value) {}
|
|
|
|
|
|
|
|
uint32_t ThawInt(const std::string &key, uint32_t defaultValue = 0) {
|
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreezeFloat(const std::string &key, double value) {}
|
|
|
|
|
|
|
|
double ThawFloat(const std::string &key, double defaultValue = 0.0) {
|
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreezeString(const std::string &key, const std::string &value) {}
|
|
|
|
|
|
|
|
std::string ThawString(const std::string &key,
|
|
|
|
const std::string &defaultValue = "") {
|
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
SettingsRef GetSettings() {
|
|
|
|
static std::shared_ptr<SettingsImplDummy> settings =
|
|
|
|
std::make_shared<SettingsImplDummy>();
|
|
|
|
return settings;
|
|
|
|
}
|
|
|
|
|
2018-07-11 13:35:31 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Timers
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class TimerImplDummy : public Timer {
|
|
|
|
public:
|
|
|
|
void WindUp(unsigned milliseconds) override {}
|
|
|
|
};
|
|
|
|
|
|
|
|
TimerRef CreateTimer() {
|
|
|
|
return std::unique_ptr<Timer>(new TimerImplDummy);
|
|
|
|
}
|
|
|
|
|
2018-07-11 18:48:38 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Menus
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
MenuRef CreateMenu() {
|
2018-07-13 03:29:44 +08:00
|
|
|
return std::shared_ptr<Menu>();
|
2018-07-11 18:48:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
MenuBarRef GetOrCreateMainMenu(bool *unique) {
|
|
|
|
*unique = false;
|
2018-07-13 03:29:44 +08:00
|
|
|
return std::shared_ptr<MenuBar>();
|
2018-07-11 18:48:38 +08:00
|
|
|
}
|
|
|
|
|
2018-07-13 03:29:44 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Windows
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
WindowRef CreateWindow(Window::Kind kind, WindowRef parentWindow) {
|
|
|
|
return std::shared_ptr<Window>();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Application-wide APIs
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Exit() {
|
|
|
|
exit(0);
|
2018-07-11 18:48:38 +08:00
|
|
|
}
|
|
|
|
|
2018-07-11 13:35:31 +08:00
|
|
|
}
|
|
|
|
|
2016-07-26 03:37:48 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Dialogs
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2017-03-11 22:43:21 +08:00
|
|
|
bool GetOpenFile(Platform::Path *filename, const std::string &activeOrEmpty,
|
2016-07-26 03:37:48 +08:00
|
|
|
const FileFilter filters[]) {
|
|
|
|
ssassert(false, "Not implemented");
|
|
|
|
}
|
2017-03-11 22:43:21 +08:00
|
|
|
bool GetSaveFile(Platform::Path *filename, const std::string &activeOrEmpty,
|
2016-07-26 03:37:48 +08:00
|
|
|
const FileFilter filters[]) {
|
|
|
|
ssassert(false, "Not implemented");
|
|
|
|
}
|
|
|
|
DialogChoice SaveFileYesNoCancel() {
|
|
|
|
ssassert(false, "Not implemented");
|
|
|
|
}
|
|
|
|
DialogChoice LoadAutosaveYesNo() {
|
|
|
|
ssassert(false, "Not implemented");
|
|
|
|
}
|
2017-03-11 22:43:21 +08:00
|
|
|
DialogChoice LocateImportedFileYesNoCancel(const Platform::Path &filename,
|
2016-07-26 03:37:48 +08:00
|
|
|
bool canCancel) {
|
|
|
|
ssassert(false, "Not implemented");
|
|
|
|
}
|
|
|
|
void DoMessageBox(const char *message, int rows, int cols, bool error) {
|
|
|
|
dbp("%s box: %s", error ? "error" : "message", message);
|
|
|
|
ssassert(false, "Not implemented");
|
|
|
|
}
|
|
|
|
void OpenWebsite(const char *url) {
|
|
|
|
ssassert(false, "Not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Resources
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2017-03-11 22:43:21 +08:00
|
|
|
std::vector<Platform::Path> fontFiles;
|
|
|
|
std::vector<Platform::Path> GetFontFiles() {
|
2016-07-31 16:43:33 +08:00
|
|
|
return fontFiles;
|
2016-07-26 03:37:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|