mirror of https://github.com/aseprite/aseprite.git
[ui] Align text with different fonts correctly to ui::Entry baseline
Regression introduced in af6e8b65c3
This commit is contained in:
parent
bd13e5d574
commit
0ddf7d939b
|
@ -42,6 +42,7 @@
|
|||
#include "text/font.h"
|
||||
#include "text/font_metrics.h"
|
||||
#include "text/font_style_set.h"
|
||||
#include "text/text_blob.h"
|
||||
#include "ui/intern.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
|
@ -1443,10 +1444,11 @@ void SkinTheme::drawEntryText(ui::Graphics* g, ui::Entry* widget)
|
|||
|
||||
IntersectClip clip(g, bounds);
|
||||
if (clip) {
|
||||
g->drawTextWithDelegate(std::string(pos, textString.end()), // TODO use a string_view()
|
||||
g->drawTextWithDelegate(
|
||||
std::string(pos, textString.end()), // TODO use a string_view()
|
||||
colors.text(),
|
||||
ColorNone,
|
||||
bounds.origin(),
|
||||
gfx::Point(bounds.x, widget->textBaseline() - widget->textBlob()->baseline()),
|
||||
&delegate);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "os/system.h"
|
||||
#include "text/draw_text.h"
|
||||
#include "text/font.h"
|
||||
#include "text/font_metrics.h"
|
||||
#include "ui/clipboard_delegate.h"
|
||||
#include "ui/display.h"
|
||||
#include "ui/menu.h"
|
||||
|
@ -549,6 +550,18 @@ void Entry::onSetText()
|
|||
m_caret = textlen;
|
||||
}
|
||||
|
||||
float Entry::onGetTextBaseline() const
|
||||
{
|
||||
text::FontMetrics metrics;
|
||||
font()->metrics(&metrics);
|
||||
// Here we only use the descent+ascent to measure the text height,
|
||||
// without the metrics.leading part (which is the used to separate
|
||||
// text lines in a paragraph, but here'd make widgets too big)
|
||||
const float textHeight = metrics.descent - metrics.ascent;
|
||||
const gfx::Rect rc = getEntryTextBounds();
|
||||
return guiscaled_center(rc.y, rc.h, textHeight) - metrics.ascent;
|
||||
}
|
||||
|
||||
void Entry::onChange()
|
||||
{
|
||||
Change();
|
||||
|
|
|
@ -84,6 +84,7 @@ protected:
|
|||
void onPaint(PaintEvent& ev) override;
|
||||
void onSetFont() override;
|
||||
void onSetText() override;
|
||||
float onGetTextBaseline() const override;
|
||||
|
||||
// New Events
|
||||
virtual void onChange();
|
||||
|
|
Loading…
Reference in New Issue