mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
Painting fixes and clean up's
git-svn-id: svn://ultimatepp.org/upp/trunk@1148 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
93081ae35b
commit
ef448a592f
6 changed files with 2368 additions and 2401 deletions
|
|
@ -20,7 +20,7 @@ void DockTabBar::FrameAddSize(Size& sz)
|
|||
TabBar::FrameAddSize(sz);
|
||||
}
|
||||
|
||||
void DockTabBar::PaintTabData(Draw& w, const Rect &r, const Tab& tab, const Font &font, Color ink, dword style, int bl)
|
||||
void DockTabBar::PaintTabData(Draw& w, const Rect &r, const Tab& tab, const Font &font, Color ink, dword style)
|
||||
{
|
||||
DockableCtrl *d;
|
||||
WString txt;
|
||||
|
|
@ -39,37 +39,21 @@ void DockTabBar::PaintTabData(Draw& w, const Rect &r, const Tab& tab, const Font
|
|||
txt = d->GetTitle();
|
||||
}
|
||||
|
||||
Point p = GetTextPosition(r, GetTextSize(txt, font).cy, bl);
|
||||
Size isz;
|
||||
if(icons)
|
||||
{
|
||||
const Image& icon = (style == CTRL_DISABLED) ? DisabledImage(d->GetIcon()) : d->GetIcon();
|
||||
if (!icon.IsEmpty()) {
|
||||
int al = GetAlign();
|
||||
Size isz = icon.GetSize();
|
||||
Point ip;
|
||||
switch (al) {
|
||||
case LEFT:
|
||||
ip = Point(r.left + (r.Width() - isz.cy) / 2, p.y - isz.cy);
|
||||
p.y -= isz.cy + TB_SPACEICON;
|
||||
break;
|
||||
case TOP:
|
||||
ip = Point(p.x, r.top + (r.Height() - isz.cy) / 2);
|
||||
p.x += isz.cx + TB_SPACEICON;
|
||||
break;
|
||||
case RIGHT:
|
||||
ip = Point(r.left + (r.Width() - isz.cy) / 2, p.y);
|
||||
p.y += isz.cy + TB_SPACEICON;
|
||||
break;
|
||||
case BOTTOM:
|
||||
ip = Point(p.x, r.top + (r.Height() - isz.cy) / 2);
|
||||
p.x += isz.cx + TB_SPACEICON;
|
||||
break;
|
||||
};
|
||||
isz = icon.GetSize();
|
||||
Point ip = GetImagePosition(r, isz.cx, isz.cy, TB_SPACEICON, LEFT);
|
||||
w.DrawImage(ip.x, ip.y, icon);
|
||||
}
|
||||
}
|
||||
if (showtext)
|
||||
{
|
||||
Point p = GetTextPosition(r, GetTextSize(txt, font).cy, isz.cx + TB_SPACEICON + TB_MARGIN);
|
||||
w.DrawText(p.x, p.y, GetTextAngle(), txt, font, ink);
|
||||
}
|
||||
}
|
||||
|
||||
Size DockTabBar::GetStdSize(const Tab& t)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ protected:
|
|||
bool showtext:1;
|
||||
|
||||
virtual void PaintTabData(Draw& w, const Rect &t, const Tab& tab, const Font &font,
|
||||
Color ink, dword style, int bl);
|
||||
Color ink, dword style);
|
||||
virtual Size GetStdSize(const Tab &q);
|
||||
|
||||
virtual void RightDown(Point p, dword keyflags);
|
||||
|
|
|
|||
|
|
@ -562,7 +562,7 @@ WString TabBar::ParseLabel(const WString& s)
|
|||
return s;
|
||||
}
|
||||
|
||||
void TabBar::PaintTabData(Draw& w, const Rect& r, const Tab& tab, const Font &font, Color ink, dword style, int bl)
|
||||
void TabBar::PaintTabData(Draw& w, const Rect& r, const Tab& tab, const Font &font, Color ink, dword style)
|
||||
{
|
||||
WString txt;
|
||||
Font f = font;
|
||||
|
|
@ -579,30 +579,57 @@ void TabBar::PaintTabData(Draw& w, const Rect& r, const Tab& tab, const Font &fo
|
|||
else
|
||||
txt = IsString(q) ? q : StdConvert().Format(q);
|
||||
|
||||
Point p = GetTextPosition(r, GetTextSize(txt, font).cy, bl);
|
||||
Point p = GetTextPosition(r, GetTextSize(txt, font).cy, TB_MARGIN);
|
||||
w.DrawText(p.x, p.y, GetTextAngle(), ParseLabel(txt), f, i);
|
||||
}
|
||||
|
||||
Point TabBar::GetTextPosition(const Rect& r, int fy, int bl) const
|
||||
Point TabBar::GetTextPosition(const Rect& r, int cy, int space) const
|
||||
{
|
||||
Point p;
|
||||
int align = GetAlign();
|
||||
|
||||
fy /= 2;
|
||||
if(align == LEFT)
|
||||
{
|
||||
p = r.BottomLeft();
|
||||
p.x = bl - fy;
|
||||
p.y = r.bottom - space;
|
||||
p.x = r.left + (r.GetWidth() - cy) / 2;
|
||||
}
|
||||
else if(align == RIGHT)
|
||||
{
|
||||
p = r.TopRight();
|
||||
p.x = bl + fy + 1;
|
||||
p.y = r.top + space;
|
||||
p.x = r.right - (r.GetWidth() - cy) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
p = r.TopLeft();
|
||||
p.y = bl - fy;
|
||||
p.x = r.left + space;
|
||||
p.y = r.top + (r.GetHeight() - cy) / 2;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
Point TabBar::GetImagePosition(const Rect& r, int cx, int cy, int space, int side) const
|
||||
{
|
||||
Point p;
|
||||
int align = GetAlign();
|
||||
|
||||
if (align == LEFT)
|
||||
{
|
||||
p.x = r.left + (r.GetWidth() - cy) / 2;
|
||||
p.y = side == LEFT ? r.bottom - space - cx : r.top + space;
|
||||
}
|
||||
else if (align == RIGHT)
|
||||
{
|
||||
p.x = r.right - (r.GetWidth() + cy) / 2;
|
||||
p.y = side == LEFT ? r.top + space : r.bottom - space - cx;
|
||||
}
|
||||
else if (align == TOP)
|
||||
{
|
||||
p.x = side == LEFT ? r.left + space : r.right - cx - space;
|
||||
p.y = r.top + (r.GetHeight() - cy) / 2;
|
||||
}
|
||||
else if (align == BOTTOM)
|
||||
{
|
||||
p.x = side == LEFT ? r.left + space : r.right - cx - space;
|
||||
p.y = r.bottom - (r.GetHeight() + cy) / 2;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
|
@ -611,9 +638,9 @@ void TabBar::PaintTab(Draw &w, const Style &s, const Size &sz, int n, bool enabl
|
|||
{
|
||||
TabBar::Tab &t = tabs[n];
|
||||
int cnt = dragsample ? 1 : tabs.GetCount();
|
||||
Size tsz, fsz(sz.cx, sz.cy + TB_SBSEPARATOR * !sc.IsShown()), isz(0, 0);
|
||||
Fix(fsz);
|
||||
int sep = TB_SBSEPARATOR * sc.IsVisible();
|
||||
|
||||
Size tsz;
|
||||
Point p;
|
||||
|
||||
int align = GetAlign();
|
||||
|
|
@ -630,110 +657,52 @@ void TabBar::PaintTab(Draw &w, const Style &s, const Size &sz, int n, bool enabl
|
|||
int lx = n > 0 ? s.extendleft : 0;
|
||||
int x = t.pos.x - sc.GetPos() + s.margin - lx;
|
||||
|
||||
if (ac) {
|
||||
p = Point(x - s.sel.left, 0);
|
||||
tsz = Size(t.size.cx + lx + s.sel.right + s.sel.left, t.size.cy + s.sel.bottom);
|
||||
}
|
||||
else {
|
||||
p = Point(x, s.sel.top);
|
||||
tsz = Size(t.size.cx + lx, t.size.cy - s.sel.top);
|
||||
}
|
||||
|
||||
if (align == BOTTOM || align == RIGHT)
|
||||
p.y -= s.sel.top - TB_SBSEPARATOR * sc.IsVisible();
|
||||
p.y -= s.sel.bottom - sep;
|
||||
|
||||
t.real_pos = Fixed(p);
|
||||
t.real_size = Fixed(tsz);
|
||||
Rect ra(Fixed(p), Fixed(tsz));
|
||||
|
||||
ChPaint(w, t.real_pos.x, t.real_pos.y, t.real_size.cx, t.real_size.cy, sv);
|
||||
p = Point(x, s.sel.top);
|
||||
tsz = Size(t.size.cx + lx, t.size.cy - s.sel.top);
|
||||
|
||||
int dy = -s.sel.top * ac;
|
||||
|
||||
if (align == BOTTOM || align == RIGHT)
|
||||
{
|
||||
p.y -= s.sel.top - sep;
|
||||
dy = -dy;
|
||||
}
|
||||
|
||||
Rect rn(Fixed(p), Fixed(tsz));
|
||||
|
||||
t.real_pos = (ac ? ra : rn).TopLeft();
|
||||
t.real_size = (ac ? ra : rn).GetSize();
|
||||
|
||||
ChPaint(w, Rect(t.real_pos, t.real_size), sv);
|
||||
|
||||
rn = Rect(Fixed(Point(p.x, p.y + dy)), Fixed(tsz));
|
||||
|
||||
#ifdef TABBAR_DEBUG
|
||||
DrawFrame(w, Rect(t.real_pos, t.real_size), Blue);
|
||||
DrawFrame(w, rn, Green);
|
||||
#endif
|
||||
|
||||
Point cp;
|
||||
|
||||
Size bsz(t.size.cx + lx, t.size.cy - s.sel.top);
|
||||
|
||||
int cly = (fsz.cy - s.sel.top - s.sel.bottom * ac) / 2 + s.sel.top;
|
||||
|
||||
if(crosses && (cnt > neverempty || t.stack.GetCount())) {
|
||||
|
||||
const Image &cimg = TabBarImg::CR0();
|
||||
isz = cimg.GetSize();
|
||||
Size isz = TabBarImg::CR0().GetSize();
|
||||
Point p = GetImagePosition(rn, isz.cx, isz.cy, TB_MARGIN, RIGHT);
|
||||
|
||||
if (align == LEFT)
|
||||
{
|
||||
cp.x = cly - isz.cy / 2;
|
||||
cp.y = x + TB_MARGIN;
|
||||
}
|
||||
else if (align == RIGHT)
|
||||
{
|
||||
cp.x = fsz.cy - (cly - isz.cy / 2 + isz.cy);
|
||||
cp.y = x + bsz.cx - isz.cx - TB_MARGIN;
|
||||
}
|
||||
else if (align == TOP)
|
||||
{
|
||||
cp.x = x + bsz.cx - isz.cx - TB_MARGIN;
|
||||
cp.y = cly - isz.cy / 2;
|
||||
}
|
||||
else if (align == BOTTOM)
|
||||
{
|
||||
cp.x = x + bsz.cx - isz.cx - TB_MARGIN;
|
||||
cp.y = fsz.cy - (cly - isz.cy / 2 + isz.cy);
|
||||
}
|
||||
|
||||
t.cross_pos = cp;
|
||||
t.cross_pos = p;
|
||||
t.cross_size = isz;
|
||||
w.DrawImage(cp.x, cp.y, (ac || hl) ? (cross == n ? TabBarImg::CR2 : ac ? TabBarImg::CR1 : TabBarImg::CR0) : TabBarImg::CR0);
|
||||
isz.cx += 2;
|
||||
w.DrawImage(p.x, p.y, (ac || hl) ? (cross == n ? TabBarImg::CR2 : ac ? TabBarImg::CR1 : TabBarImg::CR0) : TabBarImg::CR0);
|
||||
}
|
||||
|
||||
bsz.cx -= TB_MARGIN * 2 + isz.cx;
|
||||
|
||||
if (align == LEFT)
|
||||
{
|
||||
cp.x = cly - bsz.cy / 2;
|
||||
cp.y = x + TB_MARGIN + isz.cx;
|
||||
}
|
||||
else if (align == RIGHT)
|
||||
{
|
||||
cp.x = fsz.cy - (cly - bsz.cy / 2 + bsz.cy);
|
||||
cp.y = x + TB_MARGIN;
|
||||
}
|
||||
else if (align == TOP)
|
||||
{
|
||||
cp.x = x + TB_MARGIN;
|
||||
cp.y = cly - bsz.cy / 2;
|
||||
}
|
||||
else if (align == BOTTOM)
|
||||
{
|
||||
cp.x = x + TB_MARGIN;
|
||||
cp.y = fsz.cy - (cly - bsz.cy / 2 + bsz.cy);
|
||||
}
|
||||
|
||||
Fix(bsz);
|
||||
|
||||
Rect r(cp, bsz);
|
||||
|
||||
#ifdef TABBAR_DEBUG
|
||||
w.DrawRect(r, Green);
|
||||
//w.DrawText(p.x, p.y, AsString(s.sel.bottom) + ", " + AsString(s.sel.top) + ", st:" + AsString(GetHeight()) + ", sz:" + AsString(sz.cy) + ", rs:" + AsString(t.real_size.cy), StdFont().Bold());
|
||||
#endif
|
||||
|
||||
if(align == RIGHT || align == BOTTOM)
|
||||
cly = fsz.cy - cly - 1;
|
||||
|
||||
if (display)
|
||||
display->Paint(w, r, t.data, s.text_color[ndx], SColorDisabled(), ndx);
|
||||
display->Paint(w, rn, t.data, s.text_color[ndx], SColorDisabled(), ndx);
|
||||
else
|
||||
PaintTabData(w, r, t, s.font, s.text_color[ndx], ndx, cly);
|
||||
|
||||
#ifdef TABBAR_DEBUG
|
||||
Point pp(p.x, cly);
|
||||
Fix(pp);
|
||||
w.DrawRect(pp.x, pp.y, IsVert() ? 1 : bsz.cx, IsVert() ? bsz.cy : 1, LtBlue);
|
||||
#endif
|
||||
PaintTabData(w, rn, t, s.font, s.text_color[ndx], ndx);
|
||||
}
|
||||
|
||||
void TabBar::Paint(Draw &w)
|
||||
|
|
|
|||
|
|
@ -240,12 +240,13 @@ protected:
|
|||
virtual WString ParseLabel(const WString& s);
|
||||
// Sub-class display overide & helpers
|
||||
virtual void PaintTabData(Draw& w, const Rect &t, const Tab& tab, const Font &font,
|
||||
Color ink, dword style, int bl);
|
||||
Color ink, dword style);
|
||||
virtual Size GetStdSize(const Tab &t);
|
||||
Size GetStdSize(const Value &v);
|
||||
|
||||
int GetTextAngle() { return AlignedFrame::IsVert() ? (GetAlign() == LEFT ? 900 : 2700) : 0; }
|
||||
Point GetTextPosition(const Rect& r, int cy, int bl) const;
|
||||
Point GetTextPosition(const Rect& r, int cy, int space) const;
|
||||
Point GetImagePosition(const Rect& r, int cx, int cy, int space, int side) const;
|
||||
int GetTargetTab(Point p);
|
||||
|
||||
const Style &GetStyle() { return *style[GetAlign()]; }
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
description "Bazaar: Generic tab frame. Authors: Daniel Kos (unodgs), James Thomas (mrtj)";
|
||||
description "Bazaar: Generic tab frame. Authors: Daniel Kos (unodgs), James Thomas (mrtj)\377";
|
||||
|
||||
uses
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
TabBar.h,
|
||||
TabBar.iml,
|
||||
TabBar.cpp;
|
||||
TabBar.cpp,
|
||||
TabBar.iml;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
|
|
|
|||
|
|
@ -10,6 +10,17 @@ struct TabBarTest : TopWindow
|
|||
TabBar t_tabs;
|
||||
TabBar b_tabs;
|
||||
|
||||
typedef TabBarTest CLASSNAME;
|
||||
|
||||
bool Stack(Value a, Value b)
|
||||
{
|
||||
String as = a;
|
||||
String bs = b;
|
||||
as = as.Left(as.Find('.'));
|
||||
bs = bs.Left(bs.Find('.'));
|
||||
return as == bs;
|
||||
}
|
||||
|
||||
TabBarTest()
|
||||
{
|
||||
l_tabs.Crosses(true);
|
||||
|
|
@ -35,15 +46,17 @@ struct TabBarTest : TopWindow
|
|||
r_tabs.Grouping(true);
|
||||
|
||||
t_tabs.Crosses(true);
|
||||
t_tabs.Add("/ala/Test.cpp");
|
||||
t_tabs.Add("/ala/Test.h");
|
||||
t_tabs.Add("Test.cpp");
|
||||
t_tabs.Add("Test.h");
|
||||
t_tabs.Add("/ala/SuperProgram.cpp", true);
|
||||
t_tabs.Add("/kasia/SuperProgram.h");
|
||||
t_tabs.Add("/kasia/Synchronize.cpp");
|
||||
t_tabs.Add("/kasia/Synchronize.h");
|
||||
t_tabs.Add("/test/Test.cpp");
|
||||
t_tabs.Add("/test/Test.h");
|
||||
t_tabs.Grouping(true);
|
||||
t_tabs.StackingFunc(THISBACK(Stack));
|
||||
//t_tabs.Grouping(true);
|
||||
//t_tabs.Stacking(true);
|
||||
|
||||
b_tabs.Crosses(true);
|
||||
b_tabs.Add("/ala/Test.cpp");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue