app: fix warnings

This commit is contained in:
darkfi
2025-10-19 14:23:34 +02:00
parent 7fd6219ac0
commit 6919ef8782
9 changed files with 53 additions and 61 deletions

View File

@@ -134,7 +134,7 @@ impl App {
self.sg_root.link(window.clone());
self.sg_root.link(setting_root.clone());
schema::test::make(&self, window.clone(), &i18n_fish).await;
schema::make(&self, window.clone(), &i18n_fish).await;
//settings::make(&self, window, self.ex.clone()).await;

View File

@@ -123,6 +123,7 @@ pub fn create_gesture(name: &str) -> SceneNode {
node
}
#[allow(dead_code)]
pub fn create_image(name: &str) -> SceneNode {
t!("create_image({name})");
let mut node = SceneNode::new(name, SceneNodeType::Image);
@@ -360,6 +361,7 @@ pub fn create_baseedit(name: &str) -> SceneNode {
node
}
#[allow(dead_code)]
pub fn create_singleline_edit(name: &str) -> SceneNode {
// No additional properties to add
create_baseedit(name)

View File

@@ -22,7 +22,7 @@ use std::fs::File;
use crate::{
app::{
node::{create_image, create_layer, create_shortcut, create_vector_art, create_video},
node::{create_layer, create_shortcut, create_vector_art, create_video},
App,
},
expr::{self, Compiler},
@@ -30,14 +30,14 @@ use crate::{
prop::{PropertyAtomicGuard, Role},
scene::{SceneNodePtr, Slot},
shape,
ui::{emoji_picker, Image, Layer, Shortcut, VectorArt, VectorShape, Video},
ui::{emoji_picker, Layer, Shortcut, VectorArt, VectorShape, Video},
util::i18n::I18nBabelFish,
};
mod chat;
mod menu;
//mod settings;
pub mod test;
//pub mod test;
const COLOR_SCHEME: ColorScheme = ColorScheme::DarkMode;
//const COLOR_SCHEME: ColorScheme = ColorScheme::PaperLight;
@@ -55,7 +55,7 @@ mod ui_consts {
use crate::android::{get_appdata_path, get_external_storage_path};
use std::path::PathBuf;
pub const BG_PATH: &str = "bg.png";
//pub const BG_PATH: &str = "bg.png";
pub const VID_PATH: &str = "forest/forest_{frame}.png";
pub use super::android_ui_consts::*;
@@ -80,7 +80,7 @@ mod ui_consts {
mod desktop_paths {
use std::path::PathBuf;
pub const BG_PATH: &str = "assets/bg.png";
//pub const BG_PATH: &str = "assets/bg.png";
pub const VID_PATH: &str = "assets/forest/forest_{frame}.png";
pub fn get_chatdb_path() -> PathBuf {

View File

@@ -16,25 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use async_trait::async_trait;
use darkfi_serial::{
AsyncEncodable, AsyncWrite, Encodable, FutAsyncWriteExt, SerialEncodable, VarInt,
};
use parking_lot::RwLock;
use std::{
cell::RefCell,
collections::HashMap,
io::Write,
sync::{
atomic::{AtomicU32, Ordering},
Arc,
},
};
use std::collections::HashMap;
use super::{BufferId, DrawCall, GfxDrawCall, TextureId};
macro_rules! t { ($($arg:tt)*) => { trace!(target: "gfx::anim", $($arg)*); } }
#[derive(Debug, Clone)]
pub struct Frame {
/// Duration of this frame in ms
@@ -84,17 +69,34 @@ impl GfxSeqAnim {
//t!("got frame {frame_idx}");
}
fn curr_frame(&self) -> Option<&GfxFrame> {
assert!(self.current_idx < self.frames.len());
self.frames[self.current_idx].as_ref()
}
pub fn tick(&mut self) -> Option<GfxDrawCall> {
//t!("tick");
let elapsed = self.timer.elapsed();
assert!(self.current_idx < self.frames.len());
let frame = &self.frames[self.current_idx];
let Some(frame) = frame else {
if self.curr_frame().is_none() {
assert_eq!(self.current_idx, 0);
return None
};
self.increment();
let curr_frame = self.curr_frame().unwrap().clone();
Some(curr_frame.dc)
}
fn increment(&mut self) {
// One shot anims dont loop
if self.oneshot && self.current_idx + 1 == self.frames.len() {
return
}
let elapsed = self.timer.elapsed();
let frame = self.curr_frame().unwrap();
let curr_duration = frame.duration;
if elapsed >= curr_duration {
let next_idx = (self.current_idx + 1) % self.frames.len();
// Only advance when the next frame is Some
@@ -105,9 +107,6 @@ impl GfxSeqAnim {
self.timer = std::time::Instant::now();
}
}
let curr_frame = self.frames[self.current_idx].clone().unwrap();
Some(curr_frame.dc)
}
}

View File

@@ -31,7 +31,6 @@ use miniquad::{
};
use parking_lot::Mutex as SyncMutex;
use std::{
cell::RefCell,
collections::HashMap,
fs::File,
io::Write,
@@ -54,7 +53,7 @@ use trax::get_trax;
use crate::{
error::{Error, Result},
prop::{BatchGuardId, PropertyAtomicGuard},
ExecutorPtr, GOD,
GOD,
};
// This is very noisy so suppress output by default
@@ -925,7 +924,6 @@ struct Stage {
pruner: PruneMethodHeap,
screen_was_off: bool,
ex: ExecutorPtr,
#[cfg(target_os = "android")]
refresh_task: Option<smol::Task<()>>,
}
@@ -1028,7 +1026,6 @@ impl Stage {
pruner: PruneMethodHeap::new(epoch),
screen_was_off: false,
ex,
#[cfg(target_os = "android")]
refresh_task: None,
}
@@ -1322,13 +1319,13 @@ impl Stage {
GraphicsMethod::DeleteBuffer((gbuff_id, tag, buftype)) => {
trax.del_buf(epoch, *gbuff_id, *tag, *buftype);
}
GraphicsMethod::NewSeqAnim { id, frames_len, oneshot, tag } => {
GraphicsMethod::NewSeqAnim { .. } => {
//trax.put_idxs(epoch, idxs.clone(), *gbuff_id, *tag, 1);
}
GraphicsMethod::UpdateSeqAnim { .. } => {
//trax.put_idxs(epoch, idxs.clone(), *gbuff_id, *tag, 1);
}
GraphicsMethod::DeleteSeqAnim((ganim_id, tag)) => {
GraphicsMethod::DeleteSeqAnim(..) => {
//trax.del_buf(epoch, *gbuff_id, *tag, *buftype);
}
GraphicsMethod::ReplaceGfxDrawCalls { batch_id, timest, dcs } => {
@@ -1415,13 +1412,13 @@ impl PruneMethodHeap {
self.del.push(method);
}
}
GraphicsMethod::NewSeqAnim { id: _, frames_len, oneshot, tag } => {
GraphicsMethod::NewSeqAnim { .. } => {
//self.new_buf.insert(gbuff_id, method);
}
GraphicsMethod::UpdateSeqAnim { .. } => {
//self.new_buf.insert(gbuff_id, method);
}
GraphicsMethod::DeleteSeqAnim((ganim_id, _)) => {
GraphicsMethod::DeleteSeqAnim(..) => {
//if self.new_buf.remove(&gbuff_id).is_none() {
// self.del.push(method);
//}

View File

@@ -29,7 +29,7 @@ use crate::{
use super::EditorHandle;
macro_rules! t { ($($arg:tt)*) => { trace!(target: "ui::edit::behave", $($arg)*); } }
//macro_rules! t { ($($arg:tt)*) => { trace!(target: "ui::edit::behave", $($arg)*); } }
pub enum BaseEditType {
SingleLine,
@@ -43,7 +43,7 @@ pub(super) trait EditorBehavior: Send + Sync {
/// Whenever the cursor is modified this MUST be called
/// to recalculate the scroll value.
/// Must call redraw after this.
async fn apply_cursor_scroll(&self, atom: &mut PropertyAtomicGuard);
async fn apply_cursor_scroll(&self);
fn scroll(&self) -> Point;
@@ -165,7 +165,7 @@ impl EditorBehavior for MultiLine {
.unwrap();
}
async fn apply_cursor_scroll(&self, atom: &mut PropertyAtomicGuard) {
async fn apply_cursor_scroll(&self) {
//let pad_top = self.padding_top();
let pad_bot = self.padding_bottom();
@@ -278,17 +278,16 @@ impl EditorBehavior for SingleLine {
.unwrap();
}
async fn apply_cursor_scroll(&self, atom: &mut PropertyAtomicGuard) {
async fn apply_cursor_scroll(&self) {
let pad_right = self.padding.get_f32(1).unwrap();
let pad_left = self.padding.get_f32(3).unwrap();
let mut scroll = self.scroll.load(Ordering::Relaxed);
let scroll = self.scroll.load(Ordering::Relaxed);
let rect_w = self.rect.get_width() - pad_right;
let cursor_x0 = self.lock_editor().await.get_cursor_pos().x + pad_left;
let cursor_x1 = cursor_x0 + self.cursor_width.get();
if cursor_x0 < scroll {
assert!(cursor_x0 >= 0.);
scroll = cursor_x0.max(0.);
self.scroll.store(cursor_x0, Ordering::Release);
} else if cursor_x1 > rect_w + scroll {
let max_scroll = self.max_scroll().await;

View File

@@ -21,7 +21,7 @@ use async_trait::async_trait;
use atomic_float::AtomicF32;
use darkfi::system::msleep;
use darkfi_serial::Decodable;
use futures::{select, FutureExt};
use futures::FutureExt;
use miniquad::{KeyCode, KeyMods, MouseButton, TouchPhase};
use parking_lot::Mutex as SyncMutex;
use rand::{rngs::OsRng, Rng};
@@ -540,7 +540,7 @@ impl BaseEdit {
if let Some(txt) = miniquad::window::clipboard_get() {
self.insert(&txt, atom).await;
// Maybe insert should call this?
self.behave.apply_cursor_scroll(atom).await;
self.behave.apply_cursor_scroll().await;
}
}
}
@@ -676,7 +676,7 @@ impl BaseEdit {
drop(editor);
drop(txt_ctx);
self.behave.apply_cursor_scroll(atom).await;
self.behave.apply_cursor_scroll().await;
self.pause_blinking();
self.redraw(atom).await;
@@ -821,10 +821,6 @@ impl BaseEdit {
self.touch_info.lock().state = TouchStateAction::Select;
}
TouchStateAction::DragSelectHandle { side } => {
let handle_descent = self.handle_descent.get();
// New code
let rect = self.rect.get();
let is_touch_hover = rect.contains(touch_pos);
@@ -933,7 +929,7 @@ impl BaseEdit {
sel_side = side;
}
let (seltext, sel_start, sel_end) = {
let seltext = {
let mut editor = self.lock_editor().await;
// The below lines rely on parley driver which android does not use
@@ -941,7 +937,7 @@ impl BaseEdit {
//let mut drv = editor.driver(&mut txt_ctx).unwrap();
//drv.extend_selection_to_point(clip_mouse_pos.x, clip_mouse_pos.y);
let layout = editor.layout();
let mut prev_sel = editor.selection(sel_side);
let prev_sel = editor.selection(sel_side);
let sel = prev_sel.extend_to_point(layout, clip_mouse_pos.x, clip_mouse_pos.y);
let (mut prev_start, mut prev_end) =
(prev_sel.anchor().index(), prev_sel.focus().index());
@@ -981,7 +977,7 @@ impl BaseEdit {
editor.set_selection(start, end);
editor.refresh().await;
(editor.selected_text(), start, end)
editor.selected_text()
};
//d!("Select {seltext:?} from {clip_mouse_pos:?} (unclipped: {mouse_pos:?}) to ({sel_start}, {sel_end})");
// Android editor impl detail: selection disappears when anchor == index
@@ -999,7 +995,7 @@ impl BaseEdit {
}
self.pause_blinking();
//self.behave.apply_cursor_scroll(atom).await;
//self.behave.apply_cursor_scroll().await;
self.redraw_cursor(atom.batch_id).await;
self.redraw_select(atom.batch_id).await;
}
@@ -1021,8 +1017,6 @@ impl BaseEdit {
let timest = unixtime();
let rect = self.rect.get();
let phone_sel_instrs = self.regen_phone_select_handle_mesh().await;
let mut content_instrs = vec![DrawInstruction::ApplyView(rect.with_zero_pos())];
let mut bg_instrs = self.regen_bg_mesh();
content_instrs.append(&mut bg_instrs);
@@ -1329,7 +1323,7 @@ impl BaseEdit {
editor.on_buffer_changed(atom).await;
drop(editor);
self.behave.apply_cursor_scroll(atom).await;
self.behave.apply_cursor_scroll().await;
}
AndroidSuggestEvent::FinishCompose => {
let mut editor = self.lock_editor().await;
@@ -1597,7 +1591,7 @@ impl UIObject for BaseEdit {
t!("Key {:?} has {} actions", key, actions);
let key_str = key.to_string().repeat(actions as usize);
self.insert(&key_str, atom).await;
self.behave.apply_cursor_scroll(atom).await;
self.behave.apply_cursor_scroll().await;
self.redraw(atom).await;
true
}
@@ -1703,7 +1697,7 @@ impl UIObject for BaseEdit {
false
}
async fn handle_mouse_move(&self, mut mouse_pos: Point) -> bool {
async fn handle_mouse_move(&self, mouse_pos: Point) -> bool {
if !self.is_active.get() {
return false
}

View File

@@ -40,6 +40,7 @@ pub use emoji_picker::{EmojiPicker, EmojiPickerPtr};
mod gesture;
pub use gesture::GesturePtr;
mod image;
#[allow(unused_imports)]
pub use image::{Image, ImagePtr};
mod video;
pub use video::{Video, VideoPtr};

View File

@@ -18,7 +18,7 @@
use async_trait::async_trait;
use image::ImageReader;
use parking_lot::{Mutex as SyncMutex, RwLock};
use parking_lot::Mutex as SyncMutex;
use rand::{rngs::OsRng, Rng};
use std::{
io::Cursor,
@@ -185,7 +185,7 @@ impl Video {
let mut vid_data = vid_data.lock();
// vid_data becomes None if the stop() is called. In which case
// we just stop loading and return from this thread.
let Some(mut vid_data) = vid_data.as_mut() else { return };
let Some(vid_data) = vid_data.as_mut() else { return };
vid_data.textures[frame_idx] = Some(texture.clone());
// broadcast
textures_pub.try_broadcast((frame_idx, texture)).unwrap();