... actually, "unnest" the rest of the file as well.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28095 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-10-14 17:25:42 +00:00
parent 80e1925251
commit 8eeb005f20
+139 -135
View File
@@ -216,38 +216,40 @@ PadView::MouseUp(BPoint where)
void void
PadView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage) PadView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
{ {
if (MainWindow* window = dynamic_cast<MainWindow*>(Window())) { MainWindow* window = dynamic_cast<MainWindow*>(Window());
if (fDragging) { if (window == NULL)
window->MoveTo(ConvertToScreen(where) - fDragOffset); return;
} else if (window->AutoRaise()) {
where = ConvertToScreen(where); if (fDragging) {
BScreen screen(window); window->MoveTo(ConvertToScreen(where) - fDragOffset);
BRect frame = screen.Frame(); } else if (window->AutoRaise()) {
BRect windowFrame = window->Frame(); where = ConvertToScreen(where);
if (where.x == frame.left || where.x == frame.right BScreen screen(window);
|| where.y == frame.top || where.y == frame.bottom) { BRect frame = screen.Frame();
BPoint position = window->ScreenPosition(); BRect windowFrame = window->Frame();
bool raise = false; if (where.x == frame.left || where.x == frame.right
if (fabs(0.5 - position.x) > fabs(0.5 - position.y)) { || where.y == frame.top || where.y == frame.bottom) {
// left or right border BPoint position = window->ScreenPosition();
if (where.y >= windowFrame.top && where.y <= windowFrame.bottom) { bool raise = false;
if (position.x < 0.5 && where.x == frame.left) if (fabs(0.5 - position.x) > fabs(0.5 - position.y)) {
raise = true; // left or right border
else if (position.x > 0.5 && where.x == frame.right) if (where.y >= windowFrame.top && where.y <= windowFrame.bottom) {
raise = true; if (position.x < 0.5 && where.x == frame.left)
} raise = true;
} else { else if (position.x > 0.5 && where.x == frame.right)
// top or bottom border raise = true;
if (where.x >= windowFrame.left && where.x <= windowFrame.right) { }
if (position.y < 0.5 && where.y == frame.top) } else {
raise = true; // top or bottom border
else if (position.y > 0.5 && where.y == frame.top) if (where.x >= windowFrame.left && where.x <= windowFrame.right) {
raise = true; if (position.y < 0.5 && where.y == frame.top)
} raise = true;
else if (position.y > 0.5 && where.y == frame.top)
raise = true;
} }
if (raise)
window->Activate();
} }
if (raise)
window->Activate();
} }
} }
} }
@@ -280,116 +282,118 @@ PadView::ButtonAt(int32 index) const
void void
PadView::DisplayMenu(BPoint where, LaunchButton* button) const PadView::DisplayMenu(BPoint where, LaunchButton* button) const
{ {
if (MainWindow* window = dynamic_cast<MainWindow*>(Window())) { MainWindow* window = dynamic_cast<MainWindow*>(Window());
LaunchButton* nearestButton = button; if (window == NULL)
if (!nearestButton) { return;
// find the nearest button
for (int32 i = 0; (nearestButton = ButtonAt(i)); i++) { LaunchButton* nearestButton = button;
if (nearestButton->Frame().top > where.y) if (!nearestButton) {
break; // find the nearest button
} for (int32 i = 0; (nearestButton = ButtonAt(i)); i++) {
if (nearestButton->Frame().top > where.y)
break;
} }
BPopUpMenu* menu = new BPopUpMenu("launch popup", false, false); }
// add button BPopUpMenu* menu = new BPopUpMenu("launch popup", false, false);
BMessage* message = new BMessage(MSG_ADD_SLOT); // add button
message->AddPointer("be:source", (void*)nearestButton); BMessage* message = new BMessage(MSG_ADD_SLOT);
BMenuItem* item = new BMenuItem("Add Button Here", message); message->AddPointer("be:source", (void*)nearestButton);
BMenuItem* item = new BMenuItem("Add Button Here", message);
item->SetTarget(window);
menu->AddItem(item);
// button options
if (button) {
// remove button
message = new BMessage(MSG_CLEAR_SLOT);
message->AddPointer("be:source", (void*)button);
item = new BMenuItem("Clear Button", message);
item->SetTarget(window);
menu->AddItem(item);
// remove button
message = new BMessage(MSG_REMOVE_SLOT);
message->AddPointer("be:source", (void*)button);
item = new BMenuItem("Remove Button", message);
item->SetTarget(window); item->SetTarget(window);
menu->AddItem(item); menu->AddItem(item);
// button options
if (button) {
// remove button
message = new BMessage(MSG_CLEAR_SLOT);
message->AddPointer("be:source", (void*)button);
item = new BMenuItem("Clear Button", message);
item->SetTarget(window);
menu->AddItem(item);
// remove button
message = new BMessage(MSG_REMOVE_SLOT);
message->AddPointer("be:source", (void*)button);
item = new BMenuItem("Remove Button", message);
item->SetTarget(window);
menu->AddItem(item);
// TODO: disabled because Haiku does not yet support tool tips // TODO: disabled because Haiku does not yet support tool tips
// if (button->Ref()) { // if (button->Ref()) {
// message = new BMessage(MSG_SET_DESCRIPTION); // message = new BMessage(MSG_SET_DESCRIPTION);
// message->AddPointer("be:source", (void*)button); // message->AddPointer("be:source", (void*)button);
// item = new BMenuItem("Set Description"B_UTF8_ELLIPSIS, message); // item = new BMenuItem("Set Description"B_UTF8_ELLIPSIS, message);
// item->SetTarget(window); // item->SetTarget(window);
// menu->AddItem(item); // menu->AddItem(item);
// } // }
}
menu->AddSeparatorItem();
// window settings
BMenu* settingsM = new BMenu("Settings");
settingsM->SetFont(be_plain_font);
const char* toggleLayoutLabel;
if (fButtonLayout->Orientation() == B_HORIZONTAL)
toggleLayoutLabel = "Vertical Layout";
else
toggleLayoutLabel = "Horizontal Layout";
item = new BMenuItem(toggleLayoutLabel, new BMessage(MSG_TOGGLE_LAYOUT));
item->SetTarget(this);
settingsM->AddItem(item);
uint32 what = window->Look() == B_BORDERED_WINDOW_LOOK ? MSG_SHOW_BORDER : MSG_HIDE_BORDER;
item = new BMenuItem("Show Window Border", new BMessage(what));
item->SetTarget(window);
item->SetMarked(what == MSG_HIDE_BORDER);
settingsM->AddItem(item);
item = new BMenuItem("Auto Raise", new BMessage(MSG_TOGGLE_AUTORAISE));
item->SetTarget(window);
item->SetMarked(window->AutoRaise());
settingsM->AddItem(item);
item = new BMenuItem("Show On All Workspaces", new BMessage(MSG_SHOW_ON_ALL_WORKSPACES));
item->SetTarget(window);
item->SetMarked(window->ShowOnAllWorkspaces());
settingsM->AddItem(item);
menu->AddItem(settingsM);
menu->AddSeparatorItem();
// pad commands
BMenu* padM = new BMenu("Pad");
padM->SetFont(be_plain_font);
// new pad
item = new BMenuItem("New", new BMessage(MSG_ADD_WINDOW));
item->SetTarget(be_app);
padM->AddItem(item);
// new pad
item = new BMenuItem("Clone", new BMessage(MSG_ADD_WINDOW));
item->SetTarget(window);
padM->AddItem(item);
padM->AddSeparatorItem();
// close
item = new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED));
item->SetTarget(window);
padM->AddItem(item);
menu->AddItem(padM);
// app commands
BMenu* appM = new BMenu("LaunchBox");
appM->SetFont(be_plain_font);
// about
item = new BMenuItem("About", new BMessage(B_ABOUT_REQUESTED));
item->SetTarget(be_app);
appM->AddItem(item);
// quit
item = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED));
item->SetTarget(be_app);
appM->AddItem(item);
menu->AddItem(appM);
// finish popup
menu->SetAsyncAutoDestruct(true);
menu->SetFont(be_plain_font);
where = ConvertToScreen(where);
BRect mouseRect(where, where);
mouseRect.InsetBy(-4.0, -4.0);
menu->Go(where, true, false, mouseRect, true);
} }
menu->AddSeparatorItem();
// window settings
BMenu* settingsM = new BMenu("Settings");
settingsM->SetFont(be_plain_font);
const char* toggleLayoutLabel;
if (fButtonLayout->Orientation() == B_HORIZONTAL)
toggleLayoutLabel = "Vertical Layout";
else
toggleLayoutLabel = "Horizontal Layout";
item = new BMenuItem(toggleLayoutLabel, new BMessage(MSG_TOGGLE_LAYOUT));
item->SetTarget(this);
settingsM->AddItem(item);
uint32 what = window->Look() == B_BORDERED_WINDOW_LOOK ? MSG_SHOW_BORDER : MSG_HIDE_BORDER;
item = new BMenuItem("Show Window Border", new BMessage(what));
item->SetTarget(window);
item->SetMarked(what == MSG_HIDE_BORDER);
settingsM->AddItem(item);
item = new BMenuItem("Auto Raise", new BMessage(MSG_TOGGLE_AUTORAISE));
item->SetTarget(window);
item->SetMarked(window->AutoRaise());
settingsM->AddItem(item);
item = new BMenuItem("Show On All Workspaces", new BMessage(MSG_SHOW_ON_ALL_WORKSPACES));
item->SetTarget(window);
item->SetMarked(window->ShowOnAllWorkspaces());
settingsM->AddItem(item);
menu->AddItem(settingsM);
menu->AddSeparatorItem();
// pad commands
BMenu* padM = new BMenu("Pad");
padM->SetFont(be_plain_font);
// new pad
item = new BMenuItem("New", new BMessage(MSG_ADD_WINDOW));
item->SetTarget(be_app);
padM->AddItem(item);
// new pad
item = new BMenuItem("Clone", new BMessage(MSG_ADD_WINDOW));
item->SetTarget(window);
padM->AddItem(item);
padM->AddSeparatorItem();
// close
item = new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED));
item->SetTarget(window);
padM->AddItem(item);
menu->AddItem(padM);
// app commands
BMenu* appM = new BMenu("LaunchBox");
appM->SetFont(be_plain_font);
// about
item = new BMenuItem("About", new BMessage(B_ABOUT_REQUESTED));
item->SetTarget(be_app);
appM->AddItem(item);
// quit
item = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED));
item->SetTarget(be_app);
appM->AddItem(item);
menu->AddItem(appM);
// finish popup
menu->SetAsyncAutoDestruct(true);
menu->SetFont(be_plain_font);
where = ConvertToScreen(where);
BRect mouseRect(where, where);
mouseRect.InsetBy(-4.0, -4.0);
menu->Go(where, true, false, mouseRect, true);
} }
// SetOrientation // SetOrientation