git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

commitfe111406d196c877337451a21b253287934b63e5
parent37f758944f
authorLucas Galante <[email protected]>
date2026-06-29 20:03
clean: remove style.background.color and legacy TOML-related migration logic

 src/layout.rs                     | 19 +++++------
 src/widget/input/multi_control.rs | 70 ---------------------------------------
 2 files changed, 9 insertions(+), 80 deletions(-)

diff --git a/src/layout.rs b/src/layout.rs
index d7c156e..785567e 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -2,7 +2,7 @@ use crate::widget::Element;
 use crate::context::UiContext;
 use std::sync::RwLock;
 
-fn flatten_map_json(val: &serde_json::Value, prefix: &str, toml_like: &mut String) {
+fn flatten_json_to_flat_props(val: &serde_json::Value, prefix: &str, flat_props: &mut String) {
     match val {
         serde_json::Value::Object(map) => {
             for (k, v) in map {
@@ -11,12 +11,11 @@ fn flatten_map_json(val: &serde_json::Value, prefix: &str, toml_like: &mut Strin
                 } else {
                     format!("{}.{}", prefix, k)
                 };
-                flatten_map_json(v, &next_prefix, toml_like);
+                flatten_json_to_flat_props(v, &next_prefix, flat_props);
             }
         }
         _ => {
             let flat_key = match prefix {
-                "style.background.color" => "background_color",
                 "style.button.font" => "button_font",
                 "style.button.padding" => "button_padding",
                 "style.button_strip.font" => "button_strip_font",
@@ -73,13 +72,13 @@ fn flatten_map_json(val: &serde_json::Value, prefix: &str, toml_like: &mut Strin
             };
             
             if let Some(s) = val.as_str() {
-                toml_like.push_str(&format!("{} = \"{}\"\n", flat_key, s));
+                flat_props.push_str(&format!("{} = \"{}\"\n", flat_key, s));
             } else if let Some(b) = val.as_bool() {
-                toml_like.push_str(&format!("{} = {}\n", flat_key, b));
+                flat_props.push_str(&format!("{} = {}\n", flat_key, b));
             } else if let Some(n) = val.as_f64() {
-                toml_like.push_str(&format!("{} = {}\n", flat_key, n));
+                flat_props.push_str(&format!("{} = {}\n", flat_key, n));
             } else if let Some(n) = val.as_i64() {
-                toml_like.push_str(&format!("{} = {}\n", flat_key, n));
+                flat_props.push_str(&format!("{} = {}\n", flat_key, n));
             }
         }
     }
@@ -89,9 +88,9 @@ fn read_config() -> Option<String> {
     let path = crate::config::get_config_path();
     if let Ok(content) = std::fs::read_to_string(&path) {
         let val = crate::config::parse_kdl_to_json(&content);
-        let mut toml_like = String::new();
-        flatten_map_json(&val, "", &mut toml_like);
-        return Some(toml_like);
+        let mut flat_props = String::new();
+        flatten_json_to_flat_props(&val, "", &mut flat_props);
+        return Some(flat_props);
     }
     None
 }
diff --git a/src/widget/input/multi_control.rs b/src/widget/input/multi_control.rs
index 248002e..395e2f3 100644
--- a/src/widget/input/multi_control.rs
+++ b/src/widget/input/multi_control.rs
@@ -1017,43 +1017,6 @@ fn load_config(name: &str) -> Vec<InstancedControl> {
                 }
             }
         }
-        return Vec::new();
-    }
-
-    let toml_path = path.with_extension("toml");
-    if toml_path.exists() {
-        if let Ok(content) = std::fs::read_to_string(&toml_path) {
-            let mut multicontrol_sec = false;
-            for line in content.lines() {
-                let trimmed = line.trim();
-                if trimmed == "[multicontrol]" {
-                    multicontrol_sec = true;
-                } else if trimmed.starts_with('[') && trimmed.ends_with(']') {
-                    multicontrol_sec = false;
-                } else if multicontrol_sec {
-                    if trimmed.starts_with(name) {
-                        if let Some(eq_idx) = trimmed.find('=') {
-                            if trimmed[..eq_idx].trim() == name {
-                                let value_part = trimmed[eq_idx + 1..].trim();
-                                let json_str = if value_part.starts_with('\'') && value_part.ends_with('\'') {
-                                    &value_part[1..value_part.len() - 1]
-                                } else if value_part.starts_with('"') && value_part.ends_with('"') {
-                                    &value_part[1..value_part.len() - 1]
-                                } else {
-                                    value_part
-                                };
-                                let json_str = json_str.replace("''", "'");
-                                if let Ok(controls) = serde_json::from_str::<Vec<InstancedControl>>(&json_str) {
-                                    save_config(name, &controls);
-                                    let _ = std::fs::remove_file(&toml_path);
-                                    return controls;
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
     }
 
     Vec::new()
@@ -1116,39 +1079,6 @@ mod tests {
         }
     }
 
-    #[test]
-    fn test_config_toml_to_json_migration() {
-        let _guard = ENV_MUTEX.lock().unwrap();
-        let temp_dir = std::env::temp_dir().join("cce_test_home_migration");
-        let _ = std::fs::create_dir_all(&temp_dir);
-        let old_home = std::env::var("HOME").ok();
-        std::env::set_var("HOME", temp_dir.to_str().unwrap());
-
-        let path = get_application_config_path();
-        let toml_path = path.with_extension("toml");
-        if let Some(parent) = toml_path.parent() {
-            let _ = std::fs::create_dir_all(parent);
-        }
-        let toml_content = "[multicontrol]\ntest_param = '[{\"key\":\"x\",\"control_type\":\"Spinbox\",\"value\":\"5\"}]'\n";
-        std::fs::write(&toml_path, toml_content).unwrap();
-
-        let loaded = load_config("test_param");
-        assert_eq!(loaded.len(), 1);
-        assert_eq!(loaded[0].key, "x");
-        assert_eq!(loaded[0].value, "5");
-
-        assert!(!toml_path.exists());
-        assert!(path.exists());
-
-        let json_content = std::fs::read_to_string(&path).unwrap();
-        assert!(json_content.contains("\"test_param\""));
-
-        let _ = std::fs::remove_dir_all(&temp_dir);
-        if let Some(h) = old_home {
-            std::env::set_var("HOME", h);
-        }
-    }
-
     #[test]
     fn test_popover_interaction() {
         let _guard = ENV_MUTEX.lock().unwrap();