Skip to content

Commit

Permalink
Added more hints
Browse files Browse the repository at this point in the history
  • Loading branch information
mbwilding committed Dec 18, 2023
1 parent 1c41b1e commit 2d0d46c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
13 changes: 11 additions & 2 deletions dygma-layer-switcher/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
});
Expand Down Expand Up @@ -243,6 +248,7 @@ impl DygmaLayerSwitcher {
ui,
&mut window.name,
&mut window.is_editing,
Some(verbiage::MODE_WINDOWS_INPUT_HINT),
) {
self.mappings_changed = true;
};
Expand Down Expand Up @@ -273,6 +279,7 @@ impl DygmaLayerSwitcher {
ui,
&mut process.name,
&mut process.is_editing,
Some(verbiage::MODE_PROCESSES_INPUT_HINT)
) {
self.mappings_changed = true;
}
Expand Down Expand Up @@ -310,6 +317,7 @@ impl DygmaLayerSwitcher {
ui,
&mut parent.name,
&mut parent.is_editing,
Some(verbiage::MODE_PARENT_INPUT_HINT),
) {
self.mappings_changed = true;
}
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions dygma-layer-switcher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;

Expand All @@ -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| {
Expand Down
13 changes: 10 additions & 3 deletions dygma-layer-switcher/src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
}

Expand Down
11 changes: 8 additions & 3 deletions dygma-layer-switcher/src/verbiage.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
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";
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.";
Expand All @@ -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";
Expand Down

0 comments on commit 2d0d46c

Please sign in to comment.