From 02899206c2e085fb264b5603da24925c8dda0331 Mon Sep 17 00:00:00 2001 From: cxl Date: Thu, 26 May 2011 13:47:13 +0000 Subject: [PATCH] CtrlLib: Fixed appearance of small disabled scrollbars git-svn-id: svn://ultimatepp.org/upp/trunk@3461 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlLib/ScrollBar.cpp | 28 ++++++++++++++++++---------- uppsrc/CtrlLib/ScrollBar.h | 1 + 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/uppsrc/CtrlLib/ScrollBar.cpp b/uppsrc/CtrlLib/ScrollBar.cpp index d8802e9cb..3085dd2da 100644 --- a/uppsrc/CtrlLib/ScrollBar.cpp +++ b/uppsrc/CtrlLib/ScrollBar.cpp @@ -70,12 +70,12 @@ ScrollBar::ScrollBar() { ScrollBar::~ScrollBar() {} -Rect ScrollBar::Slider() const +Rect ScrollBar::Slider(int& cc) const { Size sz = GetSize(); Rect r; if(IsHorz()) { - int cc = sz.cx > (3 + style->isleft2 + style->isright2) * style->arrowsize ? style->arrowsize : 0; + cc = sz.cx > (3 + style->isleft2 + style->isright2) * style->arrowsize ? style->arrowsize : 0; r = RectC(cc, 0, sz.cx - 2 * cc, sz.cy); if(style->isleft2) r.right -= cc; @@ -83,7 +83,7 @@ Rect ScrollBar::Slider() const r.left += cc; } else { - int cc = sz.cy > (3 + style->isup2 + style->isdown2) * style->arrowsize ? style->arrowsize : 0; + cc = sz.cy > (3 + style->isup2 + style->isdown2) * style->arrowsize ? style->arrowsize : 0; r = RectC(0, cc, sz.cx, sz.cy - 2 * cc); if(style->isup2) r.bottom -= cc; @@ -93,6 +93,12 @@ Rect ScrollBar::Slider() const return r; } +Rect ScrollBar::Slider() const +{ + int dummy; + return Slider(dummy); +} + int& ScrollBar::HV(int& h, int& v) const { return IsHorz() ? h : v; @@ -126,7 +132,8 @@ Rect ScrollBar::GetPartRect(int p) const { void ScrollBar::Paint(Draw& w) { w.DrawRect(GetSize(), SColorPaper()); - Size sz = style->through ? GetSize() : Slider().GetSize(); + int cc; + Size sz = style->through ? GetSize() : Slider(cc).GetSize(); light = GetMousePart(); int p = push; if(!HasCapture()) @@ -150,17 +157,18 @@ void ScrollBar::Paint(Draw& w) { } } else - if(style->through) { + if(style->through) ChPaint(w, sz, l[0][CTRL_DISABLED]); - } else if(IsHorz()) { - ChPaint(w, style->arrowsize, 0, sz.cx / 2, sz.cy, l[0][CTRL_DISABLED]); - ChPaint(w, style->arrowsize + sz.cx / 2, 0, sz.cx - sz.cx / 2, sz.cy, l[1][CTRL_DISABLED]); + ChPaint(w, cc, 0, sz.cx / 2, sz.cy, l[0][CTRL_DISABLED]); + ChPaint(w, cc + sz.cx / 2, 0, sz.cx - sz.cx / 2, sz.cy, l[1][CTRL_DISABLED]); } else { - ChPaint(w, 0, style->arrowsize, sz.cx, sz.cy / 2, l[0][CTRL_DISABLED]); - ChPaint(w, 0, style->arrowsize + sz.cy / 2, sz.cx, sz.cy - sz.cy / 2, l[1][CTRL_DISABLED]); + ChPaint(w, 0, cc, sz.cx, sz.cy / 2, l[0][CTRL_DISABLED]); + ChPaint(w, 0, cc + sz.cy / 2, sz.cx, sz.cy - sz.cy / 2, l[1][CTRL_DISABLED]); +// w.DrawRect(0, cc, sz.cx, sz.cy / 2, Red()); _DBG_ +// w.DrawRect(0, cc + sz.cy / 2, sz.cx, sz.cy - sz.cy / 2, Green()); _DBG_ } } diff --git a/uppsrc/CtrlLib/ScrollBar.h b/uppsrc/CtrlLib/ScrollBar.h index 3760702f8..4f4a6721a 100644 --- a/uppsrc/CtrlLib/ScrollBar.h +++ b/uppsrc/CtrlLib/ScrollBar.h @@ -46,6 +46,7 @@ private: const Style *style; + Rect Slider(int& cc) const; Rect Slider() const; int& HV(int& h, int& v) const; int GetHV(int h, int v) const;