mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Closed beta 10020005: Added several buttons animations.
This commit is contained in:
@@ -156,8 +156,13 @@ bool TopBarWidget::eventFilter(QObject *obj, QEvent *e) {
|
||||
void TopBarWidget::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
|
||||
auto hasSelected = (_selectedCount > 0);
|
||||
auto selectedButtonsTop = countSelectedButtonsTop(_selectedShown.current(getms(), hasSelected ? 1. : 0.));
|
||||
|
||||
p.fillRect(QRect(0, 0, width(), st::topBarHeight), st::topBarBg);
|
||||
if (_clearSelection->isHidden()) {
|
||||
if (selectedButtonsTop < 0) {
|
||||
p.translate(0, selectedButtonsTop + st::topBarHeight);
|
||||
|
||||
p.save();
|
||||
auto decreaseWidth = 0;
|
||||
if (!_info->isHidden()) {
|
||||
@@ -195,32 +200,43 @@ void TopBarWidget::paintUnreadCounter(Painter &p, int outerWidth) {
|
||||
}
|
||||
|
||||
void TopBarWidget::mousePressEvent(QMouseEvent *e) {
|
||||
if (e->button() == Qt::LeftButton && e->pos().y() < st::topBarHeight && !_selCount) {
|
||||
if (e->button() == Qt::LeftButton && e->pos().y() < st::topBarHeight && !_selectedCount) {
|
||||
emit clicked();
|
||||
}
|
||||
}
|
||||
|
||||
void TopBarWidget::resizeEvent(QResizeEvent *e) {
|
||||
int buttonsLeft = st::topBarActionSkip + (Adaptive::OneColumn() ? 0 : st::lineWidth);
|
||||
int buttonsWidth = _forward->contentWidth() + _delete->contentWidth() + _clearSelection->width();
|
||||
updateControlsGeometry();
|
||||
}
|
||||
|
||||
int TopBarWidget::countSelectedButtonsTop(float64 selectedShown) {
|
||||
return (1. - selectedShown) * (-st::topBarHeight);
|
||||
}
|
||||
|
||||
void TopBarWidget::updateControlsGeometry() {
|
||||
auto hasSelected = (_selectedCount > 0);
|
||||
auto selectedButtonsTop = countSelectedButtonsTop(_selectedShown.current(hasSelected ? 1. : 0.));
|
||||
auto otherButtonsTop = selectedButtonsTop + st::topBarHeight;
|
||||
auto buttonsLeft = st::topBarActionSkip + (Adaptive::OneColumn() ? 0 : st::lineWidth);
|
||||
auto buttonsWidth = _forward->contentWidth() + _delete->contentWidth() + _clearSelection->width();
|
||||
buttonsWidth += buttonsLeft + st::topBarActionSkip * 3;
|
||||
|
||||
int widthLeft = qMin(width() - buttonsWidth, -2 * st::defaultActiveButton.width);
|
||||
auto widthLeft = qMin(width() - buttonsWidth, -2 * st::defaultActiveButton.width);
|
||||
_forward->setFullWidth(-(widthLeft / 2));
|
||||
_delete->setFullWidth(-(widthLeft / 2));
|
||||
|
||||
int buttonsTop = (height() - _forward->height()) / 2;
|
||||
selectedButtonsTop += (height() - _forward->height()) / 2;
|
||||
|
||||
_forward->moveToLeft(buttonsLeft, buttonsTop);
|
||||
_forward->moveToLeft(buttonsLeft, selectedButtonsTop);
|
||||
buttonsLeft += _forward->width() + st::topBarActionSkip;
|
||||
|
||||
_delete->moveToLeft(buttonsLeft, buttonsTop);
|
||||
_clearSelection->moveToRight(st::topBarActionSkip, buttonsTop);
|
||||
_delete->moveToLeft(buttonsLeft, selectedButtonsTop);
|
||||
_clearSelection->moveToRight(st::topBarActionSkip, selectedButtonsTop);
|
||||
|
||||
_info->moveToRight(0, 0);
|
||||
_menuToggle->moveToRight(0, 0);
|
||||
_mediaType->moveToRight(0, 0);
|
||||
_search->moveToRight(_info->isHidden() ? _menuToggle->width() : _info->width(), 0);
|
||||
_info->moveToRight(0, otherButtonsTop);
|
||||
_menuToggle->moveToRight(0, otherButtonsTop);
|
||||
_mediaType->moveToRight(0, otherButtonsTop);
|
||||
_search->moveToRight(_info->isHidden() ? _menuToggle->width() : _info->width(), otherButtonsTop);
|
||||
}
|
||||
|
||||
void TopBarWidget::startAnim() {
|
||||
@@ -247,31 +263,18 @@ void TopBarWidget::stopAnim() {
|
||||
|
||||
void TopBarWidget::showAll() {
|
||||
if (_animating) {
|
||||
resizeEvent(nullptr);
|
||||
updateControlsGeometry();
|
||||
return;
|
||||
}
|
||||
auto historyPeer = App::main() ? App::main()->historyPeer() : nullptr;
|
||||
auto overviewPeer = App::main() ? App::main()->overviewPeer() : nullptr;
|
||||
if (_selCount) {
|
||||
_clearSelection->show();
|
||||
if (_canDelete) {
|
||||
_delete->show();
|
||||
} else {
|
||||
_delete->hide();
|
||||
}
|
||||
_forward->show();
|
||||
_mediaType->hide();
|
||||
} else {
|
||||
_clearSelection->hide();
|
||||
_delete->hide();
|
||||
_forward->hide();
|
||||
if (App::main() && App::main()->mediaTypeSwitch()) {
|
||||
_mediaType->show();
|
||||
} else {
|
||||
_mediaType->hide();
|
||||
}
|
||||
}
|
||||
if (historyPeer && !overviewPeer && _clearSelection->isHidden()) {
|
||||
|
||||
_clearSelection->show();
|
||||
_delete->setVisible(_canDelete);
|
||||
_forward->show();
|
||||
|
||||
_mediaType->setVisible(App::main() ? App::main()->mediaTypeSwitch() : false);
|
||||
if (historyPeer && !overviewPeer) {
|
||||
if (Adaptive::OneColumn() || !App::main()->stackIsEmpty()) {
|
||||
_info->setPeer(historyPeer);
|
||||
_info->show();
|
||||
@@ -291,18 +294,18 @@ void TopBarWidget::showAll() {
|
||||
if (_membersShowArea) {
|
||||
_membersShowArea->show();
|
||||
}
|
||||
resizeEvent(nullptr);
|
||||
updateControlsGeometry();
|
||||
}
|
||||
|
||||
void TopBarWidget::updateMembersShowArea() {
|
||||
auto membersShowAreaNeeded = [this]() {
|
||||
if (_selCount || App::main()->overviewPeer() || !_selPeer) {
|
||||
if ((_selectedCount > 0) || App::main()->overviewPeer() || !_selectedInPeer) {
|
||||
return false;
|
||||
}
|
||||
if (auto chat = _selPeer->asChat()) {
|
||||
if (auto chat = _selectedInPeer->asChat()) {
|
||||
return chat->amIn();
|
||||
}
|
||||
if (auto megagroup = _selPeer->asMegagroup()) {
|
||||
if (auto megagroup = _selectedInPeer->asMegagroup()) {
|
||||
return megagroup->canViewMembers() && (megagroup->membersCount() < Global::ChatSizeMax());
|
||||
}
|
||||
return false;
|
||||
@@ -321,18 +324,36 @@ void TopBarWidget::updateMembersShowArea() {
|
||||
_membersShowArea->setGeometry(App::main()->getMembersShowAreaGeometry());
|
||||
}
|
||||
|
||||
void TopBarWidget::showSelected(uint32 selCount, bool canDelete) {
|
||||
_selPeer = App::main()->overviewPeer() ? App::main()->overviewPeer() : App::main()->peer();
|
||||
_selCount = selCount;
|
||||
if (_selCount > 0) {
|
||||
_canDelete = canDelete;
|
||||
_forward->setSecondaryText(QString::number(_selCount));
|
||||
_delete->setSecondaryText(QString::number(_selCount));
|
||||
void TopBarWidget::showSelected(int selectedCount, bool canDelete) {
|
||||
if (_selectedCount == selectedCount) {
|
||||
return;
|
||||
}
|
||||
setCursor(_selCount ? style::cur_default : style::cur_pointer);
|
||||
|
||||
updateMembersShowArea();
|
||||
showAll();
|
||||
auto wasSelected = (_selectedCount > 0);
|
||||
_selectedInPeer = App::main()->overviewPeer() ? App::main()->overviewPeer() : App::main()->peer();
|
||||
_selectedCount = selectedCount;
|
||||
if (_selectedCount > 0) {
|
||||
_forward->setSecondaryText(QString::number(_selectedCount));
|
||||
_delete->setSecondaryText(QString::number(_selectedCount));
|
||||
}
|
||||
auto hasSelected = (_selectedCount > 0);
|
||||
if (_canDelete != canDelete) {
|
||||
_canDelete = canDelete;
|
||||
showAll();
|
||||
}
|
||||
if (wasSelected != hasSelected) {
|
||||
setCursor(hasSelected ? style::cur_default : style::cur_pointer);
|
||||
|
||||
updateMembersShowArea();
|
||||
_selectedShown.start([this] { selectedShowCallback(); }, hasSelected ? 0. : 1., hasSelected ? 1. : 0., st::topBarSlideDuration, anim::easeOutCirc);
|
||||
} else {
|
||||
updateControlsGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
void TopBarWidget::selectedShowCallback() {
|
||||
updateControlsGeometry();
|
||||
update();
|
||||
}
|
||||
|
||||
void TopBarWidget::updateAdaptiveLayout() {
|
||||
|
@@ -40,7 +40,7 @@ public:
|
||||
void startAnim();
|
||||
void stopAnim();
|
||||
void showAll();
|
||||
void showSelected(uint32 selCount, bool canDelete = false);
|
||||
void showSelected(int selectedCount, bool canDelete = false);
|
||||
|
||||
void updateMembersShowArea();
|
||||
|
||||
@@ -58,6 +58,9 @@ signals:
|
||||
void clicked();
|
||||
|
||||
private:
|
||||
void updateControlsGeometry();
|
||||
void selectedShowCallback();
|
||||
|
||||
void onForwardSelection();
|
||||
void onDeleteSelection();
|
||||
void onClearSelection();
|
||||
@@ -66,16 +69,19 @@ private:
|
||||
void showMenu();
|
||||
|
||||
void updateAdaptiveLayout();
|
||||
int countSelectedButtonsTop(float64 selectedShown);
|
||||
|
||||
MainWidget *main();
|
||||
|
||||
PeerData *_searchInPeer = nullptr;
|
||||
PeerData *_selPeer = nullptr;
|
||||
int _selCount = 0;
|
||||
PeerData *_selectedInPeer = nullptr;
|
||||
int _selectedCount = 0;
|
||||
bool _canDelete = false;
|
||||
|
||||
bool _animating = false;
|
||||
|
||||
Animation _selectedShown;
|
||||
|
||||
object_ptr<Ui::RoundButton> _clearSelection;
|
||||
object_ptr<Ui::RoundButton> _forward, _delete;
|
||||
|
||||
|
@@ -82,9 +82,12 @@ notifyReplyArea: InputField(defaultInputField) {
|
||||
border: 0px;
|
||||
borderActive: 0px;
|
||||
}
|
||||
notifySendReply: IconButton(historySend) {
|
||||
notifySendReply: IconButton {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
|
||||
icon: historySendIcon;
|
||||
iconOver: historySendIconOver;
|
||||
iconPosition: point(6px, 6px);
|
||||
}
|
||||
|
||||
@@ -126,15 +129,14 @@ mainMenuTelegramLabel: FlatLabel(defaultFlatLabel) {
|
||||
linkFont: semiboldFont;
|
||||
linkFontOver: font(fsize semibold underline);
|
||||
}
|
||||
}
|
||||
mainMenuTelegramPalette: TextPalette(defaultTextPalette) {
|
||||
linkFg: windowSubTextFg;
|
||||
palette: TextPalette(defaultTextPalette) {
|
||||
linkFg: windowSubTextFg;
|
||||
}
|
||||
}
|
||||
mainMenuTelegramBottom: 43px;
|
||||
mainMenuVersionLabel: FlatLabel(mainMenuTelegramLabel) {
|
||||
style: defaultTextStyle;
|
||||
}
|
||||
mainMenuVersionPalette: mainMenuTelegramPalette;
|
||||
mainMenuVersionBottom: 21px;
|
||||
|
||||
// Windows specific title
|
||||
@@ -220,6 +222,7 @@ topBarInfoButton: PeerAvatarButton {
|
||||
size: topBarHeight;
|
||||
photoSize: 42px;
|
||||
}
|
||||
topBarSlideDuration: 150;
|
||||
|
||||
// Mac specific
|
||||
|
||||
|
@@ -147,7 +147,7 @@ void Generator::prepare() {
|
||||
_dialogs = QRect(_body.x(), _body.y(), st::themePreviewDialogsWidth, _body.height());
|
||||
_dialogsList = _dialogs.marginsRemoved(QMargins(0, st::dialogsFilterPadding.y() + st::dialogsMenuToggle.height + st::dialogsFilterPadding.y(), 0, st::dialogsPadding.y()));
|
||||
_topBar = QRect(_dialogs.x() + _dialogs.width(), _dialogs.y(), _body.width() - _dialogs.width(), st::topBarHeight);
|
||||
_composeArea = QRect(_topBar.x(), _body.y() + _body.height() - st::historySend.height, _topBar.width(), st::historySend.height);
|
||||
_composeArea = QRect(_topBar.x(), _body.y() + _body.height() - st::historySendSize.height(), _topBar.width(), st::historySendSize.height());
|
||||
_history = QRect(_topBar.x(), _topBar.y() + _topBar.height(), _topBar.width(), _body.height() - _topBar.height() - _composeArea.height());
|
||||
|
||||
generateData();
|
||||
@@ -402,10 +402,10 @@ void Generator::paintTopBar() {
|
||||
void Generator::paintComposeArea() {
|
||||
_p->fillRect(_composeArea, st::historyReplyBg[_palette]);
|
||||
|
||||
auto controlsTop = _composeArea.y() + _composeArea.height() - st::historySend.height;
|
||||
auto controlsTop = _composeArea.y() + _composeArea.height() - st::historySendSize.height();
|
||||
st::historyAttach.icon[_palette].paint(*_p, _composeArea.x() + st::historyAttach.iconPosition.x(), controlsTop + st::historyAttach.iconPosition.y(), _rect.width());
|
||||
auto right = st::historySendRight + st::historySend.width;
|
||||
st::historyRecordVoice[_palette].paintInCenter(*_p, QRect(_composeArea.x() + _composeArea.width() - right, controlsTop, st::historySend.width, st::historySend.height));
|
||||
auto right = st::historySendRight + st::historySendSize.width();
|
||||
st::historyRecordVoice[_palette].paintInCenter(*_p, QRect(_composeArea.x() + _composeArea.width() - right, controlsTop, st::historySendSize.width(), st::historySendSize.height()));
|
||||
|
||||
right += st::historyAttachEmoji.width;
|
||||
auto attachEmojiLeft = _composeArea.x() + _composeArea.width() - right;
|
||||
@@ -431,8 +431,8 @@ void Generator::paintComposeArea() {
|
||||
|
||||
auto fieldLeft = _composeArea.x() + st::historyAttach.width + fakeMargin;
|
||||
auto fieldTop = _composeArea.y() + _composeArea.height() - st::historyAttach.height + st::historySendPadding + fakeMargin;
|
||||
auto fieldWidth = _composeArea.width() - st::historyAttach.width - st::historySend.width - st::historySendRight - st::historyAttachEmoji.width - 2 * fakeMargin;
|
||||
auto fieldHeight = st::historySend.height - 2 * st::historySendPadding - 2 * fakeMargin;
|
||||
auto fieldWidth = _composeArea.width() - st::historyAttach.width - st::historySendSize.width() - st::historySendRight - st::historyAttachEmoji.width - 2 * fakeMargin;
|
||||
auto fieldHeight = st::historySendSize.height() - 2 * st::historySendPadding - 2 * fakeMargin;
|
||||
auto field = QRect(fieldLeft, fieldTop, fieldWidth, fieldHeight);
|
||||
_p->fillRect(field, st::historyComposeField.bgColor[_palette]);
|
||||
|
||||
|
Reference in New Issue
Block a user