@@ -21,12 +21,21 @@ struct xfont
2121 static void restore_render_state ();
2222 static xfont create ();
2323 static xfont create (U32 id , F32 width , F32 height , F32 space , iColor_tag color ,
24- const basic_rect < F32 > & clip );
25-
24+ const basic_rect < F32 > & clip )
25+ {
26+ xfont r ;
27+ r .id = id ;
28+ r .width = width ;
29+ r .height = height ;
30+ r .space = space ;
31+ r .color = color ;
32+ r .clip = clip ;
33+
34+ return r ;
35+ }
2636 basic_rect < F32 > bounds (char c ) const ;
2737 basic_rect < F32 > bounds (const char * text ) const ;
28- basic_rect < F32 > bounds (const char * text , size_t text_size , F32 max_width ,
29- size_t & size ) const ;
38+ basic_rect < F32 > bounds (const char * text , size_t text_size , F32 max_width , size_t & size ) const ;
3039 void start_render () const ;
3140 void stop_render () const ;
3241 void irender (const char * text , F32 x , F32 y ) const ;
@@ -158,43 +167,43 @@ struct xtextbox
158167 static callback text_cb ;
159168
160169 xtextbox & operator = (const xtextbox & rhs )
161- {
162- this -> font .id = rhs .font .id ;
170+ {
171+ this -> font .id = rhs .font .id ;
163172
164- * (S32 * )(& this -> font .width ) = * (S32 * )(& rhs .font .width );
165- * (S32 * )(& this -> font .height ) = * (S32 * )(& rhs .font .height );
166- * (S32 * )(& this -> font .space ) = * (S32 * )(& rhs .font .space );
173+ * (S32 * )(& this -> font .width ) = * (S32 * )(& rhs .font .width );
174+ * (S32 * )(& this -> font .height ) = * (S32 * )(& rhs .font .height );
175+ * (S32 * )(& this -> font .space ) = * (S32 * )(& rhs .font .space );
167176
168- * (S32 * )(& this -> font .color ) = * (S32 * )(& rhs .font .color );
177+ * (S32 * )(& this -> font .color ) = * (S32 * )(& rhs .font .color );
169178
170- * (S32 * )(& this -> font .clip .x ) = * (S32 * )(& rhs .font .clip .x );
171- * (S32 * )(& this -> font .clip .y ) = * (S32 * )(& rhs .font .clip .y );
172- * (S32 * )(& this -> font .clip .w ) = * (S32 * )(& rhs .font .clip .w );
173- * (S32 * )(& this -> font .clip .h ) = * (S32 * )(& rhs .font .clip .h );
179+ * (S32 * )(& this -> font .clip .x ) = * (S32 * )(& rhs .font .clip .x );
180+ * (S32 * )(& this -> font .clip .y ) = * (S32 * )(& rhs .font .clip .y );
181+ * (S32 * )(& this -> font .clip .w ) = * (S32 * )(& rhs .font .clip .w );
182+ * (S32 * )(& this -> font .clip .h ) = * (S32 * )(& rhs .font .clip .h );
174183
175- * (S32 * )(& this -> bounds .x ) = * (S32 * )(& rhs .bounds .x );
176- * (S32 * )(& this -> bounds .y ) = * (S32 * )(& rhs .bounds .y );
177- * (S32 * )(& this -> bounds .w ) = * (S32 * )(& rhs .bounds .w );
178- * (S32 * )(& this -> bounds .h ) = * (S32 * )(& rhs .bounds .h );
184+ * (S32 * )(& this -> bounds .x ) = * (S32 * )(& rhs .bounds .x );
185+ * (S32 * )(& this -> bounds .y ) = * (S32 * )(& rhs .bounds .y );
186+ * (S32 * )(& this -> bounds .w ) = * (S32 * )(& rhs .bounds .w );
187+ * (S32 * )(& this -> bounds .h ) = * (S32 * )(& rhs .bounds .h );
179188
180- this -> flags = rhs .flags ;
189+ this -> flags = rhs .flags ;
181190
182- this -> line_space = rhs .line_space ;
183- this -> tab_stop = rhs .tab_stop ;
184- this -> left_indent = rhs .left_indent ;
185- this -> right_indent = rhs .right_indent ;
191+ this -> line_space = rhs .line_space ;
192+ this -> tab_stop = rhs .tab_stop ;
193+ this -> left_indent = rhs .left_indent ;
194+ this -> right_indent = rhs .right_indent ;
186195
187- this -> cb = rhs .cb ;
188- this -> context = rhs .context ;
189- this -> texts = rhs .texts ;
190- this -> text_sizes = rhs .text_sizes ;
191- this -> texts_size = rhs .texts_size ;
192- this -> text .text = rhs .text .text ;
193- this -> text .size = rhs .text .size ;
194- this -> text_hash = rhs .text_hash ;
196+ this -> cb = rhs .cb ;
197+ this -> context = rhs .context ;
198+ this -> texts = rhs .texts ;
199+ this -> text_sizes = rhs .text_sizes ;
200+ this -> texts_size = rhs .texts_size ;
201+ this -> text .text = rhs .text .text ;
202+ this -> text .size = rhs .text .size ;
203+ this -> text_hash = rhs .text_hash ;
195204
196- return * this ;
197- }
205+ return * this ;
206+ }
198207
199208 static void text_render (const jot & j , const xtextbox & tb , F32 x , F32 y );
200209 static tag_entry_list read_tag (const substr & s );
@@ -207,20 +216,36 @@ struct xtextbox
207216 static tag_type * find_format_tag (const substr & s , S32 & index );
208217 static xtextbox create ();
209218 static xtextbox create (const xfont & font , const basic_rect < F32 > & bounds , U32 flags ,
210- F32 line_space , F32 tab_stop , F32 left_indent ,
211- F32 right_indent );
219+ F32 line_space , F32 tab_stop , F32 left_indent , F32 right_indent )
220+ {
221+ xtextbox r ;
222+ r .font = font ;
223+ r .bounds = bounds ;
224+ r .flags = flags ;
225+ r .line_space = line_space ;
226+ r .tab_stop = tab_stop ;
227+ r .left_indent = left_indent ;
228+ r .right_indent = right_indent ;
229+ r .texts_size = 0 ;
230+ r .text_hash = 0 ;
231+ r .cb = & text_cb ;
232+
233+ return r ;
234+ }
212235
213236 void set_text (const char * text );
214237 void set_text (const char * text , size_t text_size );
215238 void set_text (const char * * texts , size_t size );
216239 void set_text (const char * * texts , const size_t * text_sizes , size_t size );
217240 layout & temp_layout (bool cache ) const ;
218- void render (bool cache ) const ;
241+ void render (bool cache ) const
242+ {
243+ render (temp_layout (cache ), 0 , -1 );
244+ }
219245 void render (layout & l , S32 begin_jot , S32 end_jot ) const ;
220246 F32 yextent (bool cache ) const ;
221247 F32 yextent (F32 max , S32 & size , bool cache ) const ;
222- F32 yextent (F32 max , S32 & size , const layout & l , S32 begin_jot ,
223- S32 end_jot ) const ;
248+ F32 yextent (F32 max , S32 & size , const layout & l , S32 begin_jot , S32 end_jot ) const ;
224249};
225250
226251struct xtextbox ::layout
@@ -253,7 +278,14 @@ struct xtextbox::layout
253278
254279void render_fill_rect (const basic_rect < F32 > & bounds , iColor_tag color );
255280
256- F32 NSCREENX (F32 );
257- F32 NSCREENY (F32 );
281+ inline F32 NSCREENX (F32 scale )
282+ {
283+ return (1.0f / 640 ) * scale ;
284+ }
285+
286+ inline F32 NSCREENY (F32 scale )
287+ {
288+ return (1.0f / 480 ) * scale ;
289+ }
258290
259291#endif
0 commit comments