Merge branch 'master' into text-editor
This commit is contained in:
commit
6582387579
109 changed files with 370 additions and 413 deletions
|
|
@ -37,7 +37,7 @@ impl Application for Arc {
|
|||
(
|
||||
Arc {
|
||||
start: Instant::now(),
|
||||
cache: Default::default(),
|
||||
cache: Cache::default(),
|
||||
},
|
||||
Command::none(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ mod bezier {
|
|||
}
|
||||
|
||||
pub fn request_redraw(&mut self) {
|
||||
self.cache.clear()
|
||||
self.cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,12 +100,9 @@ mod bezier {
|
|||
bounds: Rectangle,
|
||||
cursor: mouse::Cursor,
|
||||
) -> (event::Status, Option<Curve>) {
|
||||
let cursor_position =
|
||||
if let Some(position) = cursor.position_in(bounds) {
|
||||
position
|
||||
} else {
|
||||
return (event::Status::Ignored, None);
|
||||
};
|
||||
let Some(cursor_position) = cursor.position_in(bounds) else {
|
||||
return (event::Status::Ignored, None);
|
||||
};
|
||||
|
||||
match event {
|
||||
Event::Mouse(mouse_event) => {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ impl Application for Clock {
|
|||
Clock {
|
||||
now: time::OffsetDateTime::now_local()
|
||||
.unwrap_or_else(|_| time::OffsetDateTime::now_utc()),
|
||||
clock: Default::default(),
|
||||
clock: Cache::default(),
|
||||
},
|
||||
Command::none(),
|
||||
)
|
||||
|
|
@ -141,7 +141,7 @@ impl<Message> canvas::Program<Message, Renderer> for Clock {
|
|||
frame.with_save(|frame| {
|
||||
frame.rotate(hand_rotation(self.now.second(), 60));
|
||||
frame.stroke(&long_hand, thin_stroke());
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
vec![clock]
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ impl Download {
|
|||
| State::Errored { .. } => {
|
||||
self.state = State::Downloading { progress: 0.0 };
|
||||
}
|
||||
_ => {}
|
||||
State::Downloading { .. } => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -406,12 +406,9 @@ mod grid {
|
|||
*interaction = Interaction::None;
|
||||
}
|
||||
|
||||
let cursor_position =
|
||||
if let Some(position) = cursor.position_in(bounds) {
|
||||
position
|
||||
} else {
|
||||
return (event::Status::Ignored, None);
|
||||
};
|
||||
let Some(cursor_position) = cursor.position_in(bounds) else {
|
||||
return (event::Status::Ignored, None);
|
||||
};
|
||||
|
||||
let cell = Cell::at(self.project(cursor_position, bounds.size()));
|
||||
let is_populated = self.state.contains(&cell);
|
||||
|
|
@ -472,7 +469,7 @@ mod grid {
|
|||
* (1.0 / self.scaling),
|
||||
))
|
||||
}
|
||||
_ => None,
|
||||
Interaction::None => None,
|
||||
};
|
||||
|
||||
let event_status = match interaction {
|
||||
|
|
@ -610,8 +607,7 @@ mod grid {
|
|||
|
||||
frame.fill_text(Text {
|
||||
content: format!(
|
||||
"{} cell{} @ {:?} ({})",
|
||||
cell_count,
|
||||
"{cell_count} cell{} @ {:?} ({})",
|
||||
if cell_count == 1 { "" } else { "s" },
|
||||
self.last_tick_duration,
|
||||
self.last_queued_ticks
|
||||
|
|
@ -677,7 +673,7 @@ mod grid {
|
|||
Interaction::None if cursor.is_over(bounds) => {
|
||||
mouse::Interaction::Crosshair
|
||||
}
|
||||
_ => mouse::Interaction::default(),
|
||||
Interaction::None => mouse::Interaction::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -793,7 +789,7 @@ mod grid {
|
|||
}
|
||||
}
|
||||
|
||||
for (cell, amount) in adjacent_life.iter() {
|
||||
for (cell, amount) in &adjacent_life {
|
||||
match amount {
|
||||
2 => {}
|
||||
3 => {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ impl Controls {
|
|||
pub fn new() -> Controls {
|
||||
Controls {
|
||||
background_color: Color::BLACK,
|
||||
text: Default::default(),
|
||||
text: String::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
{
|
||||
// We clear the frame
|
||||
let mut render_pass = scene.clear(
|
||||
let mut render_pass = Scene::clear(
|
||||
&view,
|
||||
&mut encoder,
|
||||
program.background_color(),
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ impl Scene {
|
|||
}
|
||||
|
||||
pub fn clear<'a>(
|
||||
&self,
|
||||
target: &'a wgpu::TextureView,
|
||||
encoder: &'a mut wgpu::CommandEncoder,
|
||||
background_color: Color,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ impl Default for App {
|
|||
.into_iter()
|
||||
.map(From::from)
|
||||
.collect(),
|
||||
input: Default::default(),
|
||||
input: String::default(),
|
||||
order: Order::Ascending,
|
||||
}
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ impl From<&str> for Item {
|
|||
fn from(s: &str) -> Self {
|
||||
Self {
|
||||
name: s.to_owned(),
|
||||
color: Default::default(),
|
||||
color: Color::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,7 +228,9 @@ mod modal {
|
|||
use iced::alignment::Alignment;
|
||||
use iced::event;
|
||||
use iced::mouse;
|
||||
use iced::{Color, Element, Event, Length, Point, Rectangle, Size};
|
||||
use iced::{
|
||||
BorderRadius, Color, Element, Event, Length, Point, Rectangle, Size,
|
||||
};
|
||||
|
||||
/// A widget that centers a modal element over some base element
|
||||
pub struct Modal<'a, Message, Renderer> {
|
||||
|
|
@ -474,7 +476,7 @@ mod modal {
|
|||
renderer.fill_quad(
|
||||
renderer::Quad {
|
||||
bounds: layout.bounds(),
|
||||
border_radius: Default::default(),
|
||||
border_radius: BorderRadius::default(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -61,11 +61,8 @@ impl Application for Example {
|
|||
fn update(&mut self, message: Message) -> Command<Message> {
|
||||
match message {
|
||||
Message::Split(axis, pane) => {
|
||||
let result = self.panes.split(
|
||||
axis,
|
||||
&pane,
|
||||
Pane::new(self.panes_created),
|
||||
);
|
||||
let result =
|
||||
self.panes.split(axis, pane, Pane::new(self.panes_created));
|
||||
|
||||
if let Some((pane, _)) = result {
|
||||
self.focus = Some(pane);
|
||||
|
|
@ -77,7 +74,7 @@ impl Application for Example {
|
|||
if let Some(pane) = self.focus {
|
||||
let result = self.panes.split(
|
||||
axis,
|
||||
&pane,
|
||||
pane,
|
||||
Pane::new(self.panes_created),
|
||||
);
|
||||
|
||||
|
|
@ -90,8 +87,7 @@ impl Application for Example {
|
|||
}
|
||||
Message::FocusAdjacent(direction) => {
|
||||
if let Some(pane) = self.focus {
|
||||
if let Some(adjacent) =
|
||||
self.panes.adjacent(&pane, direction)
|
||||
if let Some(adjacent) = self.panes.adjacent(pane, direction)
|
||||
{
|
||||
self.focus = Some(adjacent);
|
||||
}
|
||||
|
|
@ -101,37 +97,34 @@ impl Application for Example {
|
|||
self.focus = Some(pane);
|
||||
}
|
||||
Message::Resized(pane_grid::ResizeEvent { split, ratio }) => {
|
||||
self.panes.resize(&split, ratio);
|
||||
self.panes.resize(split, ratio);
|
||||
}
|
||||
Message::Dragged(pane_grid::DragEvent::Dropped {
|
||||
pane,
|
||||
target,
|
||||
}) => {
|
||||
self.panes.drop(&pane, target);
|
||||
self.panes.drop(pane, target);
|
||||
}
|
||||
Message::Dragged(_) => {}
|
||||
Message::TogglePin(pane) => {
|
||||
if let Some(Pane { is_pinned, .. }) = self.panes.get_mut(&pane)
|
||||
{
|
||||
if let Some(Pane { is_pinned, .. }) = self.panes.get_mut(pane) {
|
||||
*is_pinned = !*is_pinned;
|
||||
}
|
||||
}
|
||||
Message::Maximize(pane) => self.panes.maximize(&pane),
|
||||
Message::Maximize(pane) => self.panes.maximize(pane),
|
||||
Message::Restore => {
|
||||
self.panes.restore();
|
||||
}
|
||||
Message::Close(pane) => {
|
||||
if let Some((_, sibling)) = self.panes.close(&pane) {
|
||||
if let Some((_, sibling)) = self.panes.close(pane) {
|
||||
self.focus = Some(sibling);
|
||||
}
|
||||
}
|
||||
Message::CloseFocused => {
|
||||
if let Some(pane) = self.focus {
|
||||
if let Some(Pane { is_pinned, .. }) = self.panes.get(&pane)
|
||||
{
|
||||
if let Some(Pane { is_pinned, .. }) = self.panes.get(pane) {
|
||||
if !is_pinned {
|
||||
if let Some((_, sibling)) = self.panes.close(&pane)
|
||||
{
|
||||
if let Some((_, sibling)) = self.panes.close(pane) {
|
||||
self.focus = Some(sibling);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,11 @@ publish = false
|
|||
|
||||
[dependencies]
|
||||
iced.workspace = true
|
||||
iced.features = ["debug", "image", "advanced"]
|
||||
iced.features = ["debug", "image", "advanced", "tokio"]
|
||||
|
||||
image.workspace = true
|
||||
image.features = ["png"]
|
||||
|
||||
tokio.workspace = true
|
||||
|
||||
image = { workspace = true, features = ["png"]}
|
||||
tracing-subscriber = "0.3"
|
||||
|
|
@ -184,8 +184,8 @@ impl Application for Example {
|
|||
.align_items(Alignment::Center);
|
||||
|
||||
if let Some(crop_error) = &self.crop_error {
|
||||
crop_controls = crop_controls
|
||||
.push(text(format!("Crop error! \n{}", crop_error)));
|
||||
crop_controls =
|
||||
crop_controls.push(text(format!("Crop error! \n{crop_error}")));
|
||||
}
|
||||
|
||||
let mut controls = column![
|
||||
|
|
@ -221,9 +221,9 @@ impl Application for Example {
|
|||
|
||||
if let Some(png_result) = &self.saved_png_path {
|
||||
let msg = match png_result {
|
||||
Ok(path) => format!("Png saved as: {:?}!", path),
|
||||
Ok(path) => format!("Png saved as: {path:?}!"),
|
||||
Err(msg) => {
|
||||
format!("Png could not be saved due to:\n{:?}", msg)
|
||||
format!("Png could not be saved due to:\n{msg:?}")
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -273,15 +273,20 @@ impl Application for Example {
|
|||
|
||||
async fn save_to_png(screenshot: Screenshot) -> Result<String, PngError> {
|
||||
let path = "screenshot.png".to_string();
|
||||
img::save_buffer(
|
||||
&path,
|
||||
&screenshot.bytes,
|
||||
screenshot.size.width,
|
||||
screenshot.size.height,
|
||||
ColorType::Rgba8,
|
||||
)
|
||||
.map(|_| path)
|
||||
.map_err(|err| PngError(format!("{:?}", err)))
|
||||
|
||||
tokio::task::spawn_blocking(move || {
|
||||
img::save_buffer(
|
||||
&path,
|
||||
&screenshot.bytes,
|
||||
screenshot.size.width,
|
||||
screenshot.size.height,
|
||||
ColorType::Rgba8,
|
||||
)
|
||||
.map(|_| path)
|
||||
.map_err(|err| PngError(format!("{err:?}")))
|
||||
})
|
||||
.await
|
||||
.expect("Blocking task to finish")
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
@ -293,10 +298,7 @@ fn numeric_input(
|
|||
) -> Element<'_, Option<u32>> {
|
||||
text_input(
|
||||
placeholder,
|
||||
&value
|
||||
.as_ref()
|
||||
.map(ToString::to_string)
|
||||
.unwrap_or_else(String::new),
|
||||
&value.as_ref().map(ToString::to_string).unwrap_or_default(),
|
||||
)
|
||||
.on_input(move |text| {
|
||||
if text.is_empty() {
|
||||
|
|
|
|||
|
|
@ -389,14 +389,14 @@ impl scrollable::StyleSheet for ScrollbarCustomStyle {
|
|||
background: style
|
||||
.active(&theme::Scrollable::default())
|
||||
.background,
|
||||
border_radius: 0.0.into(),
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Default::default(),
|
||||
border_color: Color::default(),
|
||||
scroller: Scroller {
|
||||
color: Color::from_rgb8(250, 85, 134),
|
||||
border_radius: 0.0.into(),
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Default::default(),
|
||||
border_color: Color::default(),
|
||||
},
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -108,10 +108,7 @@ impl canvas::Program<Message> for SierpinskiGraph {
|
|||
bounds: Rectangle,
|
||||
cursor: mouse::Cursor,
|
||||
) -> (event::Status, Option<Message>) {
|
||||
let cursor_position = if let Some(position) = cursor.position_in(bounds)
|
||||
{
|
||||
position
|
||||
} else {
|
||||
let Some(cursor_position) = cursor.position_in(bounds) else {
|
||||
return (event::Status::Ignored, None);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -117,8 +117,8 @@ impl State {
|
|||
let (width, height) = window::Settings::default().size;
|
||||
|
||||
State {
|
||||
space_cache: Default::default(),
|
||||
system_cache: Default::default(),
|
||||
space_cache: canvas::Cache::default(),
|
||||
system_cache: canvas::Cache::default(),
|
||||
start: now,
|
||||
now,
|
||||
stars: Self::generate_stars(width, height),
|
||||
|
|
|
|||
|
|
@ -105,8 +105,8 @@ impl Application for Example {
|
|||
ByteSize::kb(information.memory_total).to_string();
|
||||
|
||||
let memory_total = text(format!(
|
||||
"Memory (total): {} kb ({})",
|
||||
information.memory_total, memory_readable
|
||||
"Memory (total): {} kb ({memory_readable})",
|
||||
information.memory_total,
|
||||
));
|
||||
|
||||
let memory_text = if let Some(memory_used) =
|
||||
|
|
|
|||
|
|
@ -639,7 +639,7 @@ mod toast {
|
|||
child
|
||||
.as_widget()
|
||||
.operate(state, layout, renderer, operation);
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -415,8 +415,7 @@ fn view_controls(tasks: &[Task], current_filter: Filter) -> Element<Message> {
|
|||
|
||||
row![
|
||||
text(format!(
|
||||
"{} {} left",
|
||||
tasks_left,
|
||||
"{tasks_left} {} left",
|
||||
if tasks_left == 1 { "task" } else { "tasks" }
|
||||
))
|
||||
.width(Length::Fill),
|
||||
|
|
@ -444,7 +443,7 @@ pub enum Filter {
|
|||
}
|
||||
|
||||
impl Filter {
|
||||
fn matches(&self, task: &Task) -> bool {
|
||||
fn matches(self, task: &Task) -> bool {
|
||||
match self {
|
||||
Filter::All => true,
|
||||
Filter::Active => !task.completed,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ impl Sandbox for Example {
|
|||
Position::Right => Position::FollowCursor,
|
||||
};
|
||||
|
||||
self.position = position
|
||||
self.position = position;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ impl<'a> Step {
|
|||
is_showing_icon, ..
|
||||
} = self
|
||||
{
|
||||
*is_showing_icon = toggle
|
||||
*is_showing_icon = toggle;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -482,7 +482,7 @@ impl<'a> Step {
|
|||
column(
|
||||
Language::all()
|
||||
.iter()
|
||||
.cloned()
|
||||
.copied()
|
||||
.map(|language| {
|
||||
radio(
|
||||
language,
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ impl Application for Example {
|
|||
data_row(
|
||||
label,
|
||||
match bounds {
|
||||
Some(bounds) => format!("{:?}", bounds),
|
||||
Some(bounds) => format!("{bounds:?}"),
|
||||
None => "not visible".to_string(),
|
||||
},
|
||||
if bounds
|
||||
|
|
|
|||
|
|
@ -47,10 +47,7 @@ async fn user_connected(ws: WebSocket) {
|
|||
});
|
||||
|
||||
while let Some(result) = user_ws_rx.next().await {
|
||||
let msg = match result {
|
||||
Ok(msg) => msg,
|
||||
Err(_) => break,
|
||||
};
|
||||
let Ok(msg) = result else { break };
|
||||
|
||||
let _ = tx.send(msg).await;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue