aboutsummaryrefslogtreecommitdiff
path: root/src/app/impl_view.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/impl_view.rs')
-rw-r--r--src/app/impl_view.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/app/impl_view.rs b/src/app/impl_view.rs
index c369d8f..e4eb67a 100644
--- a/src/app/impl_view.rs
+++ b/src/app/impl_view.rs
@@ -10,15 +10,16 @@ use cursive::view::View;
10use cursive::{Printer, Vec2}; 10use cursive::{Printer, Vec2};
11use notify::DebouncedEvent; 11use notify::DebouncedEvent;
12 12
13use crate::CONFIGURATION;
13use crate::app::{App, MessageKind}; 14use crate::app::{App, MessageKind};
14use crate::habit::{HabitWrapper, ViewMode}; 15use crate::habit::{HabitWrapper, ViewMode};
15use crate::utils::{self, GRID_WIDTH, VIEW_HEIGHT, VIEW_WIDTH}; 16use crate::utils::{self, VIEW_HEIGHT, VIEW_WIDTH};
16 17
17impl View for App { 18impl View for App {
18 fn draw(&self, printer: &Printer) { 19 fn draw(&self, printer: &Printer) {
19 let mut offset = Vec2::zero(); 20 let mut offset = Vec2::zero();
20 for (idx, habit) in self.habits.iter().enumerate() { 21 for (idx, habit) in self.habits.iter().enumerate() {
21 if idx >= GRID_WIDTH && idx % GRID_WIDTH == 0 { 22 if idx >= CONFIGURATION.grid_size() && idx % CONFIGURATION.grid_size() == 0 {
22 offset = offset.map_y(|y| y + VIEW_HEIGHT).map_x(|_| 0); 23 offset = offset.map_y(|y| y + VIEW_HEIGHT).map_x(|_| 0);
23 } 24 }
24 habit.draw(&printer.offset(offset).focused(self.focus == idx)); 25 habit.draw(&printer.offset(offset).focused(self.focus == idx));
@@ -41,10 +42,10 @@ impl View for App {
41 } 42 }
42 43
43 fn required_size(&mut self, _: Vec2) -> Vec2 { 44 fn required_size(&mut self, _: Vec2) -> Vec2 {
44 let width = GRID_WIDTH * (VIEW_WIDTH + 2); 45 let width = CONFIGURATION.grid_size() * (VIEW_WIDTH + 2);
45 let height = { 46 let height = {
46 if self.habits.len() > 0 { 47 if self.habits.len() > 0 {
47 (VIEW_HEIGHT as f64 * (self.habits.len() as f64 / GRID_WIDTH as f64).ceil()) 48 (VIEW_HEIGHT as f64 * (self.habits.len() as f64 / CONFIGURATION.grid_size() as f64).ceil())
48 as usize 49 as usize
49 } else { 50 } else {
50 0 51 0