ui: more descriptive global names (#28813)

* rename global bdr_s to UI_BORDER_SIZE

* rename header_h to UI_HEADER_HEIGHT

* remove unused footer_h
old-commit-hash: 5991aea10a
beeps
Dean Lee 2 years ago committed by GitHub
parent 2f56c54602
commit 724ef9d7ef
  1. 12
      selfdrive/ui/qt/maps/map.cc
  2. 16
      selfdrive/ui/qt/onroad.cc
  3. 5
      selfdrive/ui/ui.h

@ -41,7 +41,7 @@ MapWindow::MapWindow(const QMapboxGLSettings &settings) : m_settings(settings),
const int h = 120;
map_eta->setFixedHeight(h);
map_eta->move(25, 1080 - h - bdr_s*2);
map_eta->move(25, 1080 - h - UI_BORDER_SIZE*2);
map_eta->setVisible(false);
// Settings button
@ -62,7 +62,7 @@ MapWindow::MapWindow(const QMapboxGLSettings &settings) : m_settings(settings),
}
)");
settings_btn->show(); // force update
settings_btn->move(bdr_s, 1080 - bdr_s*3 - settings_btn->height());
settings_btn->move(UI_BORDER_SIZE, 1080 - UI_BORDER_SIZE*3 - settings_btn->height());
QObject::connect(settings_btn, &QPushButton::clicked, [=]() {
emit openSettings();
});
@ -216,12 +216,12 @@ void MapWindow::updateState(const UIState &s) {
// TODO: only move if position should change
// don't move while map isn't visible
if (isVisible()) {
auto pos = 1080 - bdr_s*2 - settings_btn->height() - bdr_s;
auto pos = 1080 - UI_BORDER_SIZE*2 - settings_btn->height() - UI_BORDER_SIZE;
if (map_eta->isVisible()) {
settings_btn->move(bdr_s, pos - map_eta->height());
settings_btn->move(UI_BORDER_SIZE, pos - map_eta->height());
settings_btn->setIcon(settings_icon);
} else {
settings_btn->move(bdr_s, pos);
settings_btn->move(UI_BORDER_SIZE, pos);
settings_btn->setIcon(directions_icon);
}
}
@ -701,5 +701,5 @@ void MapETA::updateETA(float s, float s_typical, float d) {
setMask(mask);
// Center
move(static_cast<QWidget*>(parent())->width() / 2 - width() / 2, 1080 - height() - bdr_s*2);
move(static_cast<QWidget*>(parent())->width() / 2 - width() / 2, 1080 - height() - UI_BORDER_SIZE*2);
}

@ -14,7 +14,7 @@
OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) {
QVBoxLayout *main_layout = new QVBoxLayout(this);
main_layout->setMargin(bdr_s);
main_layout->setMargin(UI_BORDER_SIZE);
QStackedLayout *stacked_layout = new QStackedLayout;
stacked_layout->setStackingMode(QStackedLayout::StackAll);
main_layout->addLayout(stacked_layout);
@ -68,9 +68,9 @@ void OnroadWindow::updateState(const UIState &s) {
bool navDisabledNow = (*s.sm)["controlsState"].getControlsState().getEnabled() &&
!(*s.sm)["modelV2"].getModelV2().getNavEnabled();
if (navDisabled != navDisabledNow) {
split->setSpacing(navDisabledNow ? bdr_s * 2 : 0);
split->setSpacing(navDisabledNow ? UI_BORDER_SIZE * 2 : 0);
if (map) {
map->setFixedWidth(topWidget(this)->width() / 2 - bdr_s * (navDisabledNow ? 2 : 1));
map->setFixedWidth(topWidget(this)->width() / 2 - UI_BORDER_SIZE * (navDisabledNow ? 2 : 1));
}
}
@ -106,7 +106,7 @@ void OnroadWindow::offroadTransition(bool offroad) {
QObject::connect(m, &MapPanel::mapWindowShown, this, &OnroadWindow::mapWindowShown);
m->setFixedWidth(topWidget(this)->width() / 2 - bdr_s);
m->setFixedWidth(topWidget(this)->width() / 2 - UI_BORDER_SIZE);
split->insertWidget(0, m);
// hidden by default, made visible when navRoute is published
@ -246,7 +246,7 @@ AnnotatedCameraWidget::AnnotatedCameraWidget(VisionStreamType type, QWidget* par
pm = std::make_unique<PubMaster, const std::initializer_list<const char *>>({"uiDebug"});
QVBoxLayout *main_layout = new QVBoxLayout(this);
main_layout->setMargin(bdr_s);
main_layout->setMargin(UI_BORDER_SIZE);
main_layout->setSpacing(0);
experimental_btn = new ExperimentalButton(this);
@ -314,10 +314,10 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
p.save();
// Header gradient
QLinearGradient bg(0, header_h - (header_h / 2.5), 0, header_h);
QLinearGradient bg(0, UI_HEADER_HEIGHT - (UI_HEADER_HEIGHT / 2.5), 0, UI_HEADER_HEIGHT);
bg.setColorAt(0, QColor::fromRgbF(0, 0, 0, 0.45));
bg.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));
p.fillRect(0, 0, width(), header_h, bg);
p.fillRect(0, 0, width(), UI_HEADER_HEIGHT, bg);
QString speedLimitStr = (speedLimit > 1) ? QString::number(std::nearbyint(speedLimit)) : "";
QString speedStr = QString::number(std::nearbyint(speed));
@ -520,7 +520,7 @@ void AnnotatedCameraWidget::drawDriverState(QPainter &painter, const UIState *s)
painter.save();
// base icon
int offset = bdr_s + btn_size / 2;
int offset = UI_BORDER_SIZE + btn_size / 2;
int x = rightHandDM ? width() - offset : offset;
int y = height() - offset;
float opacity = dmActive ? 0.65 : 0.2;

@ -16,9 +16,8 @@
#include "common/params.h"
#include "common/timing.h"
const int bdr_s = 30;
const int header_h = 420;
const int footer_h = 280;
const int UI_BORDER_SIZE = 30;
const int UI_HEADER_HEIGHT = 420;
const int UI_FREQ = 20; // Hz
typedef cereal::CarControl::HUDControl::AudibleAlert AudibleAlert;

Loading…
Cancel
Save