diff --git a/uppsrc/TabBar/TabBar.cpp b/uppsrc/TabBar/TabBar.cpp index af9e781c6..097e95c03 100644 --- a/uppsrc/TabBar/TabBar.cpp +++ b/uppsrc/TabBar/TabBar.cpp @@ -925,18 +925,6 @@ Image TabBar::AlignImage(int align, const Image& img) } } -Value TabBar::AlignValue(int align, const Value &v, const Size &sz) -{ - Size isz = sz; - if(align == AlignedFrame::LEFT || align == AlignedFrame::RIGHT) - Swap(isz.cx, isz.cy); - - ImagePainter w(isz.cx, isz.cy); - w.Clear(RGBAZero()); - ChPaint(w, isz, v); - return AlignImage(align, (Image)w); -} - void TabBar::TabItem::Clear() { text.Clear(); @@ -1195,9 +1183,52 @@ void TabBar::PaintTab(Draw &w, const Size &sz, int n, bool enable, bool dragsamp ac ? CTRL_PRESSED : hl ? CTRL_HOT : CTRL_NORMAL; - const Value& sv = (cnt == 1 ? s.both : c == 0 ? s.first : c == cnt - 1 ? s.last : s.normal)[ndx]; + struct TabMaker : ImageMaker { + int c; + int cnt; + int ndx; + int align; + Size size; + const Style *s; + + String Key() const override { + String h; + RawCat(h, c); + RawCat(h, cnt); + RawCat(h, ndx); + RawCat(h, align); + RawCat(h, size); + RawCat(h, s); + return h; + } + + Image Make() const override { + DTIMING("AlignValue"); + const Value& sv = (cnt == 1 ? s->both : c == 0 ? s->first : c == cnt - 1 ? s->last : s->normal)[ndx]; + Size isz = size; + if(align == AlignedFrame::LEFT || align == AlignedFrame::RIGHT) + Swap(isz.cx, isz.cy); + + Image h[2]; + for(int i = 0; i < 2; i++) { + ImageDraw w(isz.cx, isz.cy); + w.DrawRect(isz, i ? Black() : White()); + ChPaint(w, isz, sv); + h[i] = w; + } + return AlignImage(align, RecreateAlpha(h[0], h[1])); + } + }; - Image img = AlignValue(align, sv, t.tab_size); + TabMaker tm; + tm.c = c; + tm.cnt = cnt; + tm.ndx = ndx; + tm.align = align; + tm.size = t.tab_size; + tm.s = style; + + Image img = MakeImage(tm); if(!IsNull(t.col)) { diff --git a/uppsrc/TabBar/TabBar.h b/uppsrc/TabBar/TabBar.h index 89fd5114f..3331313ae 100644 --- a/uppsrc/TabBar/TabBar.h +++ b/uppsrc/TabBar/TabBar.h @@ -316,7 +316,6 @@ protected: int GetStyleHeight() const; static Image AlignImage(int align, const Image& img); - static Value AlignValue(int align, const Value& v, const Size& isz); using Ctrl::GetStdSize; using Ctrl::Close;