aboutsummaryrefslogtreecommitdiff
path: root/src/app/impl_self.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-08-03 11:35:55 +0100
committerAkshay <[email protected]>2020-08-03 11:35:55 +0100
commitfcaf919fd1e176e4b8dd6d5d21e25db7f68c32a8 (patch)
treeb1fa143f95d5bbc48f4008641ce031cd7f5f4532 /src/app/impl_self.rs
parent7e1dff439f1768fc463ddcfcd6ea58a7a1711056 (diff)
use consts for dimensions
Diffstat (limited to 'src/app/impl_self.rs')
-rw-r--r--src/app/impl_self.rs18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs
index 39882be..5cd9616 100644
--- a/src/app/impl_self.rs
+++ b/src/app/impl_self.rs
@@ -13,8 +13,7 @@ use notify::{watcher, RecursiveMode, Watcher};
13 13
14use crate::command::{Command, CommandLineError}; 14use crate::command::{Command, CommandLineError};
15use crate::habit::{Bit, Count, HabitWrapper, TrackEvent, ViewMode}; 15use crate::habit::{Bit, Count, HabitWrapper, TrackEvent, ViewMode};
16use crate::utils; 16use crate::utils::{self, GRID_WIDTH, VIEW_HEIGHT, VIEW_WIDTH};
17use crate::CONFIGURATION;
18 17
19use crate::app::{App, MessageKind, StatusLine}; 18use crate::app::{App, MessageKind, StatusLine};
20 19
@@ -87,7 +86,6 @@ impl App {
87 } 86 }
88 87
89 pub fn set_focus(&mut self, d: Absolute) { 88 pub fn set_focus(&mut self, d: Absolute) {
90 let grid_width = CONFIGURATION.grid_width;
91 match d { 89 match d {
92 Absolute::Right => { 90 Absolute::Right => {
93 if self.focus != self.habits.len() - 1 { 91 if self.focus != self.habits.len() - 1 {
@@ -100,15 +98,15 @@ impl App {
100 } 98 }
101 } 99 }
102 Absolute::Down => { 100 Absolute::Down => {
103 if self.focus + grid_width < self.habits.len() - 1 { 101 if self.focus + GRID_WIDTH < self.habits.len() - 1 {
104 self.focus += grid_width; 102 self.focus += GRID_WIDTH;
105 } else { 103 } else {
106 self.focus = self.habits.len() - 1; 104 self.focus = self.habits.len() - 1;
107 } 105 }
108 } 106 }
109 Absolute::Up => { 107 Absolute::Up => {
110 if self.focus as isize - grid_width as isize >= 0 { 108 if self.focus as isize - GRID_WIDTH as isize >= 0 {
111 self.focus -= grid_width; 109 self.focus -= GRID_WIDTH;
112 } else { 110 } else {
113 self.focus = 0; 111 self.focus = 0;
114 } 112 }
@@ -146,12 +144,10 @@ impl App {
146 } 144 }
147 145
148 pub fn max_size(&self) -> Vec2 { 146 pub fn max_size(&self) -> Vec2 {
149 let grid_width = CONFIGURATION.grid_width; 147 let width = GRID_WIDTH * VIEW_WIDTH;
150 let width = grid_width * CONFIGURATION.view_width;
151 let height = { 148 let height = {
152 if !self.habits.is_empty() { 149 if !self.habits.is_empty() {
153 (CONFIGURATION.view_height as f64 150 (VIEW_HEIGHT as f64 * (self.habits.len() as f64 / GRID_WIDTH as f64).ceil())
154 * (self.habits.len() as f64 / grid_width as f64).ceil())
155 as usize 151 as usize
156 } else { 152 } else {
157 0 153 0