Tracker: style fixes to Pose class
This commit is contained in:
+41
-33
@@ -73,7 +73,8 @@ CalcFreeSpace(BVolume* volume)
|
|||||||
// symlink itself
|
// symlink itself
|
||||||
BPose::BPose(Model* model, BPoseView* view, uint32 clipboardMode,
|
BPose::BPose(Model* model, BPoseView* view, uint32 clipboardMode,
|
||||||
bool selected)
|
bool selected)
|
||||||
: fModel(model),
|
:
|
||||||
|
fModel(model),
|
||||||
fWidgetList(4, true),
|
fWidgetList(4, true),
|
||||||
fClipboardMode(clipboardMode),
|
fClipboardMode(clipboardMode),
|
||||||
fPercent(-1),
|
fPercent(-1),
|
||||||
@@ -130,7 +131,7 @@ BPose::CreateWidgets(BPoseView* poseView)
|
|||||||
{
|
{
|
||||||
for (int32 index = 0; ; index++) {
|
for (int32 index = 0; ; index++) {
|
||||||
BColumn* column = poseView->ColumnAt(index);
|
BColumn* column = poseView->ColumnAt(index);
|
||||||
if (!column)
|
if (column == NULL)
|
||||||
break;
|
break;
|
||||||
fWidgetList.AddItem(new BTextWidget(fModel, column, poseView));
|
fWidgetList.AddItem(new BTextWidget(fModel, column, poseView));
|
||||||
}
|
}
|
||||||
@@ -160,6 +161,7 @@ BPose::AddWidget(BPoseView* poseView, BColumn* column,
|
|||||||
|
|
||||||
BTextWidget* widget = new BTextWidget(fModel, column, poseView);
|
BTextWidget* widget = new BTextWidget(fModel, column, poseView);
|
||||||
fWidgetList.AddItem(widget);
|
fWidgetList.AddItem(widget);
|
||||||
|
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,6 +205,7 @@ OneMouseUp(BTextWidget* widget, BPose* pose, BPoseView* poseView,
|
|||||||
widget->MouseUp(rect, poseView, pose, where);
|
widget->MouseUp(rect, poseView, pose, where);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,9 +243,9 @@ BPose::UpdateWidgetAndModel(Model* resolvedModel, const char* attrName,
|
|||||||
if (poseView->ViewMode() != kListMode)
|
if (poseView->ViewMode() != kListMode)
|
||||||
poseLoc = Location(poseView);
|
poseLoc = Location(poseView);
|
||||||
|
|
||||||
ASSERT(!resolvedModel || resolvedModel->IsNodeOpen());
|
ASSERT(resolvedModel == NULL || resolvedModel->IsNodeOpen());
|
||||||
|
|
||||||
if (attrName) {
|
if (attrName != NULL) {
|
||||||
// pick up new attributes and find out if icon needs updating
|
// pick up new attributes and find out if icon needs updating
|
||||||
if (resolvedModel->AttrChanged(attrName) && visible)
|
if (resolvedModel->AttrChanged(attrName) && visible)
|
||||||
UpdateIcon(poseLoc, poseView);
|
UpdateIcon(poseLoc, poseView);
|
||||||
@@ -284,7 +287,7 @@ BPose::UpdateWidgetAndModel(Model* resolvedModel, const char* attrName,
|
|||||||
// distribute stat changes
|
// distribute stat changes
|
||||||
for (int32 index = 0; ; index++) {
|
for (int32 index = 0; ; index++) {
|
||||||
BColumn* column = poseView->ColumnAt(index);
|
BColumn* column = poseView->ColumnAt(index);
|
||||||
if (!column)
|
if (column == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (column->StatField()) {
|
if (column->StatField()) {
|
||||||
@@ -327,6 +330,7 @@ BPose::UpdateVolumeSpaceBar(BVolume* volume)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,11 +427,11 @@ BPose::EditPreviousNextWidgetCommon(BPoseView* poseView, bool next)
|
|||||||
for (int32 index = next ? 0 : poseView->CountColumns() - 1; ;
|
for (int32 index = next ? 0 : poseView->CountColumns() - 1; ;
|
||||||
index += delta) {
|
index += delta) {
|
||||||
BColumn* column = poseView->ColumnAt(index);
|
BColumn* column = poseView->ColumnAt(index);
|
||||||
if (!column)
|
if (column == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
BTextWidget* widget = WidgetFor(column->AttrHash());
|
BTextWidget* widget = WidgetFor(column->AttrHash());
|
||||||
if (widget && widget->IsActive()) {
|
if (widget != NULL && widget->IsActive()) {
|
||||||
poseView->CommitActivePose();
|
poseView->CommitActivePose();
|
||||||
found = true;
|
found = true;
|
||||||
continue;
|
continue;
|
||||||
@@ -476,11 +480,10 @@ BPose::PointInPose(const BPoseView* poseView, BPoint where) const
|
|||||||
rect.right += poseView->IconSizeInt() - 1;
|
rect.right += poseView->IconSizeInt() - 1;
|
||||||
rect.bottom += poseView->IconSizeInt() - 1;
|
rect.bottom += poseView->IconSizeInt() - 1;
|
||||||
|
|
||||||
if (rect.Contains(where))
|
if (rect.Contains(where)) {
|
||||||
return IconCache::sIconCache->IconHitTest(where - location,
|
return IconCache::sIconCache->IconHitTest(where - location,
|
||||||
ResolvedModel(),
|
ResolvedModel(), kNormalIcon, poseView->IconSize());
|
||||||
kNormalIcon,
|
}
|
||||||
poseView->IconSize());
|
|
||||||
|
|
||||||
BTextWidget* widget = WidgetFor(poseView->FirstColumn()->AttrHash());
|
BTextWidget* widget = WidgetFor(poseView->FirstColumn()->AttrHash());
|
||||||
if (widget) {
|
if (widget) {
|
||||||
@@ -500,7 +503,7 @@ BPose::PointInPose(const BPoseView* poseView, BPoint where) const
|
|||||||
rect.right += B_MINI_ICON + kMiniIconSeparator;
|
rect.right += B_MINI_ICON + kMiniIconSeparator;
|
||||||
rect.bottom += poseView->IconPoseHeight();
|
rect.bottom += poseView->IconPoseHeight();
|
||||||
BTextWidget* widget = WidgetFor(poseView->FirstColumn()->AttrHash());
|
BTextWidget* widget = WidgetFor(poseView->FirstColumn()->AttrHash());
|
||||||
if (widget)
|
if (widget != NULL)
|
||||||
rect.right += ceil(widget->TextWidth(poseView) + 1);
|
rect.right += ceil(widget->TextWidth(poseView) + 1);
|
||||||
|
|
||||||
return rect.Contains(where);
|
return rect.Contains(where);
|
||||||
@@ -525,7 +528,7 @@ BPose::PointInPose(BPoint loc, const BPoseView* poseView, BPoint where,
|
|||||||
|
|
||||||
for (int32 index = 0; ; index++) {
|
for (int32 index = 0; ; index++) {
|
||||||
BColumn* column = poseView->ColumnAt(index);
|
BColumn* column = poseView->ColumnAt(index);
|
||||||
if (!column)
|
if (column == NULL)
|
||||||
break;
|
break;
|
||||||
BTextWidget* widget = WidgetFor(column->AttrHash());
|
BTextWidget* widget = WidgetFor(column->AttrHash());
|
||||||
if (widget
|
if (widget
|
||||||
@@ -579,7 +582,7 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView,
|
|||||||
|
|
||||||
for (int32 index = 0; index < columnsToDraw; index++) {
|
for (int32 index = 0; index < columnsToDraw; index++) {
|
||||||
BColumn* column = poseView->ColumnAt(index);
|
BColumn* column = poseView->ColumnAt(index);
|
||||||
if (!column)
|
if (column == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// if widget doesn't exist, create it
|
// if widget doesn't exist, create it
|
||||||
@@ -607,9 +610,9 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView,
|
|||||||
column->Width(), poseView, drawView, selected,
|
column->Width(), poseView, drawView, selected,
|
||||||
fClipboardMode, offset, directDraw);
|
fClipboardMode, offset, directDraw);
|
||||||
} else {
|
} else {
|
||||||
widget->Draw(widgetTextRect, widgetTextRect, column->Width(),
|
widget->Draw(widgetTextRect, widgetTextRect,
|
||||||
poseView, drawView, false, fClipboardMode,
|
column->Width(), poseView, drawView, false,
|
||||||
offset, directDraw);
|
fClipboardMode, offset, directDraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index == 0 && selectDuringDraw)
|
if (index == 0 && selectDuringDraw)
|
||||||
@@ -632,7 +635,6 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// draw in icon mode
|
// draw in icon mode
|
||||||
BPoint location(Location(poseView));
|
BPoint location(Location(poseView));
|
||||||
BPoint iconOrigin(location);
|
BPoint iconOrigin(location);
|
||||||
@@ -642,11 +644,11 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView,
|
|||||||
!windowActive && !showSelectionWhenInactive);
|
!windowActive && !showSelectionWhenInactive);
|
||||||
|
|
||||||
BColumn* column = poseView->FirstColumn();
|
BColumn* column = poseView->FirstColumn();
|
||||||
if (!column)
|
if (column == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BTextWidget* widget = WidgetFor(column, poseView, modelOpener);
|
BTextWidget* widget = WidgetFor(column, poseView, modelOpener);
|
||||||
if (!widget || !widget->IsVisible())
|
if (widget == NULL || !widget->IsVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rect = widget->CalcRect(location, 0, poseView);
|
rect = widget->CalcRect(location, 0, poseView);
|
||||||
@@ -696,11 +698,11 @@ BPose::DeselectWithoutErasingBackground(BRect, BPoseView* poseView)
|
|||||||
UpdateIcon(location, poseView);
|
UpdateIcon(location, poseView);
|
||||||
|
|
||||||
BColumn* column = poseView->FirstColumn();
|
BColumn* column = poseView->FirstColumn();
|
||||||
if (!column)
|
if (column == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BTextWidget* widget = WidgetFor(column->AttrHash());
|
BTextWidget* widget = WidgetFor(column->AttrHash());
|
||||||
if (!widget || !widget->IsVisible())
|
if (widget == NULL || !widget->IsVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// just invalidate the background, don't draw anything
|
// just invalidate the background, don't draw anything
|
||||||
@@ -709,7 +711,7 @@ BPose::DeselectWithoutErasingBackground(BRect, BPoseView* poseView)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPose::MoveTo(BPoint point, BPoseView* poseView, bool inval)
|
BPose::MoveTo(BPoint point, BPoseView* poseView, bool invalidate)
|
||||||
{
|
{
|
||||||
point.x = floorf(point.x);
|
point.x = floorf(point.x);
|
||||||
point.y = floorf(point.y);
|
point.y = floorf(point.y);
|
||||||
@@ -722,7 +724,7 @@ BPose::MoveTo(BPoint point, BPoseView* poseView, bool inval)
|
|||||||
if (point == oldLocation || poseView->ViewMode() == kListMode)
|
if (point == oldLocation || poseView->ViewMode() == kListMode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (inval)
|
if (invalidate)
|
||||||
oldBounds = CalcRect(poseView);
|
oldBounds = CalcRect(poseView);
|
||||||
|
|
||||||
// might need to move a text view if we're active
|
// might need to move a text view if we're active
|
||||||
@@ -744,7 +746,7 @@ BPose::MoveTo(BPoint point, BPoseView* poseView, bool inval)
|
|||||||
fHasLocation = true;
|
fHasLocation = true;
|
||||||
fNeedsSaveLocation = true;
|
fNeedsSaveLocation = true;
|
||||||
|
|
||||||
if (inval) {
|
if (invalidate) {
|
||||||
poseView->Invalidate(oldBounds);
|
poseView->Invalidate(oldBounds);
|
||||||
poseView->Invalidate(CalcRect(poseView));
|
poseView->Invalidate(CalcRect(poseView));
|
||||||
}
|
}
|
||||||
@@ -759,6 +761,7 @@ BPose::ActiveWidget() const
|
|||||||
if (widget->IsActive())
|
if (widget->IsActive())
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -770,8 +773,9 @@ BPose::WidgetFor(uint32 attr, int32* index) const
|
|||||||
for (int32 i = 0; i < count; i++) {
|
for (int32 i = 0; i < count; i++) {
|
||||||
BTextWidget* widget = fWidgetList.ItemAt(i);
|
BTextWidget* widget = fWidgetList.ItemAt(i);
|
||||||
if (widget->AttrHash() == attr) {
|
if (widget->AttrHash() == attr) {
|
||||||
if (index)
|
if (index != NULL)
|
||||||
*index = i;
|
*index = i;
|
||||||
|
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -785,7 +789,7 @@ BPose::WidgetFor(BColumn* column, BPoseView* poseView,
|
|||||||
ModelNodeLazyOpener &opener, int32* index)
|
ModelNodeLazyOpener &opener, int32* index)
|
||||||
{
|
{
|
||||||
BTextWidget* widget = WidgetFor(column->AttrHash(), index);
|
BTextWidget* widget = WidgetFor(column->AttrHash(), index);
|
||||||
if (!widget)
|
if (widget == NULL)
|
||||||
widget = AddWidget(poseView, column, opener);
|
widget = AddWidget(poseView, column, opener);
|
||||||
|
|
||||||
return widget;
|
return widget;
|
||||||
@@ -827,10 +831,13 @@ BPose::DrawBar(BPoint where,BView* view,icon_size kind)
|
|||||||
{
|
{
|
||||||
view->PushState();
|
view->PushState();
|
||||||
|
|
||||||
int32 size, barWidth, barHeight, yOffset;
|
int32 size;
|
||||||
|
int32 barWidth;
|
||||||
|
int32 barHeight;
|
||||||
|
int32 yOffset;
|
||||||
if (kind >= B_LARGE_ICON) {
|
if (kind >= B_LARGE_ICON) {
|
||||||
size = kind - 1;
|
size = kind - 1;
|
||||||
barWidth = (int32)((float)7 / (float)32 * (float)kind);
|
barWidth = (int32)(7.0f / 32.0f * (float)kind);
|
||||||
yOffset = 2;
|
yOffset = 2;
|
||||||
barHeight = size - 4 - 2 * yOffset;
|
barHeight = size - 4 - 2 * yOffset;
|
||||||
} else {
|
} else {
|
||||||
@@ -887,7 +894,6 @@ BPose::DrawBar(BPoint where,BView* view,icon_size kind)
|
|||||||
void
|
void
|
||||||
BPose::DrawToggleSwitch(BRect, BPoseView*)
|
BPose::DrawToggleSwitch(BRect, BPoseView*)
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -912,6 +918,7 @@ BPose::SetLocation(BPoint point, const BPoseView* poseView)
|
|||||||
fLocation = BPoint(floorf(point.x / scale), floorf(point.y / scale));
|
fLocation = BPoint(floorf(point.x / scale), floorf(point.y / scale));
|
||||||
if (isinff(fLocation.x) || isinff(fLocation.y))
|
if (isinff(fLocation.x) || isinff(fLocation.y))
|
||||||
debugger("BPose::SetLocation() - infinite location");
|
debugger("BPose::SetLocation() - infinite location");
|
||||||
|
|
||||||
fHasLocation = true;
|
fHasLocation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -930,7 +937,7 @@ BPose::CalcRect(BPoint loc, const BPoseView* poseView, bool minimalRect) const
|
|||||||
|
|
||||||
if (minimalRect) {
|
if (minimalRect) {
|
||||||
BTextWidget* widget = WidgetFor(poseView->FirstColumn()->AttrHash());
|
BTextWidget* widget = WidgetFor(poseView->FirstColumn()->AttrHash());
|
||||||
if (widget) {
|
if (widget != NULL) {
|
||||||
rect.right = widget->CalcRect(loc, poseView->FirstColumn(),
|
rect.right = widget->CalcRect(loc, poseView->FirstColumn(),
|
||||||
poseView).right;
|
poseView).right;
|
||||||
}
|
}
|
||||||
@@ -978,7 +985,6 @@ BPose::CalcRect(const BPoseView* poseView) const
|
|||||||
|
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|
||||||
void
|
void
|
||||||
BPose::PrintToStream()
|
BPose::PrintToStream()
|
||||||
{
|
{
|
||||||
@@ -987,11 +993,14 @@ BPose::PrintToStream()
|
|||||||
case kMoveSelectionTo:
|
case kMoveSelectionTo:
|
||||||
PRINT(("clipboardMode: Cut\n"));
|
PRINT(("clipboardMode: Cut\n"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kCopySelectionTo:
|
case kCopySelectionTo:
|
||||||
PRINT(("clipboardMode: Copy\n"));
|
PRINT(("clipboardMode: Copy\n"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
PRINT(("clipboardMode: 0 - not in clipboard\n"));
|
PRINT(("clipboardMode: 0 - not in clipboard\n"));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
PRINT(("%sselected\n", IsSelected() ? "" : "not "));
|
PRINT(("%sselected\n", IsSelected() ? "" : "not "));
|
||||||
PRINT(("location %s x:%f y:%f\n", HasLocation() ? "" : "unknown ",
|
PRINT(("location %s x:%f y:%f\n", HasLocation() ? "" : "unknown ",
|
||||||
@@ -999,5 +1008,4 @@ BPose::PrintToStream()
|
|||||||
HasLocation() ? fLocation.y : 0));
|
HasLocation() ? fLocation.y : 0));
|
||||||
PRINT(("%s autoplaced \n", WasAutoPlaced() ? "was" : "not"));
|
PRINT(("%s autoplaced \n", WasAutoPlaced() ? "was" : "not"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class BPose {
|
|||||||
ModelNodeLazyOpener &opener);
|
ModelNodeLazyOpener &opener);
|
||||||
void RemoveWidget(BPoseView*, BColumn*);
|
void RemoveWidget(BPoseView*, BColumn*);
|
||||||
void SetLocation(BPoint, const BPoseView*);
|
void SetLocation(BPoint, const BPoseView*);
|
||||||
void MoveTo(BPoint, BPoseView*, bool inval = true);
|
void MoveTo(BPoint, BPoseView*, bool invalidate = true);
|
||||||
|
|
||||||
void Draw(BRect poseRect, const BRect& updateRect, BPoseView*,
|
void Draw(BRect poseRect, const BRect& updateRect, BPoseView*,
|
||||||
bool fullDraw = true);
|
bool fullDraw = true);
|
||||||
@@ -128,7 +128,6 @@ class BPose {
|
|||||||
|
|
||||||
uint32 ClipboardMode() const;
|
uint32 ClipboardMode() const;
|
||||||
void SetClipboardMode(uint32 clipboardMode);
|
void SetClipboardMode(uint32 clipboardMode);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
void PrintToStream();
|
void PrintToStream();
|
||||||
#endif
|
#endif
|
||||||
@@ -263,4 +262,5 @@ BPose::SetClipboardMode(uint32 clipboardMode)
|
|||||||
|
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
|
|
||||||
|
|
||||||
#endif // _POSE_H
|
#endif // _POSE_H
|
||||||
|
|||||||
Reference in New Issue
Block a user