Skip to content

Commit

Permalink
update everything else but Menu. Though Grid is still not rendering 2…
Browse files Browse the repository at this point in the history
… of the widgets correcty?
  • Loading branch information
genusistimelord committed Jan 22, 2024
1 parent ebbc3ed commit 7421aa3
Show file tree
Hide file tree
Showing 27 changed files with 574 additions and 455 deletions.
64 changes: 27 additions & 37 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,19 @@ default = [
"floating_element",
"grid",
"modal",
#"tab_bar",
#"tabs",
#"time_picker",
#"slide_bar",
#"wrap",
#"selection_list",
#"split",
"tab_bar",
"tabs",
"time_picker",
"slide_bar",
"wrap",
"selection_list",
"split",
"quad",
"context_menu",
"spinner",
"cupertino",
"segmented_button",
#"menu",
#"quad",
#"context_menu",
#"spinner",
#"cupertino",
#"segmented_button",
#"num-traits"
]

[dependencies]
Expand All @@ -78,12 +77,6 @@ git = "https://github.com/iced-rs/iced.git"
#rev = "b474a2b7a763dcde6a377cb409001a7b5285ee8d"
#version = "0.1.1"

#[dependencies.iced_renderer]
#git = "https://github.com/iced-rs/iced.git"
#rev = "751ea77c29f6eb3d00f45f0a04c833a1d03a425c"
#features = ["wgpu"]
#version = "0.1.1"

[profile.dev.package."*"]
opt-level = 2

Expand All @@ -100,25 +93,22 @@ members = [
"examples/modal",
"examples/modal_component",
"examples/multiple_modals",
#"examples/cupertino/cupertino_button",
#"examples/cupertino/cupertino_spinner",
#"examples/cupertino/cupertino_switch",



#"examples/tab_bar",
#"examples/tabs",
#"examples/time_picker",
#"examples/wrap",
#"examples/selection_list",
#"examples/split",
#"examples/split_scroller",
"examples/tab_bar",
"examples/tabs",
"examples/time_picker",
"examples/sliderbar",
"examples/wrap",
"examples/selection_list",
"examples/split",
"examples/split_scroller",
"examples/context_menu",
"examples/spinner",
"examples/cupertino/cupertino_button",
"examples/cupertino/cupertino_spinner",
"examples/cupertino/cupertino_switch",
"examples/WidgetIDReturn",
"examples/segmented_button",
#"examples/menu",
#"examples/spinner",
#"examples/context_menu",
#"examples/WidgetIDReturn",
#"examples/segmented_button",
#"examples/sliderbar",
]

[workspace.dependencies.iced]
Expand Down
10 changes: 5 additions & 5 deletions examples/cupertino/cupertino_button/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use iced::{
alignment, executor, font,
widget::{column, container, text, Text},
Application, Command, Element, Length, Renderer, Settings, Theme,
Application, Command, Element, Length, Settings, Theme,
};

use iced_aw::native::cupertino::cupertino_button::CupertinoButton;
Expand Down Expand Up @@ -69,7 +69,7 @@ impl Application for ButtonApp {
}

fn view(&self) -> Element<Message> {
let disabled: CupertinoButton<Message, Renderer> = CupertinoButton::new()
let disabled = CupertinoButton::new()
.on_pressed(None)
.body(Text::new("Disabled")
.size(24)
Expand All @@ -78,7 +78,7 @@ impl Application for ButtonApp {
.height(Length::Fixed(50.0))
);

let disabled_filled: CupertinoButton<Message, Renderer> = CupertinoButton::new()
let disabled_filled = CupertinoButton::new()
.on_pressed(None)
.is_filled(true)
.body(Text::new("Disabled")
Expand All @@ -88,7 +88,7 @@ impl Application for ButtonApp {
.height(Length::Fixed(50.0))
);

let enabled: CupertinoButton<Message, Renderer> = CupertinoButton::new()
let enabled = CupertinoButton::new()
.on_pressed(Some(Message::EnabledButtonClicked))
.body(Text::new("Enabled")
.size(24)
Expand All @@ -97,7 +97,7 @@ impl Application for ButtonApp {
.height(Length::Fixed(50.0))
);

let enabled_filled: CupertinoButton<Message, Renderer> = CupertinoButton::new()
let enabled_filled = CupertinoButton::new()
.on_pressed(Some(Message::EnabledFilledButtonClicked))
.is_filled(true)
.body(Text::new("Enabled")
Expand Down
3 changes: 1 addition & 2 deletions examples/modal_component/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ impl Application for ModalExample {
},
None => "None",
}
)))
.into(),
))),
);

let overlay = if state.show_modal {
Expand Down
4 changes: 3 additions & 1 deletion examples/sliderbar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
iced_aw.workspace = true
iced_aw = { workspace = true, features = [
"slide_bar",
] }
iced.workspace = true
18 changes: 11 additions & 7 deletions examples/split_scroller/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ mod demo {
button, column, container, horizontal_space, progress_bar, radio, row, scrollable, slider,
text, vertical_space,
};
use iced::{theme, Alignment, Color};
use iced::{theme, Alignment, Border, Color};
use iced::{Command, Element, Length, Theme};
use once_cell::sync::Lazy;

Expand Down Expand Up @@ -506,14 +506,18 @@ mod demo {
fn hovered_horizontal(&self, style: &Self::Style, _is_mouse_over: bool) -> Scrollbar {
Scrollbar {
background: style.active(&theme::Scrollable::default()).background,
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Default::default(),
border: Border {
color: Default::default(),
width: 0.0,
radius: 0.0.into(),
},
scroller: Scroller {
color: Color::from_rgb8(250, 85, 134),
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Default::default(),
border: Border {
color: Default::default(),
width: 0.0,
radius: 0.0.into(),
},
},
}
}
Expand Down
52 changes: 28 additions & 24 deletions src/native/context_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,32 @@ pub use crate::style::context_menu::StyleSheet;
/// );
/// ```
#[allow(missing_debug_implementations)]
pub struct ContextMenu<'a, Overlay, Message, Renderer = crate::Renderer>
where
Overlay: Fn() -> Element<'a, Message, Renderer>,
pub struct ContextMenu<
'a,
Overlay,
Message,
Theme = iced_widget::Theme,
Renderer = iced_widget::Renderer,
> where
Overlay: Fn() -> Element<'a, Message, Theme, Renderer>,
Message: Clone,
Renderer: core::Renderer,
Renderer::Theme: StyleSheet,
Theme: StyleSheet,
{
/// The underlying element.
underlay: Element<'a, Message, Renderer>,
underlay: Element<'a, Message, Theme, Renderer>,
/// The content of [`ContextMenuOverlay`].
overlay: Overlay,
/// The style of the [`ContextMenu`].
style: <Renderer::Theme as StyleSheet>::Style,
style: <Theme as StyleSheet>::Style,
}

impl<'a, Overlay, Message, Renderer> ContextMenu<'a, Overlay, Message, Renderer>
impl<'a, Overlay, Message, Theme, Renderer> ContextMenu<'a, Overlay, Message, Theme, Renderer>
where
Overlay: Fn() -> Element<'a, Message, Renderer>,
Overlay: Fn() -> Element<'a, Message, Theme, Renderer>,
Message: Clone,
Renderer: core::Renderer,
Renderer::Theme: StyleSheet,
Theme: StyleSheet,
{
/// Creates a new [`ContextMenu`]
///
Expand All @@ -62,32 +67,31 @@ where
/// `overlay`: The content of [`ContextMenuOverlay`] which will be displayed when `underlay` is clicked.
pub fn new<U>(underlay: U, overlay: Overlay) -> Self
where
U: Into<Element<'a, Message, Renderer>>,
U: Into<Element<'a, Message, Theme, Renderer>>,
{
ContextMenu {
underlay: underlay.into(),
overlay,
style: <Renderer::Theme as StyleSheet>::Style::default(),
style: <Theme as StyleSheet>::Style::default(),
}
}

/// Sets the style of the [`ContextMenu`].
#[must_use]
pub fn style(mut self, style: <Renderer::Theme as StyleSheet>::Style) -> Self {
pub fn style(mut self, style: <Theme as StyleSheet>::Style) -> Self {
self.style = style;
self
}
}

impl<'a, Content, Message, Renderer> Widget<Message, Renderer>
for ContextMenu<'a, Content, Message, Renderer>
impl<'a, Content, Message, Theme, Renderer> Widget<Message, Theme, Renderer>
for ContextMenu<'a, Content, Message, Theme, Renderer>
where
Content: 'a + Fn() -> Element<'a, Message, Renderer>,
Content: 'a + Fn() -> Element<'a, Message, Theme, Renderer>,
Message: 'a + Clone,
Renderer: 'a + core::Renderer,
Renderer::Theme: StyleSheet,
Theme: StyleSheet,
{

fn size(&self) -> core::Size<Length> {
self.underlay.as_widget().size()
}
Expand All @@ -102,7 +106,7 @@ where
&self,
state: &Tree,
renderer: &mut Renderer,
theme: &Renderer::Theme,
theme: &Theme,
style: &renderer::Style,
layout: Layout<'_>,
cursor: Cursor,
Expand Down Expand Up @@ -214,7 +218,7 @@ where
state: &'b mut Tree,
layout: Layout<'_>,
renderer: &Renderer,
) -> Option<overlay::Element<'b, Message, Renderer>> {
) -> Option<overlay::Element<'b, Message, Theme, Renderer>> {
let s: &mut State = state.state.downcast_mut();

if !s.show {
Expand All @@ -235,15 +239,15 @@ where
}
}

impl<'a, Content, Message, Renderer> From<ContextMenu<'a, Content, Message, Renderer>>
for Element<'a, Message, Renderer>
impl<'a, Content, Message, Theme, Renderer> From<ContextMenu<'a, Content, Message, Theme, Renderer>>
for Element<'a, Message, Theme, Renderer>
where
Content: 'a + Fn() -> Element<'a, Message, Renderer>,
Content: 'a + Fn() -> Element<'a, Message, Theme, Renderer>,
Message: 'a + Clone,
Renderer: 'a + core::Renderer,
Renderer::Theme: StyleSheet,
Theme: 'a + StyleSheet,
{
fn from(modal: ContextMenu<'a, Content, Message, Renderer>) -> Self {
fn from(modal: ContextMenu<'a, Content, Message, Theme, Renderer>) -> Self {
Element::new(modal)
}
}
Expand Down
Loading

0 comments on commit 7421aa3

Please sign in to comment.