@@ -12,6 +12,7 @@ interface Coord {
1212const Main = ( ) => {
1313 const [ frameCoord , setFrameCoord ] = useState < Coord > ( ) ;
1414 const [ nextCoord , setNextCoord ] = useState < Coord > ( ) ;
15+ const [ pages , setPages ] = useState ( 0 ) ;
1516
1617 const handleCloseScreen = ( c : Coord ) => {
1718 if ( c . select === 'frame' ) {
@@ -31,46 +32,75 @@ const Main = () => {
3132 ipcRenderer . invoke ( 'open-screen' , { select } ) ;
3233 } ;
3334
35+ const handlePrint = ( ) => {
36+ ipcRenderer . invoke ( 'start-printing' , { frameCoord, nextCoord, pages } ) ;
37+ } ;
38+
3439 ipcRenderer . on ( 'close-screen' , ( _ , c : Coord ) => {
3540 handleCloseScreen ( c ) ;
3641 } ) ;
3742
3843 return (
39- < section className = "flex flex-col items-start justify-center p-8 space-y-8" >
40- < section className = "flex items-center justify-start" >
41- < button
42- type = "button"
43- onClick = { ( ) => handleOpenScreen ( 'frame' ) }
44- className = "btn"
45- >
46- Select screenshot frame...
47- </ button >
48- { frameCoord ? (
49- < p >
50- Frame: ({ frameCoord . x0 } , { frameCoord . y0 } ) and ({ frameCoord . x1 } ,{ ' ' }
51- { frameCoord . y1 } )
52- </ p >
53- ) : (
54- < p />
55- ) }
44+ < section className = "absolute inset-0 flex flex-col items-stretch justify-center p-8 space-y-8 bg-gray-100" >
45+ < section className = "flex flex-col items-stretch flex-1 p-4 border rounded space-y-7" >
46+ < section className = "flex items-center justify-start space-x-4" >
47+ < button
48+ type = "button"
49+ onClick = { ( ) => handleOpenScreen ( 'frame' ) }
50+ className = "btn"
51+ >
52+ Select screenshot frame...
53+ </ button >
54+ { frameCoord ? (
55+ < p >
56+ Rect: ({ frameCoord . x0 } , { frameCoord . y0 } ) and ({ frameCoord . x1 } ,{ ' ' }
57+ { frameCoord . y1 } )
58+ </ p >
59+ ) : (
60+ < p />
61+ ) }
62+ </ section >
63+
64+ < section className = "flex items-center justify-start space-x-4" >
65+ < button
66+ type = "button"
67+ onClick = { ( ) => handleOpenScreen ( 'next' ) }
68+ className = "btn"
69+ >
70+ Select next button...
71+ </ button >
72+ { nextCoord ? (
73+ < p >
74+ Point: ({ ( nextCoord . x0 + nextCoord . x1 ) / 2 } ,{ ' ' }
75+ { ( nextCoord . y0 + nextCoord . y1 ) / 2 } )
76+ </ p >
77+ ) : (
78+ < p />
79+ ) }
80+ </ section >
81+
82+ < section className = "flex items-center justify-start ml-1 space-x-4" >
83+ < p > Total pages:</ p >
84+ < input
85+ value = { pages }
86+ onChange = { ( e ) => setPages ( parseInt ( e . target . value , 10 ) ) }
87+ type = "number"
88+ />
89+ </ section >
5690 </ section >
5791
58- < section className = "flex items-center justify-start " >
92+ < section className = "flex flex-col items-center space-y-4 " >
5993 < button
6094 type = "button"
61- onClick = { ( ) => handleOpenScreen ( 'next' ) }
62- className = "btn"
95+ onClick = { handlePrint }
96+ className = "w-full py-2 text-base btn"
97+ disabled = { ! frameCoord || ! nextCoord || ! pages }
6398 >
64- Select next button...
99+ Start printing
65100 </ button >
66- { nextCoord ? (
67- < p >
68- Next button: ({ ( nextCoord . x0 + nextCoord . x1 ) / 2 } ,{ ' ' }
69- { ( nextCoord . y0 + nextCoord . y1 ) / 2 } )
70- </ p >
71- ) : (
72- < p />
73- ) }
101+ < p className = "opacity-50" >
102+ You can stop printing anytime by pressing the "ESC" button
103+ </ p >
74104 </ section >
75105 </ section >
76106 ) ;
0 commit comments