Minor cleanups. NFC.
A few code style changes extracted from the Emscripten port.
This commit is contained in:
parent
7f75148671
commit
75a09c8b67
@ -77,6 +77,7 @@ set_target_properties(slvs PROPERTIES
|
||||
if(NOT WIN32)
|
||||
install(TARGETS slvs
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
endif()
|
||||
|
||||
|
@ -203,6 +203,7 @@ Platform::KeyboardEvent GraphicsWindow::AcceleratorForCommand(Command cmd) {
|
||||
}
|
||||
|
||||
Platform::KeyboardEvent accel = {};
|
||||
accel.type = Platform::KeyboardEvent::Type::PRESS;
|
||||
if(rawAccel & SHIFT_MASK) {
|
||||
accel.shiftDown = true;
|
||||
}
|
||||
@ -395,12 +396,6 @@ void GraphicsWindow::Init() {
|
||||
if(!window) {
|
||||
window = Platform::CreateWindow();
|
||||
if(window) {
|
||||
canvas = CreateRenderer();
|
||||
if(canvas) {
|
||||
persistentCanvas = canvas->CreateBatch();
|
||||
persistentDirty = true;
|
||||
}
|
||||
|
||||
using namespace std::placeholders;
|
||||
window->onClose = std::bind(&SolveSpaceUI::MenuFile, Command::EXIT);
|
||||
window->onRender = std::bind(&GraphicsWindow::Paint, this);
|
||||
@ -413,6 +408,14 @@ void GraphicsWindow::Init() {
|
||||
}
|
||||
}
|
||||
|
||||
if(window) {
|
||||
canvas = CreateRenderer();
|
||||
if(canvas) {
|
||||
persistentCanvas = canvas->CreateBatch();
|
||||
persistentDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Do this last, so that all the menus get updated correctly.
|
||||
ClearSuper();
|
||||
}
|
||||
|
@ -85,8 +85,10 @@ struct KeyboardEvent {
|
||||
bool controlDown;
|
||||
|
||||
bool Equals(const KeyboardEvent &other) {
|
||||
return type == other.type && key == other.key && num == other.num &&
|
||||
shiftDown == other.shiftDown && controlDown == other.controlDown;
|
||||
return type == other.type && key == other.key &&
|
||||
shiftDown == other.shiftDown && controlDown == other.controlDown &&
|
||||
((key == Key::CHARACTER && chr == other.chr) ||
|
||||
(key == Key::FUNCTION && num == other.num));
|
||||
}
|
||||
};
|
||||
|
||||
@ -303,7 +305,7 @@ public:
|
||||
virtual void SetMessage(std::string message) = 0;
|
||||
virtual void SetDescription(std::string description) = 0;
|
||||
|
||||
virtual void AddButton(std::string name, Response response, bool isDefault = false) = 0;
|
||||
virtual void AddButton(std::string label, Response response, bool isDefault = false) = 0;
|
||||
|
||||
virtual Response RunModal() = 0;
|
||||
virtual void ShowModal() {
|
||||
|
@ -1123,7 +1123,7 @@ public:
|
||||
gtkDialog.set_secondary_text(description);
|
||||
}
|
||||
|
||||
void AddButton(std::string name, Response response, bool isDefault) override {
|
||||
void AddButton(std::string label, Response response, bool isDefault) override {
|
||||
int responseId = 0;
|
||||
switch(response) {
|
||||
case Response::NONE: ssassert(false, "Unexpected response");
|
||||
@ -1132,7 +1132,7 @@ public:
|
||||
case Response::NO: responseId = Gtk::RESPONSE_NO; break;
|
||||
case Response::CANCEL: responseId = Gtk::RESPONSE_CANCEL; break;
|
||||
}
|
||||
gtkDialog.add_button(PrepareMnemonics(name), responseId);
|
||||
gtkDialog.add_button(PrepareMnemonics(label), responseId);
|
||||
if(isDefault) {
|
||||
gtkDialog.set_default_response(responseId);
|
||||
}
|
||||
|
@ -1195,8 +1195,8 @@ public:
|
||||
nsAlert.informativeText = Wrap(description);
|
||||
}
|
||||
|
||||
void AddButton(std::string name, Response response, bool isDefault) override {
|
||||
NSButton *nsButton = [nsAlert addButtonWithTitle:Wrap(PrepareMnemonics(name))];
|
||||
void AddButton(std::string label, Response response, bool isDefault) override {
|
||||
NSButton *nsButton = [nsAlert addButtonWithTitle:Wrap(PrepareMnemonics(label))];
|
||||
if(!isDefault && [nsButton.keyEquivalent isEqualToString:@"\n"]) {
|
||||
nsButton.keyEquivalent = @"";
|
||||
} else if(response == Response::CANCEL) {
|
||||
|
@ -1428,7 +1428,7 @@ public:
|
||||
mbp.lpszText = textW.c_str();
|
||||
}
|
||||
|
||||
void AddButton(std::string _name, Response response, bool isDefault) override {
|
||||
void AddButton(std::string _label, Response response, bool isDefault) override {
|
||||
int button;
|
||||
switch(response) {
|
||||
case Response::NONE: ssassert(false, "Invalid response");
|
||||
|
@ -15,16 +15,15 @@
|
||||
|
||||
namespace SolveSpace {
|
||||
|
||||
void dbp(const char *str, ...)
|
||||
void dbp(const char *fmt, ...)
|
||||
{
|
||||
va_list f;
|
||||
static char buf[1024*50];
|
||||
va_start(f, str);
|
||||
vsnprintf(buf, sizeof(buf), str, f);
|
||||
va_end(f);
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
vfprintf(stdout, fmt, va);
|
||||
fputc('\n', stdout);
|
||||
va_end(va);
|
||||
|
||||
fputs(buf, stderr);
|
||||
fputc('\n', stderr);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -6,13 +6,13 @@
|
||||
#ifndef SOLVESPACE_GL3SHADER_H
|
||||
#define SOLVESPACE_GL3SHADER_H
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32)
|
||||
# define GL_APICALL /*static linkage*/
|
||||
# define GL_GLEXT_PROTOTYPES
|
||||
# include <GLES2/gl2.h>
|
||||
# include <GLES2/gl2ext.h>
|
||||
# define HAVE_GLES
|
||||
#elif __APPLE__
|
||||
#elif defined(__APPLE__)
|
||||
# include <OpenGL/gl.h>
|
||||
#else
|
||||
# define GL_GLEXT_PROTOTYPES
|
||||
|
Loading…
Reference in New Issue
Block a user