mirror of https://github.com/procxx/kepka.git
Added buttons to delete and edit album items in SendFilesBox.
This commit is contained in:
parent
cf1dc3df78
commit
faef5d8af6
|
@ -41,6 +41,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "numbers.h"
|
#include "numbers.h"
|
||||||
#include "observer_peer.h"
|
#include "observer_peer.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
#include "styles/style_boxes.h"
|
||||||
#include "styles/style_overview.h"
|
#include "styles/style_overview.h"
|
||||||
#include "styles/style_mediaview.h"
|
#include "styles/style_mediaview.h"
|
||||||
#include "styles/style_chat_helpers.h"
|
#include "styles/style_chat_helpers.h"
|
||||||
|
@ -180,6 +181,8 @@ namespace App {
|
||||||
prepareCorners(MessageInSelectedCorners, st::historyMessageRadius, st::msgInBgSelected, &st::msgInShadowSelected);
|
prepareCorners(MessageInSelectedCorners, st::historyMessageRadius, st::msgInBgSelected, &st::msgInShadowSelected);
|
||||||
prepareCorners(MessageOutCorners, st::historyMessageRadius, st::msgOutBg, &st::msgOutShadow);
|
prepareCorners(MessageOutCorners, st::historyMessageRadius, st::msgOutBg, &st::msgOutShadow);
|
||||||
prepareCorners(MessageOutSelectedCorners, st::historyMessageRadius, st::msgOutBgSelected, &st::msgOutShadowSelected);
|
prepareCorners(MessageOutSelectedCorners, st::historyMessageRadius, st::msgOutBgSelected, &st::msgOutShadowSelected);
|
||||||
|
|
||||||
|
prepareCorners(SendFilesBoxAlbumGroupCorners, st::sendBoxAlbumGroupRadius, st::callFingerprintBg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void createCorners() {
|
void createCorners() {
|
||||||
|
|
|
@ -63,6 +63,8 @@ enum RoundCorners : int {
|
||||||
MessageOutCorners,
|
MessageOutCorners,
|
||||||
MessageOutSelectedCorners,
|
MessageOutSelectedCorners,
|
||||||
|
|
||||||
|
SendFilesBoxAlbumGroupCorners,
|
||||||
|
|
||||||
RoundCornersCount
|
RoundCornersCount
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -514,6 +514,27 @@ editMediaButton: IconButton {
|
||||||
ripple: defaultRippleAnimation;
|
ripple: defaultRippleAnimation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SendFilesBox
|
||||||
|
|
||||||
|
sendBoxAlbumGroupEditInternalSkip: 9px;
|
||||||
|
sendBoxAlbumGroupSkipRight: 6px;
|
||||||
|
sendBoxAlbumGroupSkipTop: 6px;
|
||||||
|
sendBoxAlbumGroupRadius: 12px;
|
||||||
|
sendBoxAlbumGroupHeight: 25px;
|
||||||
|
sendBoxAlbumGroupClickArea: 34px;
|
||||||
|
|
||||||
|
sendBoxAlbumGroupEditButtonIcon: icon {{ "settings_edit", msgServiceFg }};
|
||||||
|
sendBoxAlbumGroupEditButtonIconPosition: point(4px, -1px);
|
||||||
|
sendBoxAlbumGroupButton: IconButton {
|
||||||
|
width: sendBoxAlbumGroupClickArea;
|
||||||
|
height: sendBoxAlbumGroupClickArea;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendBoxAlbumGroupDeleteButtonIcon: icon {{ "history_file_cancel", msgServiceFg}};
|
||||||
|
sendBoxAlbumGroupDeleteButtonIconPosition: point(-3px, 0px);
|
||||||
|
|
||||||
|
// End of SendFilesBox
|
||||||
|
|
||||||
calendarTitleHeight: boxTitleHeight;
|
calendarTitleHeight: boxTitleHeight;
|
||||||
calendarPrevious: IconButton {
|
calendarPrevious: IconButton {
|
||||||
width: calendarTitleHeight;
|
width: calendarTitleHeight;
|
||||||
|
|
|
@ -52,6 +52,63 @@ constexpr auto kDragDuration = crl::time(200);
|
||||||
const auto kStickerMimeString = qstr("image/webp");
|
const auto kStickerMimeString = qstr("image/webp");
|
||||||
const auto kAnimatedStickerMimeString = qstr("application/x-tgsticker");
|
const auto kAnimatedStickerMimeString = qstr("application/x-tgsticker");
|
||||||
|
|
||||||
|
void PaintAlbumThumbButtons(
|
||||||
|
Painter &p,
|
||||||
|
QPoint point,
|
||||||
|
int outerWidth,
|
||||||
|
float64 shrinkProgress,
|
||||||
|
Ui::IconButton *editButton,
|
||||||
|
Ui::IconButton *deleteButton) {
|
||||||
|
|
||||||
|
const auto skipInternal = st::sendBoxAlbumGroupEditInternalSkip;
|
||||||
|
const auto size = st::sendBoxAlbumGroupHeight;
|
||||||
|
const auto clickArea = st::sendBoxAlbumGroupClickArea;
|
||||||
|
const auto skipRight = st::sendBoxAlbumGroupSkipRight;
|
||||||
|
const auto skipTop = st::sendBoxAlbumGroupSkipTop;
|
||||||
|
const auto groupWidth = size * 2 + skipInternal;
|
||||||
|
|
||||||
|
const auto groupX = point.x() + outerWidth - skipRight - groupWidth;
|
||||||
|
const auto groupY = point.y() + skipTop;
|
||||||
|
|
||||||
|
const auto skipFromArea = (clickArea - size) / 2;
|
||||||
|
const auto buttonX = groupX - skipFromArea;
|
||||||
|
const auto buttonY = groupY - skipFromArea;
|
||||||
|
|
||||||
|
const auto deleteLeft = skipInternal + size;
|
||||||
|
|
||||||
|
editButton->moveToLeft(buttonX, buttonY);
|
||||||
|
deleteButton->moveToLeft(buttonX + deleteLeft, buttonY);
|
||||||
|
|
||||||
|
const auto alpha = 1.0 - shrinkProgress;
|
||||||
|
editButton->setDisabled(alpha < 1);
|
||||||
|
deleteButton->setDisabled(alpha < 1);
|
||||||
|
p.setOpacity(alpha);
|
||||||
|
App::roundRect(
|
||||||
|
p,
|
||||||
|
groupX,
|
||||||
|
groupY,
|
||||||
|
groupWidth,
|
||||||
|
size,
|
||||||
|
st::callFingerprintBg,
|
||||||
|
SendFilesBoxAlbumGroupCorners);
|
||||||
|
|
||||||
|
const auto editP = st::sendBoxAlbumGroupEditButtonIconPosition;
|
||||||
|
const auto deleteP = st::sendBoxAlbumGroupDeleteButtonIconPosition;
|
||||||
|
|
||||||
|
st::sendBoxAlbumGroupEditButtonIcon.paintInCenter(
|
||||||
|
p,
|
||||||
|
QRect(groupX + editP.x(), groupY + editP.y(), size, size));
|
||||||
|
st::sendBoxAlbumGroupDeleteButtonIcon.paintInCenter(
|
||||||
|
p,
|
||||||
|
QRect(
|
||||||
|
groupX + deleteLeft + deleteP.x(),
|
||||||
|
groupY + deleteP.y(),
|
||||||
|
size,
|
||||||
|
size));
|
||||||
|
p.setOpacity(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
class SingleMediaPreview : public Ui::RpWidget {
|
class SingleMediaPreview : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
static SingleMediaPreview *Create(
|
static SingleMediaPreview *Create(
|
||||||
|
@ -149,6 +206,11 @@ public:
|
||||||
void suggestMove(float64 delta, Fn<void()> callback);
|
void suggestMove(float64 delta, Fn<void()> callback);
|
||||||
void finishAnimations();
|
void finishAnimations();
|
||||||
|
|
||||||
|
void addAlbumThumbButtons(
|
||||||
|
QWidget *parent,
|
||||||
|
Fn<void()> editCallback,
|
||||||
|
Fn<void()> deleteCallback);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QRect countRealGeometry() const;
|
QRect countRealGeometry() const;
|
||||||
QRect countCurrentGeometry(float64 progress) const;
|
QRect countCurrentGeometry(float64 progress) const;
|
||||||
|
@ -174,6 +236,9 @@ private:
|
||||||
Ui::Animations::Simple _suggestedMoveAnimation;
|
Ui::Animations::Simple _suggestedMoveAnimation;
|
||||||
int _lastShrinkValue = 0;
|
int _lastShrinkValue = 0;
|
||||||
|
|
||||||
|
object_ptr<Ui::IconButton> _editMedia = nullptr;
|
||||||
|
object_ptr<Ui::IconButton> _deleteMedia = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
AlbumThumb::AlbumThumb(
|
AlbumThumb::AlbumThumb(
|
||||||
|
@ -248,6 +313,17 @@ AlbumThumb::AlbumThumb(
|
||||||
_statusWidth = st::normalFont->width(_status);
|
_statusWidth = st::normalFont->width(_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AlbumThumb::addAlbumThumbButtons(
|
||||||
|
QWidget *parent,
|
||||||
|
Fn<void()> editCallback,
|
||||||
|
Fn<void()> deleteCallback) {
|
||||||
|
_editMedia.create(parent, st::sendBoxAlbumGroupButton);
|
||||||
|
_deleteMedia.create(parent, st::sendBoxAlbumGroupButton);
|
||||||
|
|
||||||
|
_editMedia->setClickedCallback(std::move(editCallback));
|
||||||
|
_deleteMedia->setClickedCallback(std::move(deleteCallback));
|
||||||
|
}
|
||||||
|
|
||||||
void AlbumThumb::resetLayoutAnimation() {
|
void AlbumThumb::resetLayoutAnimation() {
|
||||||
_animateFromGeometry = std::nullopt;
|
_animateFromGeometry = std::nullopt;
|
||||||
}
|
}
|
||||||
|
@ -338,6 +414,14 @@ void AlbumThumb::paintInAlbum(
|
||||||
}
|
}
|
||||||
st::historyFileThumbPlay.paintInCenter(p, inner);
|
st::historyFileThumbPlay.paintInCenter(p, inner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PaintAlbumThumbButtons(
|
||||||
|
p,
|
||||||
|
{ x, y },
|
||||||
|
geometry.width(),
|
||||||
|
shrinkProgress,
|
||||||
|
_editMedia,
|
||||||
|
_deleteMedia);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlbumThumb::prepareCache(QSize size, int shrink) {
|
void AlbumThumb::prepareCache(QSize size, int shrink) {
|
||||||
|
@ -1088,6 +1172,10 @@ void SendFilesBox::AlbumPreview::prepareThumbs() {
|
||||||
_thumbs.push_back(std::make_unique<AlbumThumb>(
|
_thumbs.push_back(std::make_unique<AlbumThumb>(
|
||||||
_list.files[i],
|
_list.files[i],
|
||||||
layout[i]));
|
layout[i]));
|
||||||
|
_thumbs[i]->addAlbumThumbButtons(
|
||||||
|
this,
|
||||||
|
[=] { changeThumbUnderCursor(); },
|
||||||
|
[=] { deleteThumbUnderCursor(); });
|
||||||
}
|
}
|
||||||
_thumbsHeight = countLayoutHeight(layout);
|
_thumbsHeight = countLayoutHeight(layout);
|
||||||
_photosHeight = ranges::accumulate(ranges::view::all(
|
_photosHeight = ranges::accumulate(ranges::view::all(
|
||||||
|
|
Loading…
Reference in New Issue