Some layout fixes, std_::align() fixed to work in OS X 10.6-7 build.

This commit is contained in:
John Preston 2016-09-29 15:57:20 +03:00
parent f1f7333c7a
commit 6b8d3aa48c
4 changed files with 18 additions and 11 deletions

View File

@ -1007,7 +1007,7 @@ msgInvDblCheckImg: sprite(300px, 65px, 20px, 20px);
msgInvViewsImg: sprite(104px, 59px, 16px, 11px);
msgInvSendingViewsImg: sprite(104px, 114px, 16px, 11px);
msgDateSpace: 19px;
msgDateSpace: 12px;
msgDateCheckSpace: 4px;
msgDateViewsSpace: 11px;
msgDateDelta: point(2px, 5px);

View File

@ -20,6 +20,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/
#pragma once
#include <stdint.h>
// we copy some parts of C++11/14/17 std:: library, because on OS X 10.6+
// version we can use C++11/14/17, but we can not use its library :(
namespace std_ {
@ -204,11 +206,13 @@ public:
}
T *release() noexcept {
return getPointerAndReset(_p);
auto old = _p;
_p = nullptr;
return old;
}
void reset(T *p = nullptr) noexcept {
T *old = _p;
auto old = _p;
_p = p;
if (old) {
delete old;
@ -260,9 +264,12 @@ struct is_base_of {
static constexpr bool value = sizeof(check(_host<Base, Derived>(), int())) == sizeof(_yes);
};
#ifndef OS_MAC_OLD
inline void *align(size_t alignment, size_t size, void*& ptr, size_t& space) noexcept {
auto p = reinterpret_cast<std::uintptr_t>(ptr);
#ifndef OS_MAC_OLD
using std::uintptr_t;
#endif // OS_MAC_OLD
auto p = reinterpret_cast<uintptr_t>(ptr);
auto a = (p - 1u + alignment) & -alignment;
auto d = a - p;
if ((size + d) > space) {
@ -271,6 +278,5 @@ inline void *align(size_t alignment, size_t size, void*& ptr, size_t& space) noe
space -= d;
return ptr = reinterpret_cast<void*>(a);
}
#endif // OS_MAC_OLD
} // namespace std_

View File

@ -2560,7 +2560,7 @@ int HistoryWebPage::resizeGetHeight(int width) {
return _height;
}
_width = qMin(width, _maxw);
_width = width = qMin(width, _maxw);
width -= st::msgPadding.left() + st::webPageLeft + st::msgPadding.right();
int32 linesMax = 5;
@ -2659,10 +2659,10 @@ void HistoryWebPage::draw(Painter &p, const QRect &r, TextSelection selection, u
auto padding = inBubblePadding();
auto tshift = padding.top();
auto bshift = padding.bottom();
width -= padding.left() + padding.right();
if (_asArticle || (isBubbleBottom() && _attach && _attach->customInfoLayout() && _attach->currentWidth() + _parent->skipBlockWidth() > width + bubble.left() + bubble.right())) {
bshift += bottomInfoPadding();
}
width -= padding.left() + padding.right();
QRect bar(rtlrect(st::msgPadding.left(), tshift, st::webPageBar, _height - tshift - bshift, _width));
p.fillRect(bar, barfg);
@ -2994,7 +2994,7 @@ void HistoryGame::initDimensions() {
}
int HistoryGame::resizeGetHeight(int width) {
_width = qMin(width, _maxw);
_width = width = qMin(width, _maxw);
width -= st::msgPadding.left() + st::webPageLeft + st::msgPadding.right();
// enable any count of lines in game description / message
@ -3056,10 +3056,10 @@ void HistoryGame::draw(Painter &p, const QRect &r, TextSelection selection, uint
auto padding = inBubblePadding();
auto tshift = padding.top();
auto bshift = padding.bottom();
width -= padding.left() + padding.right();
if (isBubbleBottom() && _attach && _attach->customInfoLayout() && _attach->currentWidth() + _parent->skipBlockWidth() > width + bubble.left() + bubble.right()) {
bshift += bottomInfoPadding();
}
width -= padding.left() + padding.right();
QRect bar(rtlrect(st::msgPadding.left(), tshift, st::webPageBar, _height - tshift - bshift, _width));
p.fillRect(bar, barfg);

View File

@ -1976,7 +1976,8 @@ bool HistoryService::prepareGameScoreText(const QString &from, QString *outText,
auto getGameTitle = [item = gamescore->msg, &second]()->QString {
if (auto media = item->getMedia()) {
if (media->type() == MediaTypeGame) {
return static_cast<HistoryGame*>(media)->game()->title;
second = MakeShared<ReplyMarkupClickHandler>(item, 0, 0);
return textcmdLink(2, static_cast<HistoryGame*>(media)->game()->title);
}
}
return lang(lng_deleted_message);