Imported DeskWindow.cpp 1.8 and ContainerWindow.cpp 1.32 from OpenTracker CVS.
This fixes bug #298. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17795 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
c310520d82
commit
fe49a8a379
@ -110,6 +110,7 @@ class DraggableContainerIcon : public BView {
|
||||
virtual void MouseDown(BPoint where);
|
||||
virtual void MouseUp(BPoint where);
|
||||
virtual void MouseMoved(BPoint point, uint32 /*transit*/, const BMessage *message);
|
||||
virtual void FrameMoved(BPoint newLocation);
|
||||
virtual void Draw(BRect updateRect);
|
||||
|
||||
private:
|
||||
@ -320,7 +321,7 @@ AddMimeTypeString(BObjectList<BString> &list, Model *model)
|
||||
|
||||
DraggableContainerIcon::DraggableContainerIcon(BRect rect, const char *name,
|
||||
uint32 resizeMask)
|
||||
: BView(rect, name, resizeMask, B_WILL_DRAW),
|
||||
: BView(rect, name, resizeMask, B_WILL_DRAW | B_FRAME_EVENTS),
|
||||
fDragButton(0),
|
||||
fDragStarted(false)
|
||||
{
|
||||
@ -330,8 +331,9 @@ DraggableContainerIcon::DraggableContainerIcon(BRect rect, const char *name,
|
||||
void
|
||||
DraggableContainerIcon::AttachedToWindow()
|
||||
{
|
||||
//SetViewColor(B_TRANSPARENT_COLOR);
|
||||
SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR));
|
||||
FrameMoved(BPoint(0, 0));
|
||||
// this decides whether to hide the icon or not
|
||||
}
|
||||
|
||||
|
||||
@ -376,7 +378,8 @@ DraggableContainerIcon::MouseUp(BPoint /*point*/)
|
||||
|
||||
|
||||
void
|
||||
DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/, const BMessage */*message*/)
|
||||
DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/,
|
||||
const BMessage */*message*/)
|
||||
{
|
||||
if (fDragButton == 0 || fDragStarted
|
||||
|| (abs((int32)(point.x - fClickPoint.x)) <= kDragSlop
|
||||
@ -457,6 +460,39 @@ DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/, const BMess
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DraggableContainerIcon::FrameMoved(BPoint /*newLocation*/)
|
||||
{
|
||||
BMenuBar* bar = dynamic_cast<BMenuBar *>(Parent());
|
||||
if (bar == NULL)
|
||||
return;
|
||||
|
||||
// TODO: ugly hack following:
|
||||
// This is a trick to get the actual width of all menu items
|
||||
// (BMenuBar may not have set the item coordinates yet...)
|
||||
float width, height;
|
||||
int32 resizingMode = bar->ResizingMode();
|
||||
bar->SetResizingMode(B_FOLLOW_NONE);
|
||||
bar->GetPreferredSize(&width, &height);
|
||||
bar->SetResizingMode(resizingMode);
|
||||
|
||||
/*
|
||||
BMenuItem* item = bar->ItemAt(bar->CountItems() - 1);
|
||||
if (item == NULL)
|
||||
return;
|
||||
*/
|
||||
// BeOS shifts the coordinates for hidden views, so we cannot
|
||||
// use them to decide if we should be visible or not...
|
||||
|
||||
float gap = bar->Frame().Width() - 2 - width; //item->Frame().right;
|
||||
|
||||
if (gap <= Bounds().Width() && !IsHidden())
|
||||
Hide();
|
||||
else if (gap > Bounds().Width() && IsHidden())
|
||||
Show();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DraggableContainerIcon::Draw(BRect /*updateRect*/)
|
||||
{
|
||||
@ -2228,12 +2264,11 @@ BContainerWindow::SetupMoveCopyMenus(const entry_ref *item_ref, BMenu *parent)
|
||||
uint32 modifierKeys = modifiers();
|
||||
|
||||
// re-parent items to this menu since they're shared
|
||||
int32 index = parent->CountItems() - 7;
|
||||
if (index > 0 && dynamic_cast<BSeparatorItem *>(parent->ItemAt(index - 1)) == NULL) {
|
||||
// The items below the items to be added vary in number, so
|
||||
// this little "hack" makes sure they are always in place
|
||||
index++;
|
||||
} else
|
||||
int32 index;
|
||||
BMenuItem *trash = parent->FindItem(kMoveToTrash);
|
||||
if (trash)
|
||||
index = parent->IndexOf(trash) + 2;
|
||||
else
|
||||
index = 0;
|
||||
|
||||
if (fMoveToItem->Menu() != parent) {
|
||||
@ -2361,25 +2396,25 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref *ref, BView *)
|
||||
|
||||
BEntry entry;
|
||||
model.GetEntry(&entry);
|
||||
|
||||
// only show for directories (directory, volume, root)
|
||||
//
|
||||
// only show for directories (directory, volume, root)
|
||||
//
|
||||
// don't show a popup for the trash or printers
|
||||
// trash is handled in DeskWindow
|
||||
//
|
||||
// since this menu is opened asynchronously
|
||||
// we need to make sure we don't open it more
|
||||
// than once, the IsShowing flag is set in
|
||||
// SlowContextPopup::AttachedToWindow and
|
||||
// reset in DetachedFromWindow
|
||||
// see the notes in SlowContextPopup::AttachedToWindow
|
||||
// don't show a popup for the trash or printers
|
||||
// trash is handled in DeskWindow
|
||||
//
|
||||
// since this menu is opened asynchronously
|
||||
// we need to make sure we don't open it more
|
||||
// than once, the IsShowing flag is set in
|
||||
// SlowContextPopup::AttachedToWindow and
|
||||
// reset in DetachedFromWindow
|
||||
// see the notes in SlowContextPopup::AttachedToWindow
|
||||
|
||||
if (!FSIsPrintersDir(&entry) && !fDragContextMenu->IsShowing()) {
|
||||
// printf("ShowContextMenu - target is %s %i\n", ref->name, IsShowing(ref));
|
||||
fDragContextMenu->ClearMenu();
|
||||
//
|
||||
// in case the ref is a symlink, resolve it
|
||||
// only pop open for directories
|
||||
|
||||
// in case the ref is a symlink, resolve it
|
||||
// only pop open for directories
|
||||
BEntry resolvedEntry(ref, true);
|
||||
if (!resolvedEntry.IsDirectory())
|
||||
return;
|
||||
@ -2387,7 +2422,7 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref *ref, BView *)
|
||||
entry_ref resolvedRef;
|
||||
resolvedEntry.GetRef(&resolvedRef);
|
||||
|
||||
// use the resolved ref for the menu
|
||||
// use the resolved ref for the menu
|
||||
fDragContextMenu->SetNavDir(&resolvedRef);
|
||||
fDragContextMenu->SetTypesList(fCachedTypesList);
|
||||
fDragContextMenu->SetTarget(BMessenger(this));
|
||||
@ -2398,8 +2433,8 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref *ref, BView *)
|
||||
&BPoseView::MenuTrackingHook, &tmpTarget, fDragMessage);
|
||||
}
|
||||
|
||||
// this is now asynchronous so that we don't
|
||||
// deadlock in Window::Quit,
|
||||
// this is now asynchronous so that we don't
|
||||
// deadlock in Window::Quit,
|
||||
fDragContextMenu->Go(global, true, false, true);
|
||||
}
|
||||
return;
|
||||
@ -2488,10 +2523,12 @@ BContainerWindow::AddFileContextMenus(BMenu *menu)
|
||||
menu->AddItem(new BMenuItem("Restore", new BMessage(kRestoreFromTrash), 0));
|
||||
}
|
||||
|
||||
#ifdef CUT_COPY_PASTE_IN_CONTEXT_MENU
|
||||
menu->AddSeparatorItem();
|
||||
BMenuItem *cutItem, *copyItem;
|
||||
menu->AddItem(cutItem = new BMenuItem("Cut", new BMessage(B_CUT), 'X'));
|
||||
menu->AddItem(copyItem = new BMenuItem("Copy", new BMessage(B_COPY), 'C'));
|
||||
#endif
|
||||
|
||||
menu->AddSeparatorItem();
|
||||
menu->AddItem(new BMenuItem("Identify", new BMessage(kIdentifyEntry)));
|
||||
@ -2501,8 +2538,10 @@ BContainerWindow::AddFileContextMenus(BMenu *menu)
|
||||
|
||||
// set targets as needed
|
||||
menu->SetTargetForItems(PoseView());
|
||||
#ifdef CUT_COPY_PASTE_IN_CONTEXT_MENU
|
||||
cutItem->SetTarget(this);
|
||||
copyItem->SetTarget(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -2551,16 +2590,11 @@ BContainerWindow::AddWindowContextMenus(BMenu *menu)
|
||||
if (needSeparator)
|
||||
menu->AddSeparatorItem();
|
||||
|
||||
menu->AddItem(new BMenuItem("Icon View", new BMessage(kIconMode), '1'));
|
||||
menu->AddItem(new BMenuItem("Mini Icon View", new BMessage(kMiniIconMode), '2'));
|
||||
menu->AddItem(new BMenuItem("List View", new BMessage(kListMode), '3'));
|
||||
menu->AddSeparatorItem();
|
||||
#if 0
|
||||
BMenuItem *pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE), 'V');
|
||||
menu->AddItem(pasteItem);
|
||||
#endif
|
||||
menu->AddSeparatorItem();
|
||||
BMenuItem *resizeItem = new BMenuItem("Resize to Fit",
|
||||
new BMessage(kResizeToFit), 'Y');
|
||||
menu->AddItem(resizeItem);
|
||||
menu->AddItem(new BMenuItem("Clean Up", new BMessage(kCleanup), 'K'));
|
||||
menu->AddItem(new BMenuItem("Select"B_UTF8_ELLIPSIS,
|
||||
new BMessage(kShowSelectionWindow), 'A', B_SHIFT_KEY));
|
||||
@ -2569,9 +2603,6 @@ BContainerWindow::AddWindowContextMenus(BMenu *menu)
|
||||
menu->AddItem(new BMenuItem("Open Parent", new BMessage(kOpenParentDir),
|
||||
B_UP_ARROW));
|
||||
|
||||
BMenuItem *closeItem = new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED),
|
||||
'W');
|
||||
menu->AddItem(closeItem);
|
||||
menu->AddSeparatorItem();
|
||||
BMenu *addOnMenuItem = new BMenu(kAddOnsMenuName);
|
||||
addOnMenuItem->SetFont(be_plain_font);
|
||||
@ -2585,9 +2616,9 @@ BContainerWindow::AddWindowContextMenus(BMenu *menu)
|
||||
|
||||
// target items as needed
|
||||
menu->SetTargetForItems(PoseView());
|
||||
closeItem->SetTarget(this);
|
||||
resizeItem->SetTarget(this);
|
||||
#ifdef CUT_COPY_PASTE_IN_CONTEXT_MENU
|
||||
pasteItem->SetTarget(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -264,9 +264,11 @@ BDeskWindow::AddWindowContextMenus(BMenu *menu)
|
||||
menu->AddItem(new BMenuItem("Icon View", new BMessage(kIconMode)));
|
||||
menu->AddItem(new BMenuItem("Mini Icon View", new BMessage(kMiniIconMode)));
|
||||
menu->AddSeparatorItem();
|
||||
#ifdef CUT_COPY_PASTE_IN_CONTEXT_MENU
|
||||
BMenuItem *pasteItem;
|
||||
menu->AddItem(pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE), 'V'));
|
||||
menu->AddSeparatorItem();
|
||||
#endif
|
||||
menu->AddItem(new BMenuItem("Clean Up", new BMessage(kCleanup), 'K'));
|
||||
menu->AddItem(new BMenuItem("Select"B_UTF8_ELLIPSIS,
|
||||
new BMessage(kShowSelectionWindow), 'A', B_SHIFT_KEY));
|
||||
@ -280,7 +282,9 @@ BDeskWindow::AddWindowContextMenus(BMenu *menu)
|
||||
|
||||
// target items as needed
|
||||
menu->SetTargetForItems(PoseView());
|
||||
#ifdef CUT_COPY_PASTE_IN_CONTEXT_MENU
|
||||
pasteItem->SetTarget(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user