mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-26 12:35:33 +00:00
Use TextBlobs to paint tabs
This commit is contained in:
parent
6b7aa371ce
commit
f10bc52b6c
@ -172,7 +172,11 @@ void Tabs::updateTabs()
|
||||
x += tabWidth;
|
||||
}
|
||||
|
||||
tab->text = tab->view->getTabText();
|
||||
std::string newText = tab->view->getTabText();
|
||||
if (tab->text != newText) {
|
||||
tab->text = newText;
|
||||
tab->textBlob.reset();
|
||||
}
|
||||
tab->icon = tab->view->getTabIcon();
|
||||
tab->color = tab->view->getTabColor();
|
||||
tab->x = int(x);
|
||||
@ -480,6 +484,10 @@ void Tabs::onInitTheme(ui::InitThemeEvent& ev)
|
||||
m_tabsBottomHeight = theme->dimensions.tabsBottomHeight();
|
||||
setStyle(theme->styles.mainTabs());
|
||||
}
|
||||
|
||||
for (TabPtr& tab : m_list) {
|
||||
tab->textBlob = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Tabs::onPaint(PaintEvent& ev)
|
||||
@ -643,7 +651,19 @@ void Tabs::drawTab(Graphics* g, const gfx::Rect& _box,
|
||||
Style* stylePtr = theme->styles.tabText();
|
||||
Style newStyle(nullptr);
|
||||
|
||||
if (!tab->textBlob) {
|
||||
tab->textBlob =
|
||||
text::TextBlob::MakeWithShaper(
|
||||
theme->fontMgr(),
|
||||
AddRef(font()),
|
||||
tab->text,
|
||||
nullptr,
|
||||
text::ShaperFeatures());
|
||||
}
|
||||
|
||||
info.text = &tab->text;
|
||||
info.textBlob = tab->textBlob;
|
||||
|
||||
if (tabColor != gfx::ColorNone) {
|
||||
// TODO replace these fillRect() with a new theme part (which
|
||||
// should be painted with the specific user-defined color)
|
||||
@ -664,6 +684,7 @@ void Tabs::drawTab(Graphics* g, const gfx::Rect& _box,
|
||||
gfx::Rect(box.x+dx, box.y+dy, box.w-dx, box.h),
|
||||
info);
|
||||
info.text = nullptr;
|
||||
info.textBlob = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2024 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -10,6 +10,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "base/ref.h"
|
||||
#include "text/fwd.h"
|
||||
#include "ui/animated_widget.h"
|
||||
#include "ui/widget.h"
|
||||
|
||||
@ -122,6 +123,7 @@ namespace app {
|
||||
struct Tab {
|
||||
TabView* view;
|
||||
std::string text;
|
||||
text::TextBlobRef textBlob;
|
||||
TabIcon icon;
|
||||
gfx::Color color;
|
||||
int x, width;
|
||||
|
Loading…
x
Reference in New Issue
Block a user