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

Chore/upgrade iced #80

Closed
wants to merge 2 commits into from
Closed
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,143 changes: 558 additions & 585 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ default = ["iced/wgpu", "iced/palette"]
debug = ["iced/debug"]

[dependencies]
iced = { version = "0.10.0", features = ["wgpu", "palette", "svg", "image", "tokio"] }
iced_core = "0.10.0"
iced_runtime = "0.1.1"
iced_style = "0.9.0"
iced = { version = "0.12.0", features = ["wgpu", "palette", "svg", "image", "tokio"] }
iced_core = "0.12.0"
iced_runtime = "0.12.0"
iced_style = "0.12.0"
tokio = { version = "1.29.1", features = ["process", "macros", "io-util"] }
redb = "1.5.0"

Expand Down
8 changes: 4 additions & 4 deletions src/app/entries/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::app::Message;
use crate::icons::{fallback_icon, Extension, IconPath};
use crate::THEME;
use iced::widget::{column, container, row, text, Button, Container, Image, Row};
use iced::{Alignment, Length, Renderer};
use iced::{Alignment, Length};
use std::borrow::Cow;

pub(crate) mod db_entry;
Expand All @@ -30,7 +30,7 @@ pub(crate) trait AsEntry<'a> {
};

let row = row
.height(Length::Fill)
.height(Length::Shrink)
.width(Length::Fill)
.spacing(theme.spacing)
// See : https://github.com/iced-rs/iced/pull/1044
Expand All @@ -48,7 +48,7 @@ pub(crate) trait AsEntry<'a> {
where
'b: 'a,
{
let title_row: Container<'_, Message, Renderer> =
let title_row: Container<'_, Message> =
container(iced::widget::row(vec![text(self.get_display_name())
.size(theme.title.font_size)
.into()]))
Expand All @@ -59,7 +59,7 @@ pub(crate) trait AsEntry<'a> {
.align_x(theme.title.align_x)
.align_y(theme.title.align_y);

let description_row: Option<Container<'_, Message, Renderer>> =
let description_row: Option<Container<'_, Message>> =
self.get_description().map(|description| {
container(row!(
text(description.as_ref()).size(theme.description.font_size)
Expand Down
55 changes: 29 additions & 26 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ use std::process::exit;

use iced::alignment::{Horizontal, Vertical};
use iced::futures::channel::mpsc::{Sender, TrySendError};
use iced::keyboard::KeyCode;
use iced::keyboard::Key;
use iced::widget::{column, container, scrollable, text_input, Column, Container, Row, Text};
use iced::window::PlatformSpecific;
use iced::{
subscription, window, Application, Command, Element, Length, Renderer, Settings, Subscription,
event, window, Application, Command, Element, Length, Renderer, Settings, Subscription,
};
use iced_core::keyboard::key::Named;
use iced_core::widget::operation::scrollable::RelativeOffset;
use iced_core::{Event, Font};
use iced_core::window::settings::PlatformSpecific;
use iced_core::{Event, Font, Pixels, Size};
use iced_style::Theme;
use onagre_launcher_toolkit::launcher::{Request, Response};
use once_cell::sync::Lazy;
Expand Down Expand Up @@ -49,7 +50,7 @@ pub fn run(pre_value: Option<String>) -> iced::Result {
id: Some("onagre".to_string()),
window: window::Settings {
transparent: true,
size: THEME.size,
size: Size::new(THEME.size.0 as f32, THEME.size.1 as f32),
decorations: false,
resizable: false,
position: window::Position::Centered,
Expand All @@ -61,12 +62,13 @@ pub fn run(pre_value: Option<String>) -> iced::Result {
application_id: "onagre".to_string(),
},
level: Default::default(),
exit_on_close_request: false,
},
default_text_size: THEME.font_size as f32,
default_text_size: Pixels(THEME.font_size as f32),
antialiasing: true,
exit_on_close_request: false,
default_font,
flags: OnagreFlags { pre_value },
fonts: vec![],
})
}

Expand All @@ -81,7 +83,7 @@ pub enum Message {
Loading,
InputChanged(String),
Click(usize),
KeyboardEvent(KeyCode),
KeyboardEvent(Key),
SubscriptionResponse(SubscriptionMessage),
Unfocused,
}
Expand Down Expand Up @@ -148,7 +150,7 @@ impl Application for Onagre<'_> {
}
}

fn view(&self) -> Element<'_, Self::Message, Renderer<Self::Theme>> {
fn view(&self) -> Element<'_, Self::Message, Self::Theme> {
// Build rows from current mode search entries
let selected = self.selected();
let rows = match &self.state.get_active_mode() {
Expand All @@ -157,6 +159,7 @@ impl Application for Onagre<'_> {
history,
..
} if *history => {
// FIXME the .into() doesn't work anymore -- need to check why!
let icon = self.state.plugin_matchers.get_plugin_icon(plugin_name);
self.state
.cache
Expand All @@ -168,13 +171,15 @@ impl Application for Onagre<'_> {
}
ActiveMode::Web { modifier, .. } => {
let icon = self.state.plugin_matchers.get_plugin_icon("web");
self.state
let rows: Vec<Element<'_, Message, Theme, Renderer>> = self
.state
.cache
.web_history(modifier)
.iter()
.enumerate()
.map(|(idx, entry)| entry.to_row(selected, idx, icon.as_ref()).into())
.collect()
.collect();
rows
}
ActiveMode::History => {
let icon = self
Expand Down Expand Up @@ -208,7 +213,6 @@ impl Application for Onagre<'_> {
})
.collect(),
};

// Scrollable element containing the rows
let scrollable =
scrollable(column(rows))
Expand Down Expand Up @@ -242,7 +246,7 @@ impl Application for Onagre<'_> {
.align_y(THEME.search_input().align_y);

let search_bar = Row::new().width(Length::Fill).height(Length::Fill);
// Either plugin_hint is enabled and we try to display it
// Either plugin_hint is enabled, and we try to display it
// Or we display the normal search input
let search_bar = match THEME.plugin_hint() {
None => search_bar.push(search_input),
Expand Down Expand Up @@ -408,24 +412,24 @@ impl Onagre<'_> {
exit(0);
}

fn handle_input(&mut self, key_code: KeyCode) -> Command<Message> {
match key_code {
KeyCode::Up => {
fn handle_input(&mut self, key: Key) -> Command<Message> {
match key {
Key::Named(Named::ArrowUp) => {
trace!("Selected line : {:?}", self.selected());
return self.dec_selected();
}
KeyCode::Down => {
Key::Named(Named::ArrowDown) => {
trace!("Selected line : {:?}", self.selected());
return self.inc_selected();
}
KeyCode::Enter => return self.on_execute(),
KeyCode::Tab => {
Key::Named(Named::Enter) => return self.on_execute(),
Key::Named(Named::Tab) => {
if let Some(selected) = self.selected() {
self.pop_request(Request::Complete(selected as u32))
.expect("Unable to send request to pop-launcher");
}
}
KeyCode::Escape => {
Key::Named(Named::Escape) => {
exit(0);
}
_ => {}
Expand Down Expand Up @@ -627,12 +631,11 @@ impl Onagre<'_> {
}

fn keyboard_event() -> Subscription<Message> {
subscription::events_with(|event, _status| match event {
Event::Window(window::Event::Unfocused) => Some(Message::Unfocused),
Event::Keyboard(iced::keyboard::Event::KeyPressed {
modifiers: _,
key_code,
}) => Some(Message::KeyboardEvent(key_code)),
event::listen_with(|event, _status| match event {
Event::Window(_window_id, window::Event::Unfocused) => Some(Message::Unfocused),
Event::Keyboard(iced::keyboard::Event::KeyPressed { key, .. }) => {
Some(Message::KeyboardEvent(key))
}
_ => None,
})
}
Expand Down
11 changes: 7 additions & 4 deletions src/app/style/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::app::style::search::SearchContainerStyles;
use crate::app::style::Scale;
use crate::config::color::OnagreColor;
use crate::config::padding::OnagrePadding;
use iced_core::{Background, BorderRadius};
use iced_core::{border::Radius as BorderRadius, Background, Border};
use iced_style::container::{Appearance, StyleSheet};

// The top level container wrapping the app
Expand Down Expand Up @@ -49,9 +49,12 @@ impl StyleSheet for &AppContainerStyles {
Appearance {
text_color: Some(self.color.into()),
background: Some(Background::Color(self.background.into())),
border_radius: BorderRadius::from(self.border_radius),
border_width: self.border_width,
border_color: self.border_color.into(),
border: Border {
radius: BorderRadius::from(self.border_radius),
width: self.border_width,
color: self.border_color.into(),
},
..Default::default()
}
}
}
Expand Down
14 changes: 9 additions & 5 deletions src/app/style/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use crate::THEME_PATH;
use crate::THEME_SCALE;
use iced::widget::container::Appearance;
use iced::Background;
use iced_core::{BorderRadius, Length};
use iced_core::Border;
use iced_core::{border::Radius as BorderRadius, Length};
use tracing::{error, warn};

pub mod app;
Expand Down Expand Up @@ -148,11 +149,14 @@ impl iced::widget::container::StyleSheet for &Theme {

fn appearance(&self, _: &Self::Style) -> Appearance {
Appearance {
background: Some(Background::Color(self.background.into())),
border_radius: BorderRadius::from(self.border_radius),
border_width: self.border_width,
text_color: Some(self.color.into()),
border_color: self.border_color.into(),
background: Some(Background::Color(self.background.into())),
border: Border {
radius: BorderRadius::from(self.border_radius),
width: self.border_width,
color: self.border_color.into(),
},
..Default::default()
}
}
}
13 changes: 8 additions & 5 deletions src/app/style/rows/button.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use iced_core::{Color, Vector};
use iced_core::{Border, Color, Vector};
use iced_style::button::{Appearance, StyleSheet};

// Button is just used as a wrapper to get access to the click event.
Expand Down Expand Up @@ -28,11 +28,14 @@ impl StyleSheet for &ButtonStyle {

fn no_style() -> Appearance {
Appearance {
text_color: Color::BLACK,
shadow_offset: Vector { x: 0.0, y: 0.0 },
background: None,
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
text_color: Color::BLACK,
border: Border {
radius: 0.0.into(),
color: Color::TRANSPARENT,
width: 0.0,
},
..Default::default()
}
}
12 changes: 8 additions & 4 deletions src/app/style/rows/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use crate::config::color::OnagreColor;
use crate::config::padding::OnagrePadding;
use iced::alignment::{Horizontal, Vertical};
use iced::Length;
use iced_core::{Background, BorderRadius};
use iced_core::Border;
use iced_core::{border::Radius as BorderRadius, Background};
use iced_style::container::{Appearance, StyleSheet};

#[derive(Debug, PartialEq, Clone)]
Expand Down Expand Up @@ -60,9 +61,12 @@ impl StyleSheet for &GenericContainerStyle {
Appearance {
text_color: Some(self.color.into()),
background: Some(Background::Color(self.background.into())),
border_radius: BorderRadius::from(self.border_radius),
border_width: self.border_width,
border_color: self.border_color.into(),
border: Border {
radius: BorderRadius::from(self.border_radius),
width: self.border_width,
color: self.border_color.into(),
},
..Default::default()
}
}
}
Expand Down
13 changes: 8 additions & 5 deletions src/app/style/rows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::config::padding::OnagrePadding;
use generic::GenericContainerStyle;
use iced::alignment::{Horizontal, Vertical};
use iced::Length;
use iced_core::Background;
use iced_core::BorderRadius;
use iced_core::Border;
use iced_core::{border::Radius as BorderRadius, Background};
use iced_style::container::{Appearance, StyleSheet};
use icon::IconStyle;

Expand Down Expand Up @@ -59,9 +59,12 @@ impl StyleSheet for &RowStyles {
Appearance {
text_color: Some(self.color.into()),
background: Some(Background::Color(self.background.into())),
border_radius: BorderRadius::from(self.border_radius),
border_width: self.border_width,
border_color: self.border_color.into(),
border: Border {
radius: BorderRadius::from(self.border_radius),
width: self.border_width,
color: self.border_color.into(),
},
..Default::default()
}
}
}
Expand Down
11 changes: 7 additions & 4 deletions src/app/style/scrollable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::app::style::Scale;
use crate::config::color::OnagreColor;
use crate::config::padding::OnagrePadding;
use iced::Length;
use iced_core::{Background, BorderRadius};
use iced_core::{border::Radius as BorderRadius, Background, Border};
use iced_style::container::{Appearance, StyleSheet};

pub mod scroller;
Expand Down Expand Up @@ -48,9 +48,12 @@ impl StyleSheet for &RowContainerStyle {
Appearance {
text_color: Some(self.color.into()),
background: Some(Background::Color(self.background.into())),
border_radius: BorderRadius::from(self.border_radius),
border_width: self.border_width,
border_color: self.border_color.into(),
border: Border {
radius: BorderRadius::from(self.border_radius),
width: self.border_width,
color: self.border_color.into(),
},
..Default::default()
}
}
}
Expand Down
Loading
Loading