Decomposed painting of text in Ui::Menu::Action.

This commit is contained in:
23rd 2022-03-27 15:22:28 +03:00
parent a0b04da1d9
commit bc85f7baf3
2 changed files with 12 additions and 1 deletions

View file

@ -83,6 +83,15 @@ bool Action::hasSubmenu() const {
return _action->menu() != nullptr; return _action->menu() != nullptr;
} }
void Action::paintText(Painter &p) {
_text.drawLeftElided(
p,
_st.itemPadding.left(),
_st.itemPadding.top(),
_textWidth,
width());
}
void Action::paint(Painter &p) { void Action::paint(Painter &p) {
const auto enabled = isEnabled(); const auto enabled = isEnabled();
const auto selected = isSelected(); const auto selected = isSelected();
@ -97,7 +106,7 @@ void Action::paint(Painter &p) {
icon->paint(p, _st.itemIconPosition, width()); icon->paint(p, _st.itemIconPosition, width());
} }
p.setPen(selected ? _st.itemFgOver : (enabled ? _st.itemFg : _st.itemFgDisabled)); p.setPen(selected ? _st.itemFgOver : (enabled ? _st.itemFg : _st.itemFgDisabled));
_text.drawLeftElided(p, _st.itemPadding.left(), _st.itemPadding.top(), _textWidth, width()); paintText(p);
if (hasSubmenu()) { if (hasSubmenu()) {
const auto left = width() - _st.itemPadding.right() - _st.arrow.width(); const auto left = width() - _st.itemPadding.right() - _st.arrow.width();
const auto top = (_height - _st.arrow.height()) / 2; const auto top = (_height - _st.arrow.height()) / 2;

View file

@ -38,6 +38,8 @@ protected:
int contentHeight() const override; int contentHeight() const override;
void paintText(Painter &p);
private: private:
void processAction(); void processAction();
void paint(Painter &p); void paint(Painter &p);