@@ -2,6 +2,17 @@ use crate::gui::LauncherApp;
22use crate :: plugins:: todo:: { load_todos, save_todos, TodoEntry , TODO_FILE } ;
33use eframe:: egui;
44
5+ const TODO_VIEW_SIZE : egui:: Vec2 = egui:: vec2 ( 360.0 , 260.0 ) ;
6+ const TODO_VIEW_LIST_HEIGHT : f32 = 170.0 ;
7+
8+ pub fn todo_view_layout_sizes ( ) -> ( egui:: Vec2 , f32 ) {
9+ ( TODO_VIEW_SIZE , TODO_VIEW_LIST_HEIGHT )
10+ }
11+
12+ pub fn todo_view_window_constraints ( ) -> ( egui:: Vec2 , egui:: Vec2 ) {
13+ ( TODO_VIEW_SIZE , TODO_VIEW_SIZE )
14+ }
15+
516#[ derive( Default ) ]
617pub struct TodoViewDialog {
718 pub open : bool ,
@@ -51,14 +62,16 @@ impl TodoViewDialog {
5162 if !self . open {
5263 return ;
5364 }
65+ let ( window_size, list_height) = todo_view_layout_sizes ( ) ;
66+ let ( min_size, max_size) = todo_view_window_constraints ( ) ;
5467 let mut close = false ;
5568 let mut save_now = false ;
5669 egui:: Window :: new ( "View Todos" )
5770 . open ( & mut self . open )
58- . resizable ( true )
59- . default_size ( ( 320.0 , 240.0 ) )
60- . min_width ( 200.0 )
61- . min_height ( 150.0 )
71+ . resizable ( false )
72+ . default_size ( window_size )
73+ . min_size ( min_size )
74+ . max_size ( max_size )
6275 . show ( ctx, |ui| {
6376 ui. horizontal ( |ui| {
6477 ui. checkbox ( & mut self . sort_by_priority , "Sort by priority" ) ;
@@ -88,11 +101,10 @@ impl TodoViewDialog {
88101 indices
89102 . sort_by ( |a, b| self . entries [ * b] . priority . cmp ( & self . entries [ * a] . priority ) ) ;
90103 }
91- let area_height = ui. available_height ( ) ;
92104 // Keep horizontal overflow for long todo text without wrapping.
93105 egui:: ScrollArea :: both ( )
94106 . auto_shrink ( [ false , false ] )
95- . max_height ( area_height )
107+ . max_height ( list_height )
96108 . show ( ui, |ui| {
97109 for idx in indices {
98110 if Some ( idx) == self . editing_idx {
@@ -184,3 +196,19 @@ impl TodoViewDialog {
184196 }
185197 }
186198}
199+
200+ #[ cfg( test) ]
201+ mod tests {
202+ use super :: * ;
203+
204+ #[ test]
205+ fn todo_view_layout_sizes_constants ( ) {
206+ let ( window_size, list_height) = todo_view_layout_sizes ( ) ;
207+ let ( min_size, max_size) = todo_view_window_constraints ( ) ;
208+ assert_eq ! ( window_size, TODO_VIEW_SIZE ) ;
209+ assert_eq ! ( list_height, TODO_VIEW_LIST_HEIGHT ) ;
210+ assert_eq ! ( min_size, max_size) ;
211+ assert_eq ! ( window_size, min_size) ;
212+ assert ! ( list_height < window_size. y) ;
213+ }
214+ }
0 commit comments