Skip to content
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
4 changes: 2 additions & 2 deletions examples/overlay_editor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ crate-type = ["cdylib"]
[dependencies]

#iced = { path = "../../../../iced", features = ["wgpu", "advanced"] }
iced = { git = "https://github.com/iced-rs/iced", branch = "master", features = ["wgpu", "advanced", "fira-sans"] }
iced = { version = "0.14.0", features = ["wgpu", "advanced", "fira-sans"] }

serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
Expand All @@ -32,4 +32,4 @@ i_triangle = { version = "^0.35.0", features = ["serde"] }
#i_triangle = { path = "../../../../iShape/iTriangle/iTriangle", default-features = true, features = ["serde"] }
#i_mesh = { path = "../../../../iShape/iMesh/iMesh" }

#ICED_BACKEND=wgpu cargo r -r
#ICED_BACKEND=wgpu cargo r -r
9 changes: 6 additions & 3 deletions examples/overlay_editor/src/app/boolean/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ pub(crate) enum BooleanMessage {
impl EditorApp {
fn boolean_sidebar(&self) -> Column<AppMessage> {
let count = self.app_resource.boolean.count;
let mut column = Column::new().push(Space::new(Length::Fill, Length::Fixed(2.0)));
let mut column = Column::new().push(
Space::new()
.width(Length::Fill)
.height(Length::Fixed(2.0)),
);
for index in 0..count {
let is_selected = self.state.boolean.test == index;

Expand All @@ -62,7 +66,7 @@ impl EditorApp {
column
}

pub(crate) fn boolean_content(&self) -> Row<AppMessage> {
pub(crate) fn boolean_content(&self) -> Row<'_, AppMessage> {
Row::new()
.push(
scrollable(
Expand Down Expand Up @@ -223,4 +227,3 @@ impl BooleanState {
self.update_solution();
}
}

16 changes: 12 additions & 4 deletions examples/overlay_editor/src/app/boolean/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use iced::{Alignment, Length};
use iced::widget::{Column, Container, pick_list, Row, Space, Text};

impl EditorApp {
pub(crate) fn boolean_control(&self) -> Column<AppMessage> {
pub(crate) fn boolean_control(&self) -> Column<'_, AppMessage> {
let solver_pick_list =
Row::new()
.push(Text::new("Solver:")
Expand Down Expand Up @@ -64,9 +64,17 @@ impl EditorApp {

Column::new()
.push(solver_pick_list)
.push(Space::new(Length::Shrink, Length::Fixed(4.0)))
.push(
Space::new()
.width(Length::Shrink)
.height(Length::Fixed(4.0)),
)
.push(fill_pick_list)
.push(Space::new(Length::Shrink, Length::Fixed(4.0)))
.push(
Space::new()
.width(Length::Shrink)
.height(Length::Fixed(4.0)),
)
.push(mode_pick_list)
}
}
Expand Down Expand Up @@ -142,4 +150,4 @@ impl std::fmt::Display for ModeOption {
}
)
}
}
}
2 changes: 1 addition & 1 deletion examples/overlay_editor/src/app/boolean/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub(crate) struct WorkspaceState {
}

impl EditorApp {
pub(crate) fn boolean_workspace(&self) -> Container<AppMessage> {
pub(crate) fn boolean_workspace(&self) -> Container<'_, AppMessage> {
Container::new({
let mut stack = Stack::new();
stack = stack.push(
Expand Down
23 changes: 11 additions & 12 deletions examples/overlay_editor/src/app/design.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl Design {
}

pub(crate) fn negative_color() -> Color {
if iced::Theme::default().extended_palette().is_dark {
if Theme::Dark.extended_palette().is_dark {
Color::from_rgb8(224, 224, 224)
} else {
Color::from_rgb8(32, 32, 32)
Expand Down Expand Up @@ -58,23 +58,22 @@ impl Design {

pub(super) fn style_sidebar_button(theme: &Theme, status: button::Status) -> button::Style {
let palette = theme.extended_palette();
let text_color = theme.palette().text;
let base = button::Style {
background: Some(Background::Color(palette.primary.strong.color)),
text_color: palette.primary.strong.text,
background: Some(Background::Color(Color::TRANSPARENT)),
text_color,
border: border::rounded(6),
..button::Style::default()
};

match status {
button::Status::Pressed => base,
button::Status::Hovered => button::Style {
background: Some(Background::Color(palette.background.weak.color.scale_alpha(0.2))),
..base
},
button::Status::Disabled | button::Status::Active => button::Style {
background: Some(Background::Color(Color::TRANSPARENT)),
button::Status::Pressed | button::Status::Hovered => button::Style {
background: Some(Background::Color(
palette.background.weak.color.scale_alpha(0.2),
)),
..base
},
button::Status::Disabled | button::Status::Active => base,
}
}

Expand Down Expand Up @@ -127,9 +126,9 @@ pub(super) fn style_separator(theme: &Theme) -> rule::Style {

rule::Style {
color,
width: 1,
radius: border::Radius::new(0),
fill_mode: rule::FillMode::Padded(0),
snap: true,
}
}

Expand All @@ -139,4 +138,4 @@ pub(super) fn style_sheet_background(theme: &Theme) -> container::Style {
} else {
container::Style::default().background(Color::WHITE.scale_alpha(0.4))
}
}
}
35 changes: 18 additions & 17 deletions examples/overlay_editor/src/app/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::app::stroke::content::StrokeState;
use iced::event::Event as MainEvent;
use iced::keyboard::key::Named;
use iced::keyboard::Key;
use iced::widget::{vertical_rule, Space};
use iced::widget::{rule, Space};
use iced::widget::{Button, Column, Container, Row, Text};
use iced::{keyboard, Alignment, Element, Length};
use iced::{Subscription, Task};
Expand Down Expand Up @@ -118,16 +118,13 @@ impl EditorApp {
}

pub fn subscription(&self) -> Subscription<AppMessage> {
keyboard::on_key_press(|key, _mods| {
match key.as_ref() {
Key::Named(Named::ArrowDown) => {
Some(AppMessage::NextTest)
}
Key::Named(Named::ArrowUp) => {
Some(AppMessage::PrevTest)
}
keyboard::listen().filter_map(|event| match event {
keyboard::Event::KeyPressed { key, .. } => match key {
Key::Named(Named::ArrowDown) => Some(AppMessage::NextTest),
Key::Named(Named::ArrowUp) => Some(AppMessage::PrevTest),
_ => None,
}
},
_ => None,
})
}

Expand All @@ -145,7 +142,7 @@ impl EditorApp {
}
}

pub fn view(&self) -> Element<AppMessage> {
pub fn view(&self) -> Element<'_, AppMessage> {
let content = Row::new().push(
Container::new(self.main_navigation())
.width(Length::Fixed(160.0))
Expand All @@ -155,25 +152,29 @@ impl EditorApp {

let content = match self.state.selected_action {
MainAction::Boolean => content
.push(vertical_rule(1).style(style_separator))
.push(rule::vertical(1).style(style_separator))
.push(self.boolean_content()),
MainAction::String => content
.push(vertical_rule(1).style(style_separator))
.push(rule::vertical(1).style(style_separator))
.push(self.string_content()),
MainAction::Stroke => content
.push(vertical_rule(1).style(style_separator))
.push(rule::vertical(1).style(style_separator))
.push(self.stroke_content()),
MainAction::Outline => content
.push(vertical_rule(1).style(style_separator))
.push(rule::vertical(1).style(style_separator))
.push(self.outline_content()),
};

content.height(Length::Fill).into()
}

fn main_navigation(&self) -> Column<AppMessage> {
fn main_navigation(&self) -> Column<'_, AppMessage> {
self.main_actions.iter().fold(
Column::new().push(Space::new(Length::Fill, Length::Fixed(2.0))),
Column::new().push(
Space::new()
.width(Length::Fill)
.height(Length::Fixed(2.0)),
),
|column, item| {
let is_selected = self.state.selected_action.eq(item);
column.push(
Expand Down
10 changes: 7 additions & 3 deletions examples/overlay_editor/src/app/outline/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ pub(crate) enum OutlineMessage {
}

impl EditorApp {
fn outline_sidebar(&self) -> Column<AppMessage> {
fn outline_sidebar(&self) -> Column<'_, AppMessage> {
let count = self.app_resource.outline.count;
let mut column = Column::new().push(Space::new(Length::Fill, Length::Fixed(2.0)));
let mut column = Column::new().push(
Space::new()
.width(Length::Fill)
.height(Length::Fixed(2.0)),
);
for index in 0..count {
let is_selected = self.state.outline.test == index;
column = column.push(
Expand Down Expand Up @@ -70,7 +74,7 @@ impl EditorApp {
column
}

pub(crate) fn outline_content(&self) -> Row<AppMessage> {
pub(crate) fn outline_content(&self) -> Row<'_, AppMessage> {
Row::new()
.push(
scrollable(
Expand Down
10 changes: 7 additions & 3 deletions examples/overlay_editor/src/app/outline/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl std::fmt::Display for JoinOption {
}

impl EditorApp {
pub(crate) fn outline_control(&self) -> Column<AppMessage> {
pub(crate) fn outline_control(&self) -> Column<'_, AppMessage> {
let outer_offset_list = Row::new()
.push(
Text::new("Outer Offset:")
Expand Down Expand Up @@ -103,7 +103,11 @@ impl EditorApp {
Column::new()
.push(outer_offset_list)
.push(inner_offset_list)
.push(Space::new(Length::Shrink, Length::Fixed(4.0)))
.push(
Space::new()
.width(Length::Shrink)
.height(Length::Fixed(4.0)),
)
.push(join_pick_list)
}
}
Expand All @@ -122,4 +126,4 @@ fn on_select_join(option: JoinOption) -> AppMessage {

fn on_update_join_value(value: u8) -> AppMessage {
AppMessage::Outline(OutlineMessage::JoinValueUpdated(value))
}
}
2 changes: 1 addition & 1 deletion examples/overlay_editor/src/app/outline/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub(crate) struct WorkspaceState {
}

impl EditorApp {
pub(crate) fn outline_workspace(&self) -> Container<AppMessage> {
pub(crate) fn outline_workspace(&self) -> Container<'_, AppMessage> {
Container::new({
let mut stack = Stack::new();
stack = stack.push(
Expand Down
11 changes: 7 additions & 4 deletions examples/overlay_editor/src/app/string/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ pub(crate) enum StringMessage {
}

impl EditorApp {
fn string_sidebar(&self) -> Column<AppMessage> {
fn string_sidebar(&self) -> Column<'_, AppMessage> {
let count = self.app_resource.string.count;
let mut column = Column::new().push(Space::new(Length::Fill, Length::Fixed(2.0)));
let mut column = Column::new().push(
Space::new()
.width(Length::Fill)
.height(Length::Fixed(2.0)),
);
for index in 0..count {
let is_selected = self.state.string.test == index;
column = column.push(
Expand All @@ -62,7 +66,7 @@ impl EditorApp {
column
}

pub(crate) fn string_content(&self) -> Row<AppMessage> {
pub(crate) fn string_content(&self) -> Row<'_, AppMessage> {
Row::new()
.push(
scrollable(
Expand Down Expand Up @@ -232,4 +236,3 @@ impl StringState {
self.update_solution();
}
}

16 changes: 12 additions & 4 deletions examples/overlay_editor/src/app/string/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use iced::{Alignment, Length};
use iced::widget::{Column, Container, pick_list, Row, Space, Text};

impl EditorApp {
pub(crate) fn string_control(&self) -> Column<AppMessage> {
pub(crate) fn string_control(&self) -> Column<'_, AppMessage> {
let solver_pick_list =
Row::new()
.push(Text::new("Solver:")
Expand Down Expand Up @@ -63,9 +63,17 @@ impl EditorApp {

Column::new()
.push(solver_pick_list)
.push(Space::new(Length::Shrink, Length::Fixed(4.0)))
.push(
Space::new()
.width(Length::Shrink)
.height(Length::Fixed(4.0)),
)
.push(fill_pick_list)
.push(Space::new(Length::Shrink, Length::Fixed(4.0)))
.push(
Space::new()
.width(Length::Shrink)
.height(Length::Fixed(4.0)),
)
.push(mode_pick_list)
}
}
Expand Down Expand Up @@ -116,4 +124,4 @@ impl std::fmt::Display for ModeOption {
}
)
}
}
}
2 changes: 1 addition & 1 deletion examples/overlay_editor/src/app/string/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub(crate) struct WorkspaceState {
}

impl EditorApp {
pub(crate) fn string_workspace(&self) -> Container<AppMessage> {
pub(crate) fn string_workspace(&self) -> Container<'_, AppMessage> {
Container::new({
let mut stack = Stack::new();
stack = stack.push(
Expand Down
10 changes: 7 additions & 3 deletions examples/overlay_editor/src/app/stroke/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ pub(crate) enum StrokeMessage {
}

impl EditorApp {
fn stroke_sidebar(&self) -> Column<AppMessage> {
fn stroke_sidebar(&self) -> Column<'_, AppMessage> {
let count = self.app_resource.stroke.count;
let mut column = Column::new().push(Space::new(Length::Fill, Length::Fixed(2.0)));
let mut column = Column::new().push(
Space::new()
.width(Length::Fill)
.height(Length::Fixed(2.0)),
);
for index in 0..count {
let is_selected = self.state.stroke.test == index;
column = column.push(
Expand Down Expand Up @@ -78,7 +82,7 @@ impl EditorApp {
column
}

pub(crate) fn stroke_content(&self) -> Row<AppMessage> {
pub(crate) fn stroke_content(&self) -> Row<'_, AppMessage> {
Row::new()
.push(
scrollable(
Expand Down
Loading