hrev45652 adds 3 changesets to branch 'master' old head: 298cd4c2bffa793e9d17f22f5d2d6f49c3d07a73 new head: 55eb18ef2f0fe1db4c60bcceaee15c5d259ea856 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=55eb18e+%5E298cd4c ---------------------------------------------------------------------------- 55067df: Style fixes and update copywrite headers 88c2518: Terminal: Layout the find window better 55eb18e: Terminal: Move the find window under your cursor on open moving the window back into the screen if necessary. [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- 3 files changed, 45 insertions(+), 11 deletions(-) src/apps/terminal/FindWindow.cpp | 25 +++++++++++++++++-------- src/apps/terminal/FindWindow.h | 4 ++-- src/apps/terminal/TermWindow.cpp | 27 ++++++++++++++++++++++++++- ############################################################################ Commit: 55067dfe82790c537119b1137072ec738dbd7024 URL: http://cgit.haiku-os.org/haiku/commit/?id=55067df Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri May 10 04:51:24 2013 UTC Style fixes and update copywrite headers ---------------------------------------------------------------------------- diff --git a/src/apps/terminal/FindWindow.cpp b/src/apps/terminal/FindWindow.cpp index 181ddf2..dda76db 100644 --- a/src/apps/terminal/FindWindow.cpp +++ b/src/apps/terminal/FindWindow.cpp @@ -1,8 +1,11 @@ /* - * Copyright 2007-2010, Haiku, Inc. All rights reserved. + * Copyright 2007-2013 Haiku, Inc. All rights reserved. * Copyright 2003-2004 Kian Duffy, myob@xxxxxxxxxxxxxxxxxxxxx * Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai. * All rights reserved. Distributed under the terms of the MIT license. + * + * Authors: + * John Scipione, jscipione@xxxxxxxxx */ #include "FindWindow.h" @@ -26,11 +29,13 @@ const uint32 MSG_FIND_HIDE = 'Fhid'; const uint32 TOGGLE_FIND_CONTROL = 'MTFG'; const BRect kWindowFrame(10, 30, 250, 200); + #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "Terminal FindWindow" + FindWindow::FindWindow(BMessenger messenger, const BString& str, - bool findSelection, bool matchWord, bool matchCase, bool forwardSearch) + bool findSelection, bool matchWord, bool matchCase, bool forwardSearch) : BWindow(kWindowFrame, B_TRANSLATE("Find"), B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE @@ -39,7 +44,7 @@ FindWindow::FindWindow(BMessenger messenger, const BString& str, { SetLayout(new BGroupLayout(B_VERTICAL)); - BBox *separator = new BBox("separator"); + BBox* separator = new BBox("separator"); separator->SetExplicitMinSize(BSize(250.0, B_SIZE_UNSET)); separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1.0)); diff --git a/src/apps/terminal/FindWindow.h b/src/apps/terminal/FindWindow.h index f3c9bb3..f2b6e3c 100644 --- a/src/apps/terminal/FindWindow.h +++ b/src/apps/terminal/FindWindow.h @@ -1,5 +1,5 @@ /* - * Copyright 2007, Haiku, Inc. + * Copyright 2007-2013 Haiku, Inc. All rights reserved. * Copyright 2003-2004 Kian Duffy, myob@xxxxxxxxxxxxxxxxxxxxx * Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai. * All rights reserved. Distributed under the terms of the MIT license. @@ -29,8 +29,8 @@ public: bool matchCase, bool forwardSearch); virtual ~FindWindow(); - virtual void Quit(); virtual void MessageReceived(BMessage* msg); + virtual void Quit(); private: void _SendFindMessage(); diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp index 5c73431..67a884c 100644 --- a/src/apps/terminal/TermWindow.cpp +++ b/src/apps/terminal/TermWindow.cpp @@ -9,6 +9,7 @@ * Authors: * Kian Duffy, myob@xxxxxxxxxxxxxxxxxxxxx * Daniel Furrer, assimil8or@xxxxxxxxxxxxxxxxxxxxx + * John Scipione, jscipione@xxxxxxxxx * Siarzhuk Zharski, zharik@xxxxxx */ ############################################################################ Commit: 88c2518b233cc07ba921a287dd973ab4da61bcd2 URL: http://cgit.haiku-os.org/haiku/commit/?id=88c2518 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri May 10 04:51:57 2013 UTC Terminal: Layout the find window better ---------------------------------------------------------------------------- diff --git a/src/apps/terminal/FindWindow.cpp b/src/apps/terminal/FindWindow.cpp index dda76db..4bcd81c 100644 --- a/src/apps/terminal/FindWindow.cpp +++ b/src/apps/terminal/FindWindow.cpp @@ -21,6 +21,7 @@ #include <GroupLayoutBuilder.h> #include <Locale.h> #include <RadioButton.h> +#include <SpaceLayoutItem.h> #include <String.h> #include <TextControl.h> @@ -50,20 +51,25 @@ FindWindow::FindWindow(BMessenger messenger, const BString& str, BRadioButton* useSelection = NULL; const float spacing = be_control_look->DefaultItemSpacing(); - AddChild(BGroupLayoutBuilder(B_VERTICAL, 5.0) + AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_SMALL_SPACING) .SetInsets(spacing, spacing, spacing, spacing) - .Add(BGridLayoutBuilder() + .Add(BGridLayoutBuilder(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING) .Add(fTextRadio = new BRadioButton(B_TRANSLATE("Use text:"), new BMessage(TOGGLE_FIND_CONTROL)), 0, 0) .Add(fFindLabel = new BTextControl(NULL, NULL, NULL), 1, 0) .Add(useSelection = new BRadioButton(B_TRANSLATE("Use selection"), new BMessage(TOGGLE_FIND_CONTROL)), 0, 1)) + .Add(BSpaceLayoutItem::CreateVerticalStrut(spacing / 4)) .Add(separator) + .Add(BSpaceLayoutItem::CreateVerticalStrut(spacing / 4)) .Add(fForwardSearchBox = new BCheckBox(B_TRANSLATE("Search forward"))) .Add(fMatchCaseBox = new BCheckBox(B_TRANSLATE("Match case"))) .Add(fMatchWordBox = new BCheckBox(B_TRANSLATE("Match word"))) - .Add(fFindButton = new BButton(B_TRANSLATE("Find"), + .AddGroup(B_HORIZONTAL) + .AddGlue() + .Add(fFindButton = new BButton(B_TRANSLATE("Find"), new BMessage(MSG_FIND))) + .End() .TopView()); fFindLabel->SetDivider(0.0); ############################################################################ Revision: hrev45652 Commit: 55eb18ef2f0fe1db4c60bcceaee15c5d259ea856 URL: http://cgit.haiku-os.org/haiku/commit/?id=55eb18e Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri May 10 04:52:58 2013 UTC Terminal: Move the find window under your cursor on open moving the window back into the screen if necessary. ---------------------------------------------------------------------------- diff --git a/src/apps/terminal/FindWindow.cpp b/src/apps/terminal/FindWindow.cpp index 4bcd81c..02bd9c0 100644 --- a/src/apps/terminal/FindWindow.cpp +++ b/src/apps/terminal/FindWindow.cpp @@ -98,8 +98,6 @@ FindWindow::FindWindow(BMessenger messenger, const BString& str, fFindButton->MakeDefault(true); AddShortcut((uint32)'W', B_COMMAND_KEY, new BMessage(MSG_FIND_HIDE)); - - Show(); } diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp index 67a884c..073a697 100644 --- a/src/apps/terminal/TermWindow.cpp +++ b/src/apps/terminal/TermWindow.cpp @@ -39,6 +39,7 @@ #include <Path.h> #include <PopUpMenu.h> #include <PrintJob.h> +#include <Rect.h> #include <Roster.h> #include <Screen.h> #include <ScrollBar.h> @@ -730,9 +731,32 @@ TermWindow::MessageReceived(BMessage *message) break; case MENU_FIND_STRING: - if (!fFindPanel) { + if (fFindPanel == NULL) { fFindPanel = new FindWindow(this, fFindString, fFindSelection, fMatchWord, fMatchCase, fForwardSearch); + + // position the window under the mouse pointer + BPoint where; + uint32 buttons; + ChildAt(0)->GetMouse(&where, &buttons); + fFindPanel->MoveTo(ConvertToScreen(where)); + + // move window if outside of screen frame + BRect screenFrame = (BScreen(this)).Frame(); + BRect frame = fFindPanel->Frame(); + float extra = 30.0f; + if (frame.bottom + extra * 2 > screenFrame.bottom) { + fFindPanel->MoveBy(0, + screenFrame.bottom - frame.bottom - extra * 2); + } else if (frame.top - extra < screenFrame.top) + fFindPanel->MoveBy(0, screenFrame.top - frame.top + extra); + + if (frame.right + extra > screenFrame.right) { + fFindPanel->MoveBy(screenFrame.right - frame.right + - extra, 0); + } + + fFindPanel->Show(); } else fFindPanel->Activate(); break;