mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-22 06:53:46 +08:00
ui: Fix blinker positions when in split view (#306)
* ui: Fix blinker positions when in split view * Shorten name
This commit is contained in:
+12
-12
@@ -1418,7 +1418,7 @@ void AnnotatedCameraWidget::drawE2eStatus(QPainter &p, int x, int y, int w, int
|
||||
p.drawEllipse(e2eStatusIcon);
|
||||
}
|
||||
|
||||
void AnnotatedCameraWidget::drawLeftTurnSignal(QPainter &painter, int x, int y, int state) {
|
||||
void AnnotatedCameraWidget::drawLeftTurnSignal(QPainter &painter, int x, int y, int circle_size, int state) {
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
QColor circle_color, circle_color_0, circle_color_1;
|
||||
@@ -1444,17 +1444,16 @@ void AnnotatedCameraWidget::drawLeftTurnSignal(QPainter &painter, int x, int y,
|
||||
}
|
||||
|
||||
// Draw the circle
|
||||
int circleSize = 120;
|
||||
int circleX = x;
|
||||
int circleY = y;
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(circle_color);
|
||||
painter.drawEllipse(circleX, circleY, circleSize, circleSize);
|
||||
painter.drawEllipse(circleX, circleY, circle_size, circle_size);
|
||||
|
||||
// Draw the arrow
|
||||
int arrowSize = 50;
|
||||
int arrowX = circleX + (circleSize - arrowSize) / 4;
|
||||
int arrowY = circleY + (circleSize - arrowSize) / 2;
|
||||
int arrowX = circleX + (circle_size - arrowSize) / 4;
|
||||
int arrowY = circleY + (circle_size - arrowSize) / 2;
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(arrow_color);
|
||||
|
||||
@@ -1475,7 +1474,7 @@ void AnnotatedCameraWidget::drawLeftTurnSignal(QPainter &painter, int x, int y,
|
||||
painter.fillRect(tailRect, arrow_color);
|
||||
}
|
||||
|
||||
void AnnotatedCameraWidget::drawRightTurnSignal(QPainter &painter, int x, int y, int state) {
|
||||
void AnnotatedCameraWidget::drawRightTurnSignal(QPainter &painter, int x, int y, int circle_size, int state) {
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
QColor circle_color, circle_color_0, circle_color_1;
|
||||
@@ -1502,17 +1501,16 @@ void AnnotatedCameraWidget::drawRightTurnSignal(QPainter &painter, int x, int y,
|
||||
|
||||
|
||||
// Draw the circle
|
||||
int circleSize = 120;
|
||||
int circleX = x;
|
||||
int circleY = y;
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(circle_color);
|
||||
painter.drawEllipse(circleX, circleY, circleSize, circleSize);
|
||||
painter.drawEllipse(circleX, circleY, circle_size, circle_size);
|
||||
|
||||
// Draw the arrow
|
||||
int arrowSize = 50;
|
||||
int arrowX = circleX + (circleSize - arrowSize) / 2 + (arrowSize / 2.5) - 3;
|
||||
int arrowY = circleY + (circleSize - arrowSize) / 2;
|
||||
int arrowX = circleX + (circle_size - arrowSize) / 2 + (arrowSize / 2.5) - 3;
|
||||
int arrowY = circleY + (circle_size - arrowSize) / 2;
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(arrow_color);
|
||||
|
||||
@@ -1967,11 +1965,13 @@ void AnnotatedCameraWidget::paintEvent(QPaintEvent *event) {
|
||||
if (left_blinker || right_blinker) {
|
||||
blinker_frame++;
|
||||
int state = blinkerPulse(blinker_frame);
|
||||
int blinker_x = splitPanelVisible ? 150 : 180;
|
||||
int blinker_y = splitPanelVisible ? 220 : 90;
|
||||
if (left_blinker) {
|
||||
drawLeftTurnSignal(painter, rect().center().x() - 300, splitPanelVisible ? 210 : 90, state);
|
||||
drawLeftTurnSignal(painter, rect().center().x() - (blinker_x + blinker_size), blinker_y, blinker_size, state);
|
||||
}
|
||||
if (right_blinker) {
|
||||
drawRightTurnSignal(painter, rect().center().x() + 180, splitPanelVisible ? 210 : 90, state);
|
||||
drawRightTurnSignal(painter, rect().center().x() + blinker_x, blinker_y, blinker_size, state);
|
||||
}
|
||||
} else {
|
||||
blinker_frame = 0;
|
||||
|
||||
@@ -20,6 +20,7 @@ const int btn_size = 192;
|
||||
const int img_size = (btn_size / 4) * 3;
|
||||
const int subsign_img_size = 35;
|
||||
|
||||
const int blinker_size = 120;
|
||||
|
||||
// ***** onroad widgets *****
|
||||
class OnroadAlerts : public QWidget {
|
||||
@@ -117,8 +118,8 @@ private:
|
||||
|
||||
void drawE2eStatus(QPainter &p, int x, int y, int w, int h, int e2e_long_status);
|
||||
|
||||
void drawLeftTurnSignal(QPainter &painter, int x, int y, int state);
|
||||
void drawRightTurnSignal(QPainter &painter, int x, int y, int state);
|
||||
void drawLeftTurnSignal(QPainter &painter, int x, int y, int circle_size, int state);
|
||||
void drawRightTurnSignal(QPainter &painter, int x, int y, int circle_size, int state);
|
||||
int blinkerPulse(int frame);
|
||||
void updateButtonsLayout();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user