mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 21:44:22 +00:00
Avoid drawing empty strings
This commit is contained in:
parent
1c1c4593ed
commit
aed9127b51
2
laf
2
laf
@ -1 +1 @@
|
|||||||
Subproject commit 50573685f7af01a68233acaed99bea00145b6778
|
Subproject commit 06279da54f2849ee042897af5457efa442401ab4
|
@ -1264,6 +1264,9 @@ private:
|
|||||||
|
|
||||||
void SkinTheme::drawEntryText(ui::Graphics* g, ui::Entry* widget)
|
void SkinTheme::drawEntryText(ui::Graphics* g, ui::Entry* widget)
|
||||||
{
|
{
|
||||||
|
if (widget->text().empty())
|
||||||
|
return;
|
||||||
|
|
||||||
// Draw the text
|
// Draw the text
|
||||||
gfx::Rect bounds = widget->getEntryTextBounds();
|
gfx::Rect bounds = widget->getEntryTextBounds();
|
||||||
|
|
||||||
|
@ -340,6 +340,9 @@ void Graphics::drawText(const std::string& str,
|
|||||||
const gfx::Point& origPt,
|
const gfx::Point& origPt,
|
||||||
text::DrawTextDelegate* delegate)
|
text::DrawTextDelegate* delegate)
|
||||||
{
|
{
|
||||||
|
if (str.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
gfx::Point pt(m_dx+origPt.x, m_dy+origPt.y);
|
gfx::Point pt(m_dx+origPt.x, m_dy+origPt.y);
|
||||||
|
|
||||||
os::SurfaceLock lock(m_surface.get());
|
os::SurfaceLock lock(m_surface.get());
|
||||||
@ -423,6 +426,9 @@ private:
|
|||||||
void Graphics::drawUIText(const std::string& str, gfx::Color fg, gfx::Color bg,
|
void Graphics::drawUIText(const std::string& str, gfx::Color fg, gfx::Color bg,
|
||||||
const gfx::Point& pt, const int mnemonic)
|
const gfx::Point& pt, const int mnemonic)
|
||||||
{
|
{
|
||||||
|
if (str.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
os::SurfaceLock lock(m_surface.get());
|
os::SurfaceLock lock(m_surface.get());
|
||||||
int x = m_dx+pt.x;
|
int x = m_dx+pt.x;
|
||||||
int y = m_dy+pt.y;
|
int y = m_dy+pt.y;
|
||||||
@ -451,12 +457,10 @@ gfx::Size Graphics::measureUIText(const std::string& str)
|
|||||||
int Graphics::measureUITextLength(const std::string& str,
|
int Graphics::measureUITextLength(const std::string& str,
|
||||||
text::Font* font)
|
text::Font* font)
|
||||||
{
|
{
|
||||||
DrawUITextDelegate delegate(nullptr, font, 0);
|
if (str.empty())
|
||||||
text::draw_text(nullptr, get_theme()->fontMgr(),
|
return 0;
|
||||||
base::AddRef(font), str,
|
|
||||||
gfx::ColorNone, gfx::ColorNone,
|
return font->textLength(str);
|
||||||
0, 0, &delegate);
|
|
||||||
return delegate.bounds().w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Size Graphics::fitString(const std::string& str, int maxWidth, int align)
|
gfx::Size Graphics::fitString(const std::string& str, int maxWidth, int align)
|
||||||
@ -561,7 +565,8 @@ gfx::Size Graphics::doUIStringAlgorithm(const std::string& str, gfx::Color fg, g
|
|||||||
else
|
else
|
||||||
xout = pt.x;
|
xout = pt.x;
|
||||||
|
|
||||||
drawText(line, fg, bg, gfx::Point(xout, pt.y));
|
if (!line.empty())
|
||||||
|
drawText(line, fg, bg, gfx::Point(xout, pt.y));
|
||||||
|
|
||||||
if (!gfx::is_transparent(bg))
|
if (!gfx::is_transparent(bg))
|
||||||
fillAreaBetweenRects(bg,
|
fillAreaBetweenRects(bg,
|
||||||
|
@ -436,6 +436,9 @@ void Theme::paintLayer(Graphics* g,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Style::Layer::Type::kText:
|
case Style::Layer::Type::kText:
|
||||||
|
if (text.empty())
|
||||||
|
break;
|
||||||
|
|
||||||
if (layer.color() != gfx::ColorNone) {
|
if (layer.color() != gfx::ColorNone) {
|
||||||
text::FontRef oldFont = base::AddRef(g->font());
|
text::FontRef oldFont = base::AddRef(g->font());
|
||||||
if (style->font())
|
if (style->font())
|
||||||
@ -949,7 +952,7 @@ void Theme::drawTextBox(Graphics* g, const Widget* widget,
|
|||||||
len = font->textLength(beg);
|
len = font->textLength(beg);
|
||||||
|
|
||||||
// Render the text
|
// Render the text
|
||||||
if (g) {
|
if (g && len > 0) {
|
||||||
int xout;
|
int xout;
|
||||||
|
|
||||||
if (widget->align() & CENTER)
|
if (widget->align() & CENTER)
|
||||||
|
@ -920,7 +920,7 @@ void Widget::getDrawableRegion(gfx::Region& region, DrawableRegionFlags flags)
|
|||||||
|
|
||||||
text::TextBlobRef Widget::textBlob() const
|
text::TextBlobRef Widget::textBlob() const
|
||||||
{
|
{
|
||||||
if (!m_blob) {
|
if (!m_blob && !m_text.empty()) {
|
||||||
m_blob = text::TextBlob::MakeWithShaper(
|
m_blob = text::TextBlob::MakeWithShaper(
|
||||||
theme()->fontMgr(),
|
theme()->fontMgr(),
|
||||||
AddRef(font()),
|
AddRef(font()),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user