summary history branches tags files
commit:0b006388693c03e47e2158c69c2bf22507d82eb8
author:Trevor Bentley
committer:Trevor Bentley
date:Thu Jul 27 17:24:16 2017 +0200
parents:ebe9e6cd252b76e86b499d5d0a75c40ac3ae3c6d
Support cancelling swipes.  Fixes colors getting stuck.
diff --git a/CHANGELOG.md b/CHANGELOG.md
line changes: +7/-0
index 0000000..7ad6660
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,7 @@
+0.2.1
+-----
+ * Fixed colors getting stuck when putting down a second finger during a swipe
+
+0.2.0
+-----
+ * First release

diff --git a/Cargo.lock b/Cargo.lock
line changes: +4/-3
index 4d99767..d93c414
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3,9 +3,10 @@ name = "toucHNews"
 version = "0.2.1-rc"
 dependencies = [
  "hn 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "objc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "open 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rubrail 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rubrail 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -550,7 +551,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "rubrail"
-version = "0.4.2"
+version = "0.4.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "cocoa 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -970,7 +971,7 @@ dependencies = [
 "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
 "checksum rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "022e0636ec2519ddae48154b028864bdce4eaf7d35226ab8e65c611be97b189d"
 "checksum redox_syscall 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "80dcf663dc552529b9bfc7bdb30ea12e5fa5d3545137d850a91ad410053f68e9"
-"checksum rubrail 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2456a403846ccd31e2139306316073cf10ab5dd7491f67f3709f96385f4756f8"
+"checksum rubrail 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "95cb253f41ab78e8bf03557b46745512fdf3c3016710030ccf05056466dc0243"
 "checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084"
 "checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f"
 "checksum schannel 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "14a5f8491ae5fc8c51aded1f5806282a0218b4d69b1b76913a0559507e559b90"

diff --git a/Cargo.toml b/Cargo.toml
line changes: +1/-0
index ce33aa1..3f2126d
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,6 +22,7 @@ rubrail = "0.4"
 hn = "0.2"
 objc = "0.2"
 open = "1.2"
+log = {version = "0.3", optional = true }
 
 [package.metadata.release]
 sign-commit = false

diff --git a/src/main.rs b/src/main.rs
line changes: +24/-11
index d14369d..d6bd187
--- a/src/main.rs
+++ b/src/main.rs
@@ -10,6 +10,10 @@ use hn::HackerNews;
 
 extern crate open;
 
+#[cfg(feature = "log")]
+#[macro_use]
+extern crate log;
+
 #[macro_use]
 extern crate objc;
 use objc::runtime::Object;
@@ -59,17 +63,24 @@ impl TouchbarUI {
                 t if t < -170. => (0.8, 0.4, 0.1, 1.0),
                 _ => (0.9, 0.9, 0.9, 1.0),
             };
-            unsafe { rubrail::util::set_text_color(item, rgba.0, rgba.1, rgba.2, rgba.3); }
-            if state == SwipeState::Ended {
-                unsafe { rubrail::util::set_text_color(item, 1., 1., 1., 1.); }
-                match translation {
-                    t if t > 170. => {
-                        let _ = tx.send(Cmd::Open);
-                    },
-                    t if t < -170. => {
-                        let _ = tx.send(Cmd::Hide);
-                    },
-                    _ => {},
+            match state {
+                SwipeState::Cancelled | SwipeState::Failed | SwipeState::Unknown => {
+                    unsafe { rubrail::util::set_text_color(item, 1., 1., 1., 1.); }
+                },
+                SwipeState::Ended => {
+                    unsafe { rubrail::util::set_text_color(item, 1., 1., 1., 1.); }
+                    match translation {
+                        t if t > 170. => {
+                            let _ = tx.send(Cmd::Open);
+                        },
+                        t if t < -170. => {
+                            let _ = tx.send(Cmd::Hide);
+                        },
+                        _ => {},
+                    }
+                }
+                _ => {
+                    unsafe { rubrail::util::set_text_color(item, rgba.0, rgba.1, rgba.2, rgba.3); }
                 }
             }
         }));
@@ -143,6 +154,8 @@ impl TouchbarUI {
 }
 
 fn main() {
+    #[cfg(feature = "log")]
+    rubrail::app::create_logger(".touchnews.log");
     rubrail::app::init_app();
     let mut bar = TouchbarUI::init();
     let mut nsapp = NSApp::new();