app: fix warnings

This commit is contained in:
jkds
2026-01-07 08:43:26 +01:00
parent 27b842fa97
commit a62a809265
35 changed files with 87 additions and 168 deletions

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use miniquad::native::android::{self, ndk_sys, ndk_utils};
use miniquad::native::android::ndk_sys;
use parking_lot::Mutex as SyncMutex;
use std::sync::LazyLock;

View File

@@ -16,9 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use miniquad::native::android::{self, ndk_sys, ndk_utils};
use parking_lot::Mutex as SyncMutex;
use std::{collections::HashMap, path::PathBuf, sync::LazyLock};
use miniquad::native::android::{self, ndk_utils};
use std::path::PathBuf;
pub mod insets;
pub mod textinput;

View File

@@ -16,12 +16,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use miniquad::native::android::{self, ndk_sys, ndk_utils::*};
use parking_lot::{Mutex as SyncMutex, RwLock};
use std::{
ffi::CString,
sync::{Arc, OnceLock},
use miniquad::native::android::{
ndk_sys,
ndk_utils::{call_bool_method, call_void_method, get_utf_str, new_global_ref},
};
use parking_lot::{Mutex as SyncMutex, RwLock};
use std::{ffi::CString, sync::OnceLock};
use super::{super::util::get_jni_env, AndroidTextInputState, SharedStatePtr};
@@ -49,7 +49,7 @@ pub struct GameTextInput {
input_connection_class: ndk_sys::jclass,
state_class: ndk_sys::jclass,
set_soft_keyboard_active_method: ndk_sys::jmethodID,
restart_input_method: ndk_sys::jmethodID,
//restart_input_method: ndk_sys::jmethodID,
state_constructor: ndk_sys::jmethodID,
state_class_info: StateClassInfo,
}
@@ -88,13 +88,13 @@ impl GameTextInput {
set_soft_keyboard_active_sig.as_ptr() as _,
);
let restart_input_sig = b"()V\0";
/*let restart_input_sig = b"()V\0";
let restart_input_method = get_method_id(
env,
input_connection_class,
b"restartInput\0".as_ptr() as _,
restart_input_sig.as_ptr() as _,
);
);*/
let state_class = new_global_ref!(env, state_java_class) as ndk_sys::jclass;
@@ -153,7 +153,7 @@ impl GameTextInput {
input_connection_class,
state_class,
set_soft_keyboard_active_method,
restart_input_method,
//restart_input_method,
state_constructor,
state_class_info,
}
@@ -272,7 +272,7 @@ impl GameTextInput {
}
}
pub fn restart_input(&self) {
/*pub fn restart_input(&self) {
let Some(input_connection) = *self.input_connection.read() else {
w!("restart_input() - no input_connection set");
return
@@ -282,7 +282,7 @@ impl GameTextInput {
let call_void_method = (**env).CallVoidMethod.unwrap();
call_void_method(env, input_connection, self.restart_input_method);
}
}
}*/
fn state_to_java(&self, state: &AndroidTextInputState) -> ndk_sys::jobject {
unsafe {

View File

@@ -23,7 +23,7 @@ use std::sync::Arc;
mod gametextinput;
mod jni;
use gametextinput::{GameTextInput, GAME_TEXT_INPUT};
use gametextinput::GAME_TEXT_INPUT;
macro_rules! t { ($($arg:tt)*) => { trace!(target: "android::textinput", $($arg)*); } }

View File

@@ -16,8 +16,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use chrono::{NaiveDate, NaiveDateTime};
use darkfi_serial::Encodable;
use sled_overlay::sled;
use smol::Task;
use std::sync::{Arc, Mutex as SyncMutex};
@@ -29,9 +27,9 @@ use crate::{
error::Error,
gfx::{gfxtag, EpochIndex, GraphicsEventPublisherPtr, RenderApi},
plugin::PluginSettings,
prop::{Property, PropertyAtomicGuard, PropertySubType, PropertyType, PropertyValue, Role},
prop::{PropertyAtomicGuard, PropertyValue, Role},
scene::{Pimpl, SceneNode, SceneNodePtr, SceneNodeType},
ui::{chatview, Window},
ui::Window,
util::i18n::I18nBabelFish,
ExecutorPtr,
};
@@ -114,7 +112,7 @@ impl App {
let i18n_fish = self.setup_locale();
let mut window = create_window("window");
let window = create_window("window");
#[cfg(target_os = "android")]
{
let insets = android::insets::get_insets();

View File

@@ -21,8 +21,6 @@ use crate::{
scene::{CallArgType, SceneNode, SceneNodeType},
};
macro_rules! t { ($($arg:tt)*) => { trace!(target: "app::node", $($arg)*); } }
pub fn create_window(name: &str) -> SceneNode {
let mut node = SceneNode::new(name, SceneNodeType::Window);

View File

@@ -17,14 +17,13 @@
*/
use darkfi::system::msleep;
use darkfi_serial::Encodable;
use indoc::indoc;
use sled_overlay::sled;
use std::fs::File;
use crate::{
app::{
node::{create_button, create_layer, create_shortcut, create_vector_art, create_video},
node::{create_button, create_layer, create_vector_art, create_video},
App,
},
expr::{self, Compiler},
@@ -32,8 +31,8 @@ use crate::{
prop::{PropertyAtomicGuard, Role},
scene::{SceneNodePtr, Slot},
shape,
ui::{emoji_picker, Button, Layer, ShapeVertex, Shortcut, VectorArt, VectorShape, Video},
util::{i18n::I18nBabelFish, spawn_thread},
ui::{emoji_picker, Button, Layer, VectorArt, VectorShape, Video},
util::i18n::I18nBabelFish,
};
mod chat;
@@ -72,10 +71,6 @@ mod ui_consts {
get_appdata_path().join("first_time")
}
pub fn get_window_scale_filename() -> PathBuf {
get_appdata_path().join("window_scale")
}
pub fn get_settingsdb_path() -> PathBuf {
get_appdata_path().join("settings")
}
@@ -96,10 +91,6 @@ mod desktop_paths {
dirs::cache_dir().unwrap().join("darkfi/app/first_time")
}
pub fn get_window_scale_filename() -> PathBuf {
dirs::cache_dir().unwrap().join("darkfi/app/window_scale")
}
pub fn get_settingsdb_path() -> PathBuf {
dirs::cache_dir().unwrap().join("darkfi/app/settings")
}
@@ -591,10 +582,10 @@ pub async fn make(app: &App, window: SceneNodePtr, i18n_fish: &I18nBabelFish) {
emoji_picker::EmojiMeshes::new(app.render_api.clone(), EMOJI_PICKER_ICON_SIZE);
let emoji_meshes2 = emoji_meshes.clone();
app.ex.spawn(async move {
let _ = std::thread::spawn(move || {
for i in (0..500).step_by(20) {
for j in i..(i + 20) {
emoji_meshes2.lock().await.get(j).await;
emoji_meshes2.lock().get(j);
}
}
});

View File

@@ -21,17 +21,14 @@ use sled_overlay::sled;
use super::chat::populate_tree;
use crate::{
app::{
node::{
create_chatview, create_layer, create_singleline_edit, create_text, create_vector_art,
create_video,
},
node::{create_chatview, create_layer, create_text, create_vector_art},
App,
},
expr::{self, Compiler},
mesh::COLOR_PURPLE,
prop::{PropertyAtomicGuard, PropertyFloat32, Role},
scene::SceneNodePtr,
ui::{BaseEdit, BaseEditType, ChatView, Layer, Text, VectorArt, VectorShape, Video},
ui::{ChatView, Layer, Text, VectorArt, VectorShape},
util::i18n::I18nBabelFish,
};
@@ -46,7 +43,7 @@ mod ui_consts {
get_appdata_path().join("chatdb")
}
//pub const KING_PATH: &str = "king.png";
pub const VID_PATH: &str = "forest_720x1280.mp4";
//pub const VID_PATH: &str = "forest_720x1280.mp4";
}
#[cfg(not(target_os = "android"))]
@@ -57,7 +54,7 @@ mod ui_consts {
"chatdb".into()
}
//pub const KING_PATH: &str = "assets/king.png";
pub const VID_PATH: &str = "assets/forest_1920x1080.ivf";
//pub const VID_PATH: &str = "assets/forest_1920x1080.ivf";
}
use ui_consts::*;
@@ -74,7 +71,7 @@ pub async fn make(app: &App, window: SceneNodePtr, i18n_fish: &I18nBabelFish) {
)
.unwrap();
let mut cc = Compiler::new();
let cc = Compiler::new();
// Create a layer called view
let layer_node = create_layer("view");

View File

@@ -29,7 +29,14 @@ mod compile;
pub use compile::Compiler;
pub type MachineGlobals = Vec<(String, SExprVal)>;
pub type NativeFnCallback = fn(&mut MachineGlobals) -> Result<SExprVal>;
#[derive(Debug, Clone)]
pub struct NativeFnCallback(fn(&mut MachineGlobals) -> Result<SExprVal>);
impl PartialEq for NativeFnCallback {
fn eq(&self, _: &Self) -> bool {
false
}
}
pub fn const_f32(x: f32) -> SExprCode {
vec![Op::ConstFloat32(x)]
@@ -187,7 +194,7 @@ impl<'a> SExprMachine<'a> {
Op::LessThan((lhs, rhs)) => self.less_than(lhs, rhs),
Op::Float32ToUint32(val) => self.float32_to_uint32(val),
Op::IfElse((cond, if_val, else_val)) => self.if_else(cond, if_val, else_val),
Op::NativeFn(f) => (*f)(&mut self.globals),
Op::NativeFn(f) => (f.0)(&mut self.globals),
}
}
@@ -451,7 +458,7 @@ impl Decodable for Op {
Decodable::decode(d)?,
Decodable::decode(d)?,
)),
17 => Self::NativeFn(|_| Ok(SExprVal::Null)),
17 => Self::NativeFn(NativeFnCallback(|_| Ok(SExprVal::Null))),
_ => return Err(std::io::Error::new(std::io::ErrorKind::Other, "Invalid Op type")),
};
Ok(self_)

View File

@@ -23,13 +23,10 @@ use darkfi_serial::{
#[cfg(target_os = "android")]
use miniquad::native::egl;
use miniquad::{
conf, window, Backend, Bindings, BlendFactor, BlendState, BlendValue, BufferLayout,
BufferSource, BufferType, BufferUsage, Equation, EventHandler, KeyCode, KeyMods, MouseButton,
PassAction, Pipeline, PipelineParams, RenderingBackend, ShaderMeta, ShaderSource,
TextureFormat, TextureKind, TextureParams, TextureWrap, TouchPhase, UniformDesc, UniformType,
VertexAttribute, VertexFormat,
conf, window, Bindings, BufferSource, BufferType, BufferUsage, EventHandler, KeyCode, KeyMods,
MouseButton, PassAction, Pipeline, RenderingBackend, TextureFormat, TextureKind, TextureParams,
TextureWrap, TouchPhase, UniformType,
};
use parking_lot::Mutex as SyncMutex;
use std::{
collections::{HashMap, HashSet},
fs::File,
@@ -50,8 +47,6 @@ mod shader;
mod trax;
use trax::get_trax;
#[cfg(target_os = "android")]
use crate::ExecutorPtr;
use crate::{
prop::{BatchGuardId, PropertyAtomicGuard},
util::unixtime,

View File

@@ -29,7 +29,7 @@ use tracing_subscriber::filter::{LevelFilter, Targets};
#[cfg(any(not(target_os = "android"), feature = "enable-filelog"))]
use {
darkfi::util::logger::{EventFormatter, Level, TargetFilter},
tracing_subscriber::fmt::format::FmtSpan,
//tracing_subscriber::fmt::format::FmtSpan,
};
// Measured in bytes

View File

@@ -91,7 +91,7 @@ struct God {
_bg_ex: ExecutorPtr,
pub fg_runtime: AsyncRuntime,
pub fg_ex: ExecutorPtr,
_fg_ex: ExecutorPtr,
/// App must fully finish setup() before start() is allowed to begin.
cv_app_is_setup: Arc<CondVar>,
@@ -191,7 +191,7 @@ impl God {
_bg_ex: bg_ex,
fg_runtime,
fg_ex,
_fg_ex: fg_ex,
cv_app_is_setup,
app,

View File

@@ -30,7 +30,9 @@ pub const COLOR_DARKGREY: Color = [0.2, 0.2, 0.2, 1.];
pub const COLOR_LIGHTGREY: Color = [0.7, 0.7, 0.7, 1.];
#[allow(dead_code)]
pub const COLOR_GREEN: Color = [0., 1., 0., 1.];
#[allow(dead_code)]
pub const COLOR_BLUE: Color = [0., 0., 1., 1.];
#[allow(dead_code)]
pub const COLOR_PINK: Color = [0.8, 0.3, 0.8, 1.];
pub const COLOR_CYAN: Color = [0., 1., 1., 1.];
#[allow(dead_code)]

View File

@@ -367,6 +367,7 @@ impl PropertyRect {
}
*/
#[cfg(target_os = "android")]
pub fn set(&self, atom: &mut PropertyAtomicGuard, rect: &Rectangle) {
self.prop().set_f32(atom, self.role, 0, rect.x).unwrap();
self.prop().set_f32(atom, self.role, 1, rect.y).unwrap();

View File

@@ -20,10 +20,7 @@ use std::cmp::{max, min};
use super::driver::ParleyDriverWrapper;
use crate::{
android::{
self,
textinput::{AndroidTextInput, AndroidTextInputState},
},
android::textinput::{AndroidTextInput, AndroidTextInputState},
gfx::Point,
mesh::Color,
prop::{PropertyAtomicGuard, PropertyColor, PropertyFloat32, PropertyStr},
@@ -174,7 +171,7 @@ impl Editor {
self.on_buffer_changed(atom);
}
pub fn driver(&mut self) -> ParleyDriverWrapper {
pub fn driver(&mut self) -> ParleyDriverWrapper<'_> {
ParleyDriverWrapper::new(&mut self.layout)
}

View File

@@ -161,6 +161,7 @@ impl<'a> ParleyDriverWrapper<'a> {
unimplemented!()
}
#[allow(unused_variables)]
pub fn insert_or_replace_selection(&mut self, text: &str) {
#[cfg(not(target_os = "android"))]
self.with_driver(|drv| drv.insert_or_replace_selection(text));
@@ -265,6 +266,7 @@ impl<'a> ParleyDriverWrapper<'a> {
unimplemented!()
}
#[allow(unused_variables)]
pub fn move_to_point(&mut self, x: f32, y: f32) {
#[cfg(not(target_os = "android"))]
self.with_driver(|drv| drv.move_to_point(x, y));
@@ -273,14 +275,8 @@ impl<'a> ParleyDriverWrapper<'a> {
unimplemented!()
}
pub fn extend_selection_to_point(&mut self, x: f32, y: f32) {
#[cfg(not(target_os = "android"))]
self.with_driver(|drv| drv.extend_selection_to_point(x, y));
#[cfg(target_os = "android")]
unimplemented!()
}
#[allow(unused_variables)]
#[allow(dead_code)]
pub fn select_byte_range(&mut self, start: usize, end: usize) {
#[cfg(not(target_os = "android"))]
self.with_driver(|drv| drv.select_byte_range(start, end));

View File

@@ -21,7 +21,6 @@ mod android;
mod driver;
#[cfg(target_os = "android")]
pub use android::Editor;
pub use driver::ParleyDriverWrapper;
#[cfg(not(target_os = "android"))]
mod parley;

View File

@@ -114,7 +114,7 @@ impl Editor {
self.on_buffer_changed(atom);
}
pub fn driver(&mut self) -> ParleyDriverWrapper {
pub fn driver(&mut self) -> ParleyDriverWrapper<'_> {
ParleyDriverWrapper::new(&mut self.editor)
}

View File

@@ -23,11 +23,11 @@ use std::{
sync::{Arc, LazyLock},
};
use crate::{mesh::Color, util::spawn_thread};
use crate::mesh::Color;
pub mod atlas;
mod editor;
pub use editor::{Editor, ParleyDriverWrapper};
pub use editor::Editor;
mod render;
pub use render::{render_layout, render_layout_with_opts, DebugRenderOptions};

View File

@@ -71,7 +71,7 @@ pub fn render_layout_with_opts(
for item in line.items() {
match item {
parley::PositionedLayoutItem::GlyphRun(glyph_run) => {
push_glyphs(&mut atlas, &glyph_run, run_idx, &mut scale_ctx, render_api, tag);
push_glyphs(&mut atlas, &glyph_run, run_idx, &mut scale_ctx);
run_idx += 1;
}
parley::PositionedLayoutItem::InlineBox(_) => {}
@@ -89,15 +89,7 @@ pub fn render_layout_with_opts(
for item in line.items() {
match item {
parley::PositionedLayoutItem::GlyphRun(glyph_run) => {
let mesh = render_glyph_run(
&mut scale_ctx,
&glyph_run,
run_idx,
opts,
&atlas,
render_api,
tag,
);
let mesh = render_glyph_run(&glyph_run, run_idx, opts, &atlas, render_api, tag);
instrs.push(DrawInstruction::Draw(mesh));
run_idx += 1;
}
@@ -113,8 +105,6 @@ fn push_glyphs(
glyph_run: &parley::GlyphRun<'_, Color>,
run_idx: RunIdx,
scale_ctx: &mut swash::scale::ScaleContext,
render_api: &RenderApi,
tag: DebugTag,
) {
let run = glyph_run.run();
let font = run.font();
@@ -135,7 +125,6 @@ fn push_glyphs(
}
fn render_glyph_run(
scale_ctx: &mut swash::scale::ScaleContext,
glyph_run: &parley::GlyphRun<'_, Color>,
run_idx: usize,
opts: DebugRenderOptions,
@@ -217,31 +206,3 @@ fn render_underline(
mesh.draw_line(start, end, color, width);
}
fn create_atlas(
scale_ctx: &mut swash::scale::ScaleContext,
glyph_run: &parley::GlyphRun<'_, Color>,
run_idx: usize,
render_api: &RenderApi,
tag: DebugTag,
) -> RenderedAtlas {
let run = glyph_run.run();
let font = run.font();
let font_size = run.font_size();
let normalized_coords = run.normalized_coords();
let font_ref = swash::FontRef::from_index(font.data.as_ref(), font.index as usize).unwrap();
let mut scaler = scale_ctx
.builder(font_ref)
.size(font_size)
.hint(true)
.normalized_coords(normalized_coords)
.build();
let mut atlas = Atlas::new(render_api, tag);
for glyph in glyph_run.glyphs() {
atlas.push_glyph(glyph.id as u16, run_idx, &mut scaler);
}
//atlas.dump(&format!("/tmp/atlas_{run_idx}.png"));
atlas.make()
}

View File

@@ -43,8 +43,8 @@ use page::{FileMessageStatus, MessageBuffer};
use crate::{
gfx::{gfxtag, DrawCall, DrawInstruction, Point, Rectangle, RenderApi},
prop::{
BatchGuardId, BatchGuardPtr, PropertyAtomicGuard, PropertyBool, PropertyColor,
PropertyFloat32, PropertyRect, PropertyUint32, Role,
BatchGuardId, BatchGuardPtr, PropertyAtomicGuard, PropertyColor, PropertyFloat32,
PropertyRect, PropertyUint32, Role,
},
scene::{MethodCallSub, Pimpl, SceneNodePtr, SceneNodeWeak},
ExecutorPtr,
@@ -66,6 +66,7 @@ fn is_zero(x: f32) -> bool {
}
/// std::cmp::max() doesn't work on f32
#[allow(dead_code)]
fn max(a: f32, b: f32) -> f32 {
if a > b {
a
@@ -217,7 +218,8 @@ impl ChatView {
let hi_bg_color = PropertyColor::wrap(node_ref, Role::Internal, "hi_bg_color").unwrap();
let z_index = PropertyUint32::wrap(node_ref, Role::Internal, "z_index", 0).unwrap();
let priority = PropertyUint32::wrap(node_ref, Role::Internal, "priority", 0).unwrap();
let debug = PropertyBool::wrap(node_ref, Role::Internal, "debug", 0).unwrap();
// Unused currently
//let debug = PropertyBool::wrap(node_ref, Role::Internal, "debug", 0).unwrap();
let scroll_start_accel =
PropertyFloat32::wrap(node_ref, Role::Internal, "scroll_start_accel", 0).unwrap();
@@ -249,7 +251,6 @@ impl ChatView {
text_color,
nick_colors,
hi_bg_color,
debug,
window_scale,
render_api,
)),

View File

@@ -37,7 +37,7 @@ use super::{MessageId, Timestamp};
use crate::{
gfx::{gfxtag, DrawInstruction, ManagedTexturePtr, Point, Rectangle, RenderApi},
mesh::{Color, MeshBuilder, COLOR_CYAN, COLOR_GREEN, COLOR_RED, COLOR_WHITE},
prop::{PropertyBool, PropertyColor, PropertyFloat32, PropertyPtr},
prop::{PropertyColor, PropertyFloat32, PropertyPtr},
text,
util::enumerate_mut,
};
@@ -305,7 +305,7 @@ impl DateMessage {
&[],
);
let mut instrs = text::render_layout(&layout, render_api, gfxtag!("chatview_datemsg"));
let instrs = text::render_layout(&layout, render_api, gfxtag!("chatview_datemsg"));
// Cache the instructions
self.mesh_cache = Some(instrs.clone());
instrs
@@ -730,7 +730,6 @@ pub struct MessageBuffer {
/// From most recent to older
msgs: Vec<Message>,
date_msgs: HashMap<NaiveDate, Message>,
pub line_width: f32,
font_size: PropertyFloat32,
timestamp_font_size: PropertyFloat32,
@@ -742,7 +741,6 @@ pub struct MessageBuffer {
text_color: PropertyColor,
nick_colors: PropertyPtr,
hi_bg_color: PropertyColor,
debug: PropertyBool,
window_scale: PropertyFloat32,
/// Used to detect if the window scale was changed when drawing.
@@ -764,7 +762,6 @@ impl MessageBuffer {
text_color: PropertyColor,
nick_colors: PropertyPtr,
hi_bg_color: PropertyColor,
debug: PropertyBool,
window_scale: PropertyFloat32,
render_api: RenderApi,
) -> Self {
@@ -772,7 +769,6 @@ impl MessageBuffer {
Self {
msgs: vec![],
date_msgs: HashMap::new(),
line_width: 0.,
font_size,
timestamp_font_size,
@@ -784,7 +780,6 @@ impl MessageBuffer {
text_color,
nick_colors,
hi_bg_color,
debug,
window_scale,
old_window_scale,
@@ -812,7 +807,6 @@ impl MessageBuffer {
let window_scale = self.window_scale.get();
let font_size = self.font_size.get();
let timestamp_font_size = self.timestamp_font_size.get();
let timestamp_width = self.timestamp_width.get();
for msg in &mut self.msgs {
msg.adjust_params(font_size, timestamp_font_size, window_scale);
@@ -985,9 +979,7 @@ impl MessageBuffer {
) -> Vec<(f32, Vec<DrawInstruction>)> {
let line_height = self.line_height.get();
let msg_spacing = self.msg_spacing.get();
let baseline = self.baseline.get();
let timestamp_width = self.timestamp_width.get();
let debug_render = self.debug.get();
let timest_color = self.timestamp_color.get();
let text_color = self.text_color.get();

View File

@@ -15,7 +15,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use async_trait::async_trait;
use atomic_float::AtomicF32;
use parking_lot::Mutex as SyncMutex;
use std::sync::{atomic::Ordering, Arc};

View File

@@ -27,7 +27,6 @@ use rand::{rngs::OsRng, Rng};
use std::{
io::Cursor,
mem::swap,
ops::{Deref, DerefMut},
sync::{
atomic::{AtomicBool, Ordering},
Arc, Weak,
@@ -39,7 +38,7 @@ use tracing::instrument;
use crate::android::textinput::AndroidTextInputState;
use crate::{
gfx::{gfxtag, DrawCall, DrawInstruction, DrawMesh, Point, Rectangle, RenderApi, Vertex},
mesh::{Color, MeshBuilder},
mesh::MeshBuilder,
prop::{
BatchGuardId, BatchGuardPtr, PropertyAtomicGuard, PropertyBool, PropertyColor,
PropertyFloat32, PropertyPtr, PropertyRect, PropertyStr, PropertyUint32, Role,
@@ -236,6 +235,7 @@ pub struct BaseEdit {
touch_info: SyncMutex<TouchInfo>,
is_phone_select: AtomicBool,
// TODO: we should make use of this!
window_scale: PropertyFloat32,
parent_rect: Arc<SyncMutex<Option<Rectangle>>>,
is_mouse_hover: AtomicBool,

View File

@@ -16,23 +16,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use async_lock::Mutex as AsyncMutex;
use std::{
fs::File,
io::{BufRead, BufReader},
path::{Path, PathBuf},
sync::Arc,
};
use parking_lot::Mutex as SyncMutex;
use std::sync::Arc;
use crate::{
gfx::{gfxtag, DrawInstruction, DrawMesh, Rectangle, RenderApi},
mesh::{MeshBuilder, COLOR_WHITE},
gfx::{gfxtag, DrawInstruction, DrawMesh, RenderApi},
mesh::COLOR_WHITE,
text,
};
use super::default::DEFAULT_EMOJI_LIST;
pub type EmojiMeshesPtr = Arc<AsyncMutex<EmojiMeshes>>;
pub type EmojiMeshesPtr = Arc<SyncMutex<EmojiMeshes>>;
pub struct EmojiMeshes {
render_api: RenderApi,
@@ -42,14 +37,14 @@ pub struct EmojiMeshes {
impl EmojiMeshes {
pub fn new(render_api: RenderApi, emoji_size: f32) -> EmojiMeshesPtr {
Arc::new(AsyncMutex::new(Self { render_api, emoji_size, meshes: vec![] }))
Arc::new(SyncMutex::new(Self { render_api, emoji_size, meshes: vec![] }))
}
pub fn clear(&mut self) {
self.meshes.clear();
}
pub async fn get(&mut self, i: usize) -> DrawMesh {
pub fn get(&mut self, i: usize) -> DrawMesh {
assert!(i < DEFAULT_EMOJI_LIST.len());
self.meshes.reserve_exact(DEFAULT_EMOJI_LIST.len());
@@ -57,7 +52,7 @@ impl EmojiMeshes {
//d!("EmojiMeshes loading new glyphs");
for j in self.meshes.len()..=i {
let emoji = DEFAULT_EMOJI_LIST[j];
let mesh = self.gen_emoji_mesh(emoji).await;
let mesh = self.gen_emoji_mesh(emoji);
self.meshes.push(mesh);
}
}
@@ -66,7 +61,7 @@ impl EmojiMeshes {
}
/// Make mesh for this emoji centered at (0, 0)
async fn gen_emoji_mesh(&self, emoji: &str) -> DrawMesh {
fn gen_emoji_mesh(&self, emoji: &str) -> DrawMesh {
//d!("rendering emoji: '{emoji}'");
// The params here don't actually matter since we're talking about BMP fixed sizes
let layout = text::make_layout(emoji, COLOR_WHITE, self.emoji_size, 1., 1., None, &[]);

View File

@@ -161,7 +161,6 @@ impl EmojiPicker {
//d!(" = {idx}, emoji_len = {}", emoji::EMOJI_LIST.len());
let emoji_selected = {
let emoji_meshes = self.emoji_meshes.lock().await;
if idx < DEFAULT_EMOJI_LIST.len() {
let emoji = DEFAULT_EMOJI_LIST[idx].to_string();
Some(emoji)
@@ -218,7 +217,7 @@ impl EmojiPicker {
let mut y = -self.scroll.get();
for i in 0..DEFAULT_EMOJI_LIST.len() {
let pos = Point::new(x, y);
let mesh = self.emoji_meshes.lock().await.get(i).await;
let mesh = self.emoji_meshes.lock().get(i);
instrs.extend_from_slice(&[DrawInstruction::SetPos(pos), DrawInstruction::Draw(mesh)]);
x += off_x;

View File

@@ -30,7 +30,6 @@ use crate::{
use super::UIObject;
macro_rules! d { ($($arg:tt)*) => { debug!(target: "ui::gesture", $($arg)*); } }
macro_rules! t { ($($arg:tt)*) => { trace!(target: "ui::gesture", $($arg)*); } }
/// Maximum number of simultaneous touch events.
/// Put 3 here because any more is ridiculous.

View File

@@ -34,8 +34,6 @@ use crate::{
use super::{DrawUpdate, OnModify, UIObject};
macro_rules! t { ($($arg:tt)*) => { trace!(target: "ui::image", $($arg)*); } }
pub type ImagePtr = Arc<Image>;
pub struct Image {

View File

@@ -43,6 +43,7 @@ mod image;
#[allow(unused_imports)]
pub use image::{Image, ImagePtr};
mod vid;
#[allow(unused_imports)]
pub use vid::{Video, VideoPtr};
mod vector_art;
pub use vector_art::{

View File

@@ -37,8 +37,6 @@ use crate::{
use super::{DrawUpdate, OnModify, UIObject};
macro_rules! t { ($($arg:tt)*) => { trace!(target: "ui::text", $($arg)*); } }
pub type TextPtr = Arc<Text>;
pub struct Text {

View File

@@ -34,8 +34,6 @@ use super::{DrawUpdate, OnModify, UIObject};
pub mod shape;
use shape::VectorShape;
macro_rules! t { ($($arg:tt)*) => { trace!(target: "ui:vector_art", $($arg)*); } }
pub type VectorArtPtr = Arc<VectorArt>;
pub struct VectorArt {

View File

@@ -56,7 +56,7 @@ pub fn spawn_decoder_thread(
vid::videodecoder_set_id(decoder_handle.obj, decoder_id);
let decoded_count = vid::videodecoder_decode_all(decoder_handle.obj);
let _decoded_count = vid::videodecoder_decode_all(decoder_handle.obj);
drop(decoder_handle);

View File

@@ -66,8 +66,8 @@ pub struct IvfHeader {
version: u16,
header_len: u16,
codec_fourcc: [u8; 4],
pub width: u16,
pub height: u16,
width: u16,
height: u16,
timebase_den: u32,
timebase_num: u32,
pub num_frames: u32,

View File

@@ -36,12 +36,11 @@ use crate::{
use super::{DrawUpdate, OnModify, UIObject};
mod decode;
#[allow(dead_code)]
mod ivf;
use decode::spawn_decoder_thread;
macro_rules! t { ($($arg:tt)*) => { trace!(target: "ui:video", $($arg)*); } }
pub type VideoPtr = Arc<Video>;
#[derive(Clone)]

View File

@@ -30,8 +30,7 @@ use crate::{
GraphicsEventTouchSub, Point, Rectangle, RenderApi,
},
prop::{
BatchGuardPtr, PropertyAtomicGuard, PropertyDimension, PropertyFloat32, PropertyRect,
PropertyStr, Role,
BatchGuardPtr, PropertyAtomicGuard, PropertyDimension, PropertyFloat32, PropertyStr, Role,
},
scene::{Pimpl, SceneNodePtr, SceneNodeWeak},
util::i18n::I18nBabelFish,
@@ -39,7 +38,7 @@ use crate::{
};
#[cfg(target_os = "android")]
use crate::android;
use crate::{android, prop::PropertyRect};
use super::{get_children_ordered, get_ui_object3, get_ui_object_ptr, OnModify};
@@ -64,6 +63,7 @@ pub struct Window {
locale: PropertyStr,
screen_size: PropertyDimension,
scale: PropertyFloat32,
#[cfg(target_os = "android")]
insets: PropertyRect,
}
@@ -85,8 +85,6 @@ impl Window {
)
.unwrap();
let insets = PropertyRect::wrap(node_ref, Role::Internal, "insets").unwrap();
let self_ = Arc::new(Self {
node,
render_api,
@@ -96,7 +94,8 @@ impl Window {
locale,
screen_size,
scale,
insets,
#[cfg(target_os = "android")]
insets: PropertyRect::wrap(node_ref, Role::Internal, "insets").unwrap(),
});
Pimpl::Window(self_)