Skip to content

Commit

Permalink
updated to match iced Revision dd249a1d11c68b8fee1828d58bae158946ee2ebd
Browse files Browse the repository at this point in the history
  • Loading branch information
genusistimelord committed Dec 18, 2023
1 parent 5f56c7e commit 9ea1b24
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ itertools = { version = "0.11.0", optional = true }

[dependencies.iced_widget]
git = "https://github.com/iced-rs/iced.git"
rev = "b474a2b7a763dcde6a377cb409001a7b5285ee8d"
#rev = "b474a2b7a763dcde6a377cb409001a7b5285ee8d"
#version = "0.1.1"

#[dependencies.iced_renderer]
Expand Down Expand Up @@ -117,7 +117,7 @@ members = [

[workspace.dependencies.iced]
git = "https://github.com/iced-rs/iced.git"
rev = "b474a2b7a763dcde6a377cb409001a7b5285ee8d"
#rev = "b474a2b7a763dcde6a377cb409001a7b5285ee8d"
#version = "0.10.0"
features = ["advanced", "lazy", "tokio"]

Expand Down
7 changes: 5 additions & 2 deletions examples/multiple_modals/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ use iced_aw::{card, modal, CardStyles};
fn main() -> iced::Result {
MultipleModalsExample::run(Settings {
window: window::Settings {
size: (500, 150),
size: iced::Size {
width: 500.0,
height: 150.0,
},
position: window::Position::Centered,
..Default::default()
},
Expand Down Expand Up @@ -114,7 +117,7 @@ impl Application for MultipleModalsExample {
self.state = State::Button1;
Command::none()
}
Message::ButtonQuitPressed => window::close(),
Message::ButtonQuitPressed => window::close(window::Id::MAIN),
Message::CloseOverlay => {
match (&self.state, &self.button_pressed) {
(State::Button1, Some(ButtonPressed::Correct)) => self.state = State::Button2,
Expand Down
5 changes: 4 additions & 1 deletion examples/number_input/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ fn main() -> iced::Result {
NumberInputDemo::run(Settings {
default_text_size: iced::Pixels(12.0),
window: window::Settings {
size: (250, 200),
size: iced::Size {
width: 250.0,
height: 200.0,
},
..Default::default()
},
..Settings::default()
Expand Down
1 change: 1 addition & 0 deletions src/native/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ fn draw_head<Message, Renderer>(
},
Point::new(close_bounds.center_x(), close_bounds.center_y()),
style_sheet.close_color,
close_bounds,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/native/cupertino/cupertino_spinner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl<Message, Theme> Widget<Message, Renderer<Theme>> for CupertinoSpinner {
) -> event::Status {
let state: &mut SpinnerState = state.state.downcast_mut::<SpinnerState>();

if let Event::Window(window::Event::RedrawRequested(_now)) = &event {
if let Event::Window(_id, window::Event::RedrawRequested(_now)) = &event {
// if is_visible(&bounds) {
state.now = time::OffsetDateTime::now_local()
.unwrap_or_else(|_| time::OffsetDateTime::now_utc());
Expand Down
2 changes: 1 addition & 1 deletion src/native/cupertino/cupertino_switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ where
let state: &mut SwitchState = state.state.downcast_mut::<SwitchState>();

match event {
Event::Window(window::Event::RedrawRequested(_now)) => {
Event::Window(_id, window::Event::RedrawRequested(_now)) => {
if state.toggle_staged {
state.animation_frame += 1;

Expand Down
5 changes: 4 additions & 1 deletion src/native/number_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ where
_style: &renderer::Style,
layout: Layout<'_>,
cursor: Cursor,
_viewport: &Rectangle,
viewport: &Rectangle,
) {
let mut children = layout.children();
let content_layout = children.next().expect("fail to get content layout");
Expand All @@ -686,6 +686,7 @@ where
content_layout,
cursor,
None,
viewport,
);
let is_decrease_disabled = self.value <= self.bounds.0 || self.bounds.0 == self.bounds.1;
let is_increase_disabled = self.value >= self.bounds.1 || self.bounds.0 == self.bounds.1;
Expand Down Expand Up @@ -738,6 +739,7 @@ where
},
Point::new(dec_bounds.center_x(), dec_bounds.center_y()),
decrease_btn_style.icon_color,
dec_bounds,
);

// increase button section
Expand Down Expand Up @@ -766,6 +768,7 @@ where
},
Point::new(inc_bounds.center_x(), inc_bounds.center_y()),
increase_btn_style.icon_color,
inc_bounds,
);
}
}
Expand Down
11 changes: 10 additions & 1 deletion src/native/overlay/color_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,13 @@ where
Message: 'static + Clone,
Theme: 'a + StyleSheet + button::StyleSheet + widget::text::StyleSheet,
{
fn layout(&mut self, renderer: &Renderer<Theme>, bounds: Size, position: Point) -> Node {
fn layout(
&mut self,
renderer: &Renderer<Theme>,
bounds: Size,
position: Point,
_translation: Vector,
) -> Node {
let (max_width, max_height) = if bounds.width > bounds.height {
(600.0, 300.0)
} else {
Expand Down Expand Up @@ -1417,6 +1423,7 @@ fn rgba_color<Theme>(
label_layout.bounds().center_y(),
),
style.text_color,
label_layout.bounds(),
);

let bounds = bar_layout.bounds();
Expand Down Expand Up @@ -1488,6 +1495,7 @@ fn rgba_color<Theme>(
value_layout.bounds().center_y(),
),
style.text_color,
value_layout.bounds(),
);

if focus == target {
Expand Down Expand Up @@ -1625,6 +1633,7 @@ fn hex_text<Theme>(
}
.into()
},
layout.bounds(),
);
}

Expand Down
12 changes: 9 additions & 3 deletions src/native/overlay/context_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use iced_widget::core::{
mouse::{self, Cursor},
overlay, renderer, touch,
widget::tree::Tree,
window, Clipboard, Color, Element, Event, Layout, Point, Rectangle, Shell, Size,
window, Clipboard, Color, Element, Event, Layout, Point, Rectangle, Shell, Size, Vector,
};

/// The overlay of the [`ContextMenu`](crate::native::ContextMenu).
Expand Down Expand Up @@ -70,7 +70,13 @@ where
Renderer: 'a + core::Renderer,
Renderer::Theme: StyleSheet,
{
fn layout(&mut self, renderer: &Renderer, bounds: Size, position: Point) -> Node {
fn layout(
&mut self,
renderer: &Renderer,
bounds: Size,
position: Point,
_translation: Vector,
) -> Node {
let limits = Limits::new(Size::ZERO, bounds);
let max_size = limits.max();

Expand Down Expand Up @@ -177,7 +183,7 @@ where
Status::Captured
}

Event::Window(window::Event::Resized { .. }) => {
Event::Window(_id, window::Event::Resized { .. }) => {
self.state.show = false;
forward_event_to_children = false;
Status::Captured
Expand Down
15 changes: 13 additions & 2 deletions src/native/overlay/date_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use iced_widget::{
touch,
widget::tree::Tree,
Alignment, Clipboard, Color, Element, Event, Layout, Length, Overlay, Padding, Point,
Rectangle, Renderer as _, Shell, Size, Widget,
Rectangle, Renderer as _, Shell, Size, Vector, Widget,
},
renderer::Renderer,
text, Button, Column, Container, Row, Text,
Expand Down Expand Up @@ -368,7 +368,13 @@ where
Theme: 'a + StyleSheet + button::StyleSheet + text::StyleSheet + container::StyleSheet,
{
#[allow(clippy::too_many_lines)]
fn layout(&mut self, renderer: &Renderer<Theme>, bounds: Size, position: Point) -> Node {
fn layout(
&mut self,
renderer: &Renderer<Theme>,
bounds: Size,
position: Point,
_translation: Vector,
) -> Node {
let limits = Limits::new(Size::ZERO, bounds)
.pad(Padding::from(PADDING))
.width(Length::Fill)
Expand Down Expand Up @@ -1133,6 +1139,7 @@ fn month_year<Theme>(
.get(&style_state)
.expect("Style Sheet not found.")
.text_color,
left_bounds,
);

// Text
Expand All @@ -1152,6 +1159,7 @@ fn month_year<Theme>(
.get(&style_state)
.expect("Style Sheet not found.")
.text_color,
center_bounds,
);

// Right caret
Expand All @@ -1173,6 +1181,7 @@ fn month_year<Theme>(
.get(&style_state)
.expect("Style Sheet not found.")
.text_color,
right_bounds,
);
};

Expand Down Expand Up @@ -1233,6 +1242,7 @@ fn day_labels<Theme>(
.get(&StyleState::Active)
.expect("Style Sheet not found.")
.text_color,
bounds,
);
}
}
Expand Down Expand Up @@ -1324,6 +1334,7 @@ fn day_table<Theme>(
.expect("Style Sheet not found.")
.text_attenuated_color
},
bounds,
);
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/native/overlay/floating_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use iced_widget::core::{
mouse::{self, Cursor},
overlay, renderer,
widget::Tree,
Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Size,
Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Size, Vector,
};

/// The internal overlay of a [`FloatingElement`](crate::FloatingElement) for
Expand Down Expand Up @@ -56,7 +56,13 @@ impl<'a, 'b, Message, Renderer> core::Overlay<Message, Renderer>
where
Renderer: core::Renderer,
{
fn layout(&mut self, renderer: &Renderer, _bounds: Size, position: Point) -> layout::Node {
fn layout(
&mut self,
renderer: &Renderer,
_bounds: Size,
position: Point,
_translation: Vector,
) -> layout::Node {
// Constrain overlay to fit inside the underlay's bounds
let limits = layout::Limits::new(Size::ZERO, self.underlay_bounds.size())
.width(Length::Fill)
Expand Down
9 changes: 8 additions & 1 deletion src/native/overlay/modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use iced_widget::core::{
renderer, touch,
widget::Tree,
Alignment, Clipboard, Color, Element, Event, Layout, Overlay, Point, Rectangle, Shell, Size,
Vector,
};

use crate::style::modal::StyleSheet;
Expand Down Expand Up @@ -68,7 +69,13 @@ where
Renderer: core::Renderer,
Renderer::Theme: StyleSheet,
{
fn layout(&mut self, renderer: &Renderer, bounds: Size, _position: Point) -> layout::Node {
fn layout(
&mut self,
renderer: &Renderer,
bounds: Size,
_position: Point,
_translation: Vector,
) -> layout::Node {
let limits = layout::Limits::new(Size::ZERO, bounds);
let mut content = self
.content
Expand Down
14 changes: 13 additions & 1 deletion src/native/overlay/time_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,13 @@ where
Message: 'static + Clone,
Theme: 'a + StyleSheet + button::StyleSheet + text::StyleSheet + container::StyleSheet,
{
fn layout(&mut self, renderer: &Renderer<Theme>, bounds: Size, position: Point) -> Node {
fn layout(
&mut self,
renderer: &Renderer<Theme>,
bounds: Size,
position: Point,
_translation: Vector,
) -> Node {
let limits = Limits::new(Size::ZERO, bounds)
.pad(Padding::from(PADDING))
.width(Length::Fill)
Expand Down Expand Up @@ -1454,6 +1460,7 @@ fn draw_digital_clock<Message, Theme>(
.get(&StyleState::Active)
.expect("Style Sheet not found.")
.text_color,
up_bounds,
);

// Text
Expand All @@ -1473,6 +1480,7 @@ fn draw_digital_clock<Message, Theme>(
.get(&StyleState::Active)
.expect("Style Sheet not found.")
.text_color,
center_bounds,
);

// Down caret
Expand All @@ -1494,6 +1502,7 @@ fn draw_digital_clock<Message, Theme>(
.get(&StyleState::Active)
.expect("Style Sheet not found.")
.text_color,
down_bounds,
);
};

Expand Down Expand Up @@ -1544,6 +1553,7 @@ fn draw_digital_clock<Message, Theme>(
hour_minute_separator.bounds().center_y(),
),
style[&StyleState::Active].text_color,
hour_minute_separator.bounds(),
);

// Draw minutes
Expand Down Expand Up @@ -1581,6 +1591,7 @@ fn draw_digital_clock<Message, Theme>(
minute_second_separator.bounds().center_y(),
),
style[&StyleState::Active].text_color,
minute_second_separator.bounds(),
);

// Draw seconds
Expand Down Expand Up @@ -1617,6 +1628,7 @@ fn draw_digital_clock<Message, Theme>(
},
Point::new(period.bounds().center_x(), period.bounds().center_y()),
style[&StyleState::Active].text_color,
period.bounds(),
);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/native/selection_list/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ where
},
Point::new(bounds.x, bounds.center_y()),
text_color,
bounds,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/native/spinner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ where

let bounds = layout.bounds();

if let Event::Window(window::Event::RedrawRequested(now)) = event {
if let Event::Window(_id, window::Event::RedrawRequested(now)) = event {
if is_visible(&bounds) {
let state = state.state.downcast_mut::<SpinnerState>();
let duration = (now - state.last_update).as_secs_f32();
Expand Down
Loading

0 comments on commit 9ea1b24

Please sign in to comment.