In der Zeit vom 27.05.19 16 Uhr bis zum 28.05.19 10 Uhr steht die GitLab Instanz der RWTH Aachen nicht zur Verfügung. Es findet ein Umzug des angeschlossenen Storage Systems statt, so dass in der genannten Zeit keine Repositories angelegt, gelöscht oder verändert werden können. Wir bitten um Ihr Verständnis. // In the time from 27.05.19 16 o'clock to 28.05.19 10 o'clock the GitLab instance of the RWTH Aachen is not available. The connected storage system will be moved so that no repositories can be created, deleted or changed during this time. We ask for your understanding.

Commit a0e73151 authored by Martin Kröning's avatar Martin Kröning

Fix inconsistent window resizing

parent e22a8fbe
...@@ -48,6 +48,7 @@ private: ...@@ -48,6 +48,7 @@ private:
void onVehicleRowSelected(Gtk::ListBoxRow *row); void onVehicleRowSelected(Gtk::ListBoxRow *row);
void refreshVehicleLabels(const DrawableVehicle &vehicle); void refreshVehicleLabels(const DrawableVehicle &vehicle);
void refreshArea(int x, int y, int width, int height); void refreshArea(int x, int y, int width, int height);
void resizeWindow();
MapArea mapArea; MapArea mapArea;
Gtk::Window win; Gtk::Window win;
Gtk::ListBox *listBox; Gtk::ListBox *listBox;
......
...@@ -88,8 +88,8 @@ void MapApp::onZoomEntryActivate() { ...@@ -88,8 +88,8 @@ void MapApp::onZoomEntryActivate() {
std::istringstream zoomBuffer(input); std::istringstream zoomBuffer(input);
zoomBuffer >> zoom; zoomBuffer >> zoom;
mapArea.setScale(zoom / 100); mapArea.setScale(zoom / 100);
// The window is only resizing, when called from the main thread like this: Glib::signal_idle().connect_once([this]() { mapArea.adaptSizeRequest(); },
mapArea.adaptSizeRequest(); Glib::PRIORITY_HIGH_IDLE + 10);
std::ostringstream formatBuffer; std::ostringstream formatBuffer;
formatBuffer << zoom << '%'; formatBuffer << zoom << '%';
...@@ -105,8 +105,8 @@ void MapApp::onZoomSelectionChanged() { ...@@ -105,8 +105,8 @@ void MapApp::onZoomSelectionChanged() {
std::istringstream zoomBuffer(selection); std::istringstream zoomBuffer(selection);
zoomBuffer >> zoom; zoomBuffer >> zoom;
mapArea.setScale(zoom / 100); mapArea.setScale(zoom / 100);
// The window is only resizing, when called from the main thread like this: Glib::signal_idle().connect_once([this]() { mapArea.adaptSizeRequest(); },
mapArea.adaptSizeRequest(); Glib::PRIORITY_HIGH_IDLE + 10);
} }
} }
...@@ -160,6 +160,12 @@ void MapApp::setTimeLabel(const std::chrono::minutes minutes) { ...@@ -160,6 +160,12 @@ void MapApp::setTimeLabel(const std::chrono::minutes minutes) {
void MapApp::addJunction(const double x, const double y) { void MapApp::addJunction(const double x, const double y) {
auto &junction = junctions.emplace_back(x, y); auto &junction = junctions.emplace_back(x, y);
Glib::signal_idle().connect_once(
[this]() {
mapArea.adaptSizeRequest();
resizeWindow();
},
Glib::PRIORITY_HIGH_IDLE + 10);
int xRegion, yRegion, widthRegion, heightRegion; int xRegion, yRegion, widthRegion, heightRegion;
junction.getRegion(xRegion, yRegion, widthRegion, heightRegion); junction.getRegion(xRegion, yRegion, widthRegion, heightRegion);
Glib::signal_idle().connect_once( Glib::signal_idle().connect_once(
...@@ -172,8 +178,12 @@ void MapApp::addJunction(const double x, const double y) { ...@@ -172,8 +178,12 @@ void MapApp::addJunction(const double x, const double y) {
void MapApp::addRoad(std::string laneThereName, std::string laneBackName, void MapApp::addRoad(std::string laneThereName, std::string laneBackName,
std::vector<std::valarray<double>> coordinates) { std::vector<std::valarray<double>> coordinates) {
auto &road = roads.emplace_back(laneThereName, laneBackName, coordinates); auto &road = roads.emplace_back(laneThereName, laneBackName, coordinates);
// The window is only resizing, when called from the main thread like this: Glib::signal_idle().connect_once(
[this]() {
mapArea.adaptSizeRequest(); mapArea.adaptSizeRequest();
resizeWindow();
},
Glib::PRIORITY_HIGH_IDLE + 10);
int xRegion, yRegion, widthRegion, heightRegion; int xRegion, yRegion, widthRegion, heightRegion;
road.getRegion(xRegion, yRegion, widthRegion, heightRegion); road.getRegion(xRegion, yRegion, widthRegion, heightRegion);
Glib::signal_idle().connect_once( Glib::signal_idle().connect_once(
...@@ -264,3 +274,10 @@ void MapApp::addOrReplaceVehicle(const std::string &vehicleName, ...@@ -264,3 +274,10 @@ void MapApp::addOrReplaceVehicle(const std::string &vehicleName,
listBox->select_row(*listBoxRow); listBox->select_row(*listBoxRow);
} }
} }
void MapApp::resizeWindow() {
Gtk::Requisition minimumSize, naturalSize;
win.get_preferred_size(minimumSize, naturalSize);
win.resize(static_cast<int>(naturalSize.width),
static_cast<int>(naturalSize.height));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment