Skip to content

Commit

Permalink
Working on converstions to newest iced...
Browse files Browse the repository at this point in the history
  • Loading branch information
genusistimelord committed Jul 11, 2023
1 parent 92b024e commit 6dd25e2
Show file tree
Hide file tree
Showing 22 changed files with 588 additions and 597 deletions.
88 changes: 44 additions & 44 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ categories = ["gui"]
badge = []
card = []
date_picker = ["chrono", "lazy_static", "icon_text"]
color_picker = ["icon_text", "iced_graphics/canvas"]
cupertino = ["iced_graphics/canvas", "time"]
color_picker = ["icon_text", "iced_widget/canvas"]
cupertino = ["iced_widget/canvas", "time"]
floating_element = []
grid = []
glow = [] # TODO
Expand All @@ -25,7 +25,7 @@ icons = []
modal = []
tab_bar = []
tabs = ["tab_bar"]
time_picker = ["chrono", "icon_text", "iced_graphics/canvas"]
time_picker = ["chrono", "icon_text", "iced_widget/canvas"]
wrap = []
number_input = ["num-traits"]
selection_list = []
Expand All @@ -38,22 +38,22 @@ context_menu = []
default = [
"badge",
"card",
"number_input",
"date_picker",
"color_picker",
"floating_element",
"icon_text",
#"number_input",
#"date_picker",
#"color_picker",
#"floating_element",
#"icon_text",
"grid",
"modal",
"tab_bar",
"tabs",
"time_picker",
"wrap",
"selection_list",
"split",
"menu",
"quad",
"context_menu"
#"tab_bar",
#"tabs",
#"time_picker",
#"wrap",
#"selection_list",
#"split",
#"menu",
#"quad",
#"context_menu"
]

[dependencies]
Expand All @@ -64,20 +64,20 @@ lazy_static = { version = "1.4.0", optional = true }



[dependencies.iced_native]
#git = "https://github.com/iced-rs/iced.git"
[dependencies.iced_widget]
git = "https://github.com/iced-rs/iced.git"
#rev = "8221794"
version = "0.10.1"
version = "0.1.0"

[dependencies.iced_graphics]
#[dependencies.iced_graphics]
#git = "https://github.com/iced-rs/iced.git"
#rev = "8221794"
version = "0.8.0"
#version = "0.8.0"

[dependencies.iced_style]
#[dependencies.iced_style]
#git = "https://github.com/iced-rs/iced.git"
#rev = "8221794"
version = "0.8.0"
#version = "0.8.0"

[profile.dev.package."*"]
opt-level = 2
Expand All @@ -86,33 +86,33 @@ opt-level = 2
members = [
"examples/badge",
"examples/card",
"examples/color_picker",
"examples/cupertino/cupertino_alert",
"examples/cupertino/cupertino_button",
#"examples/color_picker",
#"examples/cupertino/cupertino_alert",
#"examples/cupertino/cupertino_button",
# "examples/cupertino/cupertino_slider",
"examples/cupertino/cupertino_spinner",
"examples/cupertino/cupertino_switch",
"examples/date_picker",
"examples/floating_element",
"examples/floating_element_anchors",
#"examples/cupertino/cupertino_spinner",
#"examples/cupertino/cupertino_switch",
#"examples/date_picker",
#"examples/floating_element",
#"examples/floating_element_anchors",
"examples/grid",
"examples/modal",
"examples/modal_component",
"examples/tab_bar",
"examples/tabs",
"examples/time_picker",
"examples/wrap",
"examples/number_input",
"examples/selection_list",
"examples/split",
"examples/split_scroller",
"examples/menu",
"examples/spinner",
"examples/context_menu"
#"examples/tab_bar",
#"examples/tabs",
#"examples/time_picker",
#"examples/wrap",
#"examples/number_input",
#"examples/selection_list",
#"examples/split",
#"examples/split_scroller",
#"examples/menu",
#"examples/spinner",
#"examples/context_menu"
]

[workspace.dependencies.iced]
#git = "https://github.com/iced-rs/iced.git"
git = "https://github.com/iced-rs/iced.git"
#rev = "8221794"
version = "0.9.0"

Expand Down
2 changes: 1 addition & 1 deletion examples/card/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Sandbox for CardExample {
fn view(&self) -> Element<'_, self::Message> {
let element: Element<'_, Message> = if self.card_open {
card(
Text::new("Head"),
Text::new("Head X"),
Column::new()
//.push(Text::new("Body").size(42))
.push(Text::new("Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro. De carne lumbering animata corpora quaeritis. Summus brains sit, morbo vel maleficia? De apocalypsi gorger omero undead survivor dictum mauris. Hi mindless mortuis soulless creaturas, imo evil stalking monstra adventus resi dentevil vultus comedat cerebella viventium. Qui animated corpse, cricket bat max brucks terribilem incessu zomby. The voodoo sacerdos flesh eater, suscitat mortuos comedere carnem virus. Zonbi tattered for solum oculi eorum defunctis go lum cerebro. Nescio brains an Undead zombies. Sicut malus putrid voodoo horror. Nigh tofth eliv ingdead."))
Expand Down
2 changes: 1 addition & 1 deletion src/core/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::fmt::Display;

use iced_graphics::Point;
use iced_widget::core::Point;

/// The size of the period on the clock based on the clock's size.
pub const PERIOD_PERCENTAGE: f32 = 0.1;
Expand Down
2 changes: 1 addition & 1 deletion src/core/color.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Helper functions and structs for picking dates.

use iced_graphics::Color;
use iced_widget::core::Color;

/// A color in the HSV color space.
#[derive(Clone, Copy, Debug, PartialEq)]
Expand Down
4 changes: 2 additions & 2 deletions src/core/overlay.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Helper functions for overlays
use iced_native::{Point, Size};
use iced_widget::core::{layout, Point, Size};

/// Trait containing functions for positioning of nodes.
pub trait Position {
Expand All @@ -8,7 +8,7 @@ pub trait Position {
fn center_and_bounce(&mut self, position: Point, bounds: Size);
}

impl Position for iced_native::layout::Node {
impl Position for layout::Node {
fn center_and_bounce(&mut self, position: Point, bounds: Size) {
self.move_to(Point::new(
(position.x - self.size().width / 2.0).max(0.0),
Expand Down
2 changes: 1 addition & 1 deletion src/core/renderer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Helper struct for drawing

use iced_native::{Layout, Point, Rectangle};
use iced_widget::core::{Layout, Point, Rectangle};

/// Collection of all necessary data to draw a widget.
#[derive(Debug)]
Expand Down
6 changes: 3 additions & 3 deletions src/graphics/icons.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! The default icon font of the widgets of this library.
use iced_graphics::Font;
use iced_widget::core::Font;

Check warning on line 2 in src/graphics/icons.rs

View workflow job for this annotation

GitHub Actions / all (nightly)

unused import: `iced_widget::core::Font`

#[cfg(feature = "icons")]
mod bootstrap;
Expand All @@ -13,10 +13,10 @@ pub use required::*;

/// The default icon font.
#[cfg(feature = "icons")]
pub const ICON_FONT: Font = iced_native::Font::External {
/*pub const ICON_FONT: Font = iced_native::Font::External {
name: "Icons",
bytes: include_bytes!("./fonts/bootstrap-icons.ttf"),
};
};*/

/// The default icon font.
#[cfg(not(feature = "icons"))]
Expand Down
17 changes: 10 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,18 @@ pub mod native;
pub mod core;
pub mod style;

pub use iced_native::Element;
pub use iced_widget::core::Element;
use iced_widget::{renderer, style as iced_style};

/// Exports for all platforms that are not WASM32.
mod platform {
#[doc(no_inline)]
#[cfg(feature = "icons")]
pub use {crate::graphics::icons::Icon, crate::graphics::icons::ICON_FONT};
// #[doc(no_inline)]
// #[cfg(feature = "icons")]
//pub use {crate::graphics::icons::Icon, crate::graphics::icons::ICON_FONT};

#[doc(no_inline)]
#[cfg(feature = "icon_text")]
pub use {crate::native::icon_text, crate::native::icon_text::IconText};
//#[doc(no_inline)]
//#[cfg(feature = "icon_text")]
//pub use {crate::native::icon_text, crate::native::icon_text::IconText};

#[doc(no_inline)]
#[cfg(feature = "badge")]
Expand Down Expand Up @@ -164,3 +165,5 @@ mod platform {

#[doc(no_inline)]
pub use platform::*;

type Renderer<Theme = iced_style::Theme> = renderer::Renderer<Theme>;
38 changes: 20 additions & 18 deletions src/native/badge.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//! Use a badge for color highlighting important information.
//!
//! *This API requires the following crate features to be activated: badge*
use iced_native::{
event, layout, mouse,
renderer::{self},
widget::Tree,
use iced_widget::core::{
self,
event, layout,
mouse::{self, Cursor},
renderer,
widget::tree::Tree,
Alignment, Clipboard, Color, Element, Event, Layout, Length, Point, Rectangle, Shell, Widget,
};

Expand All @@ -28,9 +30,9 @@ const BORDER_RADIUS_RATIO: f32 = 34.0 / 15.0;
/// let badge = Badge::<Message>::new(Text::new("Text"));
/// ```
#[allow(missing_debug_implementations)]
pub struct Badge<'a, Message, Renderer>
pub struct Badge<'a, Message, Renderer = crate::Renderer>
where
Renderer: iced_native::Renderer,
Renderer: core::Renderer,
Renderer::Theme: StyleSheet,
{
/// The padding of the [`Badge`].
Expand All @@ -51,7 +53,7 @@ where

impl<'a, Message, Renderer> Badge<'a, Message, Renderer>
where
Renderer: iced_native::Renderer,
Renderer: core::Renderer,
Renderer::Theme: StyleSheet,
{
/// Creates a new [`Badge`](Badge) with the given content.
Expand Down Expand Up @@ -119,7 +121,7 @@ where
impl<'a, Message, Renderer> Widget<Message, Renderer> for Badge<'a, Message, Renderer>
where
Message: 'a + Clone,
Renderer: 'a + iced_native::Renderer,
Renderer: 'a + core::Renderer,
Renderer::Theme: StyleSheet,
{
fn children(&self) -> Vec<Tree> {
Expand Down Expand Up @@ -160,7 +162,7 @@ where
state: &mut Tree,
event: Event,
layout: Layout<'_>,
cursor_position: Point,
cursor: Cursor,
renderer: &Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
Expand All @@ -172,7 +174,7 @@ where
.children()
.next()
.expect("Native: Layout should have a children layout for a badge."),
cursor_position,
cursor,
renderer,
clipboard,
shell,
Expand All @@ -183,32 +185,32 @@ where
&self,
state: &Tree,
layout: Layout<'_>,
cursor_position: Point,
cursor: Cursor,
viewport: &Rectangle,
renderer: &Renderer,
) -> mouse::Interaction {
self.content.as_widget().mouse_interaction(
&state.children[0],
layout,
cursor_position,
cursor,
viewport,
renderer,
)
}

fn draw(
&self,
tree: &iced_native::widget::Tree,
tree: &Tree,
renderer: &mut Renderer,
theme: &Renderer::Theme,
_style: &renderer::Style,
layout: Layout<'_>,
cursor_position: Point,
cursor: Cursor,
viewport: &Rectangle,
) {
let bounds = layout.bounds();
let mut children = layout.children();
let is_mouse_over = bounds.contains(cursor_position);
let is_mouse_over = bounds.contains(cursor.position().unwrap_or_default());
let style_sheet = if is_mouse_over {
theme.hovered(self.style)
} else {
Expand Down Expand Up @@ -242,16 +244,16 @@ where
children
.next()
.expect("Graphics: Layout should have a children layout for Badge"),
cursor_position,
cursor,
viewport,
);
}
}

impl<'a, Message, Renderer> From<Badge<'a, Message, Renderer>> for Element<'a, Message, Renderer>
where
Message: Clone + 'a,
Renderer: iced_native::Renderer + 'a,
Message: 'a + Clone,
Renderer: 'a + core::Renderer,
Renderer::Theme: StyleSheet,
{
fn from(badge: Badge<'a, Message, Renderer>) -> Self {
Expand Down
Loading

0 comments on commit 6dd25e2

Please sign in to comment.