From 2d0d46c40a79c6b2a163f42107e5297b7a3126db Mon Sep 17 00:00:00 2001 From: Matthew Wilding Date: Mon, 18 Dec 2023 17:51:50 +0800 Subject: [PATCH] Added more hints --- dygma-layer-switcher/src/app.rs | 13 +++++++++++-- dygma-layer-switcher/src/main.rs | 6 +++--- dygma-layer-switcher/src/templates.rs | 13 ++++++++++--- dygma-layer-switcher/src/verbiage.rs | 11 ++++++++--- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/dygma-layer-switcher/src/app.rs b/dygma-layer-switcher/src/app.rs index f1dbdf8..0b1070e 100644 --- a/dygma-layer-switcher/src/app.rs +++ b/dygma-layer-switcher/src/app.rs @@ -11,7 +11,7 @@ use lazy_static::lazy_static; use serde::{Deserialize, Serialize}; use std::collections::{BTreeMap, BTreeSet}; use std::sync::{Arc, Mutex}; -use tracing::{debug, error, trace, warn}; +use tracing::{debug, error, warn}; const MAX_LAYERS: u8 = 10; @@ -117,7 +117,12 @@ impl DygmaLayerSwitcher { Err(_) => warn!("{}", verbiage::NO_KEYBOARD_MESSAGE), } }; - if editable_label(ui, &mut self.port, &mut self.editing_port) { + if editable_label( + ui, + &mut self.port, + &mut self.editing_port, + Some(verbiage::PORT_SETTING_INPUT_HINT), + ) { self.mappings_changed = true; } }); @@ -243,6 +248,7 @@ impl DygmaLayerSwitcher { ui, &mut window.name, &mut window.is_editing, + Some(verbiage::MODE_WINDOWS_INPUT_HINT), ) { self.mappings_changed = true; }; @@ -273,6 +279,7 @@ impl DygmaLayerSwitcher { ui, &mut process.name, &mut process.is_editing, + Some(verbiage::MODE_PROCESSES_INPUT_HINT) ) { self.mappings_changed = true; } @@ -310,6 +317,7 @@ impl DygmaLayerSwitcher { ui, &mut parent.name, &mut parent.is_editing, + Some(verbiage::MODE_PARENT_INPUT_HINT), ) { self.mappings_changed = true; } @@ -347,6 +355,7 @@ impl DygmaLayerSwitcher { ui, &mut exclude.name, &mut exclude.is_editing, + Some(verbiage::MODE_PARENT_EXCLUDES_INPUT_HINT), ) { self.mappings_changed = true; } diff --git a/dygma-layer-switcher/src/main.rs b/dygma-layer-switcher/src/main.rs index c93c2b8..a773746 100644 --- a/dygma-layer-switcher/src/main.rs +++ b/dygma-layer-switcher/src/main.rs @@ -18,8 +18,6 @@ mod templates; mod verbiage; mod windows; -pub const ICON: &[u8] = include_bytes!("../../assets/icons/icon.ico"); - pub fn main() -> Result<()> { single::check()?; @@ -37,7 +35,9 @@ pub fn main() -> Result<()> { .with_close_button(true) .with_minimize_button(true) .with_maximize_button(true) - .with_icon(Arc::new(icon::load_icon(ICON))), + .with_icon(Arc::new(icon::load_icon(include_bytes!( + "../../assets/icons/icon.ico" + )))), ..Default::default() }, Box::new(move |cc| { diff --git a/dygma-layer-switcher/src/templates.rs b/dygma-layer-switcher/src/templates.rs index d76e92e..a66320f 100644 --- a/dygma-layer-switcher/src/templates.rs +++ b/dygma-layer-switcher/src/templates.rs @@ -2,9 +2,16 @@ use crate::verbiage; use eframe::egui; use eframe::egui::CollapsingHeader; -pub fn editable_label(ui: &mut egui::Ui, value: &mut String, editing: &mut bool) -> bool { +pub fn editable_label( + ui: &mut egui::Ui, + value: &mut String, + editing: &mut bool, + hint: Option<&str>, +) -> bool { if *editing { - let response = ui.text_edit_singleline(value); + let response = ui + .text_edit_singleline(value) + .on_hover_text(hint.unwrap_or_default()); if response.lost_focus() { *editing = false; @@ -16,7 +23,7 @@ pub fn editable_label(ui: &mut egui::Ui, value: &mut String, editing: &mut bool) } else if ui.button(value.as_str()).clicked() { *editing = true; } - + false } diff --git a/dygma-layer-switcher/src/verbiage.rs b/dygma-layer-switcher/src/verbiage.rs index 140b862..ee1e3f5 100644 --- a/dygma-layer-switcher/src/verbiage.rs +++ b/dygma-layer-switcher/src/verbiage.rs @@ -1,5 +1,5 @@ -pub const NO_KEYBOARD_MESSAGE: &str = "Connect a Dygma keyboard and restart the application."; pub const APP_NAME: &str = "Dygma Layer Switcher"; +pub const NO_KEYBOARD_MESSAGE: &str = "Connect a Dygma keyboard and restart the application."; pub const SETTINGS_HEADING: &str = "Settings"; pub const BUTTON_ADD_WINDOW: &str = "Add window"; pub const BUTTON_ADD_PROCESS: &str = "Add process"; @@ -7,18 +7,23 @@ pub const BUTTON_ADD_PARENT: &str = "Add parent"; pub const BUTTON_ADD_EXCLUDE: &str = "Add exclude"; pub const MODE_WINDOWS_HEADING: &str = "Windows"; pub const MODE_WINDOWS_HINT: &str = "Remove this window."; +pub const MODE_WINDOWS_INPUT_HINT: &str = "Click to edit the window."; pub const MODE_PROCESSES_HEADING: &str = "Processes"; pub const MODE_PROCESSES_HINT: &str = "Remove this process."; +pub const MODE_PROCESSES_INPUT_HINT: &str = "Click to edit the process."; pub const MODE_PARENT_HEADING: &str = "Parents"; pub const MODE_PARENT_HINT: &str = "Remove this parent."; +pub const MODE_PARENT_INPUT_HINT: &str = "Click to edit the parent."; pub const MODE_PARENT_EXCLUDES_HEADING: &str = "Excludes"; pub const MODE_PARENT_EXCLUDES_HINT: &str = "Remove this exclude."; +pub const MODE_PARENT_EXCLUDES_INPUT_HINT: &str = "Click to edit the exclude."; pub const LOGGING_SETTING_HEADING: &str = "Logging"; -pub const LOGGING_SETTING_HINT: &str = "Enables logging to file."; +pub const LOGGING_SETTING_HINT: &str = "Enables logging to file. Restart required."; pub const PORT_SETTING_HEADING: &str = "Port"; pub const PORT_SETTING_HINT: &str = "The serial port to communicate with."; pub const PORT_SETTING_REFRESH_HEADING: &str = "↻"; pub const PORT_SETTING_REFRESH_HINT: &str = "Rescan for the communication port."; +pub const PORT_SETTING_INPUT_HINT: &str = "Click to edit the port."; pub const BASE_LAYER_SETTING_HEADING: &str = "Base Layer"; pub const BASE_LAYER_SETTING_HINT: &str = "The layer to return to."; pub const BASE_LAYER_VALUE_HINT: &str = "Click and drag to change the base layer."; @@ -27,7 +32,7 @@ pub const HIDDEN_LAYERS_UNHIDE_HINT: &str = "Unhide layer"; pub const BUTTON_REMOVE: &str = " - "; pub const WINDOW: &str = "Partial match of window title."; pub const PROCESS: &str = "The executable name including extension."; -pub const PARENT: &str = "The parent executable name, and optional excludes of child processes."; +pub const PARENT: &str = "The parent executable name, and excludes."; pub const EXCLUDES_HINT: &str = "Exclude a child process."; pub const RENAME_HINT: &str = "Right click to rename."; pub const LAYER: &str = "Layer";