Allow many custom elements in PeerListRow.

This commit is contained in:
John Preston 2021-10-13 16:37:38 +04:00
parent 7f428f2eeb
commit ab58aa020e
17 changed files with 222 additions and 124 deletions

View file

@ -519,6 +519,55 @@ void PeerListRow::refreshName(const style::PeerListItem &st) {
_name.setText(st.nameStyle, text, Ui::NameTextOptions()); _name.setText(st.nameStyle, text, Ui::NameTextOptions());
} }
QRect PeerListRow::elementGeometry(int element, int outerWidth) const {
if (element != 1) {
return QRect();
}
const auto size = rightActionSize();
if (size.isEmpty()) {
return QRect();
}
const auto margins = rightActionMargins();
const auto right = margins.right();
const auto top = margins.top();
const auto left = outerWidth - right - size.width();
return QRect(QPoint(left, top), size);
}
bool PeerListRow::elementDisabled(int element) const {
return (element == 1) && rightActionDisabled();
}
void PeerListRow::elementAddRipple(
int element,
QPoint point,
Fn<void()> updateCallback) {
if (element == 1) {
rightActionAddRipple(point, std::move(updateCallback));
}
}
void PeerListRow::elementsStopLastRipple() {
rightActionStopLastRipple();
}
void PeerListRow::elementsPaint(
Painter &p,
int outerWidth,
bool selected,
int selectedElement) {
const auto geometry = elementGeometry(1, outerWidth);
if (!geometry.isEmpty()) {
rightActionPaint(
p,
geometry.x(),
geometry.y(),
outerWidth,
selected,
(selectedElement == 1));
}
}
QString PeerListRow::generateName() { QString PeerListRow::generateName() {
return peer()->name; return peer()->name;
} }
@ -1273,11 +1322,16 @@ void PeerListContent::mousePressEvent(QMouseEvent *e) {
auto updateCallback = [this, row, hint = _selected.index] { auto updateCallback = [this, row, hint = _selected.index] {
updateRow(row, hint); updateRow(row, hint);
}; };
if (_selected.action) { if (_selected.element) {
auto actionRect = getActiveActionRect(row, _selected.index); const auto elementRect = getElementRect(
if (!actionRect.isEmpty()) { row,
auto point = mapFromGlobal(QCursor::pos()) - actionRect.topLeft(); _selected.index,
row->addActionRipple(point, std::move(updateCallback)); _selected.element);
if (!elementRect.isEmpty()) {
row->elementAddRipple(
_selected.element,
mapFromGlobal(QCursor::pos()) - elementRect.topLeft(),
std::move(updateCallback));
} }
} else { } else {
auto point = mapFromGlobal(QCursor::pos()) - QPoint(0, getRowTop(_selected.index)); auto point = mapFromGlobal(QCursor::pos()) - QPoint(0, getRowTop(_selected.index));
@ -1309,8 +1363,8 @@ void PeerListContent::mousePressReleased(Qt::MouseButton button) {
setPressed(Selected()); setPressed(Selected());
if (button == Qt::LeftButton && pressed == _selected) { if (button == Qt::LeftButton && pressed == _selected) {
if (auto row = getRow(pressed.index)) { if (auto row = getRow(pressed.index)) {
if (pressed.action) { if (pressed.element) {
_controller->rowActionClicked(row); _controller->rowElementClicked(row, pressed.element);
} else { } else {
_controller->rowClicked(row); _controller->rowClicked(row);
} }
@ -1387,9 +1441,11 @@ void PeerListContent::contextMenuEvent(QContextMenuEvent *e) {
} }
void PeerListContent::setPressed(Selected pressed) { void PeerListContent::setPressed(Selected pressed) {
if (auto row = getRow(_pressed.index)) { if (_pressed == pressed) {
return;
} else if (const auto row = getRow(_pressed.index)) {
row->stopLastRipple(); row->stopLastRipple();
row->stopLastActionRipple(); row->elementsStopLastRipple();
} }
_pressed = pressed; _pressed = pressed;
} }
@ -1402,6 +1458,7 @@ crl::time PeerListContent::paintRow(
Assert(row != nullptr); Assert(row != nullptr);
row->lazyInitialize(_st.item); row->lazyInitialize(_st.item);
const auto outerWidth = width();
auto refreshStatusAt = row->refreshStatusTime(); auto refreshStatusAt = row->refreshStatusTime();
if (refreshStatusAt > 0 && now >= refreshStatusAt) { if (refreshStatusAt > 0 && now >= refreshStatusAt) {
@ -1419,7 +1476,6 @@ crl::time PeerListContent::paintRow(
? _pressed ? _pressed
: _selected; : _selected;
const auto selected = (active.index == index); const auto selected = (active.index == index);
const auto actionSelected = (selected && active.action);
if (_mode == Mode::Custom) { if (_mode == Mode::Custom) {
_controller->customRowPaint(p, now, row, selected); _controller->customRowPaint(p, now, row, selected);
@ -1429,27 +1485,29 @@ crl::time PeerListContent::paintRow(
const auto &bg = selected const auto &bg = selected
? _st.item.button.textBgOver ? _st.item.button.textBgOver
: _st.item.button.textBg; : _st.item.button.textBg;
p.fillRect(0, 0, width(), _rowHeight, bg); p.fillRect(0, 0, outerWidth, _rowHeight, bg);
row->paintRipple(p, 0, 0, width()); row->paintRipple(p, 0, 0, outerWidth);
row->paintUserpic( row->paintUserpic(
p, p,
_st.item, _st.item,
_st.item.photoPosition.x(), _st.item.photoPosition.x(),
_st.item.photoPosition.y(), _st.item.photoPosition.y(),
width()); outerWidth);
p.setPen(st::contactsNameFg); p.setPen(st::contactsNameFg);
auto skipRight = _st.item.photoPosition.x(); auto skipRight = _st.item.photoPosition.x();
auto actionSize = row->actionSize(); auto rightActionSize = row->rightActionSize();
auto actionMargins = actionSize.isEmpty() ? QMargins() : row->actionMargins(); auto rightActionMargins = rightActionSize.isEmpty()
? QMargins()
: row->rightActionMargins();
auto &name = row->name(); auto &name = row->name();
auto namex = _st.item.namePosition.x(); auto namex = _st.item.namePosition.x();
auto namew = width() - namex - skipRight; auto namew = outerWidth - namex - skipRight;
if (!actionSize.isEmpty()) { if (!rightActionSize.isEmpty()) {
namew -= actionMargins.left() namew -= rightActionMargins.left()
+ actionSize.width() + rightActionSize.width()
+ actionMargins.right() + rightActionMargins.right()
- skipRight; - skipRight;
} }
auto statusw = namew; auto statusw = namew;
@ -1466,20 +1524,6 @@ crl::time PeerListContent::paintRow(
p.setPen(anim::pen(_st.item.nameFg, _st.item.nameFgChecked, nameCheckedRatio)); p.setPen(anim::pen(_st.item.nameFg, _st.item.nameFgChecked, nameCheckedRatio));
name.drawLeftElided(p, namex, _st.item.namePosition.y(), namew, width()); name.drawLeftElided(p, namex, _st.item.namePosition.y(), namew, width());
if (!actionSize.isEmpty()) {
auto actionLeft = width()
- actionMargins.right()
- actionSize.width();
auto actionTop = actionMargins.top();
row->paintAction(
p,
actionLeft,
actionTop,
width(),
selected,
actionSelected);
}
p.setFont(st::contactsStatusFont); p.setFont(st::contactsStatusFont);
if (row->isSearchResult() if (row->isSearchResult()
&& !_mentionHighlight.isEmpty() && !_mentionHighlight.isEmpty()
@ -1508,6 +1552,9 @@ crl::time PeerListContent::paintRow(
} else { } else {
row->paintStatusText(p, _st.item, _st.item.statusPosition.x(), _st.item.statusPosition.y(), statusw, width(), selected); row->paintStatusText(p, _st.item, _st.item.statusPosition.x(), _st.item.statusPosition.y(), statusw, width(), selected);
} }
row->elementsPaint(p, width(), selected, selected ? active.element : 0);
return refreshStatusIn; return refreshStatusIn;
} }
@ -1573,7 +1620,7 @@ PeerListContent::SkipResult PeerListContent::selectSkip(int direction) {
} }
_selected.index.value = newSelectedIndex; _selected.index.value = newSelectedIndex;
_selected.action = false; _selected.element = 0;
if (newSelectedIndex >= 0) { if (newSelectedIndex >= 0) {
auto top = (newSelectedIndex > 0) ? getRowTop(RowIndex(newSelectedIndex)) : 0; auto top = (newSelectedIndex > 0) ? getRowTop(RowIndex(newSelectedIndex)) : 0;
auto bottom = (newSelectedIndex + 1 < rowsCount) ? getRowTop(RowIndex(newSelectedIndex + 1)) : height(); auto bottom = (newSelectedIndex + 1 < rowsCount) ? getRowTop(RowIndex(newSelectedIndex + 1)) : height();
@ -1798,7 +1845,7 @@ void PeerListContent::setSelected(Selected selected) {
} }
_selected = selected; _selected = selected;
updateRow(_selected.index); updateRow(_selected.index);
setCursor(_selected.action ? style::cur_pointer : style::cur_default); setCursor(_selected.element ? style::cur_pointer : style::cur_default);
_selectedIndex = _selected.index.value; _selectedIndex = _selected.index.value;
} }
@ -1859,25 +1906,30 @@ void PeerListContent::selectByMouse(QPoint globalPosition) {
rowsPointY - (selected.index.value * _rowHeight)))) { rowsPointY - (selected.index.value * _rowHeight)))) {
selected = Selected(); selected = Selected();
} else if (!customMode) { } else if (!customMode) {
if (getActiveActionRect(row, selected.index).contains(point)) { for (auto i = 0, count = row->elementsCount(); i != count; ++i) {
selected.action = true; const auto rect = getElementRect(row, selected.index, i + 1);
if (rect.contains(point)) {
selected.element = i + 1;
break;
}
} }
} }
} }
setSelected(selected); setSelected(selected);
} }
QRect PeerListContent::getActiveActionRect(not_null<PeerListRow*> row, RowIndex index) const { QRect PeerListContent::getElementRect(
auto actionSize = row->actionSize(); not_null<PeerListRow*> row,
if (actionSize.isEmpty() || row->actionDisabled()) { RowIndex index,
int element) const {
if (row->elementDisabled(element)) {
return QRect(); return QRect();
} }
auto actionMargins = row->actionMargins(); const auto geometry = row->elementGeometry(element, width());
auto actionRight = actionMargins.right(); if (geometry.isEmpty()) {
auto actionTop = actionMargins.top(); return QRect();
auto actionLeft = width() - actionRight - actionSize.width(); }
auto rowTop = getRowTop(index); return geometry.translated(0, getRowTop(index));
return myrtlrect(actionLeft, rowTop + actionTop, actionSize.width(), actionSize.height());
} }
int PeerListContent::rowsTop() const { int PeerListContent::rowsTop() const {

View file

@ -47,6 +47,7 @@ using PaintRoundImageCallback = Fn<void(
bool respectSavedMessagesChat); bool respectSavedMessagesChat);
using PeerListRowId = uint64; using PeerListRowId = uint64;
class PeerListRow { class PeerListRow {
public: public:
enum class State { enum class State {
@ -100,20 +101,17 @@ public:
int y, int y,
int outerWidth, int outerWidth,
bool selected); bool selected);
virtual QSize actionSize() const {
virtual QSize rightActionSize() const {
return QSize(); return QSize();
} }
virtual bool actionDisabled() const { virtual QMargins rightActionMargins() const {
return false;
}
virtual QMargins actionMargins() const {
return QMargins(); return QMargins();
} }
virtual void addActionRipple(QPoint point, Fn<void()> updateCallback) { virtual bool rightActionDisabled() const {
return false;
} }
virtual void stopLastActionRipple() { virtual void rightActionPaint(
}
virtual void paintAction(
Painter &p, Painter &p,
int x, int x,
int y, int y,
@ -121,6 +119,29 @@ public:
bool selected, bool selected,
bool actionSelected) { bool actionSelected) {
} }
virtual void rightActionAddRipple(
QPoint point,
Fn<void()> updateCallback) {
}
virtual void rightActionStopLastRipple() {
}
// By default elements code falls back to a simple right action code.
virtual int elementsCount() const {
return 1;
}
virtual QRect elementGeometry(int element, int outerWidth) const;
virtual bool elementDisabled(int element) const;
virtual void elementAddRipple(
int element,
QPoint point,
Fn<void()> updateCallback);
virtual void elementsStopLastRipple();
virtual void elementsPaint(
Painter &p,
int outerWidth,
bool selected,
int selectedElement);
virtual void refreshName(const style::PeerListItem &st); virtual void refreshName(const style::PeerListItem &st);
const Ui::Text::String &name() const { const Ui::Text::String &name() const {
@ -405,11 +426,21 @@ public:
const style::PeerList &computeListSt() const; const style::PeerList &computeListSt() const;
const style::MultiSelect &computeSelectSt() const; const style::MultiSelect &computeSelectSt() const;
virtual void prepare() = 0;
virtual void rowClicked(not_null<PeerListRow*> row) = 0;
virtual Main::Session &session() const = 0; virtual Main::Session &session() const = 0;
virtual void rowActionClicked(not_null<PeerListRow*> row) {
virtual void prepare() = 0;
virtual void rowClicked(not_null<PeerListRow*> row) = 0;
virtual void rowRightActionClicked(not_null<PeerListRow*> row) {
} }
// By default elements code falls back to a simple right action code.
virtual void rowElementClicked(not_null<PeerListRow*> row, int element) {
if (element == 1) {
rowRightActionClicked(row);
}
}
virtual void loadMoreRows() { virtual void loadMoreRows() {
} }
virtual void itemDeselectedHook(not_null<PeerData*> peer) { virtual void itemDeselectedHook(not_null<PeerData*> peer) {
@ -653,15 +684,20 @@ private:
struct Selected { struct Selected {
Selected() { Selected() {
} }
Selected(RowIndex index, bool action) : index(index), action(action) { Selected(RowIndex index, int element)
: index(index)
, element(element) {
} }
Selected(int index, bool action) : index(index), action(action) { Selected(int index, int element)
: index(index)
, element(element) {
} }
RowIndex index; RowIndex index;
bool action = false; int element = 0;
}; };
friend inline bool operator==(Selected a, Selected b) { friend inline bool operator==(Selected a, Selected b) {
return (a.index == b.index) && (a.action == b.action); return (a.index == b.index) && (a.element == b.element);
} }
friend inline bool operator!=(Selected a, Selected b) { friend inline bool operator!=(Selected a, Selected b) {
return !(a == b); return !(a == b);
@ -689,8 +725,13 @@ private:
void updateRow(RowIndex row); void updateRow(RowIndex row);
int getRowTop(RowIndex row) const; int getRowTop(RowIndex row) const;
PeerListRow *getRow(RowIndex element); PeerListRow *getRow(RowIndex element);
RowIndex findRowIndex(not_null<PeerListRow*> row, RowIndex hint = RowIndex()); RowIndex findRowIndex(
QRect getActiveActionRect(not_null<PeerListRow*> row, RowIndex index) const; not_null<PeerListRow*> row,
RowIndex hint = RowIndex());
QRect getElementRect(
not_null<PeerListRow*> row,
RowIndex index,
int element) const;
bool showRowMenu( bool showRowMenu(
RowIndex index, RowIndex index,

View file

@ -136,11 +136,11 @@ void PeerListRowWithLink::lazyInitialize(const style::PeerListItem &st) {
refreshActionLink(); refreshActionLink();
} }
QSize PeerListRowWithLink::actionSize() const { QSize PeerListRowWithLink::rightActionSize() const {
return QSize(_actionWidth, st::normalFont->height); return QSize(_actionWidth, st::normalFont->height);
} }
QMargins PeerListRowWithLink::actionMargins() const { QMargins PeerListRowWithLink::rightActionMargins() const {
return QMargins( return QMargins(
st::contactsCheckPosition.x(), st::contactsCheckPosition.x(),
(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom() - st::normalFont->height) / 2, (st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom() - st::normalFont->height) / 2,
@ -148,7 +148,7 @@ QMargins PeerListRowWithLink::actionMargins() const {
0); 0);
} }
void PeerListRowWithLink::paintAction( void PeerListRowWithLink::rightActionPaint(
Painter &p, Painter &p,
int x, int x,
int y, int y,

View file

@ -47,9 +47,9 @@ public:
private: private:
void refreshActionLink(); void refreshActionLink();
QSize actionSize() const override; QSize rightActionSize() const override;
QMargins actionMargins() const override; QMargins rightActionMargins() const override;
void paintAction( void rightActionPaint(
Painter &p, Painter &p,
int x, int x,
int y, int y,

View file

@ -1438,7 +1438,7 @@ void ParticipantsBoxController::rowClicked(not_null<PeerListRow*> row) {
} }
} }
void ParticipantsBoxController::rowActionClicked( void ParticipantsBoxController::rowRightActionClicked(
not_null<PeerListRow*> row) { not_null<PeerListRow*> row) {
const auto participant = row->peer(); const auto participant = row->peer();
const auto user = participant->asUser(); const auto user = participant->asUser();

View file

@ -157,7 +157,7 @@ public:
Main::Session &session() const override; Main::Session &session() const override;
void prepare() override; void prepare() override;
void rowClicked(not_null<PeerListRow*> row) override; void rowClicked(not_null<PeerListRow*> row) override;
void rowActionClicked(not_null<PeerListRow*> row) override; void rowRightActionClicked(not_null<PeerListRow*> row) override;
base::unique_qptr<Ui::PopupMenu> rowContextMenu( base::unique_qptr<Ui::PopupMenu> rowContextMenu(
QWidget *parent, QWidget *parent,
not_null<PeerListRow*> row) override; not_null<PeerListRow*> row) override;

View file

@ -61,9 +61,9 @@ class RequestedRow final : public PeerListRow {
public: public:
explicit RequestedRow(not_null<PeerData*> peer); explicit RequestedRow(not_null<PeerData*> peer);
QSize actionSize() const override; QSize rightActionSize() const override;
QMargins actionMargins() const override; QMargins rightActionMargins() const override;
void paintAction( void rightActionPaint(
Painter &p, Painter &p,
int x, int x,
int y, int y,
@ -77,21 +77,21 @@ RequestedRow::RequestedRow(not_null<PeerData*> peer)
: PeerListRow(peer) { : PeerListRow(peer) {
} }
QSize RequestedRow::actionSize() const { QSize RequestedRow::rightActionSize() const {
return QSize( return QSize(
st::inviteLinkThreeDotsIcon.width(), st::inviteLinkThreeDotsIcon.width(),
st::inviteLinkThreeDotsIcon.height()); st::inviteLinkThreeDotsIcon.height());
} }
QMargins RequestedRow::actionMargins() const { QMargins RequestedRow::rightActionMargins() const {
return QMargins( return QMargins(
0, 0,
(st::inviteLinkList.item.height - actionSize().height()) / 2, (st::inviteLinkList.item.height - rightActionSize().height()) / 2,
st::inviteLinkThreeDotsSkip, st::inviteLinkThreeDotsSkip,
0); 0);
} }
void RequestedRow::paintAction( void RequestedRow::rightActionPaint(
Painter &p, Painter &p,
int x, int x,
int y, int y,
@ -120,7 +120,7 @@ public:
void prepare() override; void prepare() override;
void loadMoreRows() override; void loadMoreRows() override;
void rowClicked(not_null<PeerListRow*> row) override; void rowClicked(not_null<PeerListRow*> row) override;
void rowActionClicked(not_null<PeerListRow*> row) override; void rowRightActionClicked(not_null<PeerListRow*> row) override;
Main::Session &session() const override; Main::Session &session() const override;
rpl::producer<int> boxHeightValue() const override; rpl::producer<int> boxHeightValue() const override;
@ -712,7 +712,7 @@ void Controller::rowClicked(not_null<PeerListRow*> row) {
Ui::showPeerProfile(row->peer()); Ui::showPeerProfile(row->peer());
} }
void Controller::rowActionClicked(not_null<PeerListRow*> row) { void Controller::rowRightActionClicked(not_null<PeerListRow*> row) {
if (_role != Role::Requested) { if (_role != Role::Requested) {
return; return;
} }

View file

@ -91,9 +91,9 @@ public:
QString generateShortName() override; QString generateShortName() override;
PaintRoundImageCallback generatePaintUserpicCallback() override; PaintRoundImageCallback generatePaintUserpicCallback() override;
QSize actionSize() const override; QSize rightActionSize() const override;
QMargins actionMargins() const override; QMargins rightActionMargins() const override;
void paintAction( void rightActionPaint(
Painter &p, Painter &p,
int x, int x,
int y, int y,
@ -337,21 +337,21 @@ PaintRoundImageCallback Row::generatePaintUserpicCallback() {
}; };
} }
QSize Row::actionSize() const { QSize Row::rightActionSize() const {
return QSize( return QSize(
st::inviteLinkThreeDotsIcon.width(), st::inviteLinkThreeDotsIcon.width(),
st::inviteLinkThreeDotsIcon.height()); st::inviteLinkThreeDotsIcon.height());
} }
QMargins Row::actionMargins() const { QMargins Row::rightActionMargins() const {
return QMargins( return QMargins(
0, 0,
(st::inviteLinkList.item.height - actionSize().height()) / 2, (st::inviteLinkList.item.height - rightActionSize().height()) / 2,
st::inviteLinkThreeDotsSkip, st::inviteLinkThreeDotsSkip,
0); 0);
} }
void Row::paintAction( void Row::rightActionPaint(
Painter &p, Painter &p,
int x, int x,
int y, int y,
@ -381,7 +381,7 @@ public:
void prepare() override; void prepare() override;
void loadMoreRows() override; void loadMoreRows() override;
void rowClicked(not_null<PeerListRow*> row) override; void rowClicked(not_null<PeerListRow*> row) override;
void rowActionClicked(not_null<PeerListRow*> row) override; void rowRightActionClicked(not_null<PeerListRow*> row) override;
base::unique_qptr<Ui::PopupMenu> rowContextMenu( base::unique_qptr<Ui::PopupMenu> rowContextMenu(
QWidget *parent, QWidget *parent,
not_null<PeerListRow*> row) override; not_null<PeerListRow*> row) override;
@ -545,7 +545,7 @@ void LinksController::rowClicked(not_null<PeerListRow*> row) {
ShowInviteLinkBox(_peer, static_cast<Row*>(row.get())->data()); ShowInviteLinkBox(_peer, static_cast<Row*>(row.get())->data());
} }
void LinksController::rowActionClicked(not_null<PeerListRow*> row) { void LinksController::rowRightActionClicked(not_null<PeerListRow*> row) {
delegate()->peerListShowRowMenu(row, true); delegate()->peerListShowRowMenu(row, true);
} }

View file

@ -102,23 +102,25 @@ public:
int availableWidth, int availableWidth,
int outerWidth, int outerWidth,
bool selected) override; bool selected) override;
void addActionRipple(QPoint point, Fn<void()> updateCallback) override; void rightActionAddRipple(
void stopLastActionRipple() override; QPoint point,
Fn<void()> updateCallback) override;
void rightActionStopLastRipple() override;
int nameIconWidth() const override { int nameIconWidth() const override {
return 0; return 0;
} }
QSize actionSize() const override { QSize rightActionSize() const override {
return peer()->isUser() ? QSize(_st->width, _st->height) : QSize(); return peer()->isUser() ? QSize(_st->width, _st->height) : QSize();
} }
QMargins actionMargins() const override { QMargins rightActionMargins() const override {
return QMargins( return QMargins(
0, 0,
0, 0,
st::defaultPeerListItem.photoPosition.x(), st::defaultPeerListItem.photoPosition.x(),
0); 0);
} }
void paintAction( void rightActionPaint(
Painter &p, Painter &p,
int x, int x,
int y, int y,
@ -168,14 +170,14 @@ void BoxController::Row::paintStatusText(Painter &p, const style::PeerListItem &
PeerListRow::paintStatusText(p, st, x, y, availableWidth, outerWidth, selected); PeerListRow::paintStatusText(p, st, x, y, availableWidth, outerWidth, selected);
} }
void BoxController::Row::paintAction( void BoxController::Row::rightActionPaint(
Painter &p, Painter &p,
int x, int x,
int y, int y,
int outerWidth, int outerWidth,
bool selected, bool selected,
bool actionSelected) { bool actionSelected) {
auto size = actionSize(); auto size = rightActionSize();
if (_actionRipple) { if (_actionRipple) {
_actionRipple->paint( _actionRipple->paint(
p, p,
@ -243,7 +245,7 @@ BoxController::Row::CallType BoxController::Row::ComputeCallType(
return CallType::Voice; return CallType::Voice;
} }
void BoxController::Row::addActionRipple(QPoint point, Fn<void()> updateCallback) { void BoxController::Row::rightActionAddRipple(QPoint point, Fn<void()> updateCallback) {
if (!_actionRipple) { if (!_actionRipple) {
auto mask = Ui::RippleAnimation::ellipseMask( auto mask = Ui::RippleAnimation::ellipseMask(
QSize(_st->rippleAreaSize, _st->rippleAreaSize)); QSize(_st->rippleAreaSize, _st->rippleAreaSize));
@ -255,7 +257,7 @@ void BoxController::Row::addActionRipple(QPoint point, Fn<void()> updateCallback
_actionRipple->add(point - _st->rippleAreaPosition); _actionRipple->add(point - _st->rippleAreaPosition);
} }
void BoxController::Row::stopLastActionRipple() { void BoxController::Row::rightActionStopLastRipple() {
if (_actionRipple) { if (_actionRipple) {
_actionRipple->lastStop(); _actionRipple->lastStop();
} }
@ -379,7 +381,7 @@ void BoxController::rowClicked(not_null<PeerListRow*> row) {
}); });
} }
void BoxController::rowActionClicked(not_null<PeerListRow*> row) { void BoxController::rowRightActionClicked(not_null<PeerListRow*> row) {
auto user = row->peer()->asUser(); auto user = row->peer()->asUser();
Assert(user != nullptr); Assert(user != nullptr);

View file

@ -23,7 +23,7 @@ public:
Main::Session &session() const override; Main::Session &session() const override;
void prepare() override; void prepare() override;
void rowClicked(not_null<PeerListRow*> row) override; void rowClicked(not_null<PeerListRow*> row) override;
void rowActionClicked(not_null<PeerListRow*> row) override; void rowRightActionClicked(not_null<PeerListRow*> row) override;
void loadMoreRows() override; void loadMoreRows() override;
base::unique_qptr<Ui::PopupMenu> rowContextMenu( base::unique_qptr<Ui::PopupMenu> rowContextMenu(

View file

@ -65,7 +65,7 @@ public:
Main::Session &session() const override; Main::Session &session() const override;
void prepare() override; void prepare() override;
void rowClicked(not_null<PeerListRow*> row) override; void rowClicked(not_null<PeerListRow*> row) override;
void rowActionClicked(not_null<PeerListRow*> row) override; void rowRightActionClicked(not_null<PeerListRow*> row) override;
base::unique_qptr<Ui::PopupMenu> rowContextMenu( base::unique_qptr<Ui::PopupMenu> rowContextMenu(
QWidget *parent, QWidget *parent,
not_null<PeerListRow*> row) override; not_null<PeerListRow*> row) override;
@ -1159,7 +1159,7 @@ void Members::Controller::showRowMenu(
delegate()->peerListShowRowMenu(row, highlightRow, cleanup); delegate()->peerListShowRowMenu(row, highlightRow, cleanup);
} }
void Members::Controller::rowActionClicked( void Members::Controller::rowRightActionClicked(
not_null<PeerListRow*> row) { not_null<PeerListRow*> row) {
showRowMenu(row, true); showRowMenu(row, true);
} }

View file

@ -665,19 +665,19 @@ void MembersRow::paintComplexStatusText(
: tr::lng_group_call_invited_status(tr::now))); : tr::lng_group_call_invited_status(tr::now)));
} }
QSize MembersRow::actionSize() const { QSize MembersRow::rightActionSize() const {
return _delegate->rowIsNarrow() ? QSize() : QSize( return _delegate->rowIsNarrow() ? QSize() : QSize(
st::groupCallActiveButton.width, st::groupCallActiveButton.width,
st::groupCallActiveButton.height); st::groupCallActiveButton.height);
} }
bool MembersRow::actionDisabled() const { bool MembersRow::rightActionDisabled() const {
return _delegate->rowIsMe(peer()) return _delegate->rowIsMe(peer())
|| (_state == State::Invited) || (_state == State::Invited)
|| !_delegate->rowCanMuteMembers(); || !_delegate->rowCanMuteMembers();
} }
QMargins MembersRow::actionMargins() const { QMargins MembersRow::rightActionMargins() const {
return QMargins( return QMargins(
0, 0,
0, 0,
@ -685,14 +685,14 @@ QMargins MembersRow::actionMargins() const {
0); 0);
} }
void MembersRow::paintAction( void MembersRow::rightActionPaint(
Painter &p, Painter &p,
int x, int x,
int y, int y,
int outerWidth, int outerWidth,
bool selected, bool selected,
bool actionSelected) { bool actionSelected) {
auto size = actionSize(); auto size = rightActionSize();
const auto iconRect = style::rtlrect( const auto iconRect = style::rtlrect(
x, x,
y, y,
@ -747,7 +747,9 @@ void MembersRow::refreshStatus() {
_speaking); _speaking);
} }
void MembersRow::addActionRipple(QPoint point, Fn<void()> updateCallback) { void MembersRow::rightActionAddRipple(
QPoint point,
Fn<void()> updateCallback) {
if (!_actionRipple) { if (!_actionRipple) {
auto mask = Ui::RippleAnimation::ellipseMask(QSize( auto mask = Ui::RippleAnimation::ellipseMask(QSize(
st::groupCallActiveButton.rippleAreaSize, st::groupCallActiveButton.rippleAreaSize,
@ -765,7 +767,7 @@ void MembersRow::refreshName(const style::PeerListItem &st) {
//_narrowName = Ui::Text::String(); //_narrowName = Ui::Text::String();
} }
void MembersRow::stopLastActionRipple() { void MembersRow::rightActionStopLastRipple() {
if (_actionRipple) { if (_actionRipple) {
_actionRipple->lastStop(); _actionRipple->lastStop();
} }

View file

@ -104,15 +104,16 @@ public:
return _raisedHandRating; return _raisedHandRating;
} }
void addActionRipple(QPoint point, Fn<void()> updateCallback) override;
void stopLastActionRipple() override;
void refreshName(const style::PeerListItem &st) override; void refreshName(const style::PeerListItem &st) override;
QSize actionSize() const override; void rightActionAddRipple(
bool actionDisabled() const override; QPoint point,
QMargins actionMargins() const override; Fn<void()> updateCallback) override;
void paintAction( void rightActionStopLastRipple() override;
QSize rightActionSize() const override;
bool rightActionDisabled() const override;
QMargins rightActionMargins() const override;
void rightActionPaint(
Painter &p, Painter &p,
int x, int x,
int y, int y,

View file

@ -37,7 +37,7 @@ void MemberListRow::setType(Type type) {
_type = type; _type = type;
} }
QSize MemberListRow::actionSize() const { QSize MemberListRow::rightActionSize() const {
return canRemove() return canRemove()
? QRect( ? QRect(
QPoint(), QPoint(),
@ -46,7 +46,7 @@ QSize MemberListRow::actionSize() const {
: QSize(); : QSize();
} }
void MemberListRow::paintAction( void MemberListRow::rightActionPaint(
Painter &p, Painter &p,
int x, int x,
int y, int y,

View file

@ -31,8 +31,8 @@ public:
MemberListRow(not_null<UserData*> user, Type type); MemberListRow(not_null<UserData*> user, Type type);
void setType(Type type); void setType(Type type);
QSize actionSize() const override; QSize rightActionSize() const override;
void paintAction( void rightActionPaint(
Painter &p, Painter &p,
int x, int x,
int y, int y,

View file

@ -228,7 +228,7 @@ void BlockedBoxController::rowClicked(not_null<PeerListRow*> row) {
}); });
} }
void BlockedBoxController::rowActionClicked(not_null<PeerListRow*> row) { void BlockedBoxController::rowRightActionClicked(not_null<PeerListRow*> row) {
session().api().blockedPeers().unblock(row->peer()); session().api().blockedPeers().unblock(row->peer());
} }

View file

@ -30,7 +30,7 @@ public:
Main::Session &session() const override; Main::Session &session() const override;
void prepare() override; void prepare() override;
void rowClicked(not_null<PeerListRow*> row) override; void rowClicked(not_null<PeerListRow*> row) override;
void rowActionClicked(not_null<PeerListRow*> row) override; void rowRightActionClicked(not_null<PeerListRow*> row) override;
void loadMoreRows() override; void loadMoreRows() override;
static void BlockNewPeer(not_null<Window::SessionController*> window); static void BlockNewPeer(not_null<Window::SessionController*> window);