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

fix: Prevent flickering metadata when playing animations, color picke… #634

Merged
merged 1 commit into from
Feb 1, 2025
Merged
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
2 changes: 0 additions & 2 deletions src/appstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ pub struct OculanteState {
/// Channel to load images from
pub load_channel: (Sender<PathBuf>, Receiver<PathBuf>),
pub extended_info_channel: (Sender<ExtendedImageInfo>, Receiver<ExtendedImageInfo>),
pub extended_info_loading: bool,
/// The Player, responsible for loading and sending Frames
pub player: Player,
//pub current_texture: Option<TexWrap>,
Expand Down Expand Up @@ -138,7 +137,6 @@ impl<'b> Default for OculanteState {
message_channel: msg_channel,
load_channel: mpsc::channel(),
extended_info_channel: meta_channel,
extended_info_loading: Default::default(),
mouse_delta: Default::default(),
current_texture: Default::default(),
current_image: Default::default(),
Expand Down
60 changes: 31 additions & 29 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,38 +790,38 @@ fn drawe(app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins, state: &mut O

debug!("Got frame: {}", frame.to_string());

match &frame {
Frame::AnimationStart(_) | Frame::Still(_) | Frame::ImageCollectionMember(_) => {
// Something new came in, update scrubber (index slider) and path
if let Some(path) = &state.current_path {
if state.scrubber.has_folder_changed(&path) {
debug!("Folder has changed, creating new scrubber");
state.scrubber = scrubber::Scrubber::new(path);
state.scrubber.wrap = state.persistent_settings.wrap_folder;
} else {
let index = state
.scrubber
.entries
.iter()
.position(|p| p == path)
.unwrap_or_default();
if index < state.scrubber.entries.len() {
state.scrubber.index = index;
}
if matches!(
&frame,
Frame::AnimationStart(_) | Frame::Still(_) | Frame::ImageCollectionMember(_)
) {
// Something new came in, update scrubber (index slider) and path
if let Some(path) = &state.current_path {
if state.scrubber.has_folder_changed(&path) {
debug!("Folder has changed, creating new scrubber");
state.scrubber = scrubber::Scrubber::new(path);
state.scrubber.wrap = state.persistent_settings.wrap_folder;
} else {
let index = state
.scrubber
.entries
.iter()
.position(|p| p == path)
.unwrap_or_default();
if index < state.scrubber.entries.len() {
state.scrubber.index = index;
}
}
}

if let Some(path) = &state.current_path {
if !state.volatile_settings.recent_images.contains(path) {
state
.volatile_settings
.recent_images
.insert(0, path.clone());
state.volatile_settings.recent_images.truncate(12);
}
if let Some(path) = &state.current_path {
if !state.volatile_settings.recent_images.contains(path) {
state
.volatile_settings
.recent_images
.insert(0, path.clone());
state.volatile_settings.recent_images.truncate(12);
}
}
_ => {}
}

match &frame {
Expand Down Expand Up @@ -937,6 +937,10 @@ fn drawe(app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins, state: &mut O
Frame::UpdateTexture => {}
}

if !matches!(frame, Frame::Animation(_, _)) {
state.image_metadata = None;
}

// Deal with everything that sends an image
match frame {
Frame::AnimationStart(img)
Expand Down Expand Up @@ -992,7 +996,6 @@ fn drawe(app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins, state: &mut O
// In those cases, we want the image to stay as it is.
// TODO: PERF: This copies the image buffer. This should also maybe not run for animation frames
// although it looks cool.
state.image_metadata = None;
send_extended_info(
&state.current_image,
&state.current_path,
Expand Down Expand Up @@ -1093,7 +1096,6 @@ fn drawe(app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins, state: &mut O
}

state.pointer_over_ui = ctx.is_pointer_over_area();
// ("using pointer {}", ctx.is_using_pointer());

// if there is interaction on the ui (dragging etc)
// we don't want zoom & pan to work, so we "grab" the pointer
Expand Down
29 changes: 13 additions & 16 deletions src/texture_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use image::DynamicImage;
use log::debug;
use log::error;
use log::warn;
use notan::app::Color;
use notan::draw::*;
use notan::math::{Mat4, Vec4};
use notan::prelude::{BlendMode, Buffer, Graphics, ShaderSource, Texture, TextureFilter};
Expand Down Expand Up @@ -737,7 +738,6 @@ impl TexWrap {
let x_coordinate_end = xy_tex_center.0 + xy_tex_size.0;
let mut y_coordinate = xy_tex_center.1 - xy_tex_size.1;
let y_coordinate_end = xy_tex_center.1 + xy_tex_size.1;
//print!("Start x: {}, y: {}\n",xy_tex_center.0 - xy_tex_size.0,y_coordinate);

while y_coordinate <= y_coordinate_end {
let mut y_coordinate_new = i32::MAX; //increment for y coordinate after x loop
Expand All @@ -757,9 +757,6 @@ impl TexWrap {
shader_active = false;
}

//print!("x: {} y: {} ", x_coordinate, y_coordinate);
//print!("top: {} left: {} ", curr_tex_response.y_tex_top_global, curr_tex_response.x_tex_left_global);
//print!("bottom: {} right: {} \n", curr_tex_response.y_tex_bottom_global, curr_tex_response.x_tex_right_global);

//Handling last texture in a row or col
let curr_tex_end = nalgebra::Vector2::new(
Expand Down Expand Up @@ -797,32 +794,32 @@ impl TexWrap {
curr_ui_curs.x += display_size.x;
last_display_size_y = last_display_size_y.min(display_size.y);
}
//Update y coordinates
//print!("new y: {}, old y: {} \n", y_coordinate_new, y_coordinate);
// Update y coordinates
y_coordinate = y_coordinate_new;
curr_ui_curs.y += last_display_size_y;
}
//print!("\n");
self.remove_draw_shader(draw);

//Draw crosshair
//let stroke_width = 0.5;
// Draw crosshair
let half_width = scale/4.0/*-stroke_width*/;

draw.rect(
(translation_x + width / 2.0 - half_width, translation_y),
(2.0 * half_width, width),
)
/*.fill()
.stroke(stroke_width)
.stroke_color(notan::app::Color { r: (0.0), g: (0.0), b: (0.0), a: (1.0) }) */;
).alpha(0.5);

draw.rect(
(translation_x, translation_y + width / 2.0 - half_width),
(width, 2.0 * half_width),
).alpha(0.5);

draw.rect(
(translation_x + width / 2.0 - half_width, translation_y + width / 2.0 - half_width),
(2.0 * half_width, 2.0* half_width),
)
/* .fill()
.stroke(stroke_width)
.stroke_color(notan::app::Color { r: (0.0), g: (0.0), b: (0.0), a: (1.0) })*/;
.fill_color(Color::from_rgb(0.1, 0.1, 0.1))
.alpha(0.2);

}

pub fn update_textures(
Expand Down
4 changes: 1 addition & 3 deletions src/ui/info_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,10 @@ pub fn info_ui(ctx: &Context, state: &mut OculanteState, _gfx: &mut Graphics) ->

let offset = (ui.available_width() - preview_rect.width())/2.;
preview_rect = preview_rect.translate(vec2(offset, 0.));
//Rendering a placeholder rectangle
// Rendering a placeholder rectangle
ui.painter().rect(preview_rect, ROUNDING, egui::Color32::TRANSPARENT, egui::Stroke::NONE);
bbox_tl = preview_rect.left_top();
bbox_br = preview_rect.right_bottom();

// let preview_rect = egui::Rect::from_min_max(bbox_tl, bbox_br);
ui.advance_cursor_after_rect(preview_rect);
}
ui.add_space(10.);
Expand Down
1 change: 0 additions & 1 deletion src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,6 @@ pub fn drag_area(ui: &mut Ui, state: &mut OculanteState, app: &mut App) {
}
}


pub fn blank_icon(
_ui: &egui::Ui,
_rect: egui::Rect,
Expand Down
Loading