Style cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30302 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,9 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006-2008, Haiku Inc. All rights reserved.
|
* Copyright 2006 - 2009, Stephan Aßmus <[email protected]>
|
||||||
* Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Stephan Aßmus <[email protected]>
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "LaunchButton.h"
|
#include "LaunchButton.h"
|
||||||
@@ -25,14 +22,16 @@
|
|||||||
//#include "BubbleHelper.h"
|
//#include "BubbleHelper.h"
|
||||||
#include "PadView.h"
|
#include "PadView.h"
|
||||||
|
|
||||||
|
|
||||||
static const float kDragStartDist = 10.0;
|
static const float kDragStartDist = 10.0;
|
||||||
static const float kDragBitmapAlphaScale = 0.6;
|
static const float kDragBitmapAlphaScale = 0.6;
|
||||||
//static const char* kEmptyHelpString = "You can drag an icon here.";
|
//static const char* kEmptyHelpString = "You can drag an icon here.";
|
||||||
|
|
||||||
|
|
||||||
bigtime_t
|
bigtime_t
|
||||||
LaunchButton::fClickSpeed = 0;
|
LaunchButton::fClickSpeed = 0;
|
||||||
|
|
||||||
// constructor
|
|
||||||
LaunchButton::LaunchButton(const char* name, uint32 id, const char* label,
|
LaunchButton::LaunchButton(const char* name, uint32 id, const char* label,
|
||||||
BMessage* message, BHandler* target)
|
BMessage* message, BHandler* target)
|
||||||
: IconButton(name, id, label, message, target),
|
: IconButton(name, id, label, message, target),
|
||||||
@@ -43,18 +42,18 @@ LaunchButton::LaunchButton(const char* name, uint32 id, const char* label,
|
|||||||
fLastClickTime(0),
|
fLastClickTime(0),
|
||||||
fIconSize(DEFAULT_ICON_SIZE)
|
fIconSize(DEFAULT_ICON_SIZE)
|
||||||
{
|
{
|
||||||
if (fClickSpeed == 0 || get_click_speed(&fClickSpeed) < B_OK)
|
if (fClickSpeed == 0 || get_click_speed(&fClickSpeed) != B_OK)
|
||||||
fClickSpeed = 500000;
|
fClickSpeed = 500000;
|
||||||
}
|
}
|
||||||
|
|
||||||
// destructor
|
|
||||||
LaunchButton::~LaunchButton()
|
LaunchButton::~LaunchButton()
|
||||||
{
|
{
|
||||||
delete fRef;
|
delete fRef;
|
||||||
free(fAppSig);
|
free(fAppSig);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AttachedToWindow
|
|
||||||
void
|
void
|
||||||
LaunchButton::AttachedToWindow()
|
LaunchButton::AttachedToWindow()
|
||||||
{
|
{
|
||||||
@@ -62,14 +61,14 @@ LaunchButton::AttachedToWindow()
|
|||||||
_UpdateToolTip();
|
_UpdateToolTip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// DetachedFromWindow
|
|
||||||
void
|
void
|
||||||
LaunchButton::DetachedFromWindow()
|
LaunchButton::DetachedFromWindow()
|
||||||
{
|
{
|
||||||
// BubbleHelper::Default()->SetHelp(this, NULL);
|
// BubbleHelper::Default()->SetHelp(this, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw
|
|
||||||
void
|
void
|
||||||
LaunchButton::Draw(BRect updateRect)
|
LaunchButton::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
@@ -88,7 +87,8 @@ LaunchButton::Draw(BRect updateRect)
|
|||||||
IconButton::Draw(updateRect);
|
IconButton::Draw(updateRect);
|
||||||
} else {
|
} else {
|
||||||
rgb_color background = LowColor();
|
rgb_color background = LowColor();
|
||||||
rgb_color lightShadow = tint_color(background, (B_NO_TINT + B_DARKEN_1_TINT) / 2.0);
|
rgb_color lightShadow = tint_color(background,
|
||||||
|
(B_NO_TINT + B_DARKEN_1_TINT) / 2.0);
|
||||||
rgb_color shadow = tint_color(background, B_DARKEN_1_TINT);
|
rgb_color shadow = tint_color(background, B_DARKEN_1_TINT);
|
||||||
rgb_color light = tint_color(background, B_LIGHTEN_1_TINT);
|
rgb_color light = tint_color(background, B_LIGHTEN_1_TINT);
|
||||||
BRect r(Bounds());
|
BRect r(Bounds());
|
||||||
@@ -99,7 +99,7 @@ LaunchButton::Draw(BRect updateRect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MessageReceived
|
|
||||||
void
|
void
|
||||||
LaunchButton::MessageReceived(BMessage* message)
|
LaunchButton::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
@@ -107,7 +107,7 @@ LaunchButton::MessageReceived(BMessage* message)
|
|||||||
case B_SIMPLE_DATA:
|
case B_SIMPLE_DATA:
|
||||||
case B_REFS_RECEIVED: {
|
case B_REFS_RECEIVED: {
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
if (message->FindRef("refs", &ref) >= B_OK) {
|
if (message->FindRef("refs", &ref) == B_OK) {
|
||||||
if (fRef) {
|
if (fRef) {
|
||||||
if (ref != *fRef) {
|
if (ref != *fRef) {
|
||||||
BEntry entry(fRef, true);
|
BEntry entry(fRef, true);
|
||||||
@@ -121,15 +121,18 @@ LaunchButton::MessageReceived(BMessage* message)
|
|||||||
team = be_roster->TeamFor(fAppSig);
|
team = be_roster->TeamFor(fAppSig);
|
||||||
else
|
else
|
||||||
team = be_roster->TeamFor(fRef);
|
team = be_roster->TeamFor(fRef);
|
||||||
if (team < B_OK) {
|
if (team < 0) {
|
||||||
if (fAppSig)
|
if (fAppSig)
|
||||||
be_roster->Launch(fAppSig, message, &team);
|
be_roster->Launch(fAppSig, message, &team);
|
||||||
else
|
else
|
||||||
be_roster->Launch(fRef, message, &team);
|
be_roster->Launch(fRef, message, &team);
|
||||||
} else {
|
} else {
|
||||||
app_info appInfo;
|
app_info appInfo;
|
||||||
if (team >= B_OK && be_roster->GetRunningAppInfo(team, &appInfo) >= B_OK) {
|
if (team >= 0
|
||||||
BMessenger messenger(appInfo.signature, team);
|
&& be_roster->GetRunningAppInfo(team,
|
||||||
|
&appInfo) == B_OK) {
|
||||||
|
BMessenger messenger(appInfo.signature,
|
||||||
|
team);
|
||||||
if (messenger.IsValid())
|
if (messenger.IsValid())
|
||||||
messenger.SendMessage(message);
|
messenger.SendMessage(message);
|
||||||
}
|
}
|
||||||
@@ -150,7 +153,7 @@ LaunchButton::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MouseDown
|
|
||||||
void
|
void
|
||||||
LaunchButton::MouseDown(BPoint where)
|
LaunchButton::MouseDown(BPoint where)
|
||||||
{
|
{
|
||||||
@@ -176,7 +179,7 @@ LaunchButton::MouseDown(BPoint where)
|
|||||||
IconButton::MouseDown(where);
|
IconButton::MouseDown(where);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MouseUp
|
|
||||||
void
|
void
|
||||||
LaunchButton::MouseUp(BPoint where)
|
LaunchButton::MouseUp(BPoint where)
|
||||||
{
|
{
|
||||||
@@ -187,9 +190,10 @@ LaunchButton::MouseUp(BPoint where)
|
|||||||
IconButton::MouseUp(where);
|
IconButton::MouseUp(where);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MouseMoved
|
|
||||||
void
|
void
|
||||||
LaunchButton::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
|
LaunchButton::MouseMoved(BPoint where, uint32 transit,
|
||||||
|
const BMessage* dragMessage)
|
||||||
{
|
{
|
||||||
if ((dragMessage && (transit == B_ENTERED_VIEW || transit == B_INSIDE_VIEW))
|
if ((dragMessage && (transit == B_ENTERED_VIEW || transit == B_INSIDE_VIEW))
|
||||||
&& ((dragMessage->what == B_SIMPLE_DATA
|
&& ((dragMessage->what == B_SIMPLE_DATA
|
||||||
@@ -223,7 +227,8 @@ LaunchButton::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessa
|
|||||||
for (uint32 y = 0; y < height; y++) {
|
for (uint32 y = 0; y < height; y++) {
|
||||||
uint8* bitsHandle = bits;
|
uint8* bitsHandle = bits;
|
||||||
for (uint32 x = 0; x < width; x++) {
|
for (uint32 x = 0; x < width; x++) {
|
||||||
bitsHandle[3] = uint8(bitsHandle[3] * kDragBitmapAlphaScale);
|
bitsHandle[3] = uint8(bitsHandle[3]
|
||||||
|
* kDragBitmapAlphaScale);
|
||||||
bitsHandle += 4;
|
bitsHandle += 4;
|
||||||
}
|
}
|
||||||
bits += bpr;
|
bits += bpr;
|
||||||
@@ -277,7 +282,6 @@ LaunchButton::MaxSize()
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
// SetTo
|
|
||||||
void
|
void
|
||||||
LaunchButton::SetTo(const entry_ref* ref)
|
LaunchButton::SetTo(const entry_ref* ref)
|
||||||
{
|
{
|
||||||
@@ -295,9 +299,9 @@ LaunchButton::SetTo(const entry_ref* ref)
|
|||||||
// see if this is an application
|
// see if this is an application
|
||||||
BFile file(ref, B_READ_ONLY);
|
BFile file(ref, B_READ_ONLY);
|
||||||
BAppFileInfo info;
|
BAppFileInfo info;
|
||||||
if (info.SetTo(&file) >= B_OK) {
|
if (info.SetTo(&file) == B_OK) {
|
||||||
char mimeSig[B_MIME_TYPE_LENGTH];
|
char mimeSig[B_MIME_TYPE_LENGTH];
|
||||||
if (info.GetSignature(mimeSig) >= B_OK) {
|
if (info.GetSignature(mimeSig) == B_OK) {
|
||||||
SetTo(mimeSig, false);
|
SetTo(mimeSig, false);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "no MIME signature for '%s'\n", fRef->name);
|
fprintf(stderr, "no MIME signature for '%s'\n", fRef->name);
|
||||||
@@ -312,14 +316,14 @@ LaunchButton::SetTo(const entry_ref* ref)
|
|||||||
_UpdateToolTip();
|
_UpdateToolTip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ref
|
|
||||||
entry_ref*
|
entry_ref*
|
||||||
LaunchButton::Ref() const
|
LaunchButton::Ref() const
|
||||||
{
|
{
|
||||||
return fRef;
|
return fRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTo
|
|
||||||
void
|
void
|
||||||
LaunchButton::SetTo(const char* appSig, bool updateIcon)
|
LaunchButton::SetTo(const char* appSig, bool updateIcon)
|
||||||
{
|
{
|
||||||
@@ -328,14 +332,14 @@ LaunchButton::SetTo(const char* appSig, bool updateIcon)
|
|||||||
fAppSig = strdup(appSig);
|
fAppSig = strdup(appSig);
|
||||||
if (updateIcon) {
|
if (updateIcon) {
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
if (be_roster->FindApp(fAppSig, &ref) >= B_OK)
|
if (be_roster->FindApp(fAppSig, &ref) == B_OK)
|
||||||
SetTo(&ref);
|
SetTo(&ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_UpdateToolTip();
|
_UpdateToolTip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDesciption
|
|
||||||
void
|
void
|
||||||
LaunchButton::SetDescription(const char* text)
|
LaunchButton::SetDescription(const char* text)
|
||||||
{
|
{
|
||||||
@@ -343,7 +347,7 @@ LaunchButton::SetDescription(const char* text)
|
|||||||
_UpdateToolTip();
|
_UpdateToolTip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetIconSize
|
|
||||||
void
|
void
|
||||||
LaunchButton::SetIconSize(uint32 size)
|
LaunchButton::SetIconSize(uint32 size)
|
||||||
{
|
{
|
||||||
@@ -357,9 +361,10 @@ LaunchButton::SetIconSize(uint32 size)
|
|||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
// _UpdateToolTip
|
|
||||||
void
|
void
|
||||||
LaunchButton::_UpdateToolTip()
|
LaunchButton::_UpdateToolTip()
|
||||||
{
|
{
|
||||||
@@ -371,9 +376,9 @@ LaunchButton::_UpdateToolTip()
|
|||||||
BFile file(fRef, B_READ_ONLY);
|
BFile file(fRef, B_READ_ONLY);
|
||||||
BAppFileInfo appFileInfo;
|
BAppFileInfo appFileInfo;
|
||||||
version_info info;
|
version_info info;
|
||||||
if (appFileInfo.SetTo(&file) >= B_OK
|
if (appFileInfo.SetTo(&file) == B_OK
|
||||||
&& appFileInfo.GetVersionInfo(&info,
|
&& appFileInfo.GetVersionInfo(&info,
|
||||||
B_APP_VERSION_KIND) >= B_OK
|
B_APP_VERSION_KIND) == B_OK
|
||||||
&& strlen(info.short_info) > 0) {
|
&& strlen(info.short_info) > 0) {
|
||||||
helper << "\n\n" << info.short_info;
|
helper << "\n\n" << info.short_info;
|
||||||
}
|
}
|
||||||
@@ -384,7 +389,7 @@ LaunchButton::_UpdateToolTip()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// _UpdateIcon
|
|
||||||
void
|
void
|
||||||
LaunchButton::_UpdateIcon(const entry_ref* ref)
|
LaunchButton::_UpdateIcon(const entry_ref* ref)
|
||||||
{
|
{
|
||||||
@@ -392,7 +397,7 @@ LaunchButton::_UpdateIcon(const entry_ref* ref)
|
|||||||
fIconSize - 1), B_RGBA32);
|
fIconSize - 1), B_RGBA32);
|
||||||
// NOTE: passing an invalid/unknown icon_size argument will cause
|
// NOTE: passing an invalid/unknown icon_size argument will cause
|
||||||
// the BNodeInfo to ignore it and just use the bitmap bounds.
|
// the BNodeInfo to ignore it and just use the bitmap bounds.
|
||||||
if (BNodeInfo::GetTrackerIcon(ref, icon, (icon_size)fIconSize) >= B_OK)
|
if (BNodeInfo::GetTrackerIcon(ref, icon, (icon_size)fIconSize) == B_OK)
|
||||||
SetIcon(icon);
|
SetIcon(icon);
|
||||||
|
|
||||||
delete icon;
|
delete icon;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006, Haiku.
|
* Copyright 2006 - 2009, Stephan Aßmus <[email protected]>
|
||||||
* Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Stephan Aßmus <[email protected]>
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LAUNCH_BUTTON_H
|
#ifndef LAUNCH_BUTTON_H
|
||||||
#define LAUNCH_BUTTON_H
|
#define LAUNCH_BUTTON_H
|
||||||
|
|
||||||
@@ -22,12 +18,11 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class LaunchButton : public IconButton {
|
class LaunchButton : public IconButton {
|
||||||
public:
|
public:
|
||||||
LaunchButton(const char* name,
|
LaunchButton(const char* name, uint32 id,
|
||||||
uint32 id,
|
const char* label = NULL,
|
||||||
const char* label = NULL,
|
BMessage* message = NULL,
|
||||||
BMessage* message = NULL,
|
BHandler* target = NULL);
|
||||||
BHandler* target = NULL);
|
|
||||||
virtual ~LaunchButton();
|
virtual ~LaunchButton();
|
||||||
|
|
||||||
// IconButton interface
|
// IconButton interface
|
||||||
@@ -38,7 +33,7 @@ class LaunchButton : public IconButton {
|
|||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
virtual void MouseUp(BPoint where);
|
virtual void MouseUp(BPoint where);
|
||||||
virtual void MouseMoved(BPoint where, uint32 transit,
|
virtual void MouseMoved(BPoint where, uint32 transit,
|
||||||
const BMessage* dragMessage);
|
const BMessage* dragMessage);
|
||||||
|
|
||||||
virtual BSize MinSize();
|
virtual BSize MinSize();
|
||||||
virtual BSize PreferredSize();
|
virtual BSize PreferredSize();
|
||||||
@@ -64,17 +59,17 @@ class LaunchButton : public IconButton {
|
|||||||
void _UpdateToolTip();
|
void _UpdateToolTip();
|
||||||
void _UpdateIcon(const entry_ref* ref);
|
void _UpdateIcon(const entry_ref* ref);
|
||||||
|
|
||||||
entry_ref* fRef;
|
entry_ref* fRef;
|
||||||
char* fAppSig;
|
char* fAppSig;
|
||||||
BString fDescription;
|
BString fDescription;
|
||||||
|
|
||||||
|
bool fAnticipatingDrop;
|
||||||
|
bigtime_t fLastClickTime;
|
||||||
|
BPoint fDragStart;
|
||||||
|
|
||||||
|
uint32 fIconSize;
|
||||||
|
|
||||||
bool fAnticipatingDrop;
|
static bigtime_t fClickSpeed;
|
||||||
bigtime_t fLastClickTime;
|
|
||||||
BPoint fDragStart;
|
|
||||||
|
|
||||||
uint32 fIconSize;
|
|
||||||
|
|
||||||
static bigtime_t fClickSpeed;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LAUNCH_BUTTON_H
|
#endif // LAUNCH_BUTTON_H
|
||||||
|
|||||||
Reference in New Issue
Block a user