Remove unused LeftOutlineButton type.

This commit is contained in:
John Preston 2019-08-26 17:17:00 +03:00
parent 38e4daacd4
commit 04d5158ae3
9 changed files with 7 additions and 122 deletions

View File

@ -51,11 +51,6 @@ attentionButtonFgOver: #d14e4e; // default attention button text with mouse over
attentionButtonBgOver: #fcdfde; // default attention button background with mouse over
attentionButtonBgRipple: #f4c3c2; // default attention button ripple effect
outlineButtonBg: windowBg; // default left outlined button background (like shared media links in profiles)
outlineButtonBgOver: lightButtonBgOver; // default left outlined button background with mouse over
outlineButtonOutlineFg: windowBgActive; // default left outlined button left outline border
outlineButtonBgRipple: lightButtonBgRipple; // default left outlined button ripple effect
menuBg: windowBg; // default popup menu background
menuBgOver: windowBgOver; // default popup menu item background with mouse over
menuBgRipple: windowBgRipple; // default popup menu item ripple effect

View File

@ -11,7 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Ui {
class FlatLabel;
class LeftOutlineButton;
} // namespace Ui
namespace Notify {

View File

@ -74,10 +74,10 @@ void PeerListWidget::paintItem(Painter &p, int x, int y, Item *item, bool select
auto memberRowWidth = rowWidth();
if (selected) {
paintOutlinedRect(p, x, y, memberRowWidth, _st.height);
paintItemRect(p, x, y, memberRowWidth, _st.height);
}
if (auto &ripple = item->ripple) {
ripple->paint(p, x + _st.button.outlineWidth, y, width());
ripple->paint(p, x, y, width());
if (ripple->empty()) {
ripple.reset();
}
@ -121,12 +121,8 @@ void PeerListWidget::paintItem(Painter &p, int x, int y, Item *item, bool select
p.drawTextLeft(x + _st.statusPosition.x(), y + _st.statusPosition.y(), width(), item->statusText);
}
void PeerListWidget::paintOutlinedRect(Painter &p, int x, int y, int w, int h) const {
auto outlineWidth = _st.button.outlineWidth;
if (outlineWidth) {
p.fillRect(rtlrect(x, y, outlineWidth, h, width()), _st.button.outlineFgOver);
}
p.fillRect(rtlrect(x + outlineWidth, y, w - outlineWidth, h, width()), _st.button.textBgOver);
void PeerListWidget::paintItemRect(Painter &p, int x, int y, int w, int h) const {
p.fillRect(rtlrect(x, y, w, h, width()), _st.button.textBgOver);
}
void PeerListWidget::mouseMoveEvent(QMouseEvent *e) {
@ -145,12 +141,12 @@ void PeerListWidget::mousePressEvent(QMouseEvent *e) {
auto item = _items[_pressed];
if (!item->ripple) {
auto memberRowWidth = rowWidth();
auto mask = Ui::RippleAnimation::rectMask(QSize(memberRowWidth - _st.button.outlineWidth, _st.height));
auto mask = Ui::RippleAnimation::rectMask(QSize(memberRowWidth, _st.height));
item->ripple = std::make_unique<Ui::RippleAnimation>(_st.button.ripple, std::move(mask), [this, index = _pressed] {
repaintRow(index);
});
}
auto left = getListLeft() + _st.button.outlineWidth;
auto left = getListLeft();
auto top = getListTop() + _st.height * _pressed;
item->ripple->add(e->pos() - QPoint(left, top));
}

View File

@ -93,7 +93,7 @@ protected:
int visibleTop,
int visibleBottom) override;
void paintOutlinedRect(Painter &p, int x, int y, int w, int h) const;
void paintItemRect(Painter &p, int x, int y, int w, int h) const;
void refreshVisibility();
void paintContents(Painter &p) override;

View File

@ -41,8 +41,4 @@ void BlockWidget::paintTitle(Painter &p) {
p.drawTextLeft(titleLeft, titleTop, width(), _title);
}
int defaultOutlineButtonLeft() {
return st::profileBlockTitlePosition.x() - st::defaultLeftOutlineButton.padding.left();
}
} // namespace Profile

View File

@ -59,6 +59,4 @@ private:
};
int defaultOutlineButtonLeft();
} // namespace Profile

View File

@ -497,49 +497,6 @@ QImage IconButton::prepareRippleMask() const {
return RippleAnimation::ellipseMask(QSize(_st.rippleAreaSize, _st.rippleAreaSize));
}
LeftOutlineButton::LeftOutlineButton(QWidget *parent, const QString &text, const style::OutlineButton &st) : RippleButton(parent, st.ripple)
, _text(text)
, _fullText(text)
, _textWidth(st.font->width(_text))
, _fullTextWidth(_textWidth)
, _st(st) {
resizeToWidth(_textWidth + _st.padding.left() + _st.padding.right());
setCursor(style::cur_pointer);
}
void LeftOutlineButton::setText(const QString &text) {
_text = text;
_fullText = text;
_fullTextWidth = _textWidth = _st.font->width(_text);
resizeToWidth(width());
update();
}
int LeftOutlineButton::resizeGetHeight(int newWidth) {
int availableWidth = qMax(newWidth - _st.padding.left() - _st.padding.right(), 1);
if ((availableWidth < _fullTextWidth) || (_textWidth < availableWidth)) {
_text = _st.font->elided(_fullText, availableWidth);
_textWidth = _st.font->width(_text);
}
return _st.padding.top() + _st.font->height + _st.padding.bottom();
}
void LeftOutlineButton::paintEvent(QPaintEvent *e) {
Painter p(this);
auto over = isOver();
auto down = isDown();
if (width() > _st.outlineWidth) {
p.fillRect(rtlrect(_st.outlineWidth, 0, width() - _st.outlineWidth, height(), width()), (over || down) ? _st.textBgOver : _st.textBg);
paintRipple(p, 0, 0);
p.fillRect(rtlrect(0, 0, _st.outlineWidth, height(), width()), (over || down) ? _st.outlineFgOver : _st.outlineFg);
}
p.setFont(_st.font);
p.setPen((over || down) ? _st.textFgOver : _st.textFg);
p.drawTextLeft(_st.padding.left(), _st.padding.top(), width(), _text, _textWidth);
}
CrossButton::CrossButton(QWidget *parent, const style::CrossButton &st) : RippleButton(parent, st.ripple)
, _st(st)
, _loadingAnimation([=](crl::time now) { return loadingCallback(now); }) {

View File

@ -184,25 +184,6 @@ private:
};
class LeftOutlineButton : public RippleButton {
public:
LeftOutlineButton(QWidget *parent, const QString &text, const style::OutlineButton &st = st::defaultLeftOutlineButton);
void setText(const QString &text);
protected:
void paintEvent(QPaintEvent *e) override;
int resizeGetHeight(int newWidth) override;
private:
QString _text, _fullText;
int _textWidth, _fullTextWidth;
const style::OutlineButton &_st;
};
class CrossButton : public RippleButton {
public:
CrossButton(QWidget *parent, const style::CrossButton &st);

View File

@ -239,10 +239,6 @@ InputField {
}
OutlineButton {
outlineWidth: pixels;
outlineFg: color;
outlineFgOver: color;
textBg: color;
textBgOver: color;
@ -675,37 +671,6 @@ defaultFlatInput: FlatInput {
phDuration: 100;
}
defaultLeftOutlineButton: OutlineButton {
outlineWidth: 3px;
outlineFg: outlineButtonBg;
outlineFgOver: outlineButtonOutlineFg;
textBg: outlineButtonBg;
textBgOver: outlineButtonBgOver;
textFg: windowActiveTextFg;
textFgOver: windowActiveTextFg;
font: normalFont;
padding: margins(11px, 5px, 11px, 5px);
ripple: RippleAnimation(defaultRippleAnimation) {
color: outlineButtonBgRipple;
}
}
attentionLeftOutlineButton: OutlineButton(defaultLeftOutlineButton) {
outlineFgOver: attentionButtonFg;
textBgOver: attentionButtonBgOver;
textFg: attentionButtonFg;
textFgOver: attentionButtonFgOver;
ripple: RippleAnimation(defaultRippleAnimation) {
color: attentionButtonBgRipple;
}
}
defaultInputField: InputField {
textBg: windowBg;
textFg: windowFg;
@ -1147,8 +1112,6 @@ PeerList {
}
defaultPeerListButton: OutlineButton {
outlineWidth: 0px;
textBg: windowBg;
textBgOver: windowBgOver;