* Added BSplitView drawing code to ControlLook.
* BSplitView uses ControlLook to draw itself. * Small refactoring in SplitLayout to implement IsAboveSplitter(BPoint). * BSplitView updates the view cursor when the mouse is above a splitter. * Standard splitter size is now 6 pixels, which is a bit easer to hit. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31137 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -208,6 +208,13 @@ public:
|
|||||||
const rgb_color& base, uint32 flags = 0,
|
const rgb_color& base, uint32 flags = 0,
|
||||||
uint32 borders = B_ALL_BORDERS);
|
uint32 borders = B_ALL_BORDERS);
|
||||||
|
|
||||||
|
/*virtual*/ void DrawSplitter(BView* view, BRect& rect,
|
||||||
|
const BRect& updateRect,
|
||||||
|
const rgb_color& base,
|
||||||
|
enum orientation orientation,
|
||||||
|
uint32 flags = 0,
|
||||||
|
uint32 borders = B_ALL_BORDERS);
|
||||||
|
|
||||||
// various borders
|
// various borders
|
||||||
|
|
||||||
virtual void DrawBorder(BView* view, BRect& rect,
|
virtual void DrawBorder(BView* view, BRect& rect,
|
||||||
|
|||||||
@@ -55,10 +55,12 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void DrawSplitter(BRect frame,
|
virtual void DrawSplitter(BRect frame,
|
||||||
|
const BRect& updateRect,
|
||||||
enum orientation orientation, bool pressed);
|
enum orientation orientation, bool pressed);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void _DrawDefaultSplitter(BView* view, BRect frame,
|
static void _DrawDefaultSplitter(BView* view, BRect frame,
|
||||||
|
const BRect& updateRect,
|
||||||
enum orientation orientation, bool pressed);
|
enum orientation orientation, bool pressed);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
|
|||||||
if (popupIndicator) {
|
if (popupIndicator) {
|
||||||
BRect leftRect(rect);
|
BRect leftRect(rect);
|
||||||
leftRect.right -= 10;
|
leftRect.right -= 10;
|
||||||
|
|
||||||
BRect rightRect(rect);
|
BRect rightRect(rect);
|
||||||
rightRect.left = rightRect.right - 9;
|
rightRect.left = rightRect.right - 9;
|
||||||
|
|
||||||
@@ -272,7 +272,7 @@ BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
|
|||||||
|
|
||||||
view->SetHighColor(markColor);
|
view->SetHighColor(markColor);
|
||||||
view->FillTriangle(triangle[0], triangle[1], triangle[2]);
|
view->FillTriangle(triangle[0], triangle[1], triangle[2]);
|
||||||
|
|
||||||
view->SetFlags(viewFlags);
|
view->SetFlags(viewFlags);
|
||||||
|
|
||||||
rect = leftRect;
|
rect = leftRect;
|
||||||
@@ -424,7 +424,7 @@ BControlLook::DrawStatusBar(BView* view, BRect& rect, const BRect& updateRect,
|
|||||||
|
|
||||||
_DrawOuterResessedFrame(view, rect, base, 0.6);
|
_DrawOuterResessedFrame(view, rect, base, 0.6);
|
||||||
|
|
||||||
// colors
|
// colors
|
||||||
rgb_color dark1BorderColor = tint_color(base, 1.3);
|
rgb_color dark1BorderColor = tint_color(base, 1.3);
|
||||||
rgb_color dark2BorderColor = tint_color(base, 1.2);
|
rgb_color dark2BorderColor = tint_color(base, 1.2);
|
||||||
rgb_color dark1FilledBorderColor = tint_color(barColor, 1.20);
|
rgb_color dark1FilledBorderColor = tint_color(barColor, 1.20);
|
||||||
@@ -869,7 +869,7 @@ BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
|
|||||||
rightBarSide.top = sliderPosition;
|
rightBarSide.top = sliderPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill the background for the corners, exclude the middle bar for now
|
// fill the background for the corners, exclude the middle bar for now
|
||||||
BRegion region(rect);
|
BRegion region(rect);
|
||||||
region.Exclude(rightBarSide);
|
region.Exclude(rightBarSide);
|
||||||
view->ConstrainClippingRegion(®ion);
|
view->ConstrainClippingRegion(®ion);
|
||||||
@@ -879,7 +879,7 @@ BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
|
|||||||
DrawSliderBar(view, rect, updateRect, base, leftFillColor, flags,
|
DrawSliderBar(view, rect, updateRect, base, leftFillColor, flags,
|
||||||
orientation);
|
orientation);
|
||||||
|
|
||||||
view->PopState();
|
view->PopState();
|
||||||
|
|
||||||
region.Set(rect);
|
region.Set(rect);
|
||||||
region.Exclude(leftBarSide);
|
region.Exclude(leftBarSide);
|
||||||
@@ -890,7 +890,7 @@ BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
|
|||||||
DrawSliderBar(view, rect, updateRect, base, rightFillColor, flags,
|
DrawSliderBar(view, rect, updateRect, base, rightFillColor, flags,
|
||||||
orientation);
|
orientation);
|
||||||
|
|
||||||
view->PopState();
|
view->PopState();
|
||||||
|
|
||||||
view->ConstrainClippingRegion(NULL);
|
view->ConstrainClippingRegion(NULL);
|
||||||
}
|
}
|
||||||
@@ -921,7 +921,7 @@ BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
|
|||||||
barRect.bottom -= ceilf(barRect.Width() / 2);
|
barRect.bottom -= ceilf(barRect.Width() / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill the background for the corners, exclude the middle bar for now
|
// fill the background for the corners, exclude the middle bar for now
|
||||||
BRegion region(rect);
|
BRegion region(rect);
|
||||||
region.Exclude(barRect);
|
region.Exclude(barRect);
|
||||||
view->ConstrainClippingRegion(®ion);
|
view->ConstrainClippingRegion(®ion);
|
||||||
@@ -968,7 +968,7 @@ BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
|
|||||||
_DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor,
|
_DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor,
|
||||||
edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
|
edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
|
||||||
fillShadowColor, 1.0, 1.0, 0.0, -1.0, orientation);
|
fillShadowColor, 1.0, 1.0, 0.0, -1.0, orientation);
|
||||||
|
|
||||||
_DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor,
|
_DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor,
|
||||||
edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
|
edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
|
||||||
fillShadowColor, 0.0, 1.0, -1.0, -1.0, orientation);
|
fillShadowColor, 0.0, 1.0, -1.0, -1.0, orientation);
|
||||||
@@ -976,7 +976,7 @@ BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
|
|||||||
_DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor,
|
_DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor,
|
||||||
edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
|
edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
|
||||||
fillShadowColor, 1.0, 1.0, -1.0, 0.0, orientation);
|
fillShadowColor, 1.0, 1.0, -1.0, 0.0, orientation);
|
||||||
|
|
||||||
_DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor,
|
_DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor,
|
||||||
edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
|
edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
|
||||||
fillShadowColor, 1.0, 0.0, -1.0, -1.0, orientation);
|
fillShadowColor, 1.0, 0.0, -1.0, -1.0, orientation);
|
||||||
@@ -1031,7 +1031,7 @@ BControlLook::DrawSliderThumb(BView* view, BRect& rect, const BRect& updateRect,
|
|||||||
// figure out the tints to be used
|
// figure out the tints to be used
|
||||||
float frameLightTint;
|
float frameLightTint;
|
||||||
float frameShadowTint;
|
float frameShadowTint;
|
||||||
|
|
||||||
if (flags & B_DISABLED) {
|
if (flags & B_DISABLED) {
|
||||||
frameLightTint = 1.30;
|
frameLightTint = 1.30;
|
||||||
frameShadowTint = 1.35;
|
frameShadowTint = 1.35;
|
||||||
@@ -1040,7 +1040,7 @@ BControlLook::DrawSliderThumb(BView* view, BRect& rect, const BRect& updateRect,
|
|||||||
frameLightTint = 1.6;
|
frameLightTint = 1.6;
|
||||||
frameShadowTint = 1.65;
|
frameShadowTint = 1.65;
|
||||||
}
|
}
|
||||||
|
|
||||||
frameLightColor = tint_color(base, frameLightTint);
|
frameLightColor = tint_color(base, frameLightTint);
|
||||||
frameShadowColor = tint_color(base, frameShadowTint);
|
frameShadowColor = tint_color(base, frameShadowTint);
|
||||||
}
|
}
|
||||||
@@ -1143,7 +1143,7 @@ BControlLook::DrawSliderTriangle(BView* view, BRect& rect,
|
|||||||
// figure out the tints to be used
|
// figure out the tints to be used
|
||||||
float frameLightTint;
|
float frameLightTint;
|
||||||
float frameShadowTint;
|
float frameShadowTint;
|
||||||
|
|
||||||
if (flags & B_DISABLED) {
|
if (flags & B_DISABLED) {
|
||||||
frameLightTint = 1.30;
|
frameLightTint = 1.30;
|
||||||
frameShadowTint = 1.35;
|
frameShadowTint = 1.35;
|
||||||
@@ -1152,7 +1152,7 @@ BControlLook::DrawSliderTriangle(BView* view, BRect& rect,
|
|||||||
frameLightTint = 1.6;
|
frameLightTint = 1.6;
|
||||||
frameShadowTint = 1.65;
|
frameShadowTint = 1.65;
|
||||||
}
|
}
|
||||||
|
|
||||||
frameLightColor = tint_color(base, frameLightTint);
|
frameLightColor = tint_color(base, frameLightTint);
|
||||||
frameShadowColor = tint_color(base, frameShadowTint);
|
frameShadowColor = tint_color(base, frameShadowTint);
|
||||||
}
|
}
|
||||||
@@ -1440,6 +1440,113 @@ BControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BControlLook::DrawSplitter(BView* view, BRect& rect, const BRect& updateRect,
|
||||||
|
const rgb_color& base, enum orientation orientation, uint32 flags,
|
||||||
|
uint32 borders)
|
||||||
|
{
|
||||||
|
rgb_color background;
|
||||||
|
if ((flags & (B_CLICKED | B_ACTIVATED)) != 0)
|
||||||
|
background = tint_color(base, B_DARKEN_1_TINT);
|
||||||
|
else
|
||||||
|
background = base;
|
||||||
|
|
||||||
|
rgb_color light = tint_color(background, 0.6);
|
||||||
|
rgb_color shadow = tint_color(background, 1.21);
|
||||||
|
|
||||||
|
// frame
|
||||||
|
if (borders != 0 && rect.Width() > 3 && rect.Height() > 3)
|
||||||
|
DrawRaisedBorder(view, rect, updateRect, background, flags, borders);
|
||||||
|
|
||||||
|
// dots and rest of background
|
||||||
|
if (orientation == B_HORIZONTAL) {
|
||||||
|
if (rect.Width() > 2) {
|
||||||
|
// background on left/right
|
||||||
|
BRegion region(rect);
|
||||||
|
rect.left = floorf((rect.left + rect.right) / 2.0 - 0.5);
|
||||||
|
rect.right = rect.left + 1;
|
||||||
|
region.Exclude(rect);
|
||||||
|
view->SetHighColor(background);
|
||||||
|
view->FillRegion(®ion);
|
||||||
|
}
|
||||||
|
|
||||||
|
BPoint dot = rect.LeftTop();
|
||||||
|
BPoint stop = rect.LeftBottom();
|
||||||
|
int32 num = 1;
|
||||||
|
while (dot.y <= stop.y) {
|
||||||
|
rgb_color col1;
|
||||||
|
rgb_color col2;
|
||||||
|
switch (num) {
|
||||||
|
case 1:
|
||||||
|
col1 = background;
|
||||||
|
col2 = background;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
col1 = shadow;
|
||||||
|
col2 = background;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
col1 = background;
|
||||||
|
col2 = light;
|
||||||
|
num = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
view->SetHighColor(col1);
|
||||||
|
view->StrokeLine(dot, dot, B_SOLID_HIGH);
|
||||||
|
view->SetHighColor(col2);
|
||||||
|
dot.x++;
|
||||||
|
view->StrokeLine(dot, dot, B_SOLID_HIGH);
|
||||||
|
dot.x -= 1.0;
|
||||||
|
// next pixel
|
||||||
|
num++;
|
||||||
|
dot.y++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (rect.Height() > 2) {
|
||||||
|
// background on left/right
|
||||||
|
BRegion region(rect);
|
||||||
|
rect.top = floorf((rect.top + rect.bottom) / 2.0 - 0.5);
|
||||||
|
rect.bottom = rect.top + 1;
|
||||||
|
region.Exclude(rect);
|
||||||
|
view->SetHighColor(background);
|
||||||
|
view->FillRegion(®ion);
|
||||||
|
}
|
||||||
|
|
||||||
|
BPoint dot = rect.LeftTop();
|
||||||
|
BPoint stop = rect.RightTop();
|
||||||
|
int32 num = 1;
|
||||||
|
while (dot.x <= stop.x) {
|
||||||
|
rgb_color col1;
|
||||||
|
rgb_color col2;
|
||||||
|
switch (num) {
|
||||||
|
case 1:
|
||||||
|
col1 = background;
|
||||||
|
col2 = background;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
col1 = shadow;
|
||||||
|
col2 = background;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
col1 = background;
|
||||||
|
col2 = light;
|
||||||
|
num = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
view->SetHighColor(col1);
|
||||||
|
view->StrokeLine(dot, dot, B_SOLID_HIGH);
|
||||||
|
view->SetHighColor(col2);
|
||||||
|
dot.y++;
|
||||||
|
view->StrokeLine(dot, dot, B_SOLID_HIGH);
|
||||||
|
dot.y -= 1.0;
|
||||||
|
// next pixel
|
||||||
|
num++;
|
||||||
|
dot.x++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
@@ -1601,7 +1708,7 @@ BControlLook::DrawLabel(BView* view, const char* label, BRect rect,
|
|||||||
|
|
||||||
// truncate the label if necessary and get the width and height
|
// truncate the label if necessary and get the width and height
|
||||||
BString truncatedLabel(label);
|
BString truncatedLabel(label);
|
||||||
|
|
||||||
BFont font;
|
BFont font;
|
||||||
view->GetFont(&font);
|
view->GetFont(&font);
|
||||||
|
|
||||||
@@ -1765,7 +1872,7 @@ BControlLook::_DrawOuterResessedFrame(BView* view, BRect& rect,
|
|||||||
// colors
|
// colors
|
||||||
float tintLight = kEdgeBevelLightTint;
|
float tintLight = kEdgeBevelLightTint;
|
||||||
float tintShadow = kEdgeBevelShadowTint;
|
float tintShadow = kEdgeBevelShadowTint;
|
||||||
|
|
||||||
if (contrast == 0.0) {
|
if (contrast == 0.0) {
|
||||||
tintLight = B_NO_TINT;
|
tintLight = B_NO_TINT;
|
||||||
tintShadow = B_NO_TINT;
|
tintShadow = B_NO_TINT;
|
||||||
@@ -1773,10 +1880,10 @@ BControlLook::_DrawOuterResessedFrame(BView* view, BRect& rect,
|
|||||||
tintLight = B_NO_TINT + (tintLight - B_NO_TINT) * contrast;
|
tintLight = B_NO_TINT + (tintLight - B_NO_TINT) * contrast;
|
||||||
tintShadow = B_NO_TINT + (tintShadow - B_NO_TINT) * contrast;
|
tintShadow = B_NO_TINT + (tintShadow - B_NO_TINT) * contrast;
|
||||||
}
|
}
|
||||||
|
|
||||||
rgb_color borderBevelShadow = tint_color(base, tintShadow);
|
rgb_color borderBevelShadow = tint_color(base, tintShadow);
|
||||||
rgb_color borderBevelLight = tint_color(base, tintLight);
|
rgb_color borderBevelLight = tint_color(base, tintLight);
|
||||||
|
|
||||||
if (brightness < 1.0) {
|
if (brightness < 1.0) {
|
||||||
borderBevelShadow.red = uint8(borderBevelShadow.red * brightness);
|
borderBevelShadow.red = uint8(borderBevelShadow.red * brightness);
|
||||||
borderBevelShadow.green = uint8(borderBevelShadow.green * brightness);
|
borderBevelShadow.green = uint8(borderBevelShadow.green * brightness);
|
||||||
@@ -1785,7 +1892,7 @@ BControlLook::_DrawOuterResessedFrame(BView* view, BRect& rect,
|
|||||||
borderBevelLight.green = uint8(borderBevelLight.green * brightness);
|
borderBevelLight.green = uint8(borderBevelLight.green * brightness);
|
||||||
borderBevelLight.blue = uint8(borderBevelLight.blue * brightness);
|
borderBevelLight.blue = uint8(borderBevelLight.blue * brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
_DrawFrame(view, rect, borderBevelShadow, borderBevelShadow,
|
_DrawFrame(view, rect, borderBevelShadow, borderBevelShadow,
|
||||||
borderBevelLight, borderBevelLight, borders);
|
borderBevelLight, borderBevelLight, borders);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ BSplitLayout::BSplitLayout(enum orientation orientation,
|
|||||||
fRightInset(0),
|
fRightInset(0),
|
||||||
fTopInset(0),
|
fTopInset(0),
|
||||||
fBottomInset(0),
|
fBottomInset(0),
|
||||||
fSplitterSize(3),
|
fSplitterSize(6),
|
||||||
fSpacing(spacing),
|
fSpacing(spacing),
|
||||||
|
|
||||||
fSplitterItems(),
|
fSplitterItems(),
|
||||||
@@ -153,7 +153,7 @@ BSplitLayout::BSplitLayout(enum orientation orientation,
|
|||||||
fVerticalLayouter(NULL),
|
fVerticalLayouter(NULL),
|
||||||
fHorizontalLayoutInfo(NULL),
|
fHorizontalLayoutInfo(NULL),
|
||||||
fVerticalLayoutInfo(NULL),
|
fVerticalLayoutInfo(NULL),
|
||||||
|
|
||||||
fHeightForWidthItems(),
|
fHeightForWidthItems(),
|
||||||
fHeightForWidthVerticalLayouter(NULL),
|
fHeightForWidthVerticalLayouter(NULL),
|
||||||
fHeightForWidthHorizontalLayoutInfo(NULL),
|
fHeightForWidthHorizontalLayoutInfo(NULL),
|
||||||
@@ -165,7 +165,7 @@ BSplitLayout::BSplitLayout(enum orientation orientation,
|
|||||||
fCachedMinHeightForWidth(-1),
|
fCachedMinHeightForWidth(-1),
|
||||||
fCachedMaxHeightForWidth(-1),
|
fCachedMaxHeightForWidth(-1),
|
||||||
fCachedPreferredHeightForWidth(-1),
|
fCachedPreferredHeightForWidth(-1),
|
||||||
|
|
||||||
fDraggingStartPoint(),
|
fDraggingStartPoint(),
|
||||||
fDraggingStartValue(0),
|
fDraggingStartValue(0),
|
||||||
fDraggingCurrentValue(0),
|
fDraggingCurrentValue(0),
|
||||||
@@ -482,7 +482,7 @@ BSplitLayout::LayoutView()
|
|||||||
verticalLayouter = fHeightForWidthVerticalLayouter;
|
verticalLayouter = fHeightForWidthVerticalLayouter;
|
||||||
} else
|
} else
|
||||||
verticalLayouter = fVerticalLayouter;
|
verticalLayouter = fVerticalLayouter;
|
||||||
|
|
||||||
verticalLayouter->Layout(fVerticalLayoutInfo, size.height);
|
verticalLayouter->Layout(fVerticalLayoutInfo, size.height);
|
||||||
|
|
||||||
float xOffset = fLeftInset;
|
float xOffset = fLeftInset;
|
||||||
@@ -551,6 +551,13 @@ BSplitLayout::SplitterItemFrame(int32 index) const
|
|||||||
return BRect();
|
return BRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsAboveSplitter
|
||||||
|
bool
|
||||||
|
BSplitLayout::IsAboveSplitter(const BPoint& point) const
|
||||||
|
{
|
||||||
|
return _SplitterItemAt(point) != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// StartDraggingSplitter
|
// StartDraggingSplitter
|
||||||
bool
|
bool
|
||||||
BSplitLayout::StartDraggingSplitter(BPoint point)
|
BSplitLayout::StartDraggingSplitter(BPoint point)
|
||||||
@@ -568,18 +575,14 @@ BSplitLayout::StartDraggingSplitter(BPoint point)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 splitterCount = fSplitterItems.CountItems();
|
int32 index;
|
||||||
for (int32 i = 0; i < splitterCount; i++) {
|
if (SplitterItem* splitItem = _SplitterItemAt(point, &index)) {
|
||||||
SplitterItem* splitItem = _SplitterItemAt(i);
|
fDraggingStartPoint = View()->ConvertToScreen(point);
|
||||||
BRect frame = splitItem->Frame();
|
fDraggingStartValue = _SplitterValue(index);
|
||||||
if (frame.Contains(point)) {
|
fDraggingCurrentValue = fDraggingStartValue;
|
||||||
fDraggingStartPoint = View()->ConvertToScreen(point);
|
fDraggingSplitterIndex = index;
|
||||||
fDraggingStartValue = _SplitterValue(i);
|
|
||||||
fDraggingCurrentValue = fDraggingStartValue;
|
|
||||||
fDraggingSplitterIndex = i;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -690,6 +693,23 @@ BSplitLayout::_InvalidateCachedHeightForWidth()
|
|||||||
fHeightForWidthVerticalLayouterWidth = -2;
|
fHeightForWidthVerticalLayouterWidth = -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// _SplitterItemAt
|
||||||
|
BSplitLayout::SplitterItem*
|
||||||
|
BSplitLayout::_SplitterItemAt(const BPoint& point, int32* index) const
|
||||||
|
{
|
||||||
|
int32 splitterCount = fSplitterItems.CountItems();
|
||||||
|
for (int32 i = 0; i < splitterCount; i++) {
|
||||||
|
SplitterItem* splitItem = _SplitterItemAt(i);
|
||||||
|
BRect frame = splitItem->Frame();
|
||||||
|
if (frame.Contains(point)) {
|
||||||
|
if (index != NULL)
|
||||||
|
*index = i;
|
||||||
|
return splitItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// _SplitterItemAt
|
// _SplitterItemAt
|
||||||
BSplitLayout::SplitterItem*
|
BSplitLayout::SplitterItem*
|
||||||
BSplitLayout::_SplitterItemAt(int32 index) const
|
BSplitLayout::_SplitterItemAt(int32 index) const
|
||||||
@@ -778,7 +798,7 @@ BSplitLayout::_LayoutItem(BLayoutItem* item, ItemLayoutInfo* info)
|
|||||||
bool visibilityChanged = (info->isVisible != isVisible);
|
bool visibilityChanged = (info->isVisible != isVisible);
|
||||||
if (visibilityChanged)
|
if (visibilityChanged)
|
||||||
item->SetVisible(info->isVisible);
|
item->SetVisible(info->isVisible);
|
||||||
|
|
||||||
// nothing more to do, if the item is not visible
|
// nothing more to do, if the item is not visible
|
||||||
if (!info->isVisible)
|
if (!info->isVisible)
|
||||||
return;
|
return;
|
||||||
@@ -1070,7 +1090,7 @@ BSplitLayout::_ValidateMinMax()
|
|||||||
fHeightForWidthItems.MakeEmpty();
|
fHeightForWidthItems.MakeEmpty();
|
||||||
|
|
||||||
_InvalidateCachedHeightForWidth();
|
_InvalidateCachedHeightForWidth();
|
||||||
|
|
||||||
// filter the visible items
|
// filter the visible items
|
||||||
int32 itemCount = CountItems();
|
int32 itemCount = CountItems();
|
||||||
for (int32 i = 0; i < itemCount; i++) {
|
for (int32 i = 0; i < itemCount; i++) {
|
||||||
@@ -1084,7 +1104,7 @@ BSplitLayout::_ValidateMinMax()
|
|||||||
if (item->HasHeightForWidth())
|
if (item->HasHeightForWidth())
|
||||||
fHeightForWidthItems.AddItem(item);
|
fHeightForWidthItems.AddItem(item);
|
||||||
}
|
}
|
||||||
itemCount = fVisibleItems.CountItems();
|
itemCount = fVisibleItems.CountItems();
|
||||||
|
|
||||||
// create the layouters
|
// create the layouters
|
||||||
Layouter* itemLayouter = new SimpleLayouter(itemCount, 0);
|
Layouter* itemLayouter = new SimpleLayouter(itemCount, 0);
|
||||||
@@ -1161,7 +1181,7 @@ BSplitLayout::_InternalGetHeightForWidth(float width, bool realLayout,
|
|||||||
}
|
}
|
||||||
horizontalLayoutInfo = fHeightForWidthHorizontalLayoutInfo;
|
horizontalLayoutInfo = fHeightForWidthHorizontalLayoutInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do the horizontal layout (already done when doing this for the real
|
// do the horizontal layout (already done when doing this for the real
|
||||||
// layout)
|
// layout)
|
||||||
if (!realLayout)
|
if (!realLayout)
|
||||||
@@ -1223,7 +1243,7 @@ BSplitLayout::_AddInsets(BSize size)
|
|||||||
float spacing = _SplitterSpace();
|
float spacing = _SplitterSpace();
|
||||||
if (fOrientation == B_HORIZONTAL)
|
if (fOrientation == B_HORIZONTAL)
|
||||||
size.width = BLayoutUtils::AddDistances(size.width, spacing - 1);
|
size.width = BLayoutUtils::AddDistances(size.width, spacing - 1);
|
||||||
else
|
else
|
||||||
size.height = BLayoutUtils::AddDistances(size.height, spacing - 1);
|
size.height = BLayoutUtils::AddDistances(size.height, spacing - 1);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
@@ -1257,7 +1277,7 @@ BSplitLayout::_SubtractInsets(BSize size)
|
|||||||
float spacing = _SplitterSpace();
|
float spacing = _SplitterSpace();
|
||||||
if (fOrientation == B_HORIZONTAL)
|
if (fOrientation == B_HORIZONTAL)
|
||||||
size.width = BLayoutUtils::SubtractDistances(size.width, spacing - 1);
|
size.width = BLayoutUtils::SubtractDistances(size.width, spacing - 1);
|
||||||
else
|
else
|
||||||
size.height = BLayoutUtils::SubtractDistances(size.height, spacing - 1);
|
size.height = BLayoutUtils::SubtractDistances(size.height, spacing - 1);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
|||||||
@@ -80,13 +80,14 @@ public:
|
|||||||
|
|
||||||
// interface for BSplitView
|
// interface for BSplitView
|
||||||
BRect SplitterItemFrame(int32 index) const;
|
BRect SplitterItemFrame(int32 index) const;
|
||||||
|
bool IsAboveSplitter(const BPoint& point) const;
|
||||||
|
|
||||||
bool StartDraggingSplitter(BPoint point);
|
bool StartDraggingSplitter(BPoint point);
|
||||||
bool DragSplitter(BPoint point);
|
bool DragSplitter(BPoint point);
|
||||||
bool StopDraggingSplitter();
|
bool StopDraggingSplitter();
|
||||||
int32 DraggedSplitter() const;
|
int32 DraggedSplitter() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void ItemAdded(BLayoutItem* item);
|
virtual void ItemAdded(BLayoutItem* item);
|
||||||
virtual void ItemRemoved(BLayoutItem* item);
|
virtual void ItemRemoved(BLayoutItem* item);
|
||||||
|
|
||||||
@@ -98,6 +99,8 @@ private:
|
|||||||
void _InvalidateLayout(bool invalidateView);
|
void _InvalidateLayout(bool invalidateView);
|
||||||
void _InvalidateCachedHeightForWidth();
|
void _InvalidateCachedHeightForWidth();
|
||||||
|
|
||||||
|
SplitterItem* _SplitterItemAt(const BPoint& point,
|
||||||
|
int32* index = NULL) const;
|
||||||
SplitterItem* _SplitterItemAt(int32 index) const;
|
SplitterItem* _SplitterItemAt(int32 index) const;
|
||||||
|
|
||||||
void _GetSplitterValueRange(int32 index,
|
void _GetSplitterValueRange(int32 index,
|
||||||
@@ -150,7 +153,7 @@ private:
|
|||||||
|
|
||||||
LayoutInfo* fHorizontalLayoutInfo;
|
LayoutInfo* fHorizontalLayoutInfo;
|
||||||
LayoutInfo* fVerticalLayoutInfo;
|
LayoutInfo* fVerticalLayoutInfo;
|
||||||
|
|
||||||
BList fHeightForWidthItems;
|
BList fHeightForWidthItems;
|
||||||
// Incorporates the children's height for width constraints for a
|
// Incorporates the children's height for width constraints for a
|
||||||
// concrete width. Cloned lazily from fVerticalLayout when needed.
|
// concrete width. Cloned lazily from fVerticalLayout when needed.
|
||||||
@@ -165,7 +168,7 @@ private:
|
|||||||
float fCachedMinHeightForWidth;
|
float fCachedMinHeightForWidth;
|
||||||
float fCachedMaxHeightForWidth;
|
float fCachedMaxHeightForWidth;
|
||||||
float fCachedPreferredHeightForWidth;
|
float fCachedPreferredHeightForWidth;
|
||||||
|
|
||||||
BPoint fDraggingStartPoint;
|
BPoint fDraggingStartPoint;
|
||||||
int32 fDraggingStartValue;
|
int32 fDraggingStartValue;
|
||||||
int32 fDraggingCurrentValue;
|
int32 fDraggingCurrentValue;
|
||||||
|
|||||||
@@ -5,12 +5,45 @@
|
|||||||
|
|
||||||
#include <SplitView.h>
|
#include <SplitView.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <ControlLook.h>
|
||||||
|
#include <Cursor.h>
|
||||||
|
|
||||||
#include "SplitLayout.h"
|
#include "SplitLayout.h"
|
||||||
|
|
||||||
|
|
||||||
|
static const unsigned char kHSplitterCursor[] = {
|
||||||
|
16, 1, 8, 8,
|
||||||
|
0x03, 0xc0, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40,
|
||||||
|
0x1a, 0x58, 0x2a, 0x54, 0x4a, 0x52, 0x8a, 0x51,
|
||||||
|
0x8a, 0x51, 0x4a, 0x52, 0x2a, 0x54, 0x1a, 0x58,
|
||||||
|
0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x03, 0xc0,
|
||||||
|
|
||||||
|
0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0,
|
||||||
|
0x1b, 0xd8, 0x3b, 0xdc, 0x7b, 0xde, 0xfb, 0xdf,
|
||||||
|
0xfb, 0xdf, 0x7b, 0xde, 0x3b, 0xdc, 0x1b, 0xd8,
|
||||||
|
0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned char kVSplitterCursor[] = {
|
||||||
|
16, 1, 8, 8,
|
||||||
|
0x01, 0x80, 0x02, 0x40, 0x04, 0x20, 0x08, 0x10,
|
||||||
|
0x0f, 0xf0, 0x00, 0x00, 0xff, 0xff, 0x80, 0x01,
|
||||||
|
0x80, 0x01, 0xff, 0xff, 0x00, 0x00, 0x0f, 0xf0,
|
||||||
|
0x08, 0x10, 0x04, 0x20, 0x02, 0x40, 0x01, 0x80,
|
||||||
|
|
||||||
|
0x01, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0,
|
||||||
|
0x0f, 0xf0, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
|
||||||
|
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x0f, 0xf0,
|
||||||
|
0x0f, 0xf0, 0x07, 0xe0, 0x03, 0xc0, 0x01, 0x80
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
BSplitView::BSplitView(enum orientation orientation, float spacing)
|
BSplitView::BSplitView(enum orientation orientation, float spacing)
|
||||||
: BView(NULL,
|
:
|
||||||
|
BView(NULL,
|
||||||
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_INVALIDATE_AFTER_LAYOUT,
|
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_INVALIDATE_AFTER_LAYOUT,
|
||||||
fSplitLayout = new BSplitLayout(orientation, spacing))
|
fSplitLayout = new BSplitLayout(orientation, spacing))
|
||||||
{
|
{
|
||||||
@@ -136,7 +169,8 @@ BSplitView::Draw(BRect updateRect)
|
|||||||
int32 count = fSplitLayout->CountItems();
|
int32 count = fSplitLayout->CountItems();
|
||||||
for (int32 i = 0; i < count - 1; i++) {
|
for (int32 i = 0; i < count - 1; i++) {
|
||||||
BRect frame = fSplitLayout->SplitterItemFrame(i);
|
BRect frame = fSplitLayout->SplitterItemFrame(i);
|
||||||
DrawSplitter(frame, Orientation(), draggedSplitterIndex == i);
|
DrawSplitter(frame, updateRect, Orientation(),
|
||||||
|
draggedSplitterIndex == i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +178,8 @@ BSplitView::Draw(BRect updateRect)
|
|||||||
void
|
void
|
||||||
BSplitView::MouseDown(BPoint where)
|
BSplitView::MouseDown(BPoint where)
|
||||||
{
|
{
|
||||||
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
|
SetMouseEventMask(B_POINTER_EVENTS,
|
||||||
|
B_LOCK_WINDOW_FOCUS | B_SUSPEND_VIEW_FOCUS);
|
||||||
|
|
||||||
if (fSplitLayout->StartDraggingSplitter(where))
|
if (fSplitLayout->StartDraggingSplitter(where))
|
||||||
Invalidate();
|
Invalidate();
|
||||||
@@ -164,7 +199,17 @@ BSplitView::MouseUp(BPoint where)
|
|||||||
void
|
void
|
||||||
BSplitView::MouseMoved(BPoint where, uint32 transit, const BMessage* message)
|
BSplitView::MouseMoved(BPoint where, uint32 transit, const BMessage* message)
|
||||||
{
|
{
|
||||||
|
BCursor cursor(B_CURSOR_SYSTEM_DEFAULT);
|
||||||
|
|
||||||
int32 splitterIndex = fSplitLayout->DraggedSplitter();
|
int32 splitterIndex = fSplitLayout->DraggedSplitter();
|
||||||
|
|
||||||
|
if (splitterIndex >= 0 || fSplitLayout->IsAboveSplitter(where)) {
|
||||||
|
if (Orientation() == B_VERTICAL)
|
||||||
|
cursor = BCursor(kVSplitterCursor);
|
||||||
|
else
|
||||||
|
cursor = BCursor(kHSplitterCursor);
|
||||||
|
}
|
||||||
|
|
||||||
if (splitterIndex >= 0) {
|
if (splitterIndex >= 0) {
|
||||||
BRect oldFrame = fSplitLayout->SplitterItemFrame(splitterIndex);
|
BRect oldFrame = fSplitLayout->SplitterItemFrame(splitterIndex);
|
||||||
if (fSplitLayout->DragSplitter(where)) {
|
if (fSplitLayout->DragSplitter(where)) {
|
||||||
@@ -172,6 +217,8 @@ BSplitView::MouseMoved(BPoint where, uint32 transit, const BMessage* message)
|
|||||||
Invalidate(fSplitLayout->SplitterItemFrame(splitterIndex));
|
Invalidate(fSplitLayout->SplitterItemFrame(splitterIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetViewCursor(&cursor, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLayout
|
// SetLayout
|
||||||
@@ -183,13 +230,18 @@ BSplitView::SetLayout(BLayout* layout)
|
|||||||
|
|
||||||
// DrawSplitter
|
// DrawSplitter
|
||||||
void
|
void
|
||||||
BSplitView::DrawSplitter(BRect frame, enum orientation orientation,
|
BSplitView::DrawSplitter(BRect frame, const BRect& updateRect,
|
||||||
bool pressed)
|
enum orientation orientation, bool pressed)
|
||||||
{
|
{
|
||||||
rgb_color black = { 0, 0, 0, 255 };
|
_DrawDefaultSplitter(this, frame, updateRect, orientation, pressed);
|
||||||
rgb_color white = { 255, 255, 255, 255 };
|
}
|
||||||
|
|
||||||
SetHighColor(pressed ? white : black);
|
// _DrawDefaultSplitter
|
||||||
|
void
|
||||||
FillRect(frame);
|
BSplitView::_DrawDefaultSplitter(BView* view, BRect frame,
|
||||||
|
const BRect& updateRect, enum orientation orientation, bool pressed)
|
||||||
|
{
|
||||||
|
uint32 flags = pressed ? BControlLook::B_ACTIVATED : 0;
|
||||||
|
be_control_look->DrawSplitter(view, frame, updateRect, view->ViewColor(),
|
||||||
|
orientation, flags, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user