Skip to content
Open
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
1,780 changes: 926 additions & 854 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "iced_webview"
version = "0.0.5"
version = "0.0.6"
edition = "2021"
rust-version = "1.81.0"
description = "An easily embedded webview library for iced"
Expand All @@ -27,7 +27,7 @@ docs_only = []

[dependencies]
clipboard-rs = "0.2.1"
iced = { version = "0.13", features = ["advanced", "image", "tokio", "lazy"] }
iced = { version = "0.14", features = ["advanced", "image", "tokio", "lazy"] }
rand = "0.8.5"
smol_str = "0.2.2"
ul-next = { version = "0.4", optional = true }
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ A library to embed Web views in iced applications

> [Ultralight has its own license](https://ultralig.ht/pricing/) that should be reviewed before deciding if it works for you

## Compatibility

| iced | iced_webview |
|------|--------------|
| 0.14 | 0.0.6 |
| 0.13 | 0.0.5 |

#### examples:

##### `examples/embedded_webview`
Expand Down
5 changes: 3 additions & 2 deletions examples/embedded_webview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ use std::time::Duration;
static URL: &'static str = "https://docs.rs/iced/latest/iced/index.html";

fn main() -> iced::Result {
iced::application("An embedded web view", App::update, App::view)
iced::application(App::new, App::update, App::view)
.title("An embedded web view")
.subscription(App::subscription)
.run_with(App::new)
.run()
}

#[derive(Debug, Clone)]
Expand Down
5 changes: 3 additions & 2 deletions examples/multi_webview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ static URL1: &'static str = "https://docs.rs/iced/latest/iced/index.html";
static URL2: &'static str = "https://github.com/LegitCamper/iced_webview";

fn main() -> iced::Result {
iced::application("An multi webview application", App::update, App::view)
iced::application(App::new, App::update, App::view)
.title("An multi webview application")
.subscription(App::subscription)
.run_with(App::new)
.run()
}

#[derive(Debug, Clone)]
Expand Down
9 changes: 5 additions & 4 deletions src/engines/ultralight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl Engine for Ultralight {
Cursor::VerticalText => mouse::Interaction::Text,
Cursor::IBeam => mouse::Interaction::Text,
Cursor::Cross => mouse::Interaction::Crosshair,
Cursor::Wait => mouse::Interaction::Working,
Cursor::Wait => mouse::Interaction::Wait,
Cursor::Grabbing => mouse::Interaction::Grab,
Cursor::NorthSouthResize => mouse::Interaction::ResizingVertically,
Cursor::EastWestResize => mouse::Interaction::ResizingHorizontally,
Expand Down Expand Up @@ -226,7 +226,7 @@ impl Engine for Ultralight {
.get_view(id)
.cursor
.write()
.expect("Failed cursor poisoned") = mouse::Interaction::Working;
.expect("Failed cursor poisoned") = mouse::Interaction::Progress;
match page_type {
PageType::Url(url) => self
.get_view_mut(id)
Expand Down Expand Up @@ -266,7 +266,7 @@ impl Engine for Ultralight {
modifiers,
text,
modified_key,
physical_key: _,
..
} => iced_key_to_ultralight_key(
KeyPress::Press,
Some(modified_key),
Expand All @@ -279,6 +279,7 @@ impl Engine for Ultralight {
key,
location,
modifiers,
..
} => iced_key_to_ultralight_key(
KeyPress::Unpress,
None,
Expand Down Expand Up @@ -400,7 +401,7 @@ impl Engine for Ultralight {
fn get_cursor(&self, id: ViewId) -> mouse::Interaction {
match self.get_view(id).cursor.read() {
Ok(cursor) => *cursor,
Err(_) => mouse::Interaction::Working,
Err(_) => mouse::Interaction::Idle,
}
}

Expand Down
18 changes: 7 additions & 11 deletions src/webview/advanced.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use iced::advanced::{
self,
graphics::core::event,
layout,
self, layout,
renderer::{self},
widget::Tree,
Clipboard, Layout, Shell, Widget,
};
use iced::event::Status;
use iced::keyboard;
use iced::mouse::{self, Interaction};
use iced::widget::image::{Handle, Image};
Expand Down Expand Up @@ -228,7 +225,7 @@ where
}

fn layout(
&self,
&mut self,
_tree: &mut Tree,
_renderer: &Renderer,
limits: &layout::Limits,
Expand Down Expand Up @@ -258,34 +255,33 @@ where
)
}

fn on_event(
fn update(
&mut self,
_state: &mut Tree,
event: Event,
event: &Event,
layout: Layout<'_>,
cursor: mouse::Cursor,
_renderer: &Renderer,
_clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Action>,
_viewport: &Rectangle,
) -> event::Status {
) {
let size = Size::new(layout.bounds().width as u32, layout.bounds().height as u32);
if self.bounds != size {
shell.publish(Action::Resize(size));
}

match event {
Event::Keyboard(event) => {
shell.publish(Action::SendKeyboardEvent(self.id, event));
shell.publish(Action::SendKeyboardEvent(self.id, event.clone()));
}
Event::Mouse(event) => {
if let Some(point) = cursor.position_in(layout.bounds()) {
shell.publish(Action::SendMouseEvent(self.id, event, point));
shell.publish(Action::SendMouseEvent(self.id, event.clone(), point));
}
}
_ => (),
}
Status::Ignored
}

fn mouse_interaction(
Expand Down
18 changes: 7 additions & 11 deletions src/webview/basic.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use iced::advanced::{
self,
graphics::core::event,
layout,
self, layout,
renderer::{self},
widget::Tree,
Clipboard, Layout, Shell, Widget,
};
use iced::event::Status;
use iced::keyboard;
use iced::mouse::{self, Interaction};
use iced::widget::image::{Handle, Image};
Expand Down Expand Up @@ -266,7 +263,7 @@ where
}

fn layout(
&self,
&mut self,
_tree: &mut Tree,
_renderer: &Renderer,
limits: &layout::Limits,
Expand Down Expand Up @@ -296,34 +293,33 @@ where
)
}

fn on_event(
fn update(
&mut self,
_state: &mut Tree,
event: Event,
event: &Event,
layout: Layout<'_>,
cursor: mouse::Cursor,
_renderer: &Renderer,
_clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Action>,
_viewport: &Rectangle,
) -> event::Status {
) {
let size = Size::new(layout.bounds().width as u32, layout.bounds().height as u32);
if self.image_info.width != size.width || self.image_info.height != size.height {
shell.publish(Action::Resize(size));
}

match event {
Event::Keyboard(event) => {
shell.publish(Action::SendKeyboardEvent(event));
shell.publish(Action::SendKeyboardEvent(event.clone()));
}
Event::Mouse(event) => {
if let Some(point) = cursor.position_in(layout.bounds()) {
shell.publish(Action::SendMouseEvent(event, point));
shell.publish(Action::SendMouseEvent(event.clone(), point));
}
}
_ => (),
}
Status::Ignored
}

fn mouse_interaction(
Expand Down