Skip to content

Commit

Permalink
Require Adjust Mode for Ctrl+K to toggle color picker on
Browse files Browse the repository at this point in the history
  • Loading branch information
zkxs committed Oct 23, 2023
1 parent 70db930 commit 2ae33e4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Use the tray icon to:

- Toggle crosshair visibility (you can also use Ctrl+H)
- Toggle **Adjust Mode** (you can also use Ctrl+J)
- Pick a color for the default crosshair (you can also use Ctrl+K).
- Pick a color for the default crosshair (you can also use Ctrl+K if you are in Adjust Mode).
- Load a PNG image as your crosshair
- Reset crosshair to default settings
- Safely exit the application and save your settings
Expand All @@ -48,6 +48,7 @@ In **Adjust Mode**:
- Arrow keys to move the crosshair
- PageUp/PageDown to increase/decrease the crosshair scale
- Ctrl+M to cycle through your monitors
- Ctrl+K to pick a color for the default crosshair

### Custom PNG Crosshairs

Expand Down
6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ fn main() {
hotkey_manager.poll_keys();
hotkey_manager.process_keys();

if menu_items.adjust_button.is_checked() {
let adjust_mode = menu_items.adjust_button.is_checked();
if adjust_mode {
if hotkey_manager.move_up() != 0 {
settings.persisted.window_dy -= hotkey_manager.move_up() as i32;
window_position_dirty = true;
Expand Down Expand Up @@ -284,7 +285,8 @@ fn main() {
}
}

if hotkey_manager.toggle_color_picker() {
// only enable this hotkey if the color picker is already visible OR if adjust mode is on
if hotkey_manager.toggle_color_picker() && (adjust_mode || settings.get_pick_color()) {
let color_pick = settings.toggle_pick_color();
menu_items.color_pick_button.set_checked(color_pick);
handle_color_pick(color_pick, &window, &mut last_focused_window, true);
Expand Down
5 changes: 5 additions & 0 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ impl Settings {
}
}

/// Returns `true` if color picker mode is now enabled, `false` otherwise.
pub fn get_pick_color(&self) -> bool {
self.render_mode == RenderMode::ColorPicker
}

/// Set the color of the generated crosshair. The provided `color` must not have premultiplied alpha (yet)
pub fn set_color(&mut self, color: u32) {
debug_println!("set color to {color:08X}");
Expand Down

0 comments on commit 2ae33e4

Please sign in to comment.