forked from 1b-agent/opencadstudio-upstream
feat(ui): shared dropdown popup width calculation with wide-character support
- Add dropdown_popup_width helper in common.rs replacing magic formula heuristics - Implement is_wide range table to count East Asian Wide/Fullwidth (CJK) glyphs double for localized strings - Calibrate unit scale factor to 0.68 * font_size preserving existing width behavior at font size 11 - Apply shared calculation across viewport controls and ribbon dropdowns - Update unit tests to verify width calculation on standard and CJK labels
This commit is contained in:
1 parent
a7e3cf3a6d
commit
b53cd580f6
3 files changed
+69
-9
No files matched your search
+14
-2
@@ -853,6 +853,7 @@ impl Ribbon {
|
||||
let label_el =
|
||||
text(t!(*label))
|
||||
.size(11)
|
||||
.wrapping(iced::advanced::text::Wrapping::None)
|
||||
.style(move |theme: &Theme| iced::widget::text::Style {
|
||||
color: (!is_current).then_some(
|
||||
theme
|
||||
@@ -880,11 +881,22 @@ impl Ribbon {
|
||||
})
|
||||
.collect();
|
||||
|
||||
let labels: Vec<String> = items
|
||||
.iter()
|
||||
.map(|(_, label, _)| t!(*label).to_string())
|
||||
.collect();
|
||||
let panel_w = crate::ui::style::common::dropdown_popup_width(
|
||||
labels.iter().map(|s| s.as_str()),
|
||||
11.0,
|
||||
68.0,
|
||||
190.0,
|
||||
);
|
||||
|
||||
let panel = container(column(rows))
|
||||
.style(popup_panel_style)
|
||||
.width(Length::Fixed(190.0));
|
||||
.width(Length::Fixed(panel_w));
|
||||
|
||||
let (align_right, h_pad, top) = self.dd_anchor(open_id, 190.0, win.0);
|
||||
let (align_right, h_pad, top) = self.dd_anchor(open_id, panel_w, win.0);
|
||||
Some(dropdown_backdrop(position_ribbon_dropdown(
|
||||
panel.into(),
|
||||
align_right,
|
||||
|
||||
Reference in new issue
Block a user