forked from 1b-agent/opencadstudio-upstream
fix(ui): make modal layouts intrinsic
Pin Iced 0.15 so dialogs can measure content before distributing the resolved frame across child panels. Keep the web plugin notice compact and non-resizable.\n\nCloses #582
This commit is contained in:
1 parent
284d6ef517
commit
3ab8dc3ca5
59 files changed
+2197
-1652
No files matched your search
+12
-27
@@ -13,7 +13,7 @@ use std::sync::Arc;
|
||||
|
||||
use iced::advanced::layout::{self, Layout};
|
||||
use iced::advanced::widget::{self, Widget};
|
||||
use iced::advanced::{mouse, overlay, renderer, Clipboard, Renderer as _, Shell};
|
||||
use iced::advanced::{mouse, overlay, renderer, Renderer as _, Shell};
|
||||
use iced::{
|
||||
Background, Border, Element, Event, Length, Point, Rectangle, Renderer, Shadow, Size,
|
||||
Theme, Vector,
|
||||
@@ -184,28 +184,16 @@ impl<'a> CollapsePanels<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Widget<Message, Theme, Renderer> for CollapsePanels<'a> {
|
||||
fn children(&self) -> Vec<widget::Tree> {
|
||||
let mut v = Vec::with_capacity(self.panels.len() * SLOTS);
|
||||
for p in &self.panels {
|
||||
v.push(widget::Tree::new(&p.full));
|
||||
v.push(widget::Tree::new(&p.compact));
|
||||
v.push(widget::Tree::new(&p.button));
|
||||
v.push(widget::Tree::new(&p.tight));
|
||||
v.push(widget::Tree::new(&p.flyout));
|
||||
fn diff(&mut self, tree: &mut widget::Tree) {
|
||||
let mut refs = Vec::with_capacity(self.panels.len() * SLOTS);
|
||||
for p in &mut self.panels {
|
||||
refs.push(&mut p.full);
|
||||
refs.push(&mut p.compact);
|
||||
refs.push(&mut p.button);
|
||||
refs.push(&mut p.tight);
|
||||
refs.push(&mut p.flyout);
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
fn diff(&self, tree: &mut widget::Tree) {
|
||||
let mut refs: Vec<&dyn Widget<Message, Theme, Renderer>> = Vec::new();
|
||||
for p in &self.panels {
|
||||
refs.push(p.full.as_widget());
|
||||
refs.push(p.compact.as_widget());
|
||||
refs.push(p.button.as_widget());
|
||||
refs.push(p.tight.as_widget());
|
||||
refs.push(p.flyout.as_widget());
|
||||
}
|
||||
tree.diff_children(&refs);
|
||||
tree.diff_children(&mut refs);
|
||||
}
|
||||
|
||||
fn size(&self) -> Size<Length> {
|
||||
@@ -362,7 +350,6 @@ impl<'a> Widget<Message, Theme, Renderer> for CollapsePanels<'a> {
|
||||
layout: Layout<'_>,
|
||||
cursor: mouse::Cursor,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
shell: &mut Shell<'_, Message>,
|
||||
viewport: &Rectangle,
|
||||
) {
|
||||
@@ -376,7 +363,6 @@ impl<'a> Widget<Message, Theme, Renderer> for CollapsePanels<'a> {
|
||||
child_layout,
|
||||
cursor,
|
||||
renderer,
|
||||
clipboard,
|
||||
shell,
|
||||
viewport,
|
||||
);
|
||||
@@ -477,7 +463,7 @@ impl<'a> Widget<Message, Theme, Renderer> for CollapsePanels<'a> {
|
||||
shadow: Shadow::default(),
|
||||
snap: true,
|
||||
},
|
||||
Background::Color(theme.extended_palette().background.neutral.color),
|
||||
Background::Color(theme.palette().background.neutral.color),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -611,7 +597,6 @@ impl overlay::Overlay<Message, Theme, Renderer> for FlyoutOverlay<'_, '_> {
|
||||
layout: Layout<'_>,
|
||||
cursor: mouse::Cursor,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
shell: &mut Shell<'_, Message>,
|
||||
) {
|
||||
let child = layout.children().next().unwrap();
|
||||
@@ -627,7 +612,7 @@ impl overlay::Overlay<Message, Theme, Renderer> for FlyoutOverlay<'_, '_> {
|
||||
|
||||
self.flyout
|
||||
.as_widget_mut()
|
||||
.update(self.tree, event, child, cursor, renderer, clipboard, shell, &vp);
|
||||
.update(self.tree, event, child, cursor, renderer, shell, &vp);
|
||||
}
|
||||
|
||||
fn operate(
|
||||
|
||||
+15
-15
@@ -423,7 +423,7 @@ impl Ribbon {
|
||||
button(text(module.title()).size(12))
|
||||
.on_press(Message::RibbonSelectTab(i))
|
||||
.style(move |theme: &Theme, status| {
|
||||
let palette = theme.extended_palette();
|
||||
let palette = theme.palette();
|
||||
let accent = if is_contextual {
|
||||
palette.warning.base
|
||||
} else {
|
||||
@@ -470,9 +470,9 @@ impl Ribbon {
|
||||
border: Border {
|
||||
color: if is_active {
|
||||
if is_contextual {
|
||||
theme.extended_palette().warning.base.color
|
||||
theme.palette().warning.base.color
|
||||
} else {
|
||||
theme.extended_palette().primary.base.color
|
||||
theme.palette().primary.base.color
|
||||
}
|
||||
} else {
|
||||
Color::TRANSPARENT
|
||||
@@ -526,7 +526,7 @@ impl Ribbon {
|
||||
let tab_bar = container(tab_row)
|
||||
.style(|theme: &Theme| container::Style {
|
||||
background: Some(Background::Color(
|
||||
theme.extended_palette().background.base.color,
|
||||
theme.palette().background.base.color,
|
||||
)),
|
||||
..Default::default()
|
||||
})
|
||||
@@ -647,10 +647,10 @@ impl Ribbon {
|
||||
))
|
||||
.style(|theme: &Theme| container::Style {
|
||||
background: Some(Background::Color(
|
||||
theme.extended_palette().background.weakest.color,
|
||||
theme.palette().background.weakest.color,
|
||||
)),
|
||||
border: Border {
|
||||
color: theme.extended_palette().background.neutral.color,
|
||||
color: theme.palette().background.neutral.color,
|
||||
width: 1.0,
|
||||
radius: 0.0.into(),
|
||||
},
|
||||
@@ -672,10 +672,10 @@ impl Ribbon {
|
||||
let tool_bar = container(tool_area)
|
||||
.style(|theme: &Theme| container::Style {
|
||||
background: Some(Background::Color(
|
||||
theme.extended_palette().background.weakest.color,
|
||||
theme.palette().background.weakest.color,
|
||||
)),
|
||||
border: Border {
|
||||
color: theme.extended_palette().background.neutral.color,
|
||||
color: theme.palette().background.neutral.color,
|
||||
width: 1.0,
|
||||
radius: 0.0.into(),
|
||||
},
|
||||
@@ -827,7 +827,7 @@ impl Ribbon {
|
||||
.style(move |theme: &Theme| iced::widget::text::Style {
|
||||
color: (!is_current).then_some(
|
||||
theme
|
||||
.extended_palette()
|
||||
.palette()
|
||||
.background
|
||||
.base
|
||||
.text
|
||||
@@ -895,7 +895,7 @@ impl Ribbon {
|
||||
.style(move |theme: &Theme| container::Style {
|
||||
background: Some(Background::Color(lc)),
|
||||
border: Border {
|
||||
color: theme.extended_palette().background.strong.color,
|
||||
color: theme.palette().background.strong.color,
|
||||
width: 1.0,
|
||||
radius: 1.0.into(),
|
||||
},
|
||||
@@ -924,7 +924,7 @@ impl Ribbon {
|
||||
.style(move |theme: &Theme| iced::widget::text::Style {
|
||||
color: (!is_active).then_some(
|
||||
theme
|
||||
.extended_palette()
|
||||
.palette()
|
||||
.background
|
||||
.base
|
||||
.text
|
||||
@@ -981,7 +981,7 @@ impl Ribbon {
|
||||
.padding([3, 4])
|
||||
.style(|theme: &Theme| container::Style {
|
||||
border: Border {
|
||||
color: theme.extended_palette().background.neutral.color,
|
||||
color: theme.palette().background.neutral.color,
|
||||
width: 1.0,
|
||||
radius: 0.0.into(),
|
||||
},
|
||||
@@ -1055,7 +1055,7 @@ impl Ribbon {
|
||||
.style(move |theme: &Theme| iced::widget::text::Style {
|
||||
color: (!is_sel).then_some(
|
||||
theme
|
||||
.extended_palette()
|
||||
.palette()
|
||||
.background
|
||||
.base
|
||||
.text
|
||||
@@ -1154,7 +1154,7 @@ impl Ribbon {
|
||||
.style(move |theme: &Theme| iced::widget::text::Style {
|
||||
color: (!is_cur).then_some(
|
||||
theme
|
||||
.extended_palette()
|
||||
.palette()
|
||||
.background
|
||||
.base
|
||||
.text
|
||||
@@ -1207,7 +1207,7 @@ impl Ribbon {
|
||||
.style(move |theme: &Theme| iced::widget::text::Style {
|
||||
color: (!is_cur).then_some(
|
||||
theme
|
||||
.extended_palette()
|
||||
.palette()
|
||||
.background
|
||||
.base
|
||||
.text
|
||||
|
||||
+11
-11
@@ -146,7 +146,7 @@ pub(super) fn make_icon_dim(icon: IconKind, size: f32, dim: bool) -> Element<'st
|
||||
IconKind::Glyph(s) => text(s)
|
||||
.size(size * 0.7)
|
||||
.style(|theme: &Theme| iced::widget::text::Style {
|
||||
color: Some(theme.extended_palette().background.base.text.scale_alpha(0.42)),
|
||||
color: Some(theme.palette().background.base.text.scale_alpha(0.42)),
|
||||
})
|
||||
.into(),
|
||||
IconKind::Svg(bytes) => icons::semantic_disabled(bytes, size),
|
||||
@@ -179,7 +179,7 @@ pub(super) fn tool_btn_style(
|
||||
is_active: bool,
|
||||
status: button::Status,
|
||||
) -> button::Style {
|
||||
let palette = theme.extended_palette();
|
||||
let palette = theme.palette();
|
||||
let pair = match (is_active, status) {
|
||||
(true, _) => palette.primary.weak,
|
||||
(_, button::Status::Hovered) => palette.background.weak,
|
||||
@@ -208,7 +208,7 @@ pub(super) fn combo_btn_style(
|
||||
status: button::Status,
|
||||
radius: f32,
|
||||
) -> button::Style {
|
||||
let palette = theme.extended_palette();
|
||||
let palette = theme.palette();
|
||||
let pair = if is_open {
|
||||
palette.primary.weak
|
||||
} else if matches!(status, button::Status::Hovered | button::Status::Pressed) {
|
||||
@@ -233,7 +233,7 @@ pub(super) fn combo_btn_style(
|
||||
}
|
||||
|
||||
pub(super) fn popup_row_style(theme: &Theme, status: button::Status) -> button::Style {
|
||||
let palette = theme.extended_palette();
|
||||
let palette = theme.palette();
|
||||
let pair = if matches!(status, button::Status::Hovered | button::Status::Pressed) {
|
||||
palette.background.weak
|
||||
} else {
|
||||
@@ -247,7 +247,7 @@ pub(super) fn popup_row_style(theme: &Theme, status: button::Status) -> button::
|
||||
}
|
||||
|
||||
pub(super) fn popup_panel_style(theme: &Theme) -> container::Style {
|
||||
let palette = theme.extended_palette();
|
||||
let palette = theme.palette();
|
||||
container::Style {
|
||||
background: Some(Background::Color(palette.background.base.color)),
|
||||
border: Border {
|
||||
@@ -261,14 +261,14 @@ pub(super) fn popup_panel_style(theme: &Theme) -> container::Style {
|
||||
|
||||
pub(super) fn muted_text_style(theme: &Theme) -> iced::widget::text::Style {
|
||||
iced::widget::text::Style {
|
||||
color: Some(theme.extended_palette().background.base.text.scale_alpha(0.72)),
|
||||
color: Some(theme.palette().background.base.text.scale_alpha(0.72)),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn tool_label_style(theme: &Theme, dim: bool) -> iced::widget::text::Style {
|
||||
iced::widget::text::Style {
|
||||
color: dim.then_some(
|
||||
theme.extended_palette().background.base.text.scale_alpha(0.42),
|
||||
theme.palette().background.base.text.scale_alpha(0.42),
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -280,7 +280,7 @@ pub(super) fn make_tip(tip: String) -> Element<'static, Message> {
|
||||
}
|
||||
|
||||
pub(super) fn tip_style(theme: &Theme) -> container::Style {
|
||||
let palette = theme.extended_palette();
|
||||
let palette = theme.palette();
|
||||
container::Style {
|
||||
background: Some(Background::Color(palette.background.strong.color)),
|
||||
border: Border {
|
||||
@@ -632,7 +632,7 @@ pub(super) fn render_large<'a>(
|
||||
.style(move |theme: &Theme| container::Style {
|
||||
background: Some(Background::Color(lc)),
|
||||
border: Border {
|
||||
color: theme.extended_palette().background.strong.color,
|
||||
color: theme.palette().background.strong.color,
|
||||
width: 1.0,
|
||||
radius: 1.0.into(),
|
||||
},
|
||||
@@ -778,7 +778,7 @@ pub(super) fn render_large<'a>(
|
||||
.style(move |theme: &Theme| container::Style {
|
||||
background: Some(Background::Color(c)),
|
||||
border: Border {
|
||||
color: theme.extended_palette().background.strong.color,
|
||||
color: theme.palette().background.strong.color,
|
||||
width: 1.0,
|
||||
radius: 1.0.into(),
|
||||
},
|
||||
@@ -1088,7 +1088,7 @@ pub(super) fn top_hist_btn_style(
|
||||
open: bool,
|
||||
status: button::Status,
|
||||
) -> button::Style {
|
||||
let palette = theme.extended_palette();
|
||||
let palette = theme.palette();
|
||||
let pair = match (active, open, status) {
|
||||
(false, _, _) => palette.background.weakest,
|
||||
(_, true, _) => palette.primary.weak,
|
||||
|
||||
Reference in new issue
Block a user