Skip to content

Commit 7cfd617

Browse files
committed
Fixed label text alignment when clipping
1 parent fcbc4f5 commit 7cfd617

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

src/main/widgets/simple/Label.cpp

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -183,47 +183,49 @@ namespace lsp
183183

184184
sFont.get_parameters(s, fscaling, &fp);
185185
sFont.get_multitext_parameters(s, &tp, fscaling, &text);
186+
tp.Height = lsp_max(tp.Height, fp.Height);
186187
sIPadding.sub(&size, &sSize, scaling);
187188

188-
// Apply text clipping
189+
// Estimate drawing area
189190
const bool clip = sTextClip.get();
190191
if (clip)
191192
{
193+
// Apply text clipping
192194
r.nLeft = 0;
193195
r.nTop = 0;
194196
r.nWidth = sSize.nWidth;
195197
r.nHeight = sSize.nHeight;
196198
sIPadding.enter(&r, scaling);
197199
s->clip_begin(&r);
198200
}
199-
lsp_finally {
200-
if (clip)
201-
s->clip_end();
202-
};
203-
204-
// Estimate drawing area
205-
tp.Height = lsp_max(tp.Height, fp.Height);
206-
if (tp.Width <= size.nWidth)
207-
{
208-
r.nLeft = 0;
209-
r.nWidth = size.nWidth;
210-
}
211201
else
212202
{
213-
r.nLeft = -0.5f * (tp.Width - size.nWidth);
214-
r.nWidth = ceil(tp.Width);
215-
}
203+
if (tp.Width <= size.nWidth)
204+
{
205+
r.nLeft = 0;
206+
r.nWidth = size.nWidth;
207+
}
208+
else
209+
{
210+
r.nLeft = -0.5f * (tp.Width - size.nWidth);
211+
r.nWidth = ceil(tp.Width);
212+
}
216213

217-
if (tp.Height <= size.nHeight)
218-
{
219-
r.nTop = 0;
220-
r.nHeight = size.nHeight;
221-
}
222-
else
223-
{
224-
r.nTop = -0.5f * (tp.Height - size.nHeight);
225-
r.nHeight = ceil(tp.Height);
214+
if (tp.Height <= size.nHeight)
215+
{
216+
r.nTop = 0;
217+
r.nHeight = size.nHeight;
218+
}
219+
else
220+
{
221+
r.nTop = -0.5f * (tp.Height - size.nHeight);
222+
r.nHeight = ceil(tp.Height);
223+
}
226224
}
225+
lsp_finally {
226+
if (clip)
227+
s->clip_end();
228+
};
227229

228230
// Initialize palette
229231
const style::LabelColors *colors = select_colors();

0 commit comments

Comments
 (0)