mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 19:35:33 +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 "blackgui/guiutility.h"
|
||||||
#include "blackmisc/aviation/atcstationlist.h"
|
#include "blackmisc/aviation/atcstationlist.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QPushButton>
|
#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)
|
if (added > 0)
|
||||||
{
|
{
|
||||||
this->setVisible(true);
|
this->setVisible(true);
|
||||||
this->setMinimumHeight(row * 25);
|
this->setMinimumHeight(rows * 25);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -664,7 +664,7 @@ namespace BlackGui
|
|||||||
ui->comp_AtcStations->setBackgroundUpdates(backgroundUpdates);
|
ui->comp_AtcStations->setBackgroundUpdates(backgroundUpdates);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTextMessageComponent::updateAtcButtonStations()
|
void CTextMessageComponent::updateAtcStationsButtons()
|
||||||
{
|
{
|
||||||
ui->comp_AtcStations->updateStations();
|
ui->comp_AtcStations->updateStations();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ namespace BlackGui
|
|||||||
void setAtcButtonsBackgroundUpdates(bool backgroundUpdates);
|
void setAtcButtonsBackgroundUpdates(bool backgroundUpdates);
|
||||||
|
|
||||||
//! Update buttons
|
//! Update buttons
|
||||||
void updateAtcButtonStations();
|
void updateAtcStationsButtons();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Message to be displayed in info window
|
//! Message to be displayed in info window
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
ui->sw_StatusMessagesComponent->setCurrentWidget(ui->pg_OverlayTextMessage);
|
ui->sw_StatusMessagesComponent->setCurrentWidget(ui->pg_OverlayTextMessage);
|
||||||
ui->comp_OverlayTextMessage->setTab(tab);
|
ui->comp_OverlayTextMessage->setTab(tab);
|
||||||
ui->comp_OverlayTextMessage->updateAtcButtonStations();
|
ui->comp_OverlayTextMessage->updateAtcStationsButtons();
|
||||||
this->setHeader("Text message");
|
this->setHeader("Text message");
|
||||||
this->showKill(false);
|
this->showKill(false);
|
||||||
this->display();
|
this->display();
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ namespace BlackGui
|
|||||||
//! \copydoc BlackGui::COverlayMessages::showOverlayImage
|
//! \copydoc BlackGui::COverlayMessages::showOverlayImage
|
||||||
void showOverlayInlineTextMessage(Components::TextMessageTab tab)
|
void showOverlayInlineTextMessage(Components::TextMessageTab tab)
|
||||||
{
|
{
|
||||||
this->initInnerFrame();
|
this->initInnerFrame(0.75, 0.75);
|
||||||
m_overlayMessages->showOverlayInlineTextMessage(tab);
|
m_overlayMessages->showOverlayInlineTextMessage(tab);
|
||||||
WIDGET::repaint();
|
WIDGET::repaint();
|
||||||
}
|
}
|
||||||
@@ -191,9 +191,9 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Init the inner frame (if not yet initialized)
|
//! 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)
|
if (!m_overlayMessages)
|
||||||
{
|
{
|
||||||
// lazy init
|
// lazy init
|
||||||
@@ -259,14 +259,17 @@ namespace BlackGui
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
//! Calculate inner frame size
|
//! 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
|
// check against minimum if widget is initialized, but not yet resized
|
||||||
const int w = std::max(WIDGET::width(), WIDGET::minimumWidth());
|
const int w = std::max(WIDGET::width(), WIDGET::minimumWidth());
|
||||||
const int h = std::max(WIDGET::height(), WIDGET::minimumHeight());
|
const int h = std::max(WIDGET::height(), WIDGET::minimumHeight());
|
||||||
|
|
||||||
int wInner = qRound(m_widthFactor * w);
|
widthFactor = qMin(widthFactor < 0 ? m_widthFactor : widthFactor, 0.95);
|
||||||
int hInner = qRound(m_heightFactor * h);
|
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 (wInner > WIDGET::maximumWidth()) { wInner = WIDGET::maximumWidth(); }
|
||||||
if (hInner > WIDGET::maximumHeight()) { hInner = WIDGET::maximumHeight(); }
|
if (hInner > WIDGET::maximumHeight()) { hInner = WIDGET::maximumHeight(); }
|
||||||
return QSize(wInner, hInner);
|
return QSize(wInner, hInner);
|
||||||
|
|||||||
Reference in New Issue
Block a user