From 1453a4cadcfd0b39a48d1b051b95a8ac19bc04c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Wed, 2 Sep 2026 15:39:10 +0200 Subject: [PATCH] dn: adjust the look of Entries --- dn/kit-browser.cpp | 1 + dn/kit.cpp | 18 ++++++++++++------ dn/kit.hpp | 7 +++++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/dn/kit-browser.cpp b/dn/kit-browser.cpp index be663ac..8f22858 100644 --- a/dn/kit-browser.cpp +++ b/dn/kit-browser.cpp @@ -2249,6 +2249,7 @@ make_item(Browser &b, const Spec &spec) if (spec.kind == Kind::Search) { auto e = make_unique(); b.search_ = e.get(); + e->flat = true; e->placeholder = QStringLiteral("Filter"); e->on_change = [&b](Kit &) { scan_dir(b); diff --git a/dn/kit.cpp b/dn/kit.cpp index cad79ab..0aa2f90 100644 --- a/dn/kit.cpp +++ b/dn/kit.cpp @@ -1026,13 +1026,15 @@ Entry::paint(Kit &kit) const if (!this->Widget::shown() || this->r.empty()) return; - // The border always says where the field is; only the fill is conditional. - // An idle, empty field lets the toolbar show through, and text in it is a - // filter the listing is already obeying, so that fills even unfocused, as - // the only thing on screen explaining why files are missing. + // A flat idle field lets the toolbar show through. Text in it is a filter + // the listing is already obeying, so that restores the background even + // unfocused, as the only thing on screen explaining why files are missing. const float hair = float(kit.hairline()); - if (this->focused_ || !this->text.isEmpty()) - kit.draw_fill(this->r, col(kit.colours_[ColourFrame])); + if (!this->flat || this->focused_ || !this->text.isEmpty()) + kit.list_.add_rect_filled_vgradient(this->r.x, this->r.y, + this->r.x + this->r.w, this->r.y + this->r.h, + col(kit.colours_[ColourEntryTop]), + col(kit.colours_[ColourEntryBottom])); kit.draw_border(this->r, col(kit.colours_[ColourDivider]), hair); const Rect in = this->r.inset(kit.px(this->pad_x), kit.px(kEntryPadY)); @@ -4256,6 +4258,8 @@ Kit::bake_colours(dawn::Cmm *cmm, dawn::Profile *target) this->colours_[ColourBusy] = bake_rgb(cmm, target, 0xc0, 0x00, 0x00); this->colours_[ColourInk] = bake_grey(cmm, target, 0xff); this->colours_[ColourFrame] = bake_grey(cmm, target, 0x00); + this->colours_[ColourEntryTop] = bake_grey(cmm, target, 0x10); + this->colours_[ColourEntryBottom] = this->colours_[ColourFrame]; this->colours_[ColourPanel] = bake_grey(cmm, target, 0x28); this->colours_[ColourHint] = bake_rgb(cmm, target, 0x88, 0x77, 0x00); } else { @@ -4268,6 +4272,8 @@ Kit::bake_colours(dawn::Cmm *cmm, dawn::Profile *target) this->colours_[ColourBusy] = bake_rgb(cmm, target, 0x8b, 0x00, 0x00); this->colours_[ColourInk] = bake_grey(cmm, target, 0x00); this->colours_[ColourFrame] = bake_grey(cmm, target, 0xff); + this->colours_[ColourEntryTop] = bake_grey(cmm, target, 0xf8); + this->colours_[ColourEntryBottom] = this->colours_[ColourFrame]; this->colours_[ColourPanel] = bake_grey(cmm, target, 0xf0); this->colours_[ColourHint] = bake_rgb(cmm, target, 0xff, 0xee, 0x00); } diff --git a/dn/kit.hpp b/dn/kit.hpp index 189af58..be5313e 100644 --- a/dn/kit.hpp +++ b/dn/kit.hpp @@ -89,6 +89,8 @@ enum : uint8_t { ColourBusy, ColourInk, ColourFrame, + ColourEntryTop, + ColourEntryBottom, ColourPanel, ColourHint, ColourCount, @@ -256,6 +258,7 @@ struct Entry : Widget { int preedit_caret = 0; float min_w = 160.f; float pad_x = kFramePadX; + bool flat = false; // A field takes what room it is given -- in the overflow popup it moved // into as much as in the bar, where it fills out the rest of the line it // wrapped onto. @@ -820,11 +823,11 @@ struct Kit { } // An appropriately thick rule, border or caret, in device pixels. - [[nodiscard]] int hairline() const { return std::min(px(1.f), 1); } + [[nodiscard]] int hairline() const { return std::max(px(1.f), 1); } // One icon square, in device pixels: the size pack_icon() rasterises at, // and the size the quad that samples it is drawn at. - [[nodiscard]] int icon_px() const { return std::min(px(kIconPts), 16); } + [[nodiscard]] int icon_px() const { return std::max(px(kIconPts), 16); } // Raw atlas bytes: 16-bit RGBA UNORM, 8 bytes/pixel, row-major. [[nodiscard]] bool font_pixels(