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-17 20:32:58 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Fatal errors
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FatalError(std::string message) {
|
|
|
|
fprintf(stderr, "%s", message.c_str());
|
|
|
|
|
|
|
|
#if !defined(LIBRARY) && defined(HAVE_BACKTRACE)
|
|
|
|
static void *ptrs[1024] = {};
|
|
|
|
size_t nptrs = backtrace(ptrs, sizeof(ptrs) / sizeof(ptrs[0]));
|
|
|
|
char **syms = backtrace_symbols(ptrs, nptrs);
|
|
|
|
|
|
|
|
fprintf(stderr, "Backtrace:\n");
|
|
|
|
if(syms != NULL) {
|
|
|
|
for(size_t i = 0; i < nptrs; i++) {
|
|
|
|
fprintf(stderr, "%2zu: %s\n", i, syms[i]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for(size_t i = 0; i < nptrs; i++) {
|
|
|
|
fprintf(stderr, "%2zu: %p\n", i, ptrs[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
fprintf(stderr, "Backtrace support not compiled in.\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
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>();
|
|
|
|
}
|
|
|
|
|
2018-07-18 08:48:49 +08:00
|
|
|
void Request3DConnexionEventsForWindow(WindowRef window) {}
|
|
|
|
|
2018-07-17 23:00:46 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
2018-07-18 02:51:00 +08:00
|
|
|
// Message dialogs
|
2018-07-17 23:00:46 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
MessageDialogRef CreateMessageDialog(WindowRef parentWindow) {
|
|
|
|
return std::shared_ptr<MessageDialog>();
|
|
|
|
}
|
|
|
|
|
2018-07-18 02:51:00 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// File dialogs
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
FileDialogRef CreateOpenFileDialog(WindowRef parentWindow) {
|
|
|
|
return std::shared_ptr<FileDialog>();
|
|
|
|
}
|
|
|
|
|
|
|
|
FileDialogRef CreateSaveFileDialog(WindowRef parentWindow) {
|
|
|
|
return std::shared_ptr<FileDialog>();
|
|
|
|
}
|
|
|
|
|
2018-07-13 03:29:44 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Application-wide APIs
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2018-07-18 10:20:25 +08:00
|
|
|
std::vector<Platform::Path> fontFiles;
|
|
|
|
std::vector<Platform::Path> GetFontFiles() {
|
|
|
|
return fontFiles;
|
2018-07-11 18:48:38 +08:00
|
|
|
}
|
|
|
|
|
2018-07-18 10:20:25 +08:00
|
|
|
void OpenInBrowser(const std::string &url) {}
|
2018-07-11 13:35:31 +08:00
|
|
|
|
2018-07-18 10:20:25 +08:00
|
|
|
void InitGui(int argc, char **argv) {}
|
2016-07-26 03:37:48 +08:00
|
|
|
|
2018-07-18 10:20:25 +08:00
|
|
|
void RunGui() {}
|
2016-07-26 03:37:48 +08:00
|
|
|
|
2018-07-18 10:20:25 +08:00
|
|
|
void ExitGui() {
|
|
|
|
exit(0);
|
|
|
|
}
|
2016-07-26 03:37:48 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|