mirror of
https://github.com/13hannes11/focus_annotator.git
synced 2024-09-03 23:21:01 +02:00
add code for keyboard shortcuts
This commit is contained in:
208
Cargo.lock
generated
208
Cargo.lock
generated
@@ -8,6 +8,15 @@ version = "1.0.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203"
|
||||
|
||||
[[package]]
|
||||
name = "approx"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.0.1"
|
||||
@@ -20,6 +29,12 @@ version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "439989e6b8c38d1b6570a384ef1e49c8848128f5a97f3914baef02920842712f"
|
||||
|
||||
[[package]]
|
||||
name = "cairo-rs"
|
||||
version = "0.15.1"
|
||||
@@ -53,6 +68,12 @@ dependencies = [
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "field-offset"
|
||||
version = "0.3.4"
|
||||
@@ -67,6 +88,7 @@ dependencies = [
|
||||
name = "focus-annotator"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"gls",
|
||||
"gtk4",
|
||||
"libadwaita",
|
||||
]
|
||||
@@ -211,6 +233,17 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gl_generator"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d"
|
||||
dependencies = [
|
||||
"khronos_api",
|
||||
"log",
|
||||
"xml-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib"
|
||||
version = "0.15.2"
|
||||
@@ -256,6 +289,19 @@ dependencies = [
|
||||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gls"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02e3ad781e06138bd79362ba641edcc6f85470f84a9e07af741ba44e144a66c1"
|
||||
dependencies = [
|
||||
"gl_generator",
|
||||
"libc",
|
||||
"nalgebra",
|
||||
"serde",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gobject-sys"
|
||||
version = "0.15.1"
|
||||
@@ -393,6 +439,12 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
||||
|
||||
[[package]]
|
||||
name = "khronos_api"
|
||||
version = "3.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
||||
|
||||
[[package]]
|
||||
name = "libadwaita"
|
||||
version = "0.1.0"
|
||||
@@ -431,6 +483,24 @@ version = "0.2.112"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matrixmultiply"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84"
|
||||
dependencies = [
|
||||
"rawpointer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.6.5"
|
||||
@@ -440,6 +510,74 @@ dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nalgebra"
|
||||
version = "0.30.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fb2d0de08694bed883320212c18ee3008576bfe8c306f4c3c4a58b4876998be"
|
||||
dependencies = [
|
||||
"approx",
|
||||
"matrixmultiply",
|
||||
"nalgebra-macros",
|
||||
"num-complex",
|
||||
"num-rational",
|
||||
"num-traits",
|
||||
"serde",
|
||||
"simba",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nalgebra-macros"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01fcc0b8149b4632adc89ac3b7b31a12fb6099a0317a4eb2ebff574ef7de7218"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-complex"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.9.0"
|
||||
@@ -471,6 +609,12 @@ dependencies = [
|
||||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0744126afe1a6dd7f394cb50a716dbe086cb06e255e53d8d0185d82828358fb5"
|
||||
|
||||
[[package]]
|
||||
name = "pest"
|
||||
version = "2.1.3"
|
||||
@@ -550,6 +694,12 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rawpointer"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.3.3"
|
||||
@@ -559,6 +709,15 @@ dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "safe_arch"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "794821e4ccb0d9f979512f9c1973480123f9bd62a90d74ab0f9426fcf8f4a529"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "0.11.0"
|
||||
@@ -582,6 +741,33 @@ name = "serde"
|
||||
version = "1.0.132"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b9875c23cf305cd1fd7eb77234cbb705f21ea6a72c637a5c6db5fe4b8e7f008"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.132"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ecc0db5cb2556c0e558887d9bbdcf6ac4471e83ff66cf696e5419024d1606276"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simba"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6fa406d0a270fc91831a28f705ba803ad05b971486af492317f1607390245b99"
|
||||
dependencies = [
|
||||
"approx",
|
||||
"num-complex",
|
||||
"num-traits",
|
||||
"paste",
|
||||
"wide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
@@ -648,6 +834,12 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
|
||||
|
||||
[[package]]
|
||||
name = "ucd-trie"
|
||||
version = "0.1.3"
|
||||
@@ -678,6 +870,16 @@ version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
|
||||
|
||||
[[package]]
|
||||
name = "wide"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3aba2d1dac31ac7cae82847ac5b8be822aee8f99a4e100f279605016b185c5f"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"safe_arch",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
@@ -699,3 +901,9 @@ name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "xml-rs"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3"
|
||||
|
||||
@@ -7,5 +7,6 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
adw = { version = "0.1.0", package = "libadwaita" }
|
||||
gtk = { version = "0.4.4", package = "gtk4" }
|
||||
gtk = { version = "0.4", package = "gtk4" }
|
||||
gls = { version = "0.1.6" }
|
||||
|
||||
|
||||
53
src/main.rs
53
src/main.rs
@@ -1,7 +1,10 @@
|
||||
use adw::{prelude::*, ApplicationWindow, HeaderBar, SplitButton};
|
||||
use gio::SimpleAction;
|
||||
use glib::clone;
|
||||
use gtk::{gio, glib};
|
||||
use gtk::{
|
||||
prelude::*, ActionBar, Adjustment, Application, AspectFrame, Box, Button, Grid, Image,
|
||||
Orientation, Scale, Separator, ToggleButton,
|
||||
Orientation, PositionType, Scale, Separator, ToggleButton,
|
||||
};
|
||||
|
||||
const MARGIN_TOP: i32 = 32;
|
||||
@@ -14,6 +17,8 @@ const NONE_STRING_OPTION: Option<String> = None;
|
||||
const TOGGLE_NEIGHBOURS_TEXT_TOGGLED: &str = "Hide Neighbours";
|
||||
const TOGGLE_NEIGHBOURS_TEXT: &str = "Show Neighbours";
|
||||
|
||||
const SCALE_STEP: f64 = 1.0;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct AnnotationImage {
|
||||
image_path: String,
|
||||
@@ -170,7 +175,7 @@ fn main() {
|
||||
.lower(0.0)
|
||||
.upper(10.0)
|
||||
.value(5.0)
|
||||
.step_increment(1.0)
|
||||
.step_increment(SCALE_STEP)
|
||||
.build();
|
||||
|
||||
let focus_scale = std::sync::Arc::new(
|
||||
@@ -283,8 +288,52 @@ fn main() {
|
||||
// add content to window
|
||||
.content(&application_vertical_widget)
|
||||
.build();
|
||||
|
||||
////////////////////////
|
||||
// Keyboard Shortcuts //
|
||||
////////////////////////
|
||||
|
||||
let action_toggle_neighbour = SimpleAction::new("toggle_neighbour", None);
|
||||
action_toggle_neighbour.connect_activate(clone!(@weak window => move |_, _| {
|
||||
neighbour_toggle_button.set_active(!neighbour_toggle_button.is_active());
|
||||
}));
|
||||
|
||||
let action_focus_scale_increment = SimpleAction::new("increment_focus_scale", None);
|
||||
action_focus_scale_increment.connect_activate(clone!(@strong focus_scale => move |_, _| {
|
||||
focus_scale.set_value(focus_scale.value() + SCALE_STEP);
|
||||
}));
|
||||
|
||||
let action_focus_scale_decrement = SimpleAction::new("decrement_focus_scale", None);
|
||||
action_focus_scale_decrement.connect_activate(clone!(@strong focus_scale => move |_, _| {
|
||||
focus_scale.set_value(focus_scale.value() - SCALE_STEP);
|
||||
}));
|
||||
|
||||
let mark_focus = SimpleAction::new("mark_focus", None);
|
||||
mark_focus.connect_activate(|_, _| {
|
||||
// TODO: implement mark_focus
|
||||
eprintln! {"Focus Set!"};
|
||||
});
|
||||
|
||||
let skip_focus = SimpleAction::new("skip_focus", None);
|
||||
skip_focus.connect_activate(|_, _| {
|
||||
// TODO: implement skip focus
|
||||
eprintln! {"Skip!"};
|
||||
});
|
||||
|
||||
window.add_action(&action_toggle_neighbour);
|
||||
window.add_action(&action_focus_scale_increment);
|
||||
window.add_action(&action_focus_scale_decrement);
|
||||
window.add_action(&mark_focus);
|
||||
window.add_action(&skip_focus);
|
||||
|
||||
window.show();
|
||||
});
|
||||
|
||||
application.set_accels_for_action("win.toggle_neighbour", &["G"]);
|
||||
application.set_accels_for_action("win.increment_focus_scale", &["W"]);
|
||||
application.set_accels_for_action("win.decrement_focus_scale", &["S"]);
|
||||
application.set_accels_for_action("win.mark_focus", &["M"]);
|
||||
application.set_accels_for_action("win.skip_focus", &["N"]);
|
||||
|
||||
application.run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user