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

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
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
@ -78,7 +79,7 @@ TBarMenuBar::SmartResize(float width, float height)
BRect frame = Frame();
width = frame.Width();
height = frame.Height();
} else
} else
ResizeTo(width, height);
width -= 1;
@ -96,7 +97,7 @@ TBarMenuBar::SmartResize(float width, float height)
void
TBarMenuBar::AddTeamMenu()
{
if (CountItems() > 1)
if (CountItems() > 1)
return;
BRect frame(Frame());
@ -112,7 +113,7 @@ TBarMenuBar::AddTeamMenu()
void
TBarMenuBar::RemoveTeamMenu()
{
if (CountItems() < 2)
if (CountItems() < 2)
return;
if (fAppListMenuItem) {
@ -121,7 +122,7 @@ TBarMenuBar::RemoveTeamMenu()
fAppListMenuItem = NULL;
}
BRect frame = Frame();
BRect frame = Frame();
SmartResize(frame.Width(), frame.Height());
}
@ -179,9 +180,10 @@ init_tracking_hook(BMenuItem* item, bool (*hookFunction)(BMenu*, void*),
return;
BMenu* windowMenu = item->Submenu();
if (windowMenu)
// have a menu, set the tracking hook
windowMenu->SetTrackingHook(hookFunction, state);
if (windowMenu) {
// have a menu, set the tracking hook
windowMenu->SetTrackingHook(hookFunction, state);
}
}
@ -192,13 +194,13 @@ TBarMenuBar::InitTrackingHook(bool (*hookFunction)(BMenu*, void*),
BPoint loc;
uint32 buttons;
GetMouse(&loc, &buttons);
// set the hook functions for the two menus
// will always have the be menu
// may have the app menu as well (mini mode)
if (fBeMenuItem->Frame().Contains(loc) || both)
// set the hook functions for the two menus
// will always have the be menu
// may have the app menu as well (mini mode)
if (fBeMenuItem->Frame().Contains(loc) || both)
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);
}

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
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
// Be Menu, used in vertical mode, expanded and mini
// in mini mode will have team menu next to Be menu
// Be menu in horizontal mode is embedded in ExpandoMenuBar
// Be Menu, used in vertical mode, expanded and mini
// - in mini mode will have team menu next to Be menu
// - Be menu in horizontal mode is embedded in ExpandoMenuBar
#ifndef BARMENUBAR_H
#define BARMENUBAR_H
@ -63,7 +64,7 @@ class TBarMenuBar : public BMenuBar {
void InitTrackingHook(bool (* hookfunction)(BMenu*, void*), void* state,
bool both = false);
private:
TBarView* fBarView;
TBarMenuTitle* fBeMenuItem;

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
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
@ -116,14 +117,14 @@ TBarMenuTitle::DrawContent()
if (be_control_look != NULL) {
menu->SetDrawingMode(B_OP_ALPHA);
if (fIcon != NULL) {
BRect dstRect(fIcon->Bounds());
dstRect.OffsetTo(frame.LeftTop());
dstRect.OffsetBy(rintf(((frame.Width() - dstRect.Width()) / 2)
- 1.0f), rintf(((frame.Height() - dstRect.Height()) / 2)
- 0.0f));
menu->DrawBitmapAsync(fIcon, dstRect);
}
return;
@ -200,11 +201,11 @@ TBarMenuTitle::Invoke(BMessage* message)
BLooper* looper = barview->Looper();
if (looper->Lock()) {
// tell barview to add the refs to the be menu
barview->HandleBeMenu(NULL);
barview->HandleBeMenu(NULL);
looper->Unlock();
}
}
return BMenuItem::Invoke(message);
}

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
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
@ -46,15 +47,15 @@ class BMenu;
class TBarMenuTitle : public BMenuItem {
public:
TBarMenuTitle(float width,float height, const BBitmap* icon,
BMenu* menu, bool inexpando = false);
TBarMenuTitle(float width, float height, const BBitmap* icon,
BMenu* menu, bool inexpando = false);
virtual ~TBarMenuTitle();
void SetWidthHeight(float width, float height);
void Draw();
status_t Invoke(BMessage* message);
protected:
void DrawContent();
void GetContentSize(float* width, float* height);
@ -63,7 +64,7 @@ private:
float fWidth;
float fHeight;
bool fInExpando;
const BBitmap* fIcon;
const BBitmap* fIcon;
};
#endif /* BARMENUTITLE_H */

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
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
@ -135,9 +136,9 @@ TBarView::Draw(BRect)
rgb_color light = tint_color(ViewColor(), B_LIGHTEN_2_TINT);
SetHighColor(hilite);
if (AcrossTop())
if (AcrossTop())
StrokeLine(bounds.LeftBottom(), bounds.RightBottom());
else if (AcrossBottom())
else if (AcrossBottom())
StrokeLine(bounds.LeftTop(), bounds.RightTop());
if (Vertical() && Expando()) {
@ -166,7 +167,7 @@ TBarView::MessageReceived(BMessage* message)
// so that I can follow the common pathway
// for adding icons to the tray
int32 id;
AddItem(new BMessage(*message), B_DESKBAR_TRAY, &id);
AddItem(new BMessage(*message), B_DESKBAR_TRAY, &id);
break;
}
@ -206,9 +207,9 @@ TBarView::PlaceBeMenu()
fBarMenuBar = NULL;
}
// top or bottom expando mode has Be menu built in for tracking
// only for vertical mini or expanded
// mini mode will have team menu added as part of BarMenuBar
// top or bottom expando mode has Be menu built in for tracking
// only for vertical mini or expanded
// mini mode will have team menu added as part of BarMenuBar
if (fVertical && !fBarMenuBar) {
// create the Be menu
BRect mbarFrame(Bounds());
@ -217,11 +218,11 @@ TBarView::PlaceBeMenu()
AddChild(fBarMenuBar);
}
// if there isn't a bemenu at this point,
// DB should be in top/bottom mode, else error
// if there isn't a bemenu at this point,
// DB should be in top/bottom mode, else error
if (!fBarMenuBar)
return;
float width = sMinimumWindowWidth;
BPoint loc(B_ORIGIN);
BRect menuFrame(fBarMenuBar->Frame());
@ -237,9 +238,10 @@ TBarView::PlaceBeMenu()
else
width = floorf(width) / 2;
loc = Bounds().LeftTop();
} else
} else {
// mini mode, BeMenu next to team menu
fBarMenuBar->AddTeamMenu();
}
fBarMenuBar->SmartResize(width, menuFrame.Height());
fBarMenuBar->MoveTo(loc);
@ -257,13 +259,13 @@ TBarView::PlaceTray(bool, bool, BRect screenFrame)
fDragRegion->MoveTo(statusLoc);
if (!fReplicantTray->IsHidden())
fReplicantTray->Hide();
fReplicantTray->Hide();
return;
}
if (fReplicantTray->IsHidden())
fReplicantTray->Show();
fReplicantTray->Show();
if (fTrayLocation != 0) {
fReplicantTray->SetMultiRow(fVertical);
@ -347,7 +349,7 @@ TBarView::GetPreferredWindowSize(BRect screenFrame, float* width, float* height)
}
} else {
// four corners
if (fTrayLocation != 0)
if (fTrayLocation != 0)
windowHeight = fDragRegion->Frame().bottom;
else
windowHeight = fBarMenuBar->Frame().bottom;
@ -404,10 +406,10 @@ TBarView::SaveSettings()
settings->state = (uint32)State();
settings->width = 0;
settings->showTime = ShowingClock();
fReplicantTray->RememberClockSettings();
settings->alwaysOnTop = (Window()->Feel() & B_FLOATING_ALL_WINDOW_FEEL)
!= 0;
settings->alwaysOnTop
= (Window()->Feel() & B_FLOATING_ALL_WINDOW_FEEL) != 0;
}
@ -424,7 +426,7 @@ TBarView::UpdateAutoRaise()
void
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;
if (fVertical && Expando()
&& 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
if (fVertical && Expando() && vertical && fExpando) {
for (int index = 0; index < fExpando->CountItems(); index++) {
@ -469,10 +471,10 @@ TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)
}
}
PlaceApplicationBar(screenFrame);
SizeWindow(screenFrame);
PositionWindow(screenFrame);
Window()->UpdateIfNeeded();
PlaceApplicationBar(screenFrame);
SizeWindow(screenFrame);
PositionWindow(screenFrame);
Window()->UpdateIfNeeded();
// Re-expand those apps.
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
TBarView::Vertical() const
@ -558,7 +560,7 @@ TBarView::State() const
// optional functionality functions
bool
bool
TBarView::MilTime() const
{
return fShowInterval;
@ -586,7 +588,7 @@ void
TBarView::CacheDragData(const BMessage* incoming)
{
if (!incoming)
return;
return;
if (Dragging() && SpringLoadedFolderCompareMessages(incoming, fDragMessage))
return;
@ -614,7 +616,7 @@ init_tracking_hook(BMenuItem* item,
status_t
TBarView::DragStart()
{
{
if (!Dragging())
return B_OK;
@ -624,7 +626,7 @@ TBarView::DragStart()
if (fExpando && fExpando->Frame().Contains(loc)) {
ConvertToScreen(&loc);
BPoint expandoLocation = fExpando->ConvertFromScreen(loc);
BPoint expandoLocation = fExpando->ConvertFromScreen(loc);
TTeamMenuItem* item = fExpando->TeamItemAtPoint(expandoLocation);
if (fLastDragItem)
@ -634,8 +636,8 @@ TBarView::DragStart()
if (item == fLastDragItem)
return B_OK;
fLastDragItem = item;
}
fLastDragItem = item;
}
}
return B_OK;
@ -676,7 +678,7 @@ TBarView::MenuTrackingHook(BMenu* menu, void* castToThis)
if (bemenu && bemenu->LockLooper()) {
bemenu->ConvertFromScreen(&location);
if (bemenu->Frame().Contains(location))
if (bemenu->Frame().Contains(location))
endMenu = false;
bemenu->UnlockLooper();
@ -685,7 +687,7 @@ TBarView::MenuTrackingHook(BMenu* menu, void* castToThis)
if (endMenu && expando) {
expando->ConvertFromScreen(&location);
BMenuItem* item = expando->TeamItemAtPoint(location);
if (item)
if (item)
endMenu = false;
}
barview->UnlockLooper();
@ -757,7 +759,7 @@ TBarView::AppCanHandleTypes(const char* signature)
if (appmime.GetAppHint(&hintref) != B_OK)
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
BFile file(&hintref, O_RDONLY);
BAppFileInfo fileinfo(&file);
@ -768,7 +770,7 @@ TBarView::AppCanHandleTypes(const char* signature)
int32 count = fCachedTypesList->CountItems();
for (int32 i = 0 ; i < count ; i++) {
if (fileinfo.IsSupportedType(fCachedTypesList->ItemAt(i)->String()))
if (fileinfo.IsSupportedType(fCachedTypesList->ItemAt(i)->String()))
return true;
}
@ -910,9 +912,9 @@ TBarView::ItemExists(const char* name, DeskbarShelf)
int32
TBarView::CountItems(DeskbarShelf)
{
return fReplicantTray->IconCount();
}
{
return fReplicantTray->IconCount();
}
status_t

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
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
@ -98,7 +99,7 @@ class TBarView : public BView {
void CacheDragData(const BMessage* incoming);
status_t DragStart();
static bool MenuTrackingHook(BMenu* menu, void* castToThis);
void DragStop(bool full=false);
void DragStop(bool full = false);
TrackingHookData* GetTrackingHookData();
bool Dragging() const;
const BMessage* DragMessage() const;