solvespace/src/platform/guigtk.cpp

41 lines
1.1 KiB
C++
Raw Normal View History

//-----------------------------------------------------------------------------
// The GTK-based implementation of platform-dependent GUI functionality.
//
// Copyright 2018 whitequark
//-----------------------------------------------------------------------------
#include <glibmm/main.h>
#include "solvespace.h"
namespace SolveSpace {
namespace Platform {
//-----------------------------------------------------------------------------
// Timers
//-----------------------------------------------------------------------------
class TimerImplGtk : public Timer {
public:
sigc::connection _connection;
void WindUp(unsigned milliseconds) override {
if(!_connection.empty()) {
_connection.disconnect();
}
auto handler = [this]() {
if(this->onTimeout) {
this->onTimeout();
}
return false;
};
_connection = Glib::signal_timeout().connect(handler, milliseconds);
}
};
TimerRef CreateTimer() {
return std::unique_ptr<TimerImplGtk>(new TimerImplGtk);
}
}
}