From ea0192b7e306ec0682e9576334536b7d589561b7 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 30 Jul 2022 11:38:28 -0400 Subject: [PATCH] Tweaked tooltips so that item name and kind are next to image, to reduce amount of empty space. --- voxygen/src/ui/widgets/item_tooltip.rs | 41 +++++++++++--------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/voxygen/src/ui/widgets/item_tooltip.rs b/voxygen/src/ui/widgets/item_tooltip.rs index 4151a3ca96..18bd46559a 100644 --- a/voxygen/src/ui/widgets/item_tooltip.rs +++ b/voxygen/src/ui/widgets/item_tooltip.rs @@ -534,24 +534,12 @@ impl<'a> Widget for ItemTooltip<'a> { .set(state.ids.image, ui); } - // Title - widget::Text::new(&title) - .w(text_w) - .graphics_for(id) - .parent(id) - .with_style(self.style.title) - .top_left_with_margins_on(state.ids.image_frame, V_PAD, H_PAD) - .center_justify() - .color(quality) - .set(state.ids.title, ui); - // Item frame widget::Image::new(quality_col_img) .wh(ICON_SIZE) .graphics_for(id) .parent(id) .top_left_with_margins_on(state.ids.image_frame, V_PAD, H_PAD) - .down_from(state.ids.title, V_PAD) .set(state.ids.item_frame, ui); // Item render @@ -566,14 +554,27 @@ impl<'a> Widget for ItemTooltip<'a> { .middle_of(state.ids.item_frame) .set(state.ids.item_render, ui); + let title_w = (text_w - H_PAD * 3.0 - ICON_SIZE[0]).max(0.0); + + // Title + widget::Text::new(&title) + .w(title_w) + .graphics_for(id) + .parent(id) + .with_style(self.style.title) + .top_left_with_margins_on(state.ids.image_frame, V_PAD, H_PAD) + .right_from(state.ids.item_frame, H_PAD) + .color(quality) + .set(state.ids.title, ui); + // Subtitle widget::Text::new(&subtitle) - .w(text_w) + .w(title_w) .graphics_for(id) .parent(id) .with_style(self.style.desc) .color(conrod_core::color::GREY) - .right_from(state.ids.item_frame, H_PAD) + .down_from(state.ids.title, V_PAD) .set(state.ids.subtitle, ui); // Stats @@ -1220,18 +1221,10 @@ impl<'a> Widget for ItemTooltip<'a> { fn default_y_dimension(&self, ui: &Ui) -> Dimension { let item = &self.item; - let (title, desc) = (item.name().to_string(), item.description().to_string()); + let desc = item.description().to_string(); let (text_w, _image_w) = self.text_image_width(260.0); - // Title - let title_h = widget::Text::new(&title) - .w(text_w) - .with_style(self.style.title) - .get_h(ui) - .unwrap_or(0.0) - + V_PAD; - // Item frame let frame_h = ICON_SIZE[1] + V_PAD; @@ -1282,7 +1275,7 @@ impl<'a> Widget for ItemTooltip<'a> { 0.0 }; - let height = title_h + frame_h + stat_h + desc_h + price_h + V_PAD + 5.0; // extra padding to fit frame top padding + let height = frame_h + stat_h + desc_h + price_h + V_PAD + 5.0; // extra padding to fit frame top padding Dimension::Absolute(height) } }