From 65c195bffb3c5c98e2450334cca6523cab9a37c3 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sat, 29 Sep 2012 20:15:23 -0400 Subject: [PATCH] fixed a long-standing annoyance: the GUI window now resizes properly upon tab switches if a render job finished in the meantime --- src/mtsgui/common.h | 4 +++- src/mtsgui/mainwindow.cpp | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/mtsgui/common.h b/src/mtsgui/common.h index d9d772e3..439831e9 100644 --- a/src/mtsgui/common.h +++ b/src/mtsgui/common.h @@ -179,6 +179,7 @@ struct SceneContext { /* Rendering/Preview-related */ RenderJob *renderJob; bool cancelled; + bool wasRendering; float progress; QString eta, progressName; ref framebuffer; @@ -206,7 +207,8 @@ struct SceneContext { PreviewQueueEntry previewBuffer; SceneContext() : scene(NULL), sceneResID(-1), - renderJob(NULL), selectionMode(ENothing), + renderJob(NULL), wasRendering(false), + selectionMode(ENothing), selectedShape(NULL) { } /// Detect the path length diff --git a/src/mtsgui/mainwindow.cpp b/src/mtsgui/mainwindow.cpp index 88ce8b3b..6570d307 100644 --- a/src/mtsgui/mainwindow.cpp +++ b/src/mtsgui/mainwindow.cpp @@ -775,8 +775,8 @@ void MainWindow::updateUI() { if (isRendering) { if (!m_progress->isVisible()) { - QGridLayout *centralLayout = static_cast(centralWidget()->layout()); - centralLayout->addWidget(m_progressWidget, 3, 0, 1, 3); + static_cast(centralWidget()->layout())-> + addWidget(m_progressWidget, 3, 0, 1, 3); m_progressWidget->show(); } m_progress->setValue(context->progress); @@ -831,8 +831,10 @@ void MainWindow::on_tabBar_tabMoved(int from, int to) { } void MainWindow::on_tabBar_currentChanged(int index) { - if (m_lastTab != NULL) + if (m_lastTab != NULL) { m_lastTab->windowSize = size(); + m_lastTab->wasRendering = m_lastTab->renderJob != NULL; + } ui->glView->ignoreResizeEvents(true); if (ui->tabBar->currentIndex() != -1) @@ -862,8 +864,12 @@ void MainWindow::on_tabBar_currentChanged(int index) { ui->menuCamera->clear(); if (index != -1) { - const QSize &windowSize = m_context[index]->windowSize; + SceneContext *context = m_context[index]; + QSize windowSize = context->windowSize; + if (windowSize.isValid()) { + if (context->wasRendering && !context->renderJob) + windowSize -= context->sizeIncrease; #if defined(__LINUX__) int error = (sizeHint()-windowSize).height(); if (error > 0 && error <= 5) @@ -877,9 +883,9 @@ void MainWindow::on_tabBar_currentChanged(int index) { adjustSize(); } - m_lastTab = m_context[index]; + m_lastTab = context; - const Scene *scene = m_context[index]->scene; + const Scene *scene = context->scene; if (scene) { const ref_vector &sensors = scene->getSensors(); for (size_t i = 0; i < sensors.size(); ++i) { @@ -1890,6 +1896,7 @@ SceneContext::SceneContext(SceneContext *ctx) { movementScale = ctx->movementScale; up = ctx->up; renderJob = NULL; + wasRendering = false; cancelled = false; progress = 0.0f; framebuffer = ctx->framebuffer->clone();