Mail: layout-ify the Find panel

Fixes #13163

Change-Id: I2880b3dcd824087ee998a5dd67c5e9d904b5874d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2629
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Adrien Destugues
2020-05-09 19:43:07 +00:00
committed by waddlesplash
parent 2b4c59635f
commit 5ef5cba68a
2 changed files with 23 additions and 21 deletions
+20 -18
View File
@@ -46,6 +46,7 @@ of their respective holders. All rights reserved.
#include <Box.h> #include <Box.h>
#include <Button.h> #include <Button.h>
#include <Catalog.h> #include <Catalog.h>
#include <LayoutBuilder.h>
#include <Locale.h> #include <Locale.h>
#include <String.h> #include <String.h>
#include <TextView.h> #include <TextView.h>
@@ -99,31 +100,30 @@ void FindWindow::DoFind(BWindow* window, const char* text)
} }
FindPanel::FindPanel(BRect rect) FindPanel::FindPanel()
: :
BBox(rect, "FindPanel", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW) BGroupView("FindPanel", B_VERTICAL)
{ {
BRect r = Bounds().InsetByCopy(10, 10); fTextControl = new BTextControl("BTextControl", NULL,
sPreviousFind.String(), new BMessage(M_FIND_STRING_CHANGED));
fTextControl = new BTextControl(r, "BTextControl", NULL,
sPreviousFind.String(), new BMessage(M_FIND_STRING_CHANGED),
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
fTextControl->SetModificationMessage(new BMessage(M_FIND_STRING_CHANGED)); fTextControl->SetModificationMessage(new BMessage(M_FIND_STRING_CHANGED));
fTextControl->SetText(sPreviousFind.String()); fTextControl->SetText(sPreviousFind.String());
fTextControl->MakeFocus(); fTextControl->MakeFocus();
AddChild(fTextControl);
fFindButton = new BButton(BRect(0, 0, 90, 20),"FINDBUTTON", fFindButton = new BButton("FINDBUTTON", B_TRANSLATE("Find"),
B_TRANSLATE("Find"), new BMessage(FINDBUTTON));
new BMessage(FINDBUTTON),B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
fFindButton->ResizeToPreferred();
AddChild(fFindButton);
r = fFindButton->Bounds();
fFindButton->MoveTo(Bounds().right - r.Width() - 8,
Bounds().bottom - r.Height() - 8);
fFindButton->SetEnabled(sPreviousFind.Length()); fFindButton->SetEnabled(sPreviousFind.Length());
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_WINDOW_SPACING)
.Add(fTextControl)
.AddGroup(B_HORIZONTAL)
.AddGlue()
.Add(fFindButton)
.End()
.End();
} }
@@ -218,9 +218,11 @@ void FindPanel::Find()
FindWindow::FindWindow() FindWindow::FindWindow()
: BWindow(FindWindow::fLastPosition, B_TRANSLATE("Find"), : BWindow(FindWindow::fLastPosition, B_TRANSLATE("Find"),
B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE
| B_WILL_ACCEPT_FIRST_CLICK | B_CLOSE_ON_ESCAPE) | B_WILL_ACCEPT_FIRST_CLICK | B_CLOSE_ON_ESCAPE
| B_AUTO_UPDATE_SIZE_LIMITS)
{ {
fFindPanel = new FindPanel(Bounds()); SetLayout(new BGroupLayout(B_VERTICAL));
fFindPanel = new FindPanel();
AddChild(fFindPanel); AddChild(fFindPanel);
fFindWindow = this; fFindWindow = this;
Show(); Show();
+3 -3
View File
@@ -40,7 +40,7 @@ All rights reserved.
#define _FINDWINDOW_H #define _FINDWINDOW_H
#include <AppDefs.h> #include <AppDefs.h>
#include <Box.h> #include <GroupView.h>
#include <TextControl.h> #include <TextControl.h>
#include <Window.h> #include <Window.h>
@@ -73,9 +73,9 @@ protected:
}; };
class FindPanel : public BBox { class FindPanel : public BGroupView {
public: public:
FindPanel(BRect rect); FindPanel();
virtual ~FindPanel(); virtual ~FindPanel();
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void MessageReceived(BMessage* msg); virtual void MessageReceived(BMessage* msg);