feat: f to switch FilterMethod
useful to scale pixelart images nicely. This makes me consider expanding the status bar to include info; partially because I don't use window decorations usually (so I don't see the info in the title)
This commit is contained in:
parent
e7e1400c3a
commit
f279c3aa15
1 changed files with 8 additions and 0 deletions
|
|
@ -20,6 +20,7 @@ enum Message {
|
||||||
struct State {
|
struct State {
|
||||||
image: Option<RgbaImage>,
|
image: Option<RgbaImage>,
|
||||||
image_display: Option<widget::image::Allocation>,
|
image_display: Option<widget::image::Allocation>,
|
||||||
|
image_filter: widget::image::FilterMethod,
|
||||||
|
|
||||||
error: Option<String>,
|
error: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
@ -40,6 +41,7 @@ impl State {
|
||||||
widget::column([
|
widget::column([
|
||||||
if let Some(allocation) = self.image_display.as_ref() {
|
if let Some(allocation) = self.image_display.as_ref() {
|
||||||
widget::image::viewer(allocation.handle().clone())
|
widget::image::viewer(allocation.handle().clone())
|
||||||
|
.filter_method(self.image_filter)
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.height(Length::Fill)
|
.height(Length::Fill)
|
||||||
.into()
|
.into()
|
||||||
|
|
@ -107,6 +109,12 @@ impl State {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Key::Character("f") => {
|
||||||
|
self.image_filter = match self.image_filter {
|
||||||
|
widget::image::FilterMethod::Linear => widget::image::FilterMethod::Nearest,
|
||||||
|
widget::image::FilterMethod::Nearest => widget::image::FilterMethod::Linear,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Key::Character("s") => {
|
Key::Character("s") => {
|
||||||
self.save_image();
|
self.save_image();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue