Skip to content

Commit

Permalink
Don't move moveable widgets when hiding the minimap
Browse files Browse the repository at this point in the history
  • Loading branch information
lmoureaux committed Jul 9, 2022
1 parent 65a12f3 commit f8d63b3
Showing 1 changed file with 51 additions and 45 deletions.
96 changes: 51 additions & 45 deletions client/page_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,51 +506,57 @@ void fc_game_tab_widget::init()
*/
bool fc_game_tab_widget::event(QEvent *event)
{
if (C_S_RUNNING <= client_state()
&& (event->type() == QEvent::Resize
|| event->type() == QEvent::LayoutRequest)) {
auto size = event->type() == QEvent::Resize
? static_cast<QResizeEvent *>(event)->size()
: this->size();

map_canvas_resized(size.width(), size.height());
queen()->message->resize(
qRound((size.width() * king()->qt_settings.chat_fwidth)),
qRound((size.height() * king()->qt_settings.chat_fheight)));
queen()->message->move(size.width() - queen()->message->width(), 0);
queen()->chat->resize(
qRound((size.width() * king()->qt_settings.chat_fwidth)),
qRound((size.height() * king()->qt_settings.chat_fheight)));
queen()->chat->move(
qRound((size.width() * king()->qt_settings.chat_fx_pos)),
qRound((size.height() * king()->qt_settings.chat_fy_pos)));
queen()->battlelog_wdg->set_scale(king()->qt_settings.battlelog_scale);
queen()->battlelog_wdg->move(
qRound(king()->qt_settings.battlelog_x * mapview.width),
qRound(king()->qt_settings.battlelog_y * mapview.height));
queen()->x_vote->move(width() / 2 - queen()->x_vote->width() / 2, 0);
queen()->updateSidebarTooltips();
queen()->minimap_panel->turn_done()->setEnabled(
get_turn_done_button_state());
queen()->mapview_wdg->resize(size.width(), size.height());
queen()->city_overlay->resize(queen()->mapview_wdg->size());
queen()->unitinfo_wdg->update_actions(nullptr);
queen()->civ_status->move(
qRound(king()->qt_settings.civstatus_x * mapview.width),
qRound(king()->qt_settings.civstatus_y * mapview.height));

/*
* Resize the panel at the bottom right.
*/
const auto max_size = QSize(std::max(300, size.width() / 4),
std::max(200, size.height() / 3));
const auto panel_size =
QLayout::closestAcceptableSize(queen()->minimap_panel, max_size);
const auto location = size - panel_size;
queen()->minimap_panel->move(location.width(), location.height());
queen()->minimap_panel->resize(panel_size);

return true;
const auto size = event->type() == QEvent::Resize
? static_cast<QResizeEvent *>(event)->size()
: this->size();
if (C_S_RUNNING <= client_state()) {
switch (event->type()) {
case QEvent::Resize: {
map_canvas_resized(size.width(), size.height());
queen()->message->resize(
qRound((size.width() * king()->qt_settings.chat_fwidth)),
qRound((size.height() * king()->qt_settings.chat_fheight)));
queen()->message->move(size.width() - queen()->message->width(), 0);
queen()->chat->resize(
qRound((size.width() * king()->qt_settings.chat_fwidth)),
qRound((size.height() * king()->qt_settings.chat_fheight)));
queen()->chat->move(
qRound((size.width() * king()->qt_settings.chat_fx_pos)),
qRound((size.height() * king()->qt_settings.chat_fy_pos)));
queen()->battlelog_wdg->set_scale(king()->qt_settings.battlelog_scale);
queen()->battlelog_wdg->move(
qRound(king()->qt_settings.battlelog_x * mapview.width),
qRound(king()->qt_settings.battlelog_y * mapview.height));
queen()->x_vote->move(width() / 2 - queen()->x_vote->width() / 2, 0);
queen()->civ_status->move(
qRound(king()->qt_settings.civstatus_x * mapview.width),
qRound(king()->qt_settings.civstatus_y * mapview.height));

queen()->updateSidebarTooltips();
queen()->minimap_panel->turn_done()->setEnabled(
get_turn_done_button_state());
queen()->mapview_wdg->resize(size.width(), size.height());
queen()->city_overlay->resize(queen()->mapview_wdg->size());
queen()->unitinfo_wdg->update_actions(nullptr);
}
[[fallthrough]];
case QEvent::LayoutRequest: {
/*
* Resize the panel at the bottom right.
*/
const auto max_size = QSize(std::max(300, size.width() / 4),
std::max(200, size.height() / 3));
const auto panel_size =
QLayout::closestAcceptableSize(queen()->minimap_panel, max_size);
const auto location = size - panel_size;
queen()->minimap_panel->move(location.width(), location.height());
queen()->minimap_panel->resize(panel_size);

return true;
} break;
default:
break;
}
}

return QWidget::event(event);
Expand Down

0 comments on commit f8d63b3

Please sign in to comment.