Просмотр исходного кода

wallet: remove fade logic from chatedit, reduce chatedit padding in schema + run cargo fmt

darkfi 1 год назад
Родитель
Сommit
77639da69e

+ 3 - 3
bin/darkwallet/src/app/schema.rs

@@ -26,8 +26,8 @@ use crate::{
     prop::{
         Property, PropertyBool, PropertyFloat32, PropertyStr, PropertySubType, PropertyType, Role,
     },
-    shape,
     scene::{SceneNodePtr, Slot},
+    shape,
     text::TextShaperPtr,
     ui::{
         Button, ChatEdit, ChatView, EditBox, Image, Layer, ShapeVertex, Text, VectorArt,
@@ -52,7 +52,7 @@ mod android_ui_consts {
     pub const BACKARROW_X: f32 = 50.;
     pub const BACKARROW_Y: f32 = 70.;
     pub const EDITCHAT_HEIGHT: f32 = 163.;
-    pub const EDITCHAT_BOTTOM_PAD: f32 = 30.;
+    pub const EDITCHAT_BOTTOM_PAD: f32 = 10.;
     pub const EDITCHAT_CURSOR_ASCENT: f32 = 50.;
     pub const EDITCHAT_CURSOR_DESCENT: f32 = 20.;
     pub const EDITCHAT_SELECT_ASCENT: f32 = 50.;
@@ -106,7 +106,7 @@ mod ui_consts {
     pub const BACKARROW_X: f32 = 38.;
     pub const BACKARROW_Y: f32 = 23.;
     pub const EDITCHAT_HEIGHT: f32 = 50.;
-    pub const EDITCHAT_BOTTOM_PAD: f32 = 20.;
+    pub const EDITCHAT_BOTTOM_PAD: f32 = 5.;
     pub const EDITCHAT_CURSOR_ASCENT: f32 = 25.;
     pub const EDITCHAT_CURSOR_DESCENT: f32 = 8.;
     pub const EDITCHAT_SELECT_ASCENT: f32 = 30.;

+ 1 - 1
bin/darkwallet/src/main.rs

@@ -66,8 +66,8 @@ mod prop;
 mod pubsub;
 //mod py;
 mod ringbuf;
-mod shape;
 mod scene;
+mod shape;
 use scene::SceneNode as SceneNode3;
 mod text;
 mod ui;

+ 2 - 2
bin/darkwallet/src/shape/back_arrow.rs

@@ -1,4 +1,4 @@
-use crate::ui::{VectorShape, ShapeVertex};
+use crate::ui::{ShapeVertex, VectorShape};
 pub fn create_back_arrow() -> VectorShape {
     VectorShape {
         verts: vec![
@@ -13,6 +13,6 @@ pub fn create_back_arrow() -> VectorShape {
             ShapeVertex::from_xy(-0.154072, 0.752301, [0., 1., 1., 1.]),
             ShapeVertex::from_xy(-0.198105, 0.794808, [0., 1., 1., 1.]),
         ],
-        indices: vec![0, 4, 2, 1, 5, 0, 0, 5, 7, 5, 9, 7, 0, 3, 4, 1, 6, 5, 5, 8, 9]
+        indices: vec![0, 4, 2, 1, 5, 0, 0, 5, 7, 5, 9, 7, 0, 3, 4, 1, 6, 5, 5, 8, 9],
     }
 }

+ 13 - 2
bin/darkwallet/src/shape/emoji_sel.rs

@@ -1,4 +1,4 @@
-use crate::ui::{VectorShape, ShapeVertex};
+use crate::ui::{ShapeVertex, VectorShape};
 pub fn create_emoji_selector() -> VectorShape {
     VectorShape {
         verts: vec![
@@ -77,6 +77,17 @@ pub fn create_emoji_selector() -> VectorShape {
             ShapeVertex::from_xy(-0.288443, 0.349093, [0., 1., 1., 1.]),
             ShapeVertex::from_xy(-0.350323, 0.309817, [0., 1., 1., 1.]),
         ],
-        indices: vec![0, 3, 2, 3, 4, 2, 5, 6, 4, 7, 8, 6, 9, 10, 8, 10, 13, 12, 12, 15, 14, 14, 17, 16, 17, 18, 16, 18, 21, 20, 20, 23, 22, 23, 0, 22, 24, 27, 26, 27, 28, 26, 29, 30, 28, 31, 32, 30, 33, 34, 32, 34, 37, 36, 36, 39, 38, 38, 41, 40, 41, 42, 40, 42, 45, 44, 44, 47, 46, 47, 24, 46, 48, 73, 72, 51, 52, 50, 52, 55, 54, 54, 57, 56, 57, 58, 56, 58, 61, 60, 61, 62, 60, 62, 65, 64, 65, 66, 64, 66, 69, 68, 68, 71, 70, 71, 48, 70, 72, 51, 50, 0, 1, 3, 3, 5, 4, 5, 7, 6, 7, 9, 8, 9, 11, 10, 10, 11, 13, 12, 13, 15, 14, 15, 17, 17, 19, 18, 18, 19, 21, 20, 21, 23, 23, 1, 0, 24, 25, 27, 27, 29, 28, 29, 31, 30, 31, 33, 32, 33, 35, 34, 34, 35, 37, 36, 37, 39, 38, 39, 41, 41, 43, 42, 42, 43, 45, 44, 45, 47, 47, 25, 24, 48, 49, 73, 51, 53, 52, 52, 53, 55, 54, 55, 57, 57, 59, 58, 58, 59, 61, 61, 63, 62, 62, 63, 65, 65, 67, 66, 66, 67, 69, 68, 69, 71, 71, 49, 48, 72, 73, 51]
+        indices: vec![
+            0, 3, 2, 3, 4, 2, 5, 6, 4, 7, 8, 6, 9, 10, 8, 10, 13, 12, 12, 15, 14, 14, 17, 16, 17,
+            18, 16, 18, 21, 20, 20, 23, 22, 23, 0, 22, 24, 27, 26, 27, 28, 26, 29, 30, 28, 31, 32,
+            30, 33, 34, 32, 34, 37, 36, 36, 39, 38, 38, 41, 40, 41, 42, 40, 42, 45, 44, 44, 47, 46,
+            47, 24, 46, 48, 73, 72, 51, 52, 50, 52, 55, 54, 54, 57, 56, 57, 58, 56, 58, 61, 60, 61,
+            62, 60, 62, 65, 64, 65, 66, 64, 66, 69, 68, 68, 71, 70, 71, 48, 70, 72, 51, 50, 0, 1,
+            3, 3, 5, 4, 5, 7, 6, 7, 9, 8, 9, 11, 10, 10, 11, 13, 12, 13, 15, 14, 15, 17, 17, 19,
+            18, 18, 19, 21, 20, 21, 23, 23, 1, 0, 24, 25, 27, 27, 29, 28, 29, 31, 30, 31, 33, 32,
+            33, 35, 34, 34, 35, 37, 36, 37, 39, 38, 39, 41, 41, 43, 42, 42, 43, 45, 44, 45, 47, 47,
+            25, 24, 48, 49, 73, 51, 53, 52, 52, 53, 55, 54, 55, 57, 57, 59, 58, 58, 59, 61, 61, 63,
+            62, 62, 63, 65, 65, 67, 66, 66, 67, 69, 68, 69, 71, 71, 49, 48, 72, 73, 51,
+        ],
     }
 }

+ 1 - 2
bin/darkwallet/src/shape/mod.rs

@@ -16,7 +16,7 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use crate::ui::{VectorShape, ShapeVertex};
+use crate::ui::{ShapeVertex, VectorShape};
 
 mod back_arrow;
 pub use back_arrow::create_back_arrow;
@@ -26,4 +26,3 @@ pub use send_arrow::create_send_arrow;
 
 mod emoji_sel;
 pub use emoji_sel::create_emoji_selector;
-

+ 2 - 2
bin/darkwallet/src/shape/send_arrow.rs

@@ -1,4 +1,4 @@
-use crate::ui::{VectorShape, ShapeVertex};
+use crate::ui::{ShapeVertex, VectorShape};
 pub fn create_send_arrow() -> VectorShape {
     VectorShape {
         verts: vec![
@@ -9,6 +9,6 @@ pub fn create_send_arrow() -> VectorShape {
             ShapeVertex::from_xy(-0.934894, -0.730526, [0., 1., 1., 1.]),
             ShapeVertex::from_xy(-0.89359, 0.560546, [0., 1., 1., 1.]),
         ],
-        indices: vec![0, 1, 3, 3, 1, 2, 0, 3, 4, 1, 0, 5]
+        indices: vec![0, 1, 3, 3, 1, 2, 0, 3, 4, 1, 0, 5],
     }
 }

+ 0 - 15
bin/darkwallet/src/ui/chatedit.rs

@@ -732,21 +732,6 @@ impl ChatEdit {
                     color = COLOR_WHITE;
                 }
 
-                // Some kewl styling
-                let top_y = line_idx as f32 * linespacing + baseline - font_size - scroll;
-                if top_y < 0. {
-                    let pct = 1. + (top_y / baseline).clamp(-1., 0.);
-                    color[3] = pct;
-                }
-                //let bottom_y = top_y + linespacing;
-                let bottom_y = (line_idx + 1) as f32 * linespacing - scroll;
-                let bottom_rect = clip.h;
-                if bottom_y > bottom_rect {
-                    let dist = bottom_y - bottom_rect;
-                    let pct = 1. - (dist / linespacing).clamp(0., 1.);
-                    color[3] = pct;
-                }
-
                 mesh.draw_box(&glyph_rect, color, uv_rect);
                 if self.debug.get() {
                     mesh.draw_outline(&glyph_rect, COLOR_RED, 1.);

+ 4 - 17
bin/darkwallet/src/ui/vector_art/shape.rs

@@ -46,23 +46,10 @@ impl ShapeVertex {
         let last_x = self.x.pop().unwrap();
         let last_y = self.y.pop().unwrap();
         let mut x = self.x;
-        x.push(
-            Op::Mul((
-                Box::new(Op::ConstFloat32(scale)),
-                Box::new(last_x)
-            ))
-        );
+        x.push(Op::Mul((Box::new(Op::ConstFloat32(scale)), Box::new(last_x))));
         let mut y = self.y;
-        y.push(
-            Op::Mul((
-                Box::new(Op::ConstFloat32(scale)),
-                Box::new(last_y)
-            ))
-        );
-        Self {
-            x, y,
-            color: self.color
-        }
+        y.push(Op::Mul((Box::new(Op::ConstFloat32(scale)), Box::new(last_y))));
+        Self { x, y, color: self.color }
     }
 }
 
@@ -171,7 +158,7 @@ impl VectorShape {
     pub fn scaled(self, scale: f32) -> Self {
         Self {
             verts: self.verts.into_iter().map(|v| v.scale(scale)).collect(),
-            indices: self.indices
+            indices: self.indices,
         }
     }
 }