* Added optional tracing to ScrollBar.cpp.
* Fixed line breaks to not exceed 80 char limit. * Removed any trailing spaces. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24836 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
49df4099d1
commit
c2234e0598
|
@ -21,7 +21,13 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
//#define TEST_MODE
|
//#define TRACE_SCROLLBAR
|
||||||
|
#ifdef TRACE_SCROLLBAR
|
||||||
|
# define TRACE(x...) printf(x)
|
||||||
|
#else
|
||||||
|
# define TRACE(x...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ARROW_LEFT = 0,
|
ARROW_LEFT = 0,
|
||||||
|
@ -312,6 +318,8 @@ an actual BView within the scroll bar's window.
|
||||||
void
|
void
|
||||||
BScrollBar::SetValue(float value)
|
BScrollBar::SetValue(float value)
|
||||||
{
|
{
|
||||||
|
TRACE("BScrollBar(%s)::SetValue(%.1f)\n", Name(), value);
|
||||||
|
|
||||||
if (value > fMax)
|
if (value > fMax)
|
||||||
value = fMax;
|
value = fMax;
|
||||||
else if (value < fMin)
|
else if (value < fMin)
|
||||||
|
@ -341,6 +349,8 @@ BScrollBar::Value() const
|
||||||
void
|
void
|
||||||
BScrollBar::ValueChanged(float newValue)
|
BScrollBar::ValueChanged(float newValue)
|
||||||
{
|
{
|
||||||
|
TRACE("BScrollBar(%s)::ValueChanged(%.1f)\n", Name(), newValue);
|
||||||
|
|
||||||
if (fTarget) {
|
if (fTarget) {
|
||||||
// cache target bounds
|
// cache target bounds
|
||||||
BRect targetBounds = fTarget->Bounds();
|
BRect targetBounds = fTarget->Bounds();
|
||||||
|
@ -354,6 +364,8 @@ BScrollBar::ValueChanged(float newValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRACE(" -> %.1f\n", newValue);
|
||||||
|
|
||||||
SetValue(newValue);
|
SetValue(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,6 +373,8 @@ BScrollBar::ValueChanged(float newValue)
|
||||||
void
|
void
|
||||||
BScrollBar::SetProportion(float value)
|
BScrollBar::SetProportion(float value)
|
||||||
{
|
{
|
||||||
|
TRACE("BScrollBar(%s)::SetProportion(%.1f)\n", Name(), value);
|
||||||
|
|
||||||
if (value < 0.0)
|
if (value < 0.0)
|
||||||
value = 0.0;
|
value = 0.0;
|
||||||
if (value > 1.0)
|
if (value > 1.0)
|
||||||
|
@ -393,6 +407,8 @@ BScrollBar::Proportion() const
|
||||||
void
|
void
|
||||||
BScrollBar::SetRange(float min, float max)
|
BScrollBar::SetRange(float min, float max)
|
||||||
{
|
{
|
||||||
|
TRACE("BScrollBar(%s)::SetRange(min=%.1f, max=%.1f)\n", Name(), min, max);
|
||||||
|
|
||||||
if (min > max || isnanf(min) || isnanf(max) || isinff(min) || isinff(max)) {
|
if (min > max || isnanf(min) || isnanf(max) || isinff(min) || isinff(max)) {
|
||||||
min = 0;
|
min = 0;
|
||||||
max = 0;
|
max = 0;
|
||||||
|
@ -690,7 +706,8 @@ BScrollBar::Draw(BRect updateRect)
|
||||||
|
|
||||||
// Draw arrows
|
// Draw arrows
|
||||||
if (fOrientation == B_HORIZONTAL) {
|
if (fOrientation == B_HORIZONTAL) {
|
||||||
BRect buttonFrame(bounds.left, bounds.top, bounds.left + bounds.Height(), bounds.bottom);
|
BRect buttonFrame(bounds.left, bounds.top,
|
||||||
|
bounds.left + bounds.Height(), bounds.bottom);
|
||||||
|
|
||||||
_DrawArrowButton(ARROW_LEFT, doubleArrows, buttonFrame, updateRect,
|
_DrawArrowButton(ARROW_LEFT, doubleArrows, buttonFrame, updateRect,
|
||||||
enabled, fPrivateData->fButtonDown == ARROW1);
|
enabled, fPrivateData->fButtonDown == ARROW1);
|
||||||
|
@ -715,7 +732,8 @@ BScrollBar::Draw(BRect updateRect)
|
||||||
_DrawArrowButton(ARROW_RIGHT, doubleArrows, buttonFrame, updateRect,
|
_DrawArrowButton(ARROW_RIGHT, doubleArrows, buttonFrame, updateRect,
|
||||||
enabled, fPrivateData->fButtonDown == ARROW4);
|
enabled, fPrivateData->fButtonDown == ARROW4);
|
||||||
} else {
|
} else {
|
||||||
BRect buttonFrame(bounds.left, bounds.top, bounds.right, bounds.top + bounds.Width());
|
BRect buttonFrame(bounds.left, bounds.top, bounds.right,
|
||||||
|
bounds.top + bounds.Width());
|
||||||
|
|
||||||
_DrawArrowButton(ARROW_UP, doubleArrows, buttonFrame, updateRect,
|
_DrawArrowButton(ARROW_UP, doubleArrows, buttonFrame, updateRect,
|
||||||
enabled, fPrivateData->fButtonDown == ARROW1);
|
enabled, fPrivateData->fButtonDown == ARROW1);
|
||||||
|
@ -725,7 +743,8 @@ BScrollBar::Draw(BRect updateRect)
|
||||||
_DrawArrowButton(ARROW_DOWN, doubleArrows, buttonFrame, updateRect,
|
_DrawArrowButton(ARROW_DOWN, doubleArrows, buttonFrame, updateRect,
|
||||||
enabled, fPrivateData->fButtonDown == ARROW2);
|
enabled, fPrivateData->fButtonDown == ARROW2);
|
||||||
|
|
||||||
buttonFrame.OffsetTo(bounds.left, bounds.bottom - ((bounds.Width() * 2) + 1));
|
buttonFrame.OffsetTo(bounds.left, bounds.bottom
|
||||||
|
- ((bounds.Width() * 2) + 1));
|
||||||
_DrawArrowButton(ARROW_UP, doubleArrows, buttonFrame, updateRect,
|
_DrawArrowButton(ARROW_UP, doubleArrows, buttonFrame, updateRect,
|
||||||
enabled, fPrivateData->fButtonDown == ARROW3);
|
enabled, fPrivateData->fButtonDown == ARROW3);
|
||||||
|
|
||||||
|
@ -849,29 +868,35 @@ BScrollBar::Draw(BRect updateRect)
|
||||||
// dark lines before and after thumb
|
// dark lines before and after thumb
|
||||||
if (rect.left > thumbBG.left) {
|
if (rect.left > thumbBG.left) {
|
||||||
SetHighColor(dark);
|
SetHighColor(dark);
|
||||||
StrokeLine(BPoint(rect.left - 1, rect.top), BPoint(rect.left - 1, rect.bottom));
|
StrokeLine(BPoint(rect.left - 1, rect.top),
|
||||||
|
BPoint(rect.left - 1, rect.bottom));
|
||||||
}
|
}
|
||||||
if (rect.right < thumbBG.right) {
|
if (rect.right < thumbBG.right) {
|
||||||
SetHighColor(dark4);
|
SetHighColor(dark4);
|
||||||
StrokeLine(BPoint(rect.right + 1, rect.top), BPoint(rect.right + 1, rect.bottom));
|
StrokeLine(BPoint(rect.right + 1, rect.top),
|
||||||
|
BPoint(rect.right + 1, rect.bottom));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BRect topOfThumb(thumbBG.left, thumbBG.top + 1, thumbBG.right, rect.top - 1);
|
BRect topOfThumb(thumbBG.left, thumbBG.top + 1,
|
||||||
|
thumbBG.right, rect.top - 1);
|
||||||
if (topOfThumb.IsValid())
|
if (topOfThumb.IsValid())
|
||||||
FillRect(topOfThumb);
|
FillRect(topOfThumb);
|
||||||
|
|
||||||
BRect bottomOfThumb(thumbBG.left, rect.bottom + 3, thumbBG.right, thumbBG.bottom);
|
BRect bottomOfThumb(thumbBG.left, rect.bottom + 3,
|
||||||
|
thumbBG.right, thumbBG.bottom);
|
||||||
if (bottomOfThumb.IsValid())
|
if (bottomOfThumb.IsValid())
|
||||||
FillRect(bottomOfThumb);
|
FillRect(bottomOfThumb);
|
||||||
|
|
||||||
// dark lines before and after thumb
|
// dark lines before and after thumb
|
||||||
if (rect.top > thumbBG.top) {
|
if (rect.top > thumbBG.top) {
|
||||||
SetHighColor(dark);
|
SetHighColor(dark);
|
||||||
StrokeLine(BPoint(rect.left, rect.top - 1), BPoint(rect.right, rect.top - 1));
|
StrokeLine(BPoint(rect.left, rect.top - 1),
|
||||||
|
BPoint(rect.right, rect.top - 1));
|
||||||
}
|
}
|
||||||
if (rect.bottom < thumbBG.bottom) {
|
if (rect.bottom < thumbBG.bottom) {
|
||||||
SetHighColor(dark4);
|
SetHighColor(dark4);
|
||||||
StrokeLine(BPoint(rect.left, rect.bottom + 1), BPoint(rect.right, rect.bottom + 1));
|
StrokeLine(BPoint(rect.left, rect.bottom + 1),
|
||||||
|
BPoint(rect.right, rect.bottom + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1286,10 +1311,13 @@ BScrollBar::_ButtonRectFor(int32 button) const
|
||||||
void
|
void
|
||||||
BScrollBar::_UpdateTargetValue(BPoint where)
|
BScrollBar::_UpdateTargetValue(BPoint where)
|
||||||
{
|
{
|
||||||
if (fOrientation == B_VERTICAL)
|
if (fOrientation == B_VERTICAL) {
|
||||||
fPrivateData->fStopValue = _ValueFor(BPoint(where.x, where.y - fPrivateData->fThumbFrame.Height() / 2.0));
|
fPrivateData->fStopValue = _ValueFor(BPoint(where.x, where.y
|
||||||
else
|
- fPrivateData->fThumbFrame.Height() / 2.0));
|
||||||
fPrivateData->fStopValue = _ValueFor(BPoint(where.x - fPrivateData->fThumbFrame.Width() / 2.0, where.y));
|
} else {
|
||||||
|
fPrivateData->fStopValue = _ValueFor(BPoint(where.x
|
||||||
|
- fPrivateData->fThumbFrame.Width() / 2.0, where.y));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// _UpdateArrowButtons
|
// _UpdateArrowButtons
|
||||||
|
@ -1342,7 +1370,8 @@ control_scrollbar(scroll_bar_info *info, BScrollBar *bar)
|
||||||
else
|
else
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
if (info->min_knob_size >= SCROLL_BAR_MINIMUM_KNOB_SIZE && info->min_knob_size <= SCROLL_BAR_MAXIMUM_KNOB_SIZE)
|
if (info->min_knob_size >= SCROLL_BAR_MINIMUM_KNOB_SIZE
|
||||||
|
&& info->min_knob_size <= SCROLL_BAR_MAXIMUM_KNOB_SIZE)
|
||||||
bar->fPrivateData->fScrollBarInfo.min_knob_size = info->min_knob_size;
|
bar->fPrivateData->fScrollBarInfo.min_knob_size = info->min_knob_size;
|
||||||
else
|
else
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
Loading…
Reference in New Issue