mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
Improved size calculation of overlay text message
* larger text message overlay * fixed min.size calculation
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "blackgui/guiutility.h"
|
||||
#include "blackmisc/aviation/atcstationlist.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
@@ -91,10 +92,13 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
const double a = added;
|
||||
const double c = m_cols;
|
||||
const int rows = qRound(ceil(a / c)); // row can be too high
|
||||
if (added > 0)
|
||||
{
|
||||
this->setVisible(true);
|
||||
this->setMinimumHeight(row * 25);
|
||||
this->setMinimumHeight(rows * 25);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -664,7 +664,7 @@ namespace BlackGui
|
||||
ui->comp_AtcStations->setBackgroundUpdates(backgroundUpdates);
|
||||
}
|
||||
|
||||
void CTextMessageComponent::updateAtcButtonStations()
|
||||
void CTextMessageComponent::updateAtcStationsButtons()
|
||||
{
|
||||
ui->comp_AtcStations->updateStations();
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace BlackGui
|
||||
void setAtcButtonsBackgroundUpdates(bool backgroundUpdates);
|
||||
|
||||
//! Update buttons
|
||||
void updateAtcButtonStations();
|
||||
void updateAtcStationsButtons();
|
||||
|
||||
signals:
|
||||
//! Message to be displayed in info window
|
||||
|
||||
@@ -252,7 +252,7 @@ namespace BlackGui
|
||||
{
|
||||
ui->sw_StatusMessagesComponent->setCurrentWidget(ui->pg_OverlayTextMessage);
|
||||
ui->comp_OverlayTextMessage->setTab(tab);
|
||||
ui->comp_OverlayTextMessage->updateAtcButtonStations();
|
||||
ui->comp_OverlayTextMessage->updateAtcStationsButtons();
|
||||
this->setHeader("Text message");
|
||||
this->showKill(false);
|
||||
this->display();
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace BlackGui
|
||||
//! Set the size factors
|
||||
void setOverlaySizeFactors(double widthFactor, double heightFactor, double middleFactor = 2)
|
||||
{
|
||||
m_widthFactor = widthFactor;
|
||||
m_widthFactor = widthFactor;
|
||||
m_heightFactor = heightFactor;
|
||||
if (middleFactor >= 0) { m_middleFactor = middleFactor; }
|
||||
}
|
||||
@@ -174,7 +174,7 @@ namespace BlackGui
|
||||
//! \copydoc BlackGui::COverlayMessages::showOverlayImage
|
||||
void showOverlayInlineTextMessage(Components::TextMessageTab tab)
|
||||
{
|
||||
this->initInnerFrame();
|
||||
this->initInnerFrame(0.75, 0.75);
|
||||
m_overlayMessages->showOverlayInlineTextMessage(tab);
|
||||
WIDGET::repaint();
|
||||
}
|
||||
@@ -191,9 +191,9 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
//! Init the inner frame (if not yet initialized)
|
||||
void initInnerFrame()
|
||||
void initInnerFrame(double widthFactor = -1, double heightFactor = -1)
|
||||
{
|
||||
const QSize inner(innerFrameSize());
|
||||
const QSize inner(innerFrameSize(widthFactor, heightFactor));
|
||||
if (!m_overlayMessages)
|
||||
{
|
||||
// lazy init
|
||||
@@ -259,14 +259,17 @@ namespace BlackGui
|
||||
|
||||
private:
|
||||
//! Calculate inner frame size
|
||||
QSize innerFrameSize() const
|
||||
QSize innerFrameSize(double widthFactor = -1, double heightFactor = -1) const
|
||||
{
|
||||
// check against minimum if widget is initialized, but not yet resized
|
||||
const int w = std::max(WIDGET::width(), WIDGET::minimumWidth());
|
||||
const int h = std::max(WIDGET::height(), WIDGET::minimumHeight());
|
||||
|
||||
int wInner = qRound(m_widthFactor * w);
|
||||
int hInner = qRound(m_heightFactor * h);
|
||||
widthFactor = qMin(widthFactor < 0 ? m_widthFactor : widthFactor, 0.95);
|
||||
heightFactor = qMin(heightFactor < 0 ? m_heightFactor : heightFactor, 0.95);
|
||||
|
||||
int wInner = qRound(widthFactor * w);
|
||||
int hInner = qRound(heightFactor * h);
|
||||
if (wInner > WIDGET::maximumWidth()) { wInner = WIDGET::maximumWidth(); }
|
||||
if (hInner > WIDGET::maximumHeight()) { hInner = WIDGET::maximumHeight(); }
|
||||
return QSize(wInner, hInner);
|
||||
|
||||
Reference in New Issue
Block a user