@@ -50,6 +50,7 @@ namespace lsp
5050
5151 sTextLayout .bind(" text.layout" , this );
5252 sTextAdjust .bind(" text.adjust" , this );
53+ sTextClip .bind(" text.clip" , this );
5354 sFont .bind(" font" , this );
5455 sHover .bind(" text.hover" , this );
5556 sConstraints .bind(" size.constraints" , this );
@@ -70,6 +71,7 @@ namespace lsp
7071
7172 sTextLayout .set(0 .0f , 0 .0f );
7273 sTextAdjust .set(TA_NONE);
74+ sTextClip .set(false );
7375 sFont .set_size(12 .0f );
7476 sHover .set(false );
7577 sConstraints .set(-1 , -1 , -1 , -1 );
@@ -97,6 +99,7 @@ namespace lsp
9799 sFont (&sProperties ),
98100 sHover (&sProperties ),
99101 sText (&sProperties ),
102+ sTextClip (&sProperties ),
100103 sConstraints (&sProperties ),
101104 sPopup (&sProperties )
102105 {
@@ -135,6 +138,7 @@ namespace lsp
135138 sFont .bind (" font" , &sStyle );
136139 sHover .bind (" text.hover" , &sStyle );
137140 sText .bind (&sStyle , pDisplay->dictionary ());
141+ sTextClip .bind (" text.clip" , &sStyle );
138142 sConstraints .bind (" size.constraints" , &sStyle );
139143 sIPadding .bind (" ipadding" , &sStyle );
140144 sPopup .bind (NULL );
@@ -159,7 +163,7 @@ namespace lsp
159163 if (prop->one_of (sTextLayout , sHover ))
160164 query_draw ();
161165
162- if (prop->one_of (sTextAdjust , sFont , sText , sConstraints , sIPadding ))
166+ if (prop->one_of (sTextAdjust , sTextClip , sFont , sText , sConstraints , sIPadding ))
163167 query_resize ();
164168 }
165169
@@ -181,6 +185,22 @@ namespace lsp
181185 sFont .get_multitext_parameters (s, &tp, fscaling, &text);
182186 sIPadding .sub (&size, &sSize , scaling);
183187
188+ // Apply text clipping
189+ const bool clip = sTextClip .get ();
190+ if (clip)
191+ {
192+ r.nLeft = 0 ;
193+ r.nTop = 0 ;
194+ r.nWidth = sSize .nWidth ;
195+ r.nHeight = sSize .nHeight ;
196+ sIPadding .enter (&r, scaling);
197+ s->clip_begin (&r);
198+ }
199+ lsp_finally {
200+ if (clip)
201+ s->clip_end ();
202+ };
203+
184204 // Estimate drawing area
185205 tp.Height = lsp_max (tp.Height , fp.Height );
186206 if (tp.Width <= size.nWidth )
@@ -347,10 +367,15 @@ namespace lsp
347367 e.r = r;
348368 sFont .get_parameters (pDisplay, e.fscaling , &e.fp );
349369
350- // Estimate the size of the label
351- for (lltl::iterator<prop::String> it = vEstimations.values (); it; ++it)
352- estimate_string_size (&e, it.get ());
353- estimate_string_size (&e, &sText );
370+ if (!sTextClip .get ())
371+ {
372+ // Estimate the size of the label
373+ for (lltl::iterator<prop::String> it = vEstimations.values (); it; ++it)
374+ estimate_string_size (&e, it.get ());
375+ estimate_string_size (&e, &sText );
376+ }
377+ else
378+ r->nMinHeight = e.fp .Height ;
354379
355380 // Apply size constraints
356381 sConstraints .apply (r, e.scaling );
0 commit comments