Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to latest Iced rev dd249a1d11c68b8fee1828d58bae158946ee2ebd #198

Merged
merged 23 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,42 @@
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'slidebar'",
"cargo": {
"args": [
"build",
"--bin=slidebar",
"--package=slidebar"
],
"filter": {
"name": "slidebar",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'segmented_button'",
"cargo": {
"args": [
"build",
"--bin=segmented_button",
"--package=segmented_button"
],
"filter": {
"name": "segmented_button",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
Expand Down
34 changes: 20 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@ categories = ["gui"]
[features]
badge = []
card = []
date_picker = ["chrono", "once_cell", "icon_text"]
color_picker = ["icon_text", "iced_widget/canvas"]
date_picker = ["chrono", "once_cell", "icons"]
color_picker = ["icons", "iced_widget/canvas"]
cupertino = ["iced_widget/canvas", "time"]
floating_element = []
grid = ["itertools"]
glow = [] # TODO
icon_text = ["icons"]
icons = []
modal = []
tab_bar = []
tabs = ["tab_bar"]
time_picker = ["chrono", "icon_text", "iced_widget/canvas"]
time_picker = ["chrono", "icons", "iced_widget/canvas"]
wrap = []
number_input = ["num-traits"]
selection_list = []
Expand All @@ -46,7 +45,6 @@ default = [
"date_picker",
"color_picker",
"floating_element",
"icon_text",
"grid",
"modal",
"tab_bar",
Expand All @@ -55,12 +53,13 @@ default = [
"wrap",
"selection_list",
"split",
"menu",
#"menu",
"quad",
"context_menu",
"spinner",
"cupertino",
"segmented_button",
"num-traits"
]

[dependencies]
Expand All @@ -73,9 +72,15 @@ itertools = { version = "0.11.0", optional = true }


[dependencies.iced_widget]
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 = "8221794"
version = "0.1.1"
#rev = "751ea77c29f6eb3d00f45f0a04c833a1d03a425c"
#features = ["wgpu"]
#version = "0.1.1"

[profile.dev.package."*"]
opt-level = 2
Expand All @@ -85,7 +90,6 @@ members = [
"examples/badge",
"examples/card",
"examples/color_picker",
"examples/cupertino/cupertino_alert",
"examples/cupertino/cupertino_button",
"examples/cupertino/cupertino_spinner",
"examples/cupertino/cupertino_switch",
Expand All @@ -104,19 +108,21 @@ members = [
"examples/selection_list",
"examples/split",
"examples/split_scroller",
"examples/menu",
#"examples/menu",
"examples/spinner",
"examples/context_menu",
"examples/WidgetIDReturn",
#"examples/WidgetIDReturn",
"examples/segmented_button",
"examples/sliderbar",
]

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

[workspace.dependencies.iced_aw]
path = "./"
default-features = false
features = ["num-traits"]
10 changes: 8 additions & 2 deletions examples/cupertino/cupertino_switch/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,16 @@ impl Application for Switch {
fn view(&self) -> Element<Message> {
let toggle_1: CupertinoSwitch<Message> = CupertinoSwitch::new().on_changed(Some(Box::new(
Message::LeftSwitchChanged
)));
))).value(match self {
Switch::LeftSwitchChanged(v) => *v,
_ => true,
});

let toggle_2: CupertinoSwitch<Message> = CupertinoSwitch::new()
.value(false)
.value(match self {
Switch::LeftSwitchChanged(v) => *v,
_ => false,
})
.on_changed(Some(Box::new(Message::RightSwitchChanged)));

let left_text: String = match self {
Expand Down
2 changes: 1 addition & 1 deletion examples/menu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ publish = false
iced_aw = { workspace = true, features = [
"menu",
"quad",
"icon_text"
"icons"
] }
iced = {workspace = true, features = ["svg"]}
2 changes: 1 addition & 1 deletion examples/modal/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl Application for ModalExample {
modal(underlay, overlay)
.backdrop(Message::CloseModal)
.on_esc(Message::CloseModal)
.align_y(alignment::Vertical::Top)
.align_y(alignment::Vertical::Center)
.into()
}
}
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
7 changes: 5 additions & 2 deletions examples/number_input/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ pub enum Message {

fn main() -> iced::Result {
NumberInputDemo::run(Settings {
default_text_size: 12.0,
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
6 changes: 3 additions & 3 deletions examples/selection_list/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ impl Sandbox for Example {
self.manual_select = None;
}
Message::ManualSelection => {
if let Some(option) = self.vec.get(0) {
if let Some(option) = self.vec.get(2) {
self.selected_language = option.to_owned();
self.selected_index = 0;
self.manual_select = Some(0);
self.selected_index = 2;
self.manual_select = Some(2);
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions examples/sliderbar/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "slidebar"
version = "0.1.0"
authors = ["Andrew Wheeler <[email protected]>"]
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
iced_aw.workspace = true
iced.workspace = true
57 changes: 57 additions & 0 deletions examples/sliderbar/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
use iced::{
widget::{Column, Container, Text},
Element, Length, Sandbox, Settings,
};

use iced_aw::SlideBar;

fn main() -> iced::Result {
SlideBarExample::run(Settings::default())
}

#[derive(Debug, Clone)]
enum Message {
SliderBarChange(u32),
}

struct SlideBarExample {
value: u32,
}

impl Sandbox for SlideBarExample {
type Message = Message;

fn new() -> Self {
SlideBarExample { value: 1 }
}

fn title(&self) -> String {
String::from("Slider Bar example")
}

fn update(&mut self, message: Message) {
let Message::SliderBarChange(v) = message;
self.value = v;
}

fn view(&self) -> Element<Message> {
let bar = SlideBar::new(0..=100, self.value, Message::SliderBarChange).width(100.0);

let content_all = Column::new()
.spacing(10)
.push(

Check failure on line 42 in examples/sliderbar/src/main.rs

View workflow job for this annotation

GitHub Actions / all

Diff in /home/runner/work/iced_aw/iced_aw/examples/sliderbar/src/main.rs

Check failure on line 42 in examples/sliderbar/src/main.rs

View workflow job for this annotation

GitHub Actions / all

Diff in /home/runner/work/iced_aw/iced_aw/examples/sliderbar/src/main.rs
Text::new(format!("Value is {}", self.value))
.width(Length::Fill)
.vertical_alignment(iced::alignment::Vertical::Center).horizontal_alignment(iced::alignment::Horizontal::Center),
)
.push(bar)
.align_items(iced::Alignment::Center);

Container::new(content_all)
.width(Length::Fill)
.height(Length::Fill)
.center_x()
.center_y()
.into()
}
}
9 changes: 6 additions & 3 deletions examples/tab_bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ use iced::{
use iced_aw::{TabBar, TabLabel};

fn main() -> iced::Result {
TabBarExample::run(Settings::default())
TabBarExample::run(Settings {
default_text_size: 12.into(),
..Default::default()
})
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -131,13 +134,13 @@ impl Application for TabBarExample {
.push(
TextInput::new("Tab label", &state.new_tab_label)
.on_input(Message::TabLabelInputChanged)
.size(22)
.size(16)
.padding(5.0),
)
.push(
TextInput::new("Tab content", &state.new_tab_content)
.on_input(Message::TabContentInputChanged)
.size(22)
.size(12)
.padding(5.0),
)
.push(Button::new(Text::new("New")).on_press(Message::NewTab))
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ mod platform {
#[cfg(feature = "spinner")]
pub use {crate::native::spinner, crate::style::SpinnerStyle, spinner::Spinner};

pub use crate::native::SlideBar;

#[doc(no_inline)]
#[cfg(feature = "context_menu")]
pub use {
Expand Down
7 changes: 5 additions & 2 deletions src/native/badge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,18 @@ where
self.height
}

fn layout(&self, renderer: &Renderer, limits: &Limits) -> Node {
fn layout(&self, tree: &mut Tree, renderer: &Renderer, limits: &Limits) -> Node {
let padding = self.padding.into();
let limits = limits
.loose()
.width(self.width)
.height(self.height)
.pad(padding);

let mut content = self.content.as_widget().layout(renderer, &limits.loose());
let mut content =
self.content
.as_widget()
.layout(&mut tree.children[0], renderer, &limits.loose());
let size = limits.resolve(content.size());

content.move_to(Point::new(padding.left, padding.top));
Expand Down
Loading
Loading