2018-07-11 10:48:38 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Platform-dependent GUI functionality that has only minor differences.
|
|
|
|
//
|
|
|
|
// Copyright 2018 whitequark
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
#include "solvespace.h"
|
|
|
|
|
|
|
|
namespace SolveSpace {
|
|
|
|
namespace Platform {
|
|
|
|
|
2018-07-16 10:37:41 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Keyboard events
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2018-07-11 10:48:38 +00:00
|
|
|
std::string AcceleratorDescription(const KeyboardEvent &accel) {
|
|
|
|
std::string label;
|
|
|
|
if(accel.controlDown) {
|
|
|
|
#ifdef __APPLE__
|
|
|
|
label += "⌘+";
|
|
|
|
#else
|
|
|
|
label += "Ctrl+";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if(accel.shiftDown) {
|
|
|
|
label += "Shift+";
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(accel.key) {
|
|
|
|
case KeyboardEvent::Key::FUNCTION:
|
|
|
|
label += ssprintf("F%d", accel.num);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KeyboardEvent::Key::CHARACTER:
|
|
|
|
if(accel.chr == '\t') {
|
|
|
|
label += "Tab";
|
|
|
|
} else if(accel.chr == ' ') {
|
|
|
|
label += "Space";
|
|
|
|
} else if(accel.chr == '\x1b') {
|
|
|
|
label += "Esc";
|
|
|
|
} else if(accel.chr == '\x7f') {
|
|
|
|
label += "Del";
|
|
|
|
} else if(accel.chr != 0) {
|
|
|
|
label += toupper((char)(accel.chr & 0xff));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
2018-07-16 10:37:41 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Settings
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Settings::FreezeBool(const std::string &key, bool value) {
|
|
|
|
FreezeInt(key, (int)value);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Settings::ThawBool(const std::string &key, bool defaultValue) {
|
2018-07-18 01:13:05 +00:00
|
|
|
return ThawInt(key, (int)defaultValue) != 0;
|
2018-07-16 10:37:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::FreezeColor(const std::string &key, RgbaColor value) {
|
|
|
|
FreezeInt(key, value.ToPackedInt());
|
|
|
|
}
|
|
|
|
|
|
|
|
RgbaColor Settings::ThawColor(const std::string &key, RgbaColor defaultValue) {
|
|
|
|
return RgbaColor::FromPackedInt(ThawInt(key, defaultValue.ToPackedInt()));
|
|
|
|
}
|
|
|
|
|
2018-07-17 18:51:00 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// File dialogs
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FileDialog::AddFilter(const FileFilter &filter) {
|
|
|
|
AddFilter(Translate("file-type", filter.name.c_str()), filter.extensions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FileDialog::AddFilters(const std::vector<FileFilter> &filters) {
|
|
|
|
for(auto filter : filters) AddFilter(filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<FileFilter> SolveSpaceModelFileFilters = {
|
|
|
|
{ CN_("file-type", "SolveSpace models"), { "slvs" } },
|
|
|
|
};
|
|
|
|
|
2020-09-24 16:30:06 +00:00
|
|
|
std::vector<FileFilter> SolveSpaceLinkFileFilters = {
|
2021-07-29 01:01:46 +00:00
|
|
|
{ CN_("file-type", "ALL"), { "slvs", "emn", "stl" } },
|
2020-09-24 16:30:06 +00:00
|
|
|
{ CN_("file-type", "SolveSpace models"), { "slvs" } },
|
|
|
|
{ CN_("file-type", "IDF circuit board"), { "emn" } },
|
2020-10-01 04:05:33 +00:00
|
|
|
{ CN_("file-type", "STL triangle mesh"), { "stl" } },
|
2020-09-24 16:30:06 +00:00
|
|
|
};
|
|
|
|
|
2018-07-17 18:51:00 +00:00
|
|
|
std::vector<FileFilter> RasterFileFilters = {
|
|
|
|
{ CN_("file-type", "PNG image"), { "png" } },
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<FileFilter> MeshFileFilters = {
|
|
|
|
{ CN_("file-type", "STL mesh"), { "stl" } },
|
|
|
|
{ CN_("file-type", "Wavefront OBJ mesh"), { "obj" } },
|
|
|
|
{ CN_("file-type", "Three.js-compatible mesh, with viewer"), { "html" } },
|
|
|
|
{ CN_("file-type", "Three.js-compatible mesh, mesh only"), { "js" } },
|
2019-08-09 19:08:54 +00:00
|
|
|
{ CN_("file-type", "VRML text file"), { "wrl" } },
|
2018-07-17 18:51:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<FileFilter> SurfaceFileFilters = {
|
|
|
|
{ CN_("file-type", "STEP file"), { "step", "stp" } },
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<FileFilter> VectorFileFilters = {
|
|
|
|
{ CN_("file-type", "PDF file"), { "pdf" } },
|
|
|
|
{ CN_("file-type", "Encapsulated PostScript"), { "eps", "ps" } },
|
|
|
|
{ CN_("file-type", "Scalable Vector Graphics"), { "svg" } },
|
|
|
|
{ CN_("file-type", "STEP file"), { "step", "stp" } },
|
|
|
|
{ CN_("file-type", "DXF file (AutoCAD 2007)"), { "dxf" } },
|
|
|
|
{ CN_("file-type", "HPGL file"), { "plt", "hpgl" } },
|
|
|
|
{ CN_("file-type", "G Code"), { "ngc", "txt" } },
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<FileFilter> Vector3dFileFilters = {
|
|
|
|
{ CN_("file-type", "STEP file"), { "step", "stp" } },
|
|
|
|
{ CN_("file-type", "DXF file (AutoCAD 2007)"), { "dxf" } },
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<FileFilter> ImportFileFilters = {
|
|
|
|
{ CN_("file-type", "AutoCAD DXF and DWG files"), { "dxf", "dwg" } },
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<FileFilter> CsvFileFilters = {
|
|
|
|
{ CN_("file-type", "Comma-separated values"), { "csv" } },
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-07-11 10:48:38 +00:00
|
|
|
}
|
|
|
|
}
|