Merge feat/notifier-tweaks — vora externa al notificador
This commit is contained in:
commit
2c1c1a442b
2 files changed
+16
-6
No files matched your search
@@ -71,8 +71,8 @@ void Notifier::update(int delta_ms) {
|
|||||||
switch (status_) {
|
switch (status_) {
|
||||||
case Status::RISING:
|
case Status::RISING:
|
||||||
y_ += SLIDE_SPEED * DT;
|
y_ += SLIDE_SPEED * DT;
|
||||||
if (y_ >= static_cast<float>(MARGIN_TOP)) {
|
if (y_ >= static_cast<float>(MARGIN_TOP + BORDER_PX)) {
|
||||||
y_ = static_cast<float>(MARGIN_TOP);
|
y_ = static_cast<float>(MARGIN_TOP + BORDER_PX);
|
||||||
status_ = Status::ACTIVE;
|
status_ = Status::ACTIVE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -82,8 +82,8 @@ void Notifier::update(int delta_ms) {
|
|||||||
break;
|
break;
|
||||||
case Status::VANISHING:
|
case Status::VANISHING:
|
||||||
y_ -= SLIDE_SPEED * DT;
|
y_ -= SLIDE_SPEED * DT;
|
||||||
if (y_ <= static_cast<float>(-current_box_h_)) {
|
if (y_ <= static_cast<float>(-current_box_h_ - BORDER_PX)) {
|
||||||
y_ = static_cast<float>(-current_box_h_ - MARGIN_TOP);
|
y_ = static_cast<float>(-current_box_h_ - BORDER_PX - MARGIN_TOP);
|
||||||
status_ = Status::HIDDEN;
|
status_ = Status::HIDDEN;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -102,6 +102,15 @@ void Notifier::render() {
|
|||||||
// (ARGB directe al canvas, sense tocar cap surface paletada).
|
// (ARGB directe al canvas, sense tocar cap surface paletada).
|
||||||
Screen::get().fillRect(BOX_X, BOX_Y, current_box_w_, current_box_h_, ui_palette_[current_bg_color_]);
|
Screen::get().fillRect(BOX_X, BOX_Y, current_box_w_, current_box_h_, ui_palette_[current_bg_color_]);
|
||||||
|
|
||||||
|
// Vora externa: 4 línies d'1 px del color del text, paral·leles a cada
|
||||||
|
// costat i una mica fora de la caixa. Cada segment es queda dins del
|
||||||
|
// rang del costat corresponent perquè les cantonades no es cobrisquen.
|
||||||
|
const std::uint32_t BORDER_ARGB = ui_palette_[current_text_color_];
|
||||||
|
Screen::get().fillRect(BOX_X, BOX_Y - BORDER_PX, current_box_w_, BORDER_PX, BORDER_ARGB);
|
||||||
|
Screen::get().fillRect(BOX_X, BOX_Y + current_box_h_, current_box_w_, BORDER_PX, BORDER_ARGB);
|
||||||
|
Screen::get().fillRect(BOX_X - BORDER_PX, BOX_Y, BORDER_PX, current_box_h_, BORDER_ARGB);
|
||||||
|
Screen::get().fillRect(BOX_X + current_box_w_, BOX_Y, BORDER_PX, current_box_h_, BORDER_ARGB);
|
||||||
|
|
||||||
const int LINE_STEP = Rendering::Hud::FONT_SIZE_PX + LINE_GAP;
|
const int LINE_STEP = Rendering::Hud::FONT_SIZE_PX + LINE_GAP;
|
||||||
int line_y = BOX_Y + PADDING_V;
|
int line_y = BOX_Y + PADDING_V;
|
||||||
for (const auto& line : current_lines_) {
|
for (const auto& line : current_lines_) {
|
||||||
@@ -132,6 +141,6 @@ void Notifier::notify(const std::string& text, Uint8 text_color, Uint8 bg_color,
|
|||||||
current_text_color_ = text_color;
|
current_text_color_ = text_color;
|
||||||
current_bg_color_ = bg_color;
|
current_bg_color_ = bg_color;
|
||||||
remaining_ms_ = time_ms;
|
remaining_ms_ = time_ms;
|
||||||
y_ = static_cast<float>(-current_box_h_ - MARGIN_TOP);
|
y_ = static_cast<float>(-current_box_h_ - BORDER_PX - MARGIN_TOP);
|
||||||
status_ = Status::RISING;
|
status_ = Status::RISING;
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,8 @@ class Notifier {
|
|||||||
static constexpr int PADDING_H = 6;
|
static constexpr int PADDING_H = 6;
|
||||||
static constexpr int PADDING_V = 3;
|
static constexpr int PADDING_V = 3;
|
||||||
static constexpr int LINE_GAP = 1; // Separació vertical entre línies multilinia.
|
static constexpr int LINE_GAP = 1; // Separació vertical entre línies multilinia.
|
||||||
static constexpr int MARGIN_TOP = 2; // Separació amb la vora superior del canvas.
|
static constexpr int MARGIN_TOP = 2; // Separació amb la vora superior del canvas (fins a la línia exterior).
|
||||||
|
static constexpr int BORDER_PX = 1; // Gruix de la vora externa de color text.
|
||||||
static constexpr float SLIDE_SPEED = 120.0F;
|
static constexpr float SLIDE_SPEED = 120.0F;
|
||||||
// Amplada màxima (sense comptar padding) que pot ocupar el text abans que
|
// Amplada màxima (sense comptar padding) que pot ocupar el text abans que
|
||||||
// `wrapToWidth` el parteixi en línies. Deixem marge respecte a la vora del
|
// `wrapToWidth` el parteixi en línies. Deixem marge respecte a la vora del
|
||||||
|
|||||||
Reference in new issue
Block a user