photos redesigned

This commit is contained in:
John Preston 2015-12-09 21:06:20 +03:00
parent 006ca44aa5
commit dda1ad987d
7 changed files with 392 additions and 713 deletions

View File

@ -52,7 +52,7 @@ if exist %ReleasePath%\deploy\%AppVersionStrMajor%\%AppVersionStr%\ (
) )
cd SourceFiles\ cd SourceFiles\
rem copy telegram.qrc /B+,,/Y copy telegram.qrc /B+,,/Y
cd ..\ cd ..\
if %errorlevel% neq 0 goto error if %errorlevel% neq 0 goto error

View File

@ -1165,7 +1165,9 @@ introErrLabelTextStyle: textStyle(defaultTextStyle) {
lineHeight: 27px; lineHeight: 27px;
} }
mediaPadding: margins(7px, 6px, 7px, 6px); mediaPadding: margins(0px, 0px, 0px, 0px);//2px, 2px, 2px, 2px);
mediaCaptionSkip: 5px;
mediaHeaderSkip: 5px;
mediaThumbSize: 48px; mediaThumbSize: 48px;
mediaNameTop: 3px; mediaNameTop: 3px;
mediaDetailsShift: 3px; mediaDetailsShift: 3px;

View File

@ -2147,7 +2147,6 @@ namespace App {
prepareCorners(MessageInSelectedCorners, st::msgRadius, st::msgInSelectBg, &st::msgInSelectShadow); prepareCorners(MessageInSelectedCorners, st::msgRadius, st::msgInSelectBg, &st::msgInSelectShadow);
prepareCorners(MessageOutCorners, st::msgRadius, st::msgOutBg, &st::msgOutShadow); prepareCorners(MessageOutCorners, st::msgRadius, st::msgOutBg, &st::msgOutShadow);
prepareCorners(MessageOutSelectedCorners, st::msgRadius, st::msgOutSelectBg, &st::msgOutSelectShadow); prepareCorners(MessageOutSelectedCorners, st::msgRadius, st::msgOutSelectBg, &st::msgOutSelectShadow);
prepareCorners(ButtonHoverCorners, st::msgRadius, st::mediaSaveButton.overBgColor, &st::msgInShadow);
} }

View File

@ -75,7 +75,6 @@ enum RoundCorners {
MessageInSelectedCorners, MessageInSelectedCorners,
MessageOutCorners, MessageOutCorners,
MessageOutSelectedCorners, MessageOutSelectedCorners,
ButtonHoverCorners,
RoundCornersCount RoundCornersCount
}; };

View File

@ -100,9 +100,9 @@ PhotoSendBox::PhotoSendBox(const FileLoadResultPtr &file) : AbstractBox(st::boxW
} }
_name = _file->filename; _name = _file->filename;
_namew = st::mediaFont->width(_name); _namew = st::normalFont->width(_name);
_size = formatSizeText(_file->filesize); _size = formatSizeText(_file->filesize);
_textw = qMax(_namew, st::mediaFont->width(_size)); _textw = qMax(_namew, st::normalFont->width(_size));
} }
updateBoxSize(); updateBoxSize();
_caption.setMaxLength(MaxPhotoCaption); _caption.setMaxLength(MaxPhotoCaption);
@ -136,9 +136,9 @@ PhotoSendBox::PhotoSendBox(const QString &phone, const QString &fname, const QSt
_compressed.hide(); _compressed.hide();
_name = lng_full_name(lt_first_name, _fname, lt_last_name, _lname); _name = lng_full_name(lt_first_name, _fname, lt_last_name, _lname);
_namew = st::mediaFont->width(_name); _namew = st::normalFont->width(_name);
_size = _phone; _size = _phone;
_textw = qMax(_namew, st::mediaFont->width(_size)); _textw = qMax(_namew, st::normalFont->width(_size));
updateBoxSize(); updateBoxSize();
prepare(); prepare();
@ -210,16 +210,16 @@ void PhotoSendBox::paintEvent(QPaintEvent *e) {
p.drawPixmap(x + st::mediaPadding.left(), y + st::mediaPadding.top(), userDefPhoto(1)->pix(st::mediaThumbSize)); p.drawPixmap(x + st::mediaPadding.left(), y + st::mediaPadding.top(), userDefPhoto(1)->pix(st::mediaThumbSize));
} }
p.setFont(st::mediaFont->f); p.setFont(st::normalFont->f);
p.setPen(st::black->c); p.setPen(st::black->c);
if (twidth < _namew) { if (twidth < _namew) {
p.drawText(x + tleft, y + st::mediaPadding.top() + st::mediaNameTop + st::mediaFont->ascent, st::mediaFont->elided(_name, twidth)); p.drawText(x + tleft, y + st::mediaPadding.top() + st::mediaNameTop + st::normalFont->ascent, st::normalFont->elided(_name, twidth));
} else { } else {
p.drawText(x + tleft, y + st::mediaPadding.top() + st::mediaNameTop + st::mediaFont->ascent, _name); p.drawText(x + tleft, y + st::mediaPadding.top() + st::mediaNameTop + st::normalFont->ascent, _name);
} }
p.setPen(st::mediaOutColor->p); p.setPen(st::mediaOutColor->p);
p.drawText(x + tleft, y + st::mediaPadding.top() + st::mediaThumbSize - st::mediaDetailsShift - st::mediaFont->descent, _size); p.drawText(x + tleft, y + st::mediaPadding.top() + st::mediaThumbSize - st::mediaDetailsShift - st::normalFont->descent, _size);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -941,6 +941,9 @@ public:
} }
virtual void updateMedia(const MTPMessageMedia *media, bool allowEmitResize) { virtual void updateMedia(const MTPMessageMedia *media, bool allowEmitResize) {
} }
virtual bool hasBubble() const {
return false;
}
virtual QString selectedText(uint32 selection) const { virtual QString selectedText(uint32 selection) const {
return qsl("[-]"); return qsl("[-]");
@ -1166,7 +1169,7 @@ public:
return QString(); return QString();
} }
virtual bool needsBubble(const HistoryItem *parent) const = 0; virtual bool needsBubble(const HistoryItem *parent) const = 0;
virtual bool customTime() const = 0; virtual bool customInfoLayout() const = 0;
int32 currentWidth() const { int32 currentWidth() const {
return qMin(w, _maxw); return qMin(w, _maxw);
@ -1199,22 +1202,22 @@ public:
HistoryMedia *clone() const; HistoryMedia *clone() const;
PhotoData *photo() const { PhotoData *photo() const {
return data; return _data;
} }
void updateFrom(const MTPMessageMedia &media); void updateFrom(const MTPMessageMedia &media);
TextLinkPtr lnk() const { TextLinkPtr lnk() const {
return openl; return _openl;
} }
virtual bool animating() const { virtual bool animating() const {
if (data->full->loaded()) return false; if (_data->full->loaded()) return false;
return data->full->loading() ? true : !data->medium->loaded(); return _data->full->loading() ? true : !_data->medium->loaded();
} }
bool hasReplyPreview() const { bool hasReplyPreview() const {
return !data->thumb->isNull(); return !_data->thumb->isNull();
} }
ImagePtr replyPreview(); ImagePtr replyPreview();
@ -1224,15 +1227,16 @@ public:
bool needsBubble(const HistoryItem *parent) const { bool needsBubble(const HistoryItem *parent) const {
return !_caption.isEmpty() || parent->toHistoryReply(); return !_caption.isEmpty() || parent->toHistoryReply();
} }
bool customTime() const { bool customInfoLayout() const {
return _caption.isEmpty(); return _caption.isEmpty();
} }
private: private:
int16 pixw, pixh; PhotoData *_data;
PhotoData *data; TextLinkPtr _openl;
int16 _pixw, _pixh;
Text _caption; Text _caption;
TextLinkPtr openl;
}; };
@ -1272,7 +1276,7 @@ public:
bool needsBubble(const HistoryItem *parent) const { bool needsBubble(const HistoryItem *parent) const {
return !_caption.isEmpty() || parent->toHistoryReply(); return !_caption.isEmpty() || parent->toHistoryReply();
} }
bool customTime() const { bool customInfoLayout() const {
return _caption.isEmpty(); return _caption.isEmpty();
} }
@ -1320,7 +1324,7 @@ public:
bool needsBubble(const HistoryItem *parent) const { bool needsBubble(const HistoryItem *parent) const {
return true; return true;
} }
bool customTime() const { bool customInfoLayout() const {
return false; return false;
} }
@ -1379,7 +1383,7 @@ public:
bool needsBubble(const HistoryItem *parent) const { bool needsBubble(const HistoryItem *parent) const {
return true; return true;
} }
bool customTime() const { bool customInfoLayout() const {
return false; return false;
} }
@ -1390,16 +1394,22 @@ private:
int32 _namew; int32 _namew;
QString _name; QString _name;
int32 _thumbw, _thumbx, _thumby; int32 _thumbw;
// >= 0 will contain download / upload string, _statusSize = loaded bytes // >= 0 will contain download / upload string, _statusSize = loaded bytes
// < 0 will contain played string, _statusSize = seconds played // < 0 will contain played string, _statusSize = -(seconds + 1) played
// 0x7FFFFF0 will contain status for not yet downloaded file // 0x7FFFFFF0 will contain status for not yet downloaded file
// 0x7FFFFF1 will contain status for already downloaded file // 0x7FFFFFF1 will contain status for already downloaded file
// 0x7FFFFF2 will contain status for failed to download / upload file // 0x7FFFFFF2 will contain status for failed to download / upload file
mutable int32 _statusSize; mutable int32 _statusSize;
mutable QString _statusText; mutable QString _statusText;
void setStatusSize(int32 newSize, qint64 realDuration = 0) const;
bool updateStatusText(const HistoryItem *parent) const; // returns showPause
}; };
static const int32 DocumentStatusSizeReady = 0x7FFFFFF0;
static const int32 DocumentStatusSizeLoaded = 0x7FFFFFF1;
static const int32 DocumentStatusSizeFailed = 0x7FFFFFF2;
class HistoryGif : public HistoryMedia { class HistoryGif : public HistoryMedia {
public: public:
@ -1442,7 +1452,7 @@ public:
bool needsBubble(const HistoryItem *parent) const { bool needsBubble(const HistoryItem *parent) const {
return parent->toHistoryReply(); return parent->toHistoryReply();
} }
bool customTime() const { bool customInfoLayout() const {
return true; return true;
} }
@ -1490,7 +1500,7 @@ public:
bool needsBubble(const HistoryItem *parent) const { bool needsBubble(const HistoryItem *parent) const {
return false; return false;
} }
bool customTime() const { bool customInfoLayout() const {
return true; return true;
} }
@ -1525,7 +1535,7 @@ public:
bool needsBubble(const HistoryItem *parent) const { bool needsBubble(const HistoryItem *parent) const {
return true; return true;
} }
bool customTime() const { bool customInfoLayout() const {
return false; return false;
} }
@ -1577,7 +1587,7 @@ public:
bool needsBubble(const HistoryItem *parent) const { bool needsBubble(const HistoryItem *parent) const {
return true; return true;
} }
bool customTime() const { bool customInfoLayout() const {
return false; return false;
} }
@ -1675,7 +1685,7 @@ public:
bool needsBubble(const HistoryItem *parent) const { bool needsBubble(const HistoryItem *parent) const {
return !_title.isEmpty() || !_description.isEmpty() || parent->toHistoryReply(); return !_title.isEmpty() || !_description.isEmpty() || parent->toHistoryReply();
} }
bool customTime() const { bool customInfoLayout() const {
return true; return true;
} }
@ -1700,12 +1710,18 @@ public:
void initDimensions(); void initDimensions();
void fromNameUpdated() const; void fromNameUpdated() const;
int32 plainMaxWidth() const;
void countPositionAndSize(int32 &left, int32 &width) const;
bool justMedia() const { bool justMedia() const {
return _text.isEmpty(); return _text.isEmpty();
} }
bool drawBubble() const { bool drawBubble() const {
return _media ? (!justMedia() || _media->needsBubble(this)) : true; return _media ? (!justMedia() || _media->needsBubble(this)) : true;
} }
bool hasBubble() const {
return drawBubble();
}
bool uploading() const; bool uploading() const;
void drawInfo(Painter &p, int32 right, int32 bottom, bool selected, InfoDisplayType type) const; void drawInfo(Painter &p, int32 right, int32 bottom, bool selected, InfoDisplayType type) const;