kitgit

tirbofish/dropbear · diff

519e08b · Thribhu K

wip: still doing testing on the buttons, doesn't look like its working Unverified

diff --git a/crates/eucalyptus-core/src/ui.rs b/crates/eucalyptus-core/src/ui.rs
index 8764363..a6426a1 100644
--- a/crates/eucalyptus-core/src/ui.rs
+++ b/crates/eucalyptus-core/src/ui.rs
@@ -2,6 +2,7 @@ mod button;
 mod utils;
 
 use std::cell::RefCell;
+use std::collections::HashMap;
 use ::jni::JNIEnv;
 use ::jni::objects::JObject;
 use parking_lot::Mutex;
@@ -31,13 +32,29 @@ pub struct UIComponent {
 
 // note for tomorrow: use UIInstruction like that of asm
 
+#[derive(Clone, Copy, Debug, Default)]
+pub struct WidgetState {
+    pub clicked: bool,
+    pub hovering: bool,
+}
+
 pub trait NativeWidget: Send + std::fmt::Debug {
-    fn build(self: Box<Self>);
+    fn build(self: Box<Self>, states: &mut HashMap<i64, WidgetState>);
+}
+
+#[derive(Debug)]
+pub struct WrapperWidget<T> {
+    pub id: i64,
+    pub widget: T,
 }
 
-impl NativeWidget for yakui::widgets::Button {
-    fn build(mut self: Box<Self>) {
-        let _ = self.show();
+impl NativeWidget for WrapperWidget<yakui::widgets::Button> {
+    fn build(self: Box<Self>, states: &mut HashMap<i64, WidgetState>) {
+        let res = self.widget.show();
+        states.insert(self.id, WidgetState {
+            clicked: res.clicked,
+            hovering: res.hovering,
+        });
     }
 }
 
@@ -71,7 +88,14 @@ impl WidgetParser for ButtonParser {
         if name_string.contains("ButtonInstruction$Button") {
             let button_obj = env.get_field(obj, "button", "Lcom/dropbear/ui/widgets/Button;")?.l()?;
             let btn = yakui::widgets::Button::from_jobject(env, &button_obj)?;

Large diffs are not rendered by default. Showing the first 50 of 224 lines. Show full diff