diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 1713a564e..29d48319f 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -2012,6 +2012,7 @@ namespace App { ::cornersMask[i]->setDevicePixelRatio(cRetinaFactor()); } prepareCorners(BlackCorners, st::msgRadius, st::black); + prepareCorners(WhiteCorners, st::msgRadius, st::white); prepareCorners(ServiceCorners, st::msgRadius, st::msgServiceBg); prepareCorners(ServiceSelectedCorners, st::msgRadius, st::msgServiceSelectBg); prepareCorners(SelectedOverlayCorners, st::msgRadius, st::msgSelectOverlay); diff --git a/Telegram/SourceFiles/gui/flatlabel.cpp b/Telegram/SourceFiles/gui/flatlabel.cpp index 9e3676b3b..34ac0e9e2 100644 --- a/Telegram/SourceFiles/gui/flatlabel.cpp +++ b/Telegram/SourceFiles/gui/flatlabel.cpp @@ -83,6 +83,11 @@ void FlatLabel::mouseReleaseEvent(QMouseEvent *e) { } } +void FlatLabel::enterEvent(QEvent *e) { + _lastMousePos = QCursor::pos(); + updateHover(); +} + void FlatLabel::leaveEvent(QEvent *e) { ClickHandler::clearActive(this); } diff --git a/Telegram/SourceFiles/gui/flatlabel.h b/Telegram/SourceFiles/gui/flatlabel.h index 4c3a60571..af6b558f2 100644 --- a/Telegram/SourceFiles/gui/flatlabel.h +++ b/Telegram/SourceFiles/gui/flatlabel.h @@ -33,6 +33,7 @@ public: void mouseMoveEvent(QMouseEvent *e); void mousePressEvent(QMouseEvent *e); void mouseReleaseEvent(QMouseEvent *e); + void enterEvent(QEvent *e); void leaveEvent(QEvent *e); void updateLink(); void setOpacity(float64 o); diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index 7d853db86..78f72741b 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -2830,34 +2830,36 @@ void ReplyKeyboard::getState(ClickHandlerPtr &lnk, int x, int y) const { } void ReplyKeyboard::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { - /*if (newSel != _sel) { - if (newSel < 0) { - setCursor(style::cur_default); - } else if (_sel < 0) { - setCursor(style::cur_pointer); - } - bool startanim = false; - if (_sel >= 0) { - _animations.remove(_sel + 1); - if (_animations.find(-_sel - 1) == _animations.end()) { - if (_animations.isEmpty()) startanim = true; - _animations.insert(-_sel - 1, getms()); + if (!p) return; + + bool startAnimation = false; + for (int i = 0, rows = _rows.size(); i != rows; ++i) { + const ButtonRow &row(_rows.at(i)); + for (int j = 0, cols = row.size(); j != cols; ++j) { + if (row.at(j).link == p) { + bool startAnimation = _animations.isEmpty(); + + int indexForAnimation = i * MatrixRowShift + j + 1; + if (!active) { + indexForAnimation = -indexForAnimation; + } + + _animations.remove(-indexForAnimation); + if (!_animations.contains(indexForAnimation)) { + _animations.insert(indexForAnimation, getms()); + } + + if (startAnimation && !_a_selected.animating()) { + _a_selected.start(); + } + return; } } - _sel = newSel; - if (_sel >= 0) { - _animations.remove(-_sel - 1); - if (_animations.find(_sel + 1) == _animations.end()) { - if (_animations.isEmpty()) startanim = true; - _animations.insert(_sel + 1, getms()); - } - } - if (startanim && !_a_selected.animating()) _a_selected.start(); - }*/ + } } void ReplyKeyboard::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) { - + _st->repaint(_item); } void ReplyKeyboard::step_selected(uint64 ms, bool timer) { @@ -6451,6 +6453,14 @@ void HistoryMessage::KeyboardStyle::repaint(const HistoryItem *item) const { void HistoryMessage::KeyboardStyle::paintButtonBg(Painter &p, const QRect &rect, bool down, float64 howMuchOver) const { App::roundRect(p, rect, App::msgServiceBg(), ServiceCorners); + if (down) { + howMuchOver = 1.; + } + if (howMuchOver > 0) { + p.setOpacity(howMuchOver * 0.1); + App::roundRect(p, rect, st::white, WhiteCorners); + p.setOpacity(1); + } } HistoryMessage::HistoryMessage(History *history, const MTPDmessage &msg) @@ -7055,7 +7065,7 @@ void HistoryMessage::draw(Painter &p, const QRect &r, uint32 selection, uint64 m if (const ReplyKeyboard *keyboard = inlineReplyKeyboard()) { int h = st::msgBotKbButton.margin + keyboard->naturalHeight(); height -= h; - int top = marginTop() + height; + int top = height + st::msgBotKbButton.margin - marginBottom(); p.translate(left, top); keyboard->paint(p, r.translated(-left, -top)); p.translate(-left, -top); @@ -7312,7 +7322,7 @@ void HistoryMessage::getState(ClickHandlerPtr &lnk, HistoryCursorState &state, i if (const ReplyKeyboard *keyboard = inlineReplyKeyboard()) { int h = st::msgBotKbButton.margin + keyboard->naturalHeight(); height -= h; - int top = marginTop() + height; + int top = height + st::msgBotKbButton.margin - marginBottom(); if (x >= left && x < left + width && y >= top && y < _height - marginBottom()) { return keyboard->getState(lnk, x - left, y - top); } diff --git a/Telegram/SourceFiles/history.h b/Telegram/SourceFiles/history.h index 080fe8392..458963445 100644 --- a/Telegram/SourceFiles/history.h +++ b/Telegram/SourceFiles/history.h @@ -1244,7 +1244,7 @@ public: } private: - HistoryMedia *_p; + HistoryMedia *_p = nullptr; }; diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index ce29895ef..d725e98a8 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -1483,6 +1483,7 @@ void HistoryInner::updateSize() { } void HistoryInner::enterEvent(QEvent *e) { + dragActionUpdate(QCursor::pos()); return QWidget::enterEvent(e); } @@ -1685,10 +1686,11 @@ void HistoryInner::onUpdateSelected() { } } else if (item) { item->getState(lnk, cursorState, m.x(), m.y()); + lnkhost = item; if (!lnk && m.x() >= st::msgMargin.left() && m.x() < st::msgMargin.left() + st::msgPhotoSize) { if (HistoryMessage *msg = item->toHistoryMessage()) { if (msg->hasFromPhoto()) { - enumerateUserpics([&lnk, &lnkhost, msg, &point](HistoryMessage *message, int userpicTop) -> bool { + enumerateUserpics([&lnk, &lnkhost, &point](HistoryMessage *message, int userpicTop) -> bool { // stop enumeration if the userpic is above our point if (userpicTop + st::msgPhotoSize <= point.y()) { return false; @@ -1697,7 +1699,7 @@ void HistoryInner::onUpdateSelected() { // stop enumeration if we've found a userpic under the cursor if (point.y() >= userpicTop && point.y() < userpicTop + st::msgPhotoSize) { lnk = message->from()->openLink(); - lnkhost = msg; + lnkhost = message; return false; } return true; @@ -2204,15 +2206,24 @@ void BotKeyboard::mouseReleaseEvent(QMouseEvent *e) { } } +void BotKeyboard::enterEvent(QEvent *e) { + _lastMousePos = QCursor::pos(); + updateSelected(); +} + void BotKeyboard::leaveEvent(QEvent *e) { _lastMousePos = QPoint(-1, -1); updateSelected(); } void BotKeyboard::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { + if (!_impl) return; + _impl->clickHandlerActiveChanged(p, active); } void BotKeyboard::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) { + if (!_impl) return; + _impl->clickHandlerPressedChanged(p, pressed); } bool BotKeyboard::updateMarkup(HistoryItem *to) { diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h index 626320a46..7bef37ca6 100644 --- a/Telegram/SourceFiles/historywidget.h +++ b/Telegram/SourceFiles/historywidget.h @@ -311,6 +311,7 @@ public: void mousePressEvent(QMouseEvent *e); void mouseMoveEvent(QMouseEvent *e); void mouseReleaseEvent(QMouseEvent *e); + void enterEvent(QEvent *e); void leaveEvent(QEvent *e); bool updateMarkup(HistoryItem *last); diff --git a/Telegram/SourceFiles/layout.h b/Telegram/SourceFiles/layout.h index 31ddea8cb..3a740e403 100644 --- a/Telegram/SourceFiles/layout.h +++ b/Telegram/SourceFiles/layout.h @@ -31,6 +31,7 @@ const TextParseOptions &itemTextNoMonoOptions(History *h, PeerData *f); enum RoundCorners { NoneCorners = 0x00, // for images BlackCorners, + WhiteCorners, ServiceCorners, ServiceSelectedCorners, SelectedOverlayCorners,