@@ -31,7 +31,9 @@ public class Label : Widget
3131 SupportsCommands = false
3232 } ;
3333
34- [ Category ( "Appearance" ) ]
34+ private bool _singleLine = false ;
35+
36+ [ Category ( "Appearance" ) ]
3537 [ DefaultValue ( 0 ) ]
3638 public int VerticalSpacing
3739 {
@@ -101,10 +103,31 @@ public bool Wrap
101103 }
102104 }
103105
104- /// <summary>
105- /// The method used to abbreviate overflowing text.
106- /// </summary>
107- [ Category ( "Appearance" ) ]
106+ [ Category ( "Appearance" ) ]
107+ [ DefaultValue ( false ) ]
108+ public bool SingleLine
109+ {
110+ get
111+ {
112+ return _singleLine ;
113+ }
114+
115+ set
116+ {
117+ if ( value == _singleLine )
118+ {
119+ return ;
120+ }
121+
122+ _singleLine = value ;
123+ InvalidateMeasure ( ) ;
124+ }
125+ }
126+
127+ /// <summary>
128+ /// The method used to abbreviate overflowing text.
129+ /// </summary>
130+ [ Category ( "Appearance" ) ]
108131 [ DefaultValue ( AutoEllipsisMethod . None ) ]
109132 public AutoEllipsisMethod AutoEllipsisMethod
110133 {
@@ -255,11 +278,24 @@ protected override void InternalArrange()
255278 {
256279 base . InternalArrange ( ) ;
257280
258- _richText . Width = _wrap ? ActualBounds . Width : default ( int ? ) ;
259- _richText . Height = _wrap ? ActualBounds . Height : default ( int ? ) ;
260- }
261-
262- public void ApplyLabelStyle ( LabelStyle style )
281+ if ( _singleLine )
282+ {
283+ _richText . Width = ActualBounds . Width ;
284+ _richText . Height = Font . LineHeight ;
285+ }
286+ else if ( _wrap )
287+ {
288+ _richText . Width = ActualBounds . Width ;
289+ _richText . Height = ActualBounds . Height ;
290+ }
291+ else
292+ {
293+ _richText . Width = _wrap ? ActualBounds . Width : default ( int ? ) ;
294+ _richText . Height = _wrap ? ActualBounds . Height : default ( int ? ) ;
295+ }
296+ }
297+
298+ public void ApplyLabelStyle ( LabelStyle style )
263299 {
264300 ApplyWidgetStyle ( style ) ;
265301
0 commit comments