removed unnecessary borders in files / links overview, crash fixed in history repaint optimization

This commit is contained in:
John Preston 2016-01-04 07:38:47 +08:00
parent 827055f32a
commit c146843ab4
4 changed files with 30 additions and 6 deletions

View File

@ -5857,6 +5857,8 @@ void HistoryWidget::ui_repaintHistoryItem(const HistoryItem *item) {
} }
void HistoryWidget::onUpdateHistoryItems() { void HistoryWidget::onUpdateHistoryItems() {
if (!_list) return;
uint64 ms = getms(); uint64 ms = getms();
if (_lastScrolled + 100 <= ms) { if (_lastScrolled + 100 <= ms) {
_list->update(); _list->update();

View File

@ -850,9 +850,11 @@ void LayoutOverviewDocument::paint(Painter &p, const QRect &clip, uint32 selecti
statustop = st::linksBorder + st::overviewFileStatusTop; statustop = st::linksBorder + st::overviewFileStatusTop;
datetop = st::linksBorder + st::overviewFileDateTop; datetop = st::linksBorder + st::overviewFileDateTop;
QRect shadow(rtlrect(nameleft, 0, _width - nameleft, st::linksBorder, _width)); const OverviewPaintContext *pcontext = context->toOverviewPaintContext();
if (clip.intersects(shadow)) { t_assert(pcontext != 0);
p.fillRect(clip.intersected(shadow), st::linksBorderFg); QRect border(rtlrect(nameleft, 0, _width - nameleft, st::linksBorder, _width));
if (!pcontext->isAfterDate && clip.intersects(border)) {
p.fillRect(clip.intersected(border), st::linksBorderFg);
} }
QRect rthumb(rtlrect(0, st::linksBorder + st::overviewFilePadding.top(), st::overviewFileSize, st::overviewFileSize, _width)); QRect rthumb(rtlrect(0, st::linksBorder + st::overviewFilePadding.top(), st::overviewFileSize, st::overviewFileSize, _width));
@ -1274,8 +1276,11 @@ void LayoutOverviewLink::paint(Painter &p, const QRect &clip, uint32 selection,
top += st::normalFont->height; top += st::normalFont->height;
} }
if (clip.intersects(rtlrect(left, 0, w, st::linksBorder, _width))) { const OverviewPaintContext *pcontext = context->toOverviewPaintContext();
p.fillRect(clip.intersected(rtlrect(left, 0, w, st::linksBorder, _width)), st::linksBorderFg); t_assert(pcontext != 0);
QRect border(rtlrect(left, 0, w, st::linksBorder, _width));
if (!pcontext->isAfterDate && clip.intersects(border)) {
p.fillRect(clip.intersected(border), st::linksBorderFg);
} }
} }

View File

@ -81,6 +81,7 @@ style::color documentSelectedColor(int32 colorIndex);
style::sprite documentCorner(int32 colorIndex); style::sprite documentCorner(int32 colorIndex);
RoundCorners documentCorners(int32 colorIndex); RoundCorners documentCorners(int32 colorIndex);
class OverviewPaintContext;
class InlinePaintContext; class InlinePaintContext;
class PaintContext { class PaintContext {
public: public:
@ -89,6 +90,10 @@ public:
} }
uint64 ms; uint64 ms;
bool selecting; bool selecting;
virtual const OverviewPaintContext *toOverviewPaintContext() const {
return 0;
}
virtual const InlinePaintContext *toInlinePaintContext() const { virtual const InlinePaintContext *toInlinePaintContext() const {
return 0; return 0;
} }
@ -260,6 +265,17 @@ protected:
}; };
class OverviewPaintContext : public PaintContext {
public:
OverviewPaintContext(uint64 ms, bool selecting) : PaintContext(ms, selecting), isAfterDate(false) {
}
const OverviewPaintContext *toOverviewPaintContext() const {
return this;
}
bool isAfterDate;
};
class OverviewItemInfo { class OverviewItemInfo {
public: public:
OverviewItemInfo() : _top(0) { OverviewItemInfo() : _top(0) {

View File

@ -834,7 +834,7 @@ void OverviewInner::paintEvent(QPaintEvent *e) {
p.setClipRect(r); p.setClipRect(r);
} }
uint64 ms = getms(); uint64 ms = getms();
PaintContext context(ms, _selMode); OverviewPaintContext context(ms, _selMode);
if (_history->overview[_type].isEmpty() && (!_migrated || !_history->overviewLoaded(_type) || _migrated->overview[_type].isEmpty())) { if (_history->overview[_type].isEmpty() && (!_migrated || !_history->overviewLoaded(_type) || _migrated->overview[_type].isEmpty())) {
QPoint dogPos((_width - st::msgDogImg.pxWidth()) / 2, ((height() - st::msgDogImg.pxHeight()) * 4) / 9); QPoint dogPos((_width - st::msgDogImg.pxWidth()) / 2, ((height() - st::msgDogImg.pxHeight()) * 4) / 9);
@ -887,6 +887,7 @@ void OverviewInner::paintEvent(QPaintEvent *e) {
if (_reversed) curY = _height - curY; if (_reversed) curY = _height - curY;
if (_marginTop + curY >= r.y() + r.height()) break; if (_marginTop + curY >= r.y() + r.height()) break;
context.isAfterDate = (j > 0) ? !_items.at(j - 1)->toLayoutMediaItem() : false;
p.translate(0, curY - y); p.translate(0, curY - y);
_items.at(i)->paint(p, r.translated(-_rowsLeft, -_marginTop - curY), itemSelectedValue(i), &context); _items.at(i)->paint(p, r.translated(-_rowsLeft, -_marginTop - curY), itemSelectedValue(i), &context);
y = curY; y = curY;