mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
fix(ui): avoid drawing panel borders twice (#2226)
* fix: don't draw panel borders twice * fix: avoid drawing caption buttons over titlebar border * fix: remove manually painted separator on statusbar * titlebar test: caption buttons stop above the panel's separator line --------- Co-authored-by: Brandon Thomas <[email protected]>
This commit is contained in:
1 parent
44636cb6f2
commit
4aa511bb05
2 files changed
+3
-9
No files matched your search
@@ -89,8 +89,6 @@ pub fn toolbar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
|
||||
ui,
|
||||
|ui| {
|
||||
if t.pro {
|
||||
let r = ui.max_rect();
|
||||
ui.painter().line_segment([r.right_top() + vec2(m as f32, -8.0), r.right_bottom() + vec2(m as f32, 8.0)], Stroke::new(1.0, t.separator));
|
||||
// Photoshop's toolbar header chevrons switch between one and two columns.
|
||||
let (cr, resp) = ui.allocate_exact_size(vec2(bx, 14.0), Sense::click());
|
||||
icons::paint(ui, cr, if double { "chevrons-left" } else { "chevrons-right" }, 11.0, if resp.hovered() { t.text } else { t.text_faint });
|
||||
@@ -777,9 +775,6 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
|
||||
.exact_size(if t.pro { 36.0 } else { 42.0 })
|
||||
.frame(egui::Frame::NONE.fill(t.chrome).inner_margin(egui::Margin::symmetric(10, 0)))
|
||||
.show(ui, |ui| {
|
||||
let r = ui.max_rect();
|
||||
ui.painter().line_segment([r.left_top(), r.right_top()], Stroke::new(1.0, t.separator));
|
||||
ui.painter().line_segment([r.left_bottom(), r.right_bottom()], Stroke::new(1.0, t.separator));
|
||||
ui.horizontal_centered(|ui| {
|
||||
if t.pro {
|
||||
crate::chrome_ui::home_button(app, ui);
|
||||
@@ -1316,8 +1311,6 @@ pub fn status_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
|
||||
.exact_size(if t.pro { 24.0 } else { 30.0 })
|
||||
.frame(egui::Frame::NONE.fill(t.chrome).inner_margin(egui::Margin::symmetric(10, 0)))
|
||||
.show(ui, |ui| {
|
||||
let r = ui.max_rect();
|
||||
ui.painter().line_segment([r.left_top(), r.right_top()], Stroke::new(1.0, t.separator));
|
||||
ui.horizontal_centered(|ui| {
|
||||
if t.pro {
|
||||
crate::chrome_ui::status_bar_pro(app, ui);
|
||||
|
||||
@@ -52,7 +52,7 @@ pub fn caption_buttons(app: &mut PhotocraftApp, ui: &mut Ui, bar: Rect) {
|
||||
let right = bar.right().min(ui.ctx().content_rect().right());
|
||||
let mut clicked = None;
|
||||
for (i, c) in CAPTIONS.into_iter().enumerate() {
|
||||
let r = Rect::from_min_size(pos2(right - WIDTH + i as f32 * BUTTON_WIDTH, bar.top()), vec2(BUTTON_WIDTH, bar.height()));
|
||||
let r = Rect::from_min_size(pos2(right - WIDTH + i as f32 * BUTTON_WIDTH, bar.top()), vec2(BUTTON_WIDTH, bar.height() - 1.0));
|
||||
let resp = ui.interact(r, caption_id(c), Sense::click());
|
||||
let close = c == Caption::Close;
|
||||
let fill = match (resp.is_pointer_button_down_on(), resp.hovered()) {
|
||||
@@ -244,7 +244,8 @@ mod tests {
|
||||
let out = w.frame(vec![]);
|
||||
let [min, max, close] = CAPTIONS.map(|c| w.caption(c));
|
||||
assert_eq!((close.right(), close.top()), (width, 0.0), "Close sits in the window's corner at {width}");
|
||||
assert!(close.height() >= 32.0 && [min, max, close].iter().all(|r| r.width() == BUTTON_WIDTH));
|
||||
// The bar's bottom point is the panel's separator line, which the buttons leave visible.
|
||||
assert!(close.height() >= 31.0 && [min, max, close].iter().all(|r| r.width() == BUTTON_WIDTH));
|
||||
assert_eq!((min.right(), max.right()), (max.left(), close.left()));
|
||||
let widgets = w.bar_widgets();
|
||||
assert!(widgets.len() >= 10, "menus, search, theme, workspace: {widgets:?}");
|
||||
|
||||
Reference in new issue
Block a user