Skip to content

Update notan #666

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
331 changes: 153 additions & 178 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ lexical-sort = "0.3"
libavif-image = { version = "0.14", optional = true }
log = "0.4"
nalgebra = "0.33"
notan = { version = "0.12", default-features = false, features = [
notan = { version = "0.13", default-features = false, features = [
"backend",
"draw",
"drop_files",
"egui",
"clipboard"
] }
egui_plot = "0.27"
egui_plot = "0.31"
egui-notify = "0.19"
egui_extras = { version = "0.31", features = ["image", "file"] }
palette = "0.7"
psd = "0.3"
quickraw = "0.1.6"
Expand Down Expand Up @@ -71,7 +73,6 @@ dark-light = "1.0"
trash = "5.0"
lutgen = { version = "0.10.0", features = ["lutgen-palettes"] }
libheif-rs = { version = "1.0", default-features = false, optional = true }
egui-notify = "0.14"
ktx2 = "0.3.0"
thiserror = "1.0.51"
bitflags = "2.4.1"
Expand All @@ -89,9 +90,8 @@ jpeg2k = { version = "0.9", optional = true, default-features = false, features
"openjpeg-sys",
] }
file-format = "0.25.0"
egui_extras = { version = "0.27.2", features = ["image", "file"] }

libblur = "0.13.5"
egui-modal = "0.3.6"
zip = "2.2.0"
ase-swatch = "0.1.0"
quantette = { version = "0.3.0", features = ["threads"] }
Expand Down
38 changes: 19 additions & 19 deletions src/filebrowser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub fn browse<F: FnMut(&PathBuf)>(
RichText::new(format!("{search_icon}"))
.color(ui.style().visuals.selection.bg_fill),
)
.rounding(ui.get_rounding(BUTTON_HEIGHT_LARGE))
.corner_radius(ui.get_rounding(BUTTON_HEIGHT_LARGE))
.min_size(vec2(BUTTON_HEIGHT_LARGE, BUTTON_HEIGHT_LARGE)), // .shortcut_text("sds")
)
.clicked()
Expand All @@ -212,12 +212,12 @@ pub fn browse<F: FnMut(&PathBuf)>(
if state.search_active {
ui.scope(|ui| {
ui.visuals_mut().selection.stroke = Stroke::NONE;
ui.visuals_mut().widgets.active.rounding =
Rounding::same(ui.get_rounding(BUTTON_HEIGHT_LARGE));
ui.visuals_mut().widgets.inactive.rounding =
Rounding::same(ui.get_rounding(BUTTON_HEIGHT_LARGE));
ui.visuals_mut().widgets.hovered.rounding =
Rounding::same(ui.get_rounding(BUTTON_HEIGHT_LARGE));
ui.visuals_mut().widgets.active.corner_radius =
CornerRadius::same(ui.get_rounding(BUTTON_HEIGHT_LARGE));
ui.visuals_mut().widgets.inactive.corner_radius =
CornerRadius::same(ui.get_rounding(BUTTON_HEIGHT_LARGE));
ui.visuals_mut().widgets.hovered.corner_radius =
CornerRadius::same(ui.get_rounding(BUTTON_HEIGHT_LARGE));
let resp = ui.add(
TextEdit::singleline(&mut state.search_term)
.min_size(vec2(0., BUTTON_HEIGHT_LARGE))
Expand All @@ -240,7 +240,7 @@ pub fn browse<F: FnMut(&PathBuf)>(
RichText::new(format!("{CHEVRON_UP}"))
.color(ui.style().visuals.selection.bg_fill),
)
.rounding(ui.get_rounding(BUTTON_HEIGHT_LARGE))
.corner_radius(ui.get_rounding(BUTTON_HEIGHT_LARGE))
.min_size(vec2(BUTTON_HEIGHT_LARGE, BUTTON_HEIGHT_LARGE)), // .shortcut_text("sds")
)
.clicked()
Expand All @@ -258,7 +258,7 @@ pub fn browse<F: FnMut(&PathBuf)>(
egui::Button::new(
RichText::new(path_icon).color(ui.style().visuals.selection.bg_fill),
)
.rounding(ui.get_rounding(BUTTON_HEIGHT_LARGE))
.corner_radius(ui.get_rounding(BUTTON_HEIGHT_LARGE))
.min_size(vec2(BUTTON_HEIGHT_LARGE, BUTTON_HEIGHT_LARGE)), // .shortcut_text("sds")
)
.clicked()
Expand Down Expand Up @@ -306,12 +306,12 @@ pub fn browse<F: FnMut(&PathBuf)>(
* ui.available_width()) as usize;
let mut path_string = path.to_string_lossy().to_string();
ui.visuals_mut().selection.stroke = Stroke::NONE;
ui.visuals_mut().widgets.active.rounding =
Rounding::same(ui.get_rounding(BUTTON_HEIGHT_LARGE));
ui.visuals_mut().widgets.inactive.rounding =
Rounding::same(ui.get_rounding(BUTTON_HEIGHT_LARGE));
ui.visuals_mut().widgets.hovered.rounding =
Rounding::same(ui.get_rounding(BUTTON_HEIGHT_LARGE));
ui.visuals_mut().widgets.active.corner_radius =
CornerRadius::same(ui.get_rounding(BUTTON_HEIGHT_LARGE));
ui.visuals_mut().widgets.inactive.corner_radius =
CornerRadius::same(ui.get_rounding(BUTTON_HEIGHT_LARGE));
ui.visuals_mut().widgets.hovered.corner_radius =
CornerRadius::same(ui.get_rounding(BUTTON_HEIGHT_LARGE));
let resp = ui.add(
TextEdit::singleline(&mut path_string)
.min_size(vec2(0., BUTTON_HEIGHT_LARGE))
Expand Down Expand Up @@ -426,7 +426,7 @@ pub fn browse<F: FnMut(&PathBuf)>(
if ui
.add(
egui::Button::new(RichText::new(PLUS).color(col))
.rounding(ui.get_rounding(BUTTON_HEIGHT_LARGE))
.corner_radius(ui.get_rounding(BUTTON_HEIGHT_LARGE))
.fill(Color32::TRANSPARENT)
.frame(true)
.stroke(Stroke::new(2., col))
Expand Down Expand Up @@ -457,10 +457,10 @@ pub fn browse<F: FnMut(&PathBuf)>(
.min(num_entries as f32);
let num_rows = (num_entries as f32 / (thumbs_per_row).max(1.)).ceil() as usize;

egui::Frame::none()
egui::Frame::new()
.fill(panel_bg_color)
.rounding(ui.style().visuals.widgets.active.rounding * 2.0)
.inner_margin(Margin::same(10.))
.corner_radius(ui.style().visuals.widgets.active.corner_radius * 2.0)
.inner_margin(Margin::same(10))
.show(ui, |ui| {
egui::ScrollArea::new([false, true])
.min_scrolled_height(400.)
Expand Down
72 changes: 34 additions & 38 deletions src/image_editing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use log::{debug, error, info};
use nalgebra::{Vector2, Vector4};
use notan::egui::epaint::PathShape;
use notan::egui::{
self, lerp, vec2, Align2, Color32, DragValue, FontId, Id, Pos2, Rect, Sense, Stroke, Vec2,
self, lerp, vec2, Align2, Color32, DragValue, FontId, Id, Pos2, Rect, Sense, Stroke,
StrokeKind, Vec2,
};
use notan::egui::{Response, Ui};
use palette::{rgb::Rgb, Hsl, IntoColor};
Expand Down Expand Up @@ -305,7 +306,7 @@ impl ImageOperation {
match self {
Self::ColorConverter(ct) => {
let mut x = ui.allocate_response(vec2(0.0, 0.0), Sense::click_and_drag());
egui::ComboBox::from_id_source("color_types")
egui::ComboBox::from_id_salt("color_types")
.selected_text(ct.to_string())
.show_ui(ui, |ui| {
for t in ColorTypeExt::iter() {
Expand Down Expand Up @@ -367,10 +368,7 @@ impl ImageOperation {
for triplet in val.chunks_mut(3) {
ui.horizontal(|ui| {
for v in triplet {
if ui
.add(egui::DragValue::new(v).clamp_range(-255..=255))
.changed()
{
if ui.add(egui::DragValue::new(v).range(-255..=255)).changed() {
x.mark_changed();
}
ui.add_space(30.);
Expand Down Expand Up @@ -483,7 +481,7 @@ impl ImageOperation {
let combo_width = 50.;

ui.horizontal(|ui| {
egui::ComboBox::from_id_source(format!("ccopy 0 {}", val.0 as usize))
egui::ComboBox::from_id_salt(format!("ccopy 0 {}", val.0 as usize))
.selected_text(format!("{:?}", val.0))
.width(combo_width)
.show_ui(ui, |ui| {
Expand All @@ -492,14 +490,14 @@ impl ImageOperation {
.selectable_value(&mut val.0, f, format!("{f:?}"))
.clicked()
{
r.changed = true;
r.mark_changed();
}
}
});

ui.label("=");

egui::ComboBox::from_id_source(format!("ccopy 1 {}", val.1 as usize))
egui::ComboBox::from_id_salt(format!("ccopy 1 {}", val.1 as usize))
.selected_text(format!("{:?}", val.1))
.width(combo_width)
.show_ui(ui, |ui| {
Expand All @@ -508,7 +506,7 @@ impl ImageOperation {
.selectable_value(&mut val.1, f, format!("{f:?}"))
.clicked()
{
r.changed = true;
r.mark_changed();
}
}
});
Expand All @@ -517,26 +515,20 @@ impl ImageOperation {
r
}
Self::HSV(val) => {
let mut r = ui.add(DragValue::new(&mut val.0).clamp_range(0..=360));
if ui
.add(DragValue::new(&mut val.1).clamp_range(0..=200))
.changed()
{
r.changed = true;
let mut r = ui.add(DragValue::new(&mut val.0).range(0..=360));
if ui.add(DragValue::new(&mut val.1).range(0..=200)).changed() {
r.mark_changed();
}
if ui
.add(DragValue::new(&mut val.2).clamp_range(0..=200))
.changed()
{
r.changed = true;
if ui.add(DragValue::new(&mut val.2).range(0..=200)).changed() {
r.mark_changed();
}
r
}
Self::Blur(val) => ui.styled_slider(val, 0..=254),
Self::Noise { amt, mono } => {
let mut r = ui.styled_slider(amt, 0..=100);
if ui.styled_checkbox(mono, "Grey").changed() {
r.changed = true
r.mark_changed();
}
r
}
Expand Down Expand Up @@ -669,7 +661,7 @@ impl ImageOperation {
.add(
egui::DragValue::new(&mut p.pos)
.speed(0.1)
.clamp_range(0..=255)
.range(0..=255)
.custom_formatter(|n, _| {
let n = n / 256.;
format!("{n:.2}")
Expand Down Expand Up @@ -710,7 +702,7 @@ impl ImageOperation {
Self::Flip(horizontal) => {
let mut r = ui.radio_value(horizontal, true, "V");
if ui.radio_value(horizontal, false, "H").changed() {
r.changed = true
r.mark_changed();
}
r
}
Expand Down Expand Up @@ -837,7 +829,7 @@ impl ImageOperation {
.clicked()
{
ui.ctx().data_mut(|w| w.insert_temp(id, true));
r.changed = true;
r.mark_changed();
}
}

Expand Down Expand Up @@ -917,11 +909,13 @@ impl ImageOperation {
rect,
0.0,
Stroke::new(*width as f32, Color32::BLACK),
StrokeKind::Inside,
);
ui.painter().rect_stroke(
rect,
0.0,
Stroke::new(*width as f32 / 2., Color32::WHITE),
StrokeKind::Inside,
);

ui.painter().text(
Expand Down Expand Up @@ -995,37 +989,37 @@ impl ImageOperation {
egui::vec2(available_w_single_spacing / 4., ui.available_height()),
egui::DragValue::new(&mut float_bounds[0])
.speed(0.004)
.clamp_range(0.0..=1.0)
.range(0.0..=1.0)
// X
.prefix("⏵ "),
);
let r2 = ui.add_sized(
egui::vec2(available_w_single_spacing / 4., ui.available_height()),
egui::DragValue::new(&mut float_bounds[2])
.speed(0.004)
.clamp_range(0.0..=1.0)
.range(0.0..=1.0)
// WIDTH
.prefix("⏴ "),
);
let r3 = ui.add_sized(
egui::vec2(available_w_single_spacing / 4., ui.available_height()),
egui::DragValue::new(&mut float_bounds[1])
.speed(0.004)
.clamp_range(0.0..=1.0)
.range(0.0..=1.0)
// Y
.prefix("⏷ "),
);
let r4 = ui.add_sized(
egui::vec2(available_w_single_spacing / 4., ui.available_height()),
egui::DragValue::new(&mut float_bounds[3])
.speed(0.004)
.clamp_range(0.0..=1.0)
.range(0.0..=1.0)
// HEIGHT
.prefix("⏶ "),
);
// TODO rewrite with any
if r2.changed() || r3.changed() || r4.changed() {
r1.changed = true;
r1.mark_changed();
}
if r1.changed() {
// commit back changed vals
Expand All @@ -1044,20 +1038,20 @@ impl ImageOperation {
egui::vec2(available_w_single_spacing / 4., ui.available_height()),
egui::DragValue::new(&mut bounds.0)
// .speed(2.)
.clamp_range(-128..=128)
.range(-128..=128)
.prefix("dark "),
);
let r2 = ui.add_sized(
egui::vec2(available_w_single_spacing / 4., ui.available_height()),
egui::DragValue::new(&mut bounds.1)
.speed(2.)
.clamp_range(64..=2000)
.range(64..=2000)
.prefix("bright "),
);

// TODO rewrite with any
if r2.changed() {
r1.changed = true;
r1.mark_changed();
}
r1
})
Expand Down Expand Up @@ -1123,13 +1117,13 @@ impl ImageOperation {
let r0 = ui.add(
egui::DragValue::new(&mut dimensions.0)
.speed(4.)
.clamp_range(1..=10000)
.range(1..=10000)
.prefix("X "),
);
let r1 = ui.add(
egui::DragValue::new(&mut dimensions.1)
.speed(4.)
.clamp_range(1..=10000)
.range(1..=10000)
.prefix("Y "),
);

Expand All @@ -1155,10 +1149,12 @@ impl ImageOperation {
// Since all operators are processed the same, we use the hack to emit `changed` just on release.
// Users dragging the resize values will now only trigger a resize on release, which feels
// more snappy.
r.changed = r0.drag_stopped() || r1.drag_stopped() || r2.changed();
if r0.drag_stopped() || r1.drag_stopped() || r2.changed() {
r.mark_changed();
}
});

egui::ComboBox::from_id_source("filter")
egui::ComboBox::from_id_salt("filter")
.selected_text(format!("{filter:?}"))
.show_ui(ui, |ui| {
for f in [
Expand All @@ -1170,7 +1166,7 @@ impl ImageOperation {
ScaleFilter::Lanczos3,
] {
if ui.selectable_value(filter, f, format!("{f:?}")).clicked() {
r.changed = true;
r.mark_changed();
}
}
});
Expand Down
Loading
Loading