mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-28 06:12:53 -06:00
TabBar: Tab alignment rotation now cached
This commit is contained in:
parent
f1f28cd00a
commit
413eec2a31
2 changed files with 45 additions and 15 deletions
|
|
@ -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))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue