@@ -18,6 +18,43 @@ const Main = () => {
18
18
const [ pageNum , setPageNum ] = useState ( 0 ) ;
19
19
const [ printing , setPrinting ] = useState ( false ) ;
20
20
21
+ const setFrameCoordValue = ( label : string , value : number ) => {
22
+ if ( frameCoord ) {
23
+ switch ( label ) {
24
+ case 'x0' :
25
+ setFrameCoord ( { ...frameCoord , x0 : value } ) ;
26
+ break ;
27
+ case 'x1' :
28
+ setFrameCoord ( { ...frameCoord , x1 : value } ) ;
29
+ break ;
30
+ case 'y0' :
31
+ frameCoord . y0 = value ;
32
+ setFrameCoord ( { ...frameCoord , y0 : value } ) ;
33
+ break ;
34
+ case 'y1' :
35
+ setFrameCoord ( { ...frameCoord , y1 : value } ) ;
36
+ break ;
37
+ default :
38
+ break ;
39
+ }
40
+ }
41
+ } ;
42
+
43
+ const setNextCoordValue = ( label : string , value : number ) => {
44
+ if ( nextCoord ) {
45
+ switch ( label ) {
46
+ case 'x' :
47
+ setNextCoord ( { ...nextCoord , x0 : value , x1 : value } ) ;
48
+ break ;
49
+ case 'y' :
50
+ setNextCoord ( { ...nextCoord , y0 : value , y1 : value } ) ;
51
+ break ;
52
+ default :
53
+ break ;
54
+ }
55
+ }
56
+ } ;
57
+
21
58
const handleCloseScreen = ( c : Coord ) => {
22
59
if ( c . select === 'frame' ) {
23
60
setFrameCoord ( { ...c } ) ;
@@ -80,8 +117,39 @@ const Main = () => {
80
117
{ frameCoord ? (
81
118
< span className = "flex items-center justify-center space-x-2 opacity-70" >
82
119
< p >
83
- Rectangle: ({ frameCoord . x0 } , { frameCoord . y0 } ) ({ frameCoord . x1 } ,{ ' ' }
84
- { frameCoord . y1 } )
120
+ Rectangle: [
121
+ < input
122
+ className = "w-16"
123
+ value = { frameCoord . x0 }
124
+ onChange = { ( e ) =>
125
+ setFrameCoordValue ( 'x0' , parseInt ( e . target . value , 10 ) )
126
+ }
127
+ />
128
+ ,{ ' ' }
129
+ < input
130
+ className = "w-16"
131
+ value = { frameCoord . y0 }
132
+ onChange = { ( e ) =>
133
+ setFrameCoordValue ( 'y0' , parseInt ( e . target . value , 10 ) )
134
+ }
135
+ />
136
+ ] [
137
+ < input
138
+ className = "w-16"
139
+ value = { frameCoord . x1 }
140
+ onChange = { ( e ) =>
141
+ setFrameCoordValue ( 'x1' , parseInt ( e . target . value , 10 ) )
142
+ }
143
+ />
144
+ ,{ ' ' }
145
+ < input
146
+ className = "w-16"
147
+ value = { frameCoord . y1 }
148
+ onChange = { ( e ) =>
149
+ setFrameCoordValue ( 'y1' , parseInt ( e . target . value , 10 ) )
150
+ }
151
+ />
152
+ ]
85
153
</ p >
86
154
< FaTimesCircle
87
155
onClick = { ( ) => setFrameCoord ( undefined ) }
@@ -105,8 +173,23 @@ const Main = () => {
105
173
{ nextCoord ? (
106
174
< span className = "flex items-center justify-center space-x-2 opacity-70" >
107
175
< p >
108
- Point: ({ ( nextCoord . x0 + nextCoord . x1 ) / 2 } ,{ ' ' }
109
- { ( nextCoord . y0 + nextCoord . y1 ) / 2 } )
176
+ Point: [
177
+ < input
178
+ className = "w-16"
179
+ value = { ( nextCoord . x0 + nextCoord . x1 ) / 2 }
180
+ onChange = { ( e ) =>
181
+ setNextCoordValue ( 'x' , parseInt ( e . target . value , 10 ) )
182
+ }
183
+ />
184
+ ,{ ' ' }
185
+ < input
186
+ className = "w-16"
187
+ value = { ( nextCoord . y0 + nextCoord . y1 ) / 2 }
188
+ onChange = { ( e ) =>
189
+ setNextCoordValue ( 'y' , parseInt ( e . target . value , 10 ) )
190
+ }
191
+ />
192
+ ]
110
193
</ p >
111
194
< FaTimesCircle
112
195
onClick = { ( ) => setNextCoord ( undefined ) }
0 commit comments