From b1da5a40db4b5f39bac61adce56db29bb3c7e1fb Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Tue, 3 Nov 2020 21:24:02 +0300 Subject: [PATCH] Rebase on master and fix errors --- examples/tooltip/src/main.rs | 2 +- graphics/src/widget/tooltip.rs | 12 +++++++++--- native/src/overlay.rs | 2 ++ native/src/overlay/element.rs | 8 ++++++-- native/src/overlay/menu.rs | 1 + native/src/user_interface.rs | 1 + native/src/widget/tooltip.rs | 21 +++++++++++++++++++-- src/widget.rs | 10 +++------- 8 files changed, 42 insertions(+), 15 deletions(-) diff --git a/examples/tooltip/src/main.rs b/examples/tooltip/src/main.rs index 56b10a92f3..8c0ef29e64 100644 --- a/examples/tooltip/src/main.rs +++ b/examples/tooltip/src/main.rs @@ -1,7 +1,7 @@ use iced::{Container, Element, Length, Sandbox, Settings, Text, Tooltip}; pub fn main() { - Example::run(Settings::default()) + Example::run(Settings::default()).unwrap() } #[derive(Default)] diff --git a/graphics/src/widget/tooltip.rs b/graphics/src/widget/tooltip.rs index 8a591d2076..b5b0c55894 100644 --- a/graphics/src/widget/tooltip.rs +++ b/graphics/src/widget/tooltip.rs @@ -1,7 +1,7 @@ //! Decorate content and apply alignment. use crate::defaults::Defaults; use crate::{Backend, Renderer}; -use iced_native::{Element, Layout, Point}; +use iced_native::{Element, Layout, Point, Rectangle}; /// An element decorating some content. /// @@ -22,9 +22,15 @@ where cursor_position: Point, content: &Element<'_, Message, Self>, content_layout: Layout<'_>, + viewport: &Rectangle, ) -> Self::Output { - let (content, mouse_interaction) = - content.draw(self, &defaults, content_layout, cursor_position); + let (content, mouse_interaction) = content.draw( + self, + &defaults, + content_layout, + cursor_position, + viewport, + ); (content, mouse_interaction) } diff --git a/native/src/overlay.rs b/native/src/overlay.rs index 7c3bec3294..4a3af439d6 100644 --- a/native/src/overlay.rs +++ b/native/src/overlay.rs @@ -4,6 +4,7 @@ mod element; pub mod menu; pub use element::Element; +use iced_core::Rectangle; pub use menu::Menu; use crate::{layout, Clipboard, Event, Hasher, Layout, Point, Size}; @@ -37,6 +38,7 @@ where defaults: &Renderer::Defaults, layout: Layout<'_>, cursor_position: Point, + viewport: &Rectangle, ) -> Renderer::Output; /// Computes the _layout_ hash of the [`Overlay`]. diff --git a/native/src/overlay/element.rs b/native/src/overlay/element.rs index e1fd9b88a8..b5425410ee 100644 --- a/native/src/overlay/element.rs +++ b/native/src/overlay/element.rs @@ -1,3 +1,5 @@ +use iced_core::Rectangle; + pub use crate::Overlay; use crate::{layout, Clipboard, Event, Hasher, Layout, Point, Size, Vector}; @@ -88,9 +90,10 @@ where defaults: &Renderer::Defaults, layout: Layout<'_>, cursor_position: Point, + viewport: &Rectangle, ) -> Renderer::Output { self.overlay - .draw(renderer, defaults, layout, cursor_position) + .draw(renderer, defaults, layout, cursor_position, viewport) } /// Computes the _layout_ hash of the [`Element`]. @@ -159,9 +162,10 @@ where defaults: &Renderer::Defaults, layout: Layout<'_>, cursor_position: Point, + viewport: &Rectangle, ) -> Renderer::Output { self.content - .draw(renderer, defaults, layout, cursor_position) + .draw(renderer, defaults, layout, cursor_position, viewport) } fn hash_layout(&self, state: &mut Hasher, position: Point) { diff --git a/native/src/overlay/menu.rs b/native/src/overlay/menu.rs index 4b392a8ee2..78574fb87b 100644 --- a/native/src/overlay/menu.rs +++ b/native/src/overlay/menu.rs @@ -252,6 +252,7 @@ where defaults: &Renderer::Defaults, layout: Layout<'_>, cursor_position: Point, + _viewport: &Rectangle, ) -> Renderer::Output { let primitives = self.container.draw( renderer, diff --git a/native/src/user_interface.rs b/native/src/user_interface.rs index 59d91f42c8..48fc37dc5e 100644 --- a/native/src/user_interface.rs +++ b/native/src/user_interface.rs @@ -348,6 +348,7 @@ where &Renderer::Defaults::default(), Layout::new(&layer.layout), cursor_position, + &viewport, ); self.overlay = Some(layer); diff --git a/native/src/widget/tooltip.rs b/native/src/widget/tooltip.rs index 1ed18ad12b..4a8ef676cf 100644 --- a/native/src/widget/tooltip.rs +++ b/native/src/widget/tooltip.rs @@ -1,6 +1,8 @@ //! Display a widget over another. use std::hash::Hash; +use iced_core::Rectangle; + use crate::{ layout, overlay, Clipboard, Element, Event, Hasher, Layout, Length, Point, Size, Vector, Widget, @@ -97,8 +99,15 @@ where defaults: &Renderer::Defaults, layout: Layout<'_>, cursor_position: Point, + viewport: &Rectangle, ) -> Renderer::Output { - renderer.draw(defaults, cursor_position, &self.content, layout) + renderer.draw( + defaults, + cursor_position, + &self.content, + layout, + viewport, + ) } fn hash_layout(&self, state: &mut Hasher) { @@ -186,8 +195,15 @@ where defaults: &Renderer::Defaults, layout: Layout<'_>, cursor_position: Point, + viewport: &Rectangle, ) -> Renderer::Output { - renderer.draw(defaults, cursor_position, &self.content, layout) + renderer.draw( + defaults, + cursor_position, + &self.content, + layout, + viewport, + ) } } @@ -211,6 +227,7 @@ pub trait Renderer: crate::Renderer { cursor_position: Point, content: &Element<'_, Message, Self>, content_layout: Layout<'_>, + viewport: &Rectangle, ) -> Self::Output; } diff --git a/src/widget.rs b/src/widget.rs index 74090e0161..a6d39b225b 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -20,7 +20,8 @@ mod platform { pub use crate::renderer::widget::{ button, checkbox, container, pane_grid, pick_list, progress_bar, radio, - rule, scrollable, slider, text_input, tooltip, Column, Row, Space, Text, + rule, scrollable, slider, text_input, tooltip, Column, Row, Space, + Text, }; #[cfg(any(feature = "canvas", feature = "glow_canvas"))] @@ -46,13 +47,8 @@ mod platform { pub use { button::Button, checkbox::Checkbox, container::Container, image::Image, pane_grid::PaneGrid, pick_list::PickList, progress_bar::ProgressBar, -<<<<<<< HEAD radio::Radio, rule::Rule, scrollable::Scrollable, slider::Slider, - svg::Svg, text_input::TextInput, -======= - radio::Radio, scrollable::Scrollable, slider::Slider, svg::Svg, - text_input::TextInput, tooltip::Tooltip, ->>>>>>> b37deb2... add Tooltip widget with simple example + svg::Svg, text_input::TextInput, tooltip::Tooltip, }; #[cfg(any(feature = "canvas", feature = "glow_canvas"))]