Patches from John Scipione as part of bug 7052.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40815 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Fredrik Holmqvist
2011-03-05 15:52:49 +00:00
parent 62a78b3566
commit 4ec67d2b37
6 changed files with 87 additions and 79 deletions
+17 -15
View File
@@ -26,9 +26,10 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated. this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
of Be Incorporated in the United States and other countries. Other brand product trademarks of Be Incorporated in the United States and other countries. Other
names are registered trademarks or trademarks of their respective holders. brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved. All rights reserved.
*/ */
@@ -78,7 +79,7 @@ TBarMenuBar::SmartResize(float width, float height)
BRect frame = Frame(); BRect frame = Frame();
width = frame.Width(); width = frame.Width();
height = frame.Height(); height = frame.Height();
} else } else
ResizeTo(width, height); ResizeTo(width, height);
width -= 1; width -= 1;
@@ -96,7 +97,7 @@ TBarMenuBar::SmartResize(float width, float height)
void void
TBarMenuBar::AddTeamMenu() TBarMenuBar::AddTeamMenu()
{ {
if (CountItems() > 1) if (CountItems() > 1)
return; return;
BRect frame(Frame()); BRect frame(Frame());
@@ -112,7 +113,7 @@ TBarMenuBar::AddTeamMenu()
void void
TBarMenuBar::RemoveTeamMenu() TBarMenuBar::RemoveTeamMenu()
{ {
if (CountItems() < 2) if (CountItems() < 2)
return; return;
if (fAppListMenuItem) { if (fAppListMenuItem) {
@@ -121,7 +122,7 @@ TBarMenuBar::RemoveTeamMenu()
fAppListMenuItem = NULL; fAppListMenuItem = NULL;
} }
BRect frame = Frame(); BRect frame = Frame();
SmartResize(frame.Width(), frame.Height()); SmartResize(frame.Width(), frame.Height());
} }
@@ -179,9 +180,10 @@ init_tracking_hook(BMenuItem* item, bool (*hookFunction)(BMenu*, void*),
return; return;
BMenu* windowMenu = item->Submenu(); BMenu* windowMenu = item->Submenu();
if (windowMenu) if (windowMenu) {
// have a menu, set the tracking hook // have a menu, set the tracking hook
windowMenu->SetTrackingHook(hookFunction, state); windowMenu->SetTrackingHook(hookFunction, state);
}
} }
@@ -192,13 +194,13 @@ TBarMenuBar::InitTrackingHook(bool (*hookFunction)(BMenu*, void*),
BPoint loc; BPoint loc;
uint32 buttons; uint32 buttons;
GetMouse(&loc, &buttons); GetMouse(&loc, &buttons);
// set the hook functions for the two menus // set the hook functions for the two menus
// will always have the be menu // will always have the be menu
// may have the app menu as well (mini mode) // may have the app menu as well (mini mode)
if (fBeMenuItem->Frame().Contains(loc) || both) if (fBeMenuItem->Frame().Contains(loc) || both)
init_tracking_hook(fBeMenuItem, hookFunction, state); init_tracking_hook(fBeMenuItem, hookFunction, state);
if (fAppListMenuItem && (fAppListMenuItem->Frame().Contains(loc) || both)) if (fAppListMenuItem && (fAppListMenuItem->Frame().Contains(loc) || both))
init_tracking_hook(fAppListMenuItem, hookFunction, state); init_tracking_hook(fAppListMenuItem, hookFunction, state);
} }
+8 -7
View File
@@ -26,15 +26,16 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated. this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
of Be Incorporated in the United States and other countries. Other brand product trademarks of Be Incorporated in the United States and other countries. Other
names are registered trademarks or trademarks of their respective holders. brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved. All rights reserved.
*/ */
// Be Menu, used in vertical mode, expanded and mini // Be Menu, used in vertical mode, expanded and mini
// in mini mode will have team menu next to Be menu // - in mini mode will have team menu next to Be menu
// Be menu in horizontal mode is embedded in ExpandoMenuBar // - Be menu in horizontal mode is embedded in ExpandoMenuBar
#ifndef BARMENUBAR_H #ifndef BARMENUBAR_H
#define BARMENUBAR_H #define BARMENUBAR_H
@@ -63,7 +64,7 @@ class TBarMenuBar : public BMenuBar {
void InitTrackingHook(bool (* hookfunction)(BMenu*, void*), void* state, void InitTrackingHook(bool (* hookfunction)(BMenu*, void*), void* state,
bool both = false); bool both = false);
private: private:
TBarView* fBarView; TBarView* fBarView;
TBarMenuTitle* fBeMenuItem; TBarMenuTitle* fBeMenuItem;
+8 -7
View File
@@ -26,9 +26,10 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated. this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
of Be Incorporated in the United States and other countries. Other brand product trademarks of Be Incorporated in the United States and other countries. Other
names are registered trademarks or trademarks of their respective holders. brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved. All rights reserved.
*/ */
@@ -116,14 +117,14 @@ TBarMenuTitle::DrawContent()
if (be_control_look != NULL) { if (be_control_look != NULL) {
menu->SetDrawingMode(B_OP_ALPHA); menu->SetDrawingMode(B_OP_ALPHA);
if (fIcon != NULL) { if (fIcon != NULL) {
BRect dstRect(fIcon->Bounds()); BRect dstRect(fIcon->Bounds());
dstRect.OffsetTo(frame.LeftTop()); dstRect.OffsetTo(frame.LeftTop());
dstRect.OffsetBy(rintf(((frame.Width() - dstRect.Width()) / 2) dstRect.OffsetBy(rintf(((frame.Width() - dstRect.Width()) / 2)
- 1.0f), rintf(((frame.Height() - dstRect.Height()) / 2) - 1.0f), rintf(((frame.Height() - dstRect.Height()) / 2)
- 0.0f)); - 0.0f));
menu->DrawBitmapAsync(fIcon, dstRect); menu->DrawBitmapAsync(fIcon, dstRect);
} }
return; return;
@@ -200,11 +201,11 @@ TBarMenuTitle::Invoke(BMessage* message)
BLooper* looper = barview->Looper(); BLooper* looper = barview->Looper();
if (looper->Lock()) { if (looper->Lock()) {
// tell barview to add the refs to the be menu // tell barview to add the refs to the be menu
barview->HandleBeMenu(NULL); barview->HandleBeMenu(NULL);
looper->Unlock(); looper->Unlock();
} }
} }
return BMenuItem::Invoke(message); return BMenuItem::Invoke(message);
} }
+8 -7
View File
@@ -26,9 +26,10 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated. this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
of Be Incorporated in the United States and other countries. Other brand product trademarks of Be Incorporated in the United States and other countries. Other
names are registered trademarks or trademarks of their respective holders. brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved. All rights reserved.
*/ */
@@ -46,15 +47,15 @@ class BMenu;
class TBarMenuTitle : public BMenuItem { class TBarMenuTitle : public BMenuItem {
public: public:
TBarMenuTitle(float width,float height, const BBitmap* icon, TBarMenuTitle(float width, float height, const BBitmap* icon,
BMenu* menu, bool inexpando = false); BMenu* menu, bool inexpando = false);
virtual ~TBarMenuTitle(); virtual ~TBarMenuTitle();
void SetWidthHeight(float width, float height); void SetWidthHeight(float width, float height);
void Draw(); void Draw();
status_t Invoke(BMessage* message); status_t Invoke(BMessage* message);
protected: protected:
void DrawContent(); void DrawContent();
void GetContentSize(float* width, float* height); void GetContentSize(float* width, float* height);
@@ -63,7 +64,7 @@ private:
float fWidth; float fWidth;
float fHeight; float fHeight;
bool fInExpando; bool fInExpando;
const BBitmap* fIcon; const BBitmap* fIcon;
}; };
#endif /* BARMENUTITLE_H */ #endif /* BARMENUTITLE_H */
+41 -39
View File
@@ -26,9 +26,10 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated. this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
of Be Incorporated in the United States and other countries. Other brand product trademarks of Be Incorporated in the United States and other countries. Other
names are registered trademarks or trademarks of their respective holders. brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved. All rights reserved.
*/ */
@@ -135,9 +136,9 @@ TBarView::Draw(BRect)
rgb_color light = tint_color(ViewColor(), B_LIGHTEN_2_TINT); rgb_color light = tint_color(ViewColor(), B_LIGHTEN_2_TINT);
SetHighColor(hilite); SetHighColor(hilite);
if (AcrossTop()) if (AcrossTop())
StrokeLine(bounds.LeftBottom(), bounds.RightBottom()); StrokeLine(bounds.LeftBottom(), bounds.RightBottom());
else if (AcrossBottom()) else if (AcrossBottom())
StrokeLine(bounds.LeftTop(), bounds.RightTop()); StrokeLine(bounds.LeftTop(), bounds.RightTop());
if (Vertical() && Expando()) { if (Vertical() && Expando()) {
@@ -166,7 +167,7 @@ TBarView::MessageReceived(BMessage* message)
// so that I can follow the common pathway // so that I can follow the common pathway
// for adding icons to the tray // for adding icons to the tray
int32 id; int32 id;
AddItem(new BMessage(*message), B_DESKBAR_TRAY, &id); AddItem(new BMessage(*message), B_DESKBAR_TRAY, &id);
break; break;
} }
@@ -206,9 +207,9 @@ TBarView::PlaceBeMenu()
fBarMenuBar = NULL; fBarMenuBar = NULL;
} }
// top or bottom expando mode has Be menu built in for tracking // top or bottom expando mode has Be menu built in for tracking
// only for vertical mini or expanded // only for vertical mini or expanded
// mini mode will have team menu added as part of BarMenuBar // mini mode will have team menu added as part of BarMenuBar
if (fVertical && !fBarMenuBar) { if (fVertical && !fBarMenuBar) {
// create the Be menu // create the Be menu
BRect mbarFrame(Bounds()); BRect mbarFrame(Bounds());
@@ -217,11 +218,11 @@ TBarView::PlaceBeMenu()
AddChild(fBarMenuBar); AddChild(fBarMenuBar);
} }
// if there isn't a bemenu at this point, // if there isn't a bemenu at this point,
// DB should be in top/bottom mode, else error // DB should be in top/bottom mode, else error
if (!fBarMenuBar) if (!fBarMenuBar)
return; return;
float width = sMinimumWindowWidth; float width = sMinimumWindowWidth;
BPoint loc(B_ORIGIN); BPoint loc(B_ORIGIN);
BRect menuFrame(fBarMenuBar->Frame()); BRect menuFrame(fBarMenuBar->Frame());
@@ -237,9 +238,10 @@ TBarView::PlaceBeMenu()
else else
width = floorf(width) / 2; width = floorf(width) / 2;
loc = Bounds().LeftTop(); loc = Bounds().LeftTop();
} else } else {
// mini mode, BeMenu next to team menu // mini mode, BeMenu next to team menu
fBarMenuBar->AddTeamMenu(); fBarMenuBar->AddTeamMenu();
}
fBarMenuBar->SmartResize(width, menuFrame.Height()); fBarMenuBar->SmartResize(width, menuFrame.Height());
fBarMenuBar->MoveTo(loc); fBarMenuBar->MoveTo(loc);
@@ -257,13 +259,13 @@ TBarView::PlaceTray(bool, bool, BRect screenFrame)
fDragRegion->MoveTo(statusLoc); fDragRegion->MoveTo(statusLoc);
if (!fReplicantTray->IsHidden()) if (!fReplicantTray->IsHidden())
fReplicantTray->Hide(); fReplicantTray->Hide();
return; return;
} }
if (fReplicantTray->IsHidden()) if (fReplicantTray->IsHidden())
fReplicantTray->Show(); fReplicantTray->Show();
if (fTrayLocation != 0) { if (fTrayLocation != 0) {
fReplicantTray->SetMultiRow(fVertical); fReplicantTray->SetMultiRow(fVertical);
@@ -347,7 +349,7 @@ TBarView::GetPreferredWindowSize(BRect screenFrame, float* width, float* height)
} }
} else { } else {
// four corners // four corners
if (fTrayLocation != 0) if (fTrayLocation != 0)
windowHeight = fDragRegion->Frame().bottom; windowHeight = fDragRegion->Frame().bottom;
else else
windowHeight = fBarMenuBar->Frame().bottom; windowHeight = fBarMenuBar->Frame().bottom;
@@ -404,10 +406,10 @@ TBarView::SaveSettings()
settings->state = (uint32)State(); settings->state = (uint32)State();
settings->width = 0; settings->width = 0;
settings->showTime = ShowingClock(); settings->showTime = ShowingClock();
fReplicantTray->RememberClockSettings(); fReplicantTray->RememberClockSettings();
settings->alwaysOnTop = (Window()->Feel() & B_FLOATING_ALL_WINDOW_FEEL) settings->alwaysOnTop
!= 0; = (Window()->Feel() & B_FLOATING_ALL_WINDOW_FEEL) != 0;
} }
@@ -424,7 +426,7 @@ TBarView::UpdateAutoRaise()
void void
TBarView::UpdatePlacement() TBarView::UpdatePlacement()
{ {
ChangeState(fState, fVertical, fLeft, fTop); ChangeState(fState, fVertical, fLeft, fTop);
} }
@@ -455,7 +457,7 @@ TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)
BString* signature = NULL; BString* signature = NULL;
if (fVertical && Expando() if (fVertical && Expando()
&& static_cast<TBarApp*>(be_app)->Settings()->superExpando) { && static_cast<TBarApp*>(be_app)->Settings()->superExpando) {
// Get a list of the signatures of expanded apps. Can't use // Get a list of the signatures of expanded apps. Can't use
// team_id because there can be more than one team per application // team_id because there can be more than one team per application
if (fVertical && Expando() && vertical && fExpando) { if (fVertical && Expando() && vertical && fExpando) {
for (int index = 0; index < fExpando->CountItems(); index++) { for (int index = 0; index < fExpando->CountItems(); index++) {
@@ -469,10 +471,10 @@ TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)
} }
} }
PlaceApplicationBar(screenFrame); PlaceApplicationBar(screenFrame);
SizeWindow(screenFrame); SizeWindow(screenFrame);
PositionWindow(screenFrame); PositionWindow(screenFrame);
Window()->UpdateIfNeeded(); Window()->UpdateIfNeeded();
// Re-expand those apps. // Re-expand those apps.
if (expandedItems.CountItems() > 0) { if (expandedItems.CountItems() > 0) {
@@ -505,7 +507,7 @@ TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)
} }
// window placement functions // window placement functions
bool bool
TBarView::Vertical() const TBarView::Vertical() const
@@ -558,7 +560,7 @@ TBarView::State() const
// optional functionality functions // optional functionality functions
bool bool
TBarView::MilTime() const TBarView::MilTime() const
{ {
return fShowInterval; return fShowInterval;
@@ -586,7 +588,7 @@ void
TBarView::CacheDragData(const BMessage* incoming) TBarView::CacheDragData(const BMessage* incoming)
{ {
if (!incoming) if (!incoming)
return; return;
if (Dragging() && SpringLoadedFolderCompareMessages(incoming, fDragMessage)) if (Dragging() && SpringLoadedFolderCompareMessages(incoming, fDragMessage))
return; return;
@@ -614,7 +616,7 @@ init_tracking_hook(BMenuItem* item,
status_t status_t
TBarView::DragStart() TBarView::DragStart()
{ {
if (!Dragging()) if (!Dragging())
return B_OK; return B_OK;
@@ -624,7 +626,7 @@ TBarView::DragStart()
if (fExpando && fExpando->Frame().Contains(loc)) { if (fExpando && fExpando->Frame().Contains(loc)) {
ConvertToScreen(&loc); ConvertToScreen(&loc);
BPoint expandoLocation = fExpando->ConvertFromScreen(loc); BPoint expandoLocation = fExpando->ConvertFromScreen(loc);
TTeamMenuItem* item = fExpando->TeamItemAtPoint(expandoLocation); TTeamMenuItem* item = fExpando->TeamItemAtPoint(expandoLocation);
if (fLastDragItem) if (fLastDragItem)
@@ -634,8 +636,8 @@ TBarView::DragStart()
if (item == fLastDragItem) if (item == fLastDragItem)
return B_OK; return B_OK;
fLastDragItem = item; fLastDragItem = item;
} }
} }
return B_OK; return B_OK;
@@ -676,7 +678,7 @@ TBarView::MenuTrackingHook(BMenu* menu, void* castToThis)
if (bemenu && bemenu->LockLooper()) { if (bemenu && bemenu->LockLooper()) {
bemenu->ConvertFromScreen(&location); bemenu->ConvertFromScreen(&location);
if (bemenu->Frame().Contains(location)) if (bemenu->Frame().Contains(location))
endMenu = false; endMenu = false;
bemenu->UnlockLooper(); bemenu->UnlockLooper();
@@ -685,7 +687,7 @@ TBarView::MenuTrackingHook(BMenu* menu, void* castToThis)
if (endMenu && expando) { if (endMenu && expando) {
expando->ConvertFromScreen(&location); expando->ConvertFromScreen(&location);
BMenuItem* item = expando->TeamItemAtPoint(location); BMenuItem* item = expando->TeamItemAtPoint(location);
if (item) if (item)
endMenu = false; endMenu = false;
} }
barview->UnlockLooper(); barview->UnlockLooper();
@@ -757,7 +759,7 @@ TBarView::AppCanHandleTypes(const char* signature)
if (appmime.GetAppHint(&hintref) != B_OK) if (appmime.GetAppHint(&hintref) != B_OK)
return false; return false;
// an app was found, now see if it supports any of // an app was found, now see if it supports any of
// the refs in the message // the refs in the message
BFile file(&hintref, O_RDONLY); BFile file(&hintref, O_RDONLY);
BAppFileInfo fileinfo(&file); BAppFileInfo fileinfo(&file);
@@ -768,7 +770,7 @@ TBarView::AppCanHandleTypes(const char* signature)
int32 count = fCachedTypesList->CountItems(); int32 count = fCachedTypesList->CountItems();
for (int32 i = 0 ; i < count ; i++) { for (int32 i = 0 ; i < count ; i++) {
if (fileinfo.IsSupportedType(fCachedTypesList->ItemAt(i)->String())) if (fileinfo.IsSupportedType(fCachedTypesList->ItemAt(i)->String()))
return true; return true;
} }
@@ -910,9 +912,9 @@ TBarView::ItemExists(const char* name, DeskbarShelf)
int32 int32
TBarView::CountItems(DeskbarShelf) TBarView::CountItems(DeskbarShelf)
{ {
return fReplicantTray->IconCount(); return fReplicantTray->IconCount();
} }
status_t status_t
+5 -4
View File
@@ -26,9 +26,10 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated. this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
of Be Incorporated in the United States and other countries. Other brand product trademarks of Be Incorporated in the United States and other countries. Other
names are registered trademarks or trademarks of their respective holders. brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved. All rights reserved.
*/ */
@@ -98,7 +99,7 @@ class TBarView : public BView {
void CacheDragData(const BMessage* incoming); void CacheDragData(const BMessage* incoming);
status_t DragStart(); status_t DragStart();
static bool MenuTrackingHook(BMenu* menu, void* castToThis); static bool MenuTrackingHook(BMenu* menu, void* castToThis);
void DragStop(bool full=false); void DragStop(bool full = false);
TrackingHookData* GetTrackingHookData(); TrackingHookData* GetTrackingHookData();
bool Dragging() const; bool Dragging() const;
const BMessage* DragMessage() const; const BMessage* DragMessage() const;