summaryrefslogtreecommitdiff
path: root/src/gui/windows/maileditwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/windows/maileditwindow.cpp')
-rw-r--r--src/gui/windows/maileditwindow.cpp62
1 files changed, 38 insertions, 24 deletions
diff --git a/src/gui/windows/maileditwindow.cpp b/src/gui/windows/maileditwindow.cpp
index e7fad6aab..bc2574c64 100644
--- a/src/gui/windows/maileditwindow.cpp
+++ b/src/gui/windows/maileditwindow.cpp
@@ -25,6 +25,8 @@
#include "being/playerinfo.h"
+#include "enums/gui/layouttype.h"
+
#include "gui/windows/inventorywindow.h"
#include "gui/windows/itemamountwindow.h"
@@ -33,6 +35,7 @@
#include "gui/widgets/inttextfield.h"
#include "gui/widgets/itemcontainer.h"
#include "gui/widgets/label.h"
+#include "gui/widgets/layout.h"
#include "gui/widgets/scrollarea.h"
#include "resources/item/item.h"
@@ -67,7 +70,7 @@ MailEditWindow::MailEditWindow() :
// TRANSLATORS: mail edit window label
mMoneyLabel(new Label(this, _("Money:"))),
// TRANSLATORS: mail edit window label
- mItemLabel(new Label(this, _("Item:"))),
+ mItemLabel(new Label(this, _("Items:"))),
// TRANSLATORS: mail edit window label
mMessageLabel(new Label(this, _("Message:"))),
mToField(new TextField(this, std::string(), LoseFocusOnTab_true,
@@ -95,35 +98,46 @@ MailEditWindow::MailEditWindow() :
setStickyButtonLock(true);
setVisible(Visible_true);
- setDefaultSize(380, 200, ImagePosition::CENTER, 0, 0);
- setMinWidth(200);
- setMinHeight(200);
- center();
-
- ContainerPlacer placer(nullptr, nullptr);
- placer = getPlacer(0, 0);
-
mToField->setWidth(100);
mSubjectField->setWidth(100);
mMessageField->setWidth(100);
- mItemScrollArea->setHeight(100);
+ // 1x3 items (current ML limit) times some padding
+ // + a handful of pixels to cover scrollbar/padding
+ mItemScrollArea->setHeight(43); // same as itemcontainer default
+ mItemScrollArea->setWidth(3 * (32 + 2) + 5 + 10);
mItemScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
mToField->addFocusListener(this);
- placer(0, 0, mToLabel, 1, 1);
- placer(1, 0, mToField, 3, 1);
- placer(0, 1, mSubjectLabel, 1, 1);
- placer(1, 1, mSubjectField, 3, 1);
- placer(0, 2, mMoneyLabel, 1, 1);
- placer(1, 2, mMoneyField, 3, 1);
- placer(0, 3, mItemLabel, 1, 1);
- placer(1, 3, mItemScrollArea, 2, 2);
- placer(3, 4, mAddButton, 1, 1);
-
- placer(0, 5, mMessageLabel, 1, 1);
- placer(1, 5, mMessageField, 3, 1);
- placer(0, 6, mSendButton, 1, 1);
- placer(3, 6, mCloseButton, 1, 1);
+ place(0, 0, mToLabel);
+ place(1, 0, mToField, 2, 1);
+ place(0, 1, mSubjectLabel);
+ place(1, 1, mSubjectField, 2, 1);
+ place(0, 2, mMoneyLabel);
+ place(1, 2, mMoneyField, 2, 1);
+ place(0, 3, mItemLabel);
+ place(1, 3, mItemScrollArea, 1, 2);
+ place(2, 4, mAddButton);
+
+ place(0, 5, mMessageLabel);
+ place(1, 5, mMessageField, 2, 1);
+ place(0, 6, mSendButton);
+ place(2, 6, mCloseButton);
+
+ Layout &layout = getLayout();
+ // mid column shall eat all remaining available window space.
+ layout.setColWidth(1, LayoutType::SET);
+ layout.setRowHeight(3, LayoutType::SET);
+
+ // Enforce a minimum size.
+ int width = 0;
+ int height = 0;
+ layout.reflow(width, height);
+ setContentSize(width, height);
+
+ setMinWidth(getWidth());
+ setMinHeight(getHeight());
+ setDefaultSize(getWidth(), getHeight(), ImagePosition::CENTER, 0, 0);
+ center();
loadWindowState();
if (mUseMail2)