Tracker: style fixes to Navigator

This commit is contained in:
John Scipione 2014-06-20 18:42:32 -04:00
parent dbe62cc77f
commit 808af41c2a
2 changed files with 26 additions and 21 deletions

View File

@ -58,9 +58,13 @@ static const int32 kMaxHistory = 32;
static BPicture sPicture; static BPicture sPicture;
// #pragma mark - BNavigatorButton
BNavigatorButton::BNavigatorButton(BRect rect, const char* name, BNavigatorButton::BNavigatorButton(BRect rect, const char* name,
BMessage* message, int32 resIDon, int32 resIDoff, int32 resIDdisabled) BMessage* message, int32 resIDon, int32 resIDoff, int32 resIDdisabled)
: BPictureButton(rect, name, &sPicture, &sPicture, message), :
BPictureButton(rect, name, &sPicture, &sPicture, message),
fResIDOn(resIDon), fResIDOn(resIDon),
fResIDOff(resIDoff), fResIDOff(resIDoff),
fResIDDisabled(resIDdisabled) fResIDDisabled(resIDdisabled)
@ -104,7 +108,7 @@ BNavigatorButton::AttachedToWindow()
void void
BNavigatorButton::SetPicture(BBitmap* bitmap, bool enabled, bool on) BNavigatorButton::SetPicture(BBitmap* bitmap, bool enabled, bool on)
{ {
if (bitmap) { if (bitmap != NULL) {
BPicture picture; BPicture picture;
BView view(bitmap->Bounds(), "", 0, 0); BView view(bitmap->Bounds(), "", 0, 0);
AddChild(&view); AddChild(&view);
@ -116,21 +120,19 @@ BNavigatorButton::SetPicture(BBitmap* bitmap, bool enabled, bool on)
view.EndPicture(); view.EndPicture();
RemoveChild(&view); RemoveChild(&view);
if (enabled) if (enabled)
if (on) on ? SetEnabledOn(&picture) : SetEnabledOff(&picture);
SetEnabledOn(&picture);
else else
SetEnabledOff(&picture); on ? SetDisabledOn(&picture) : SetDisabledOff(&picture);
else
if (on)
SetDisabledOn(&picture);
else
SetDisabledOff(&picture);
} }
} }
// #pragma mark - BNavigator
BNavigator::BNavigator(const Model* model, BRect rect, uint32 resizeMask) BNavigator::BNavigator(const Model* model, BRect rect, uint32 resizeMask)
: BView(rect, "Navigator", resizeMask, B_WILL_DRAW), :
BView(rect, "Navigator", resizeMask, B_WILL_DRAW),
fBack(0), fBack(0),
fForw(0), fForw(0),
fUp(0), fUp(0),
@ -321,7 +323,7 @@ BNavigator::SendNavigationMessage(NavigationAction action, BEntry* entry,
// so we have to select the item manually // so we have to select the item manually
if (option) { if (option) {
message.what = B_REFS_RECEIVED; message.what = B_REFS_RECEIVED;
if (nodeRef) { if (nodeRef != NULL) {
message.AddData("nodeRefToSelect", B_RAW_TYPE, nodeRef, message.AddData("nodeRefToSelect", B_RAW_TYPE, nodeRef,
sizeof(node_ref)); sizeof(node_ref));
} }
@ -388,11 +390,13 @@ BNavigator::UpdateLocation(const Model* newmodel, int32 action)
// Modify history according to commands // Modify history according to commands
switch (action) { switch (action) {
case kActionBackward: case kActionBackward:
fForwHistory.AddItem(fBackHistory.RemoveItemAt(fBackHistory.CountItems()-1)); fForwHistory.AddItem(fBackHistory.RemoveItemAt(
fBackHistory.CountItems() - 1));
break; break;
case kActionForward: case kActionForward:
fBackHistory.AddItem(fForwHistory.RemoveItemAt(fForwHistory.CountItems()-1)); fBackHistory.AddItem(fForwHistory.RemoveItemAt(
fForwHistory.CountItems() - 1));
break; break;
case kActionUpdatePath: case kActionUpdatePath:
@ -430,5 +434,5 @@ BNavigator::CalcNavigatorHeight(void)
{ {
// Empiric formula from how much space the textview // Empiric formula from how much space the textview
// will take once it is attached (using be_plain_font): // will take once it is attached (using be_plain_font):
return ceilf(11.0f + be_plain_font->Size()*(1.0f + 7.0f / 30.0f)); return ceilf(11.0f + be_plain_font->Size() * (1.0f + 7.0f / 30.0f));
} }

View File

@ -31,8 +31,8 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders. names are registered trademarks or trademarks of their respective holders.
All rights reserved. All rights reserved.
*/ */
#ifndef _NAVIGATOR_H_ #ifndef _NAVIGATOR_H
#define _NAVIGATOR_H_ #define _NAVIGATOR_H
#include "Model.h" #include "Model.h"
@ -134,4 +134,5 @@ BNavigator::Window() const
using namespace BPrivate; using namespace BPrivate;
#endif // _NAVIGATOR_H_
#endif // _NAVIGATOR_H