summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-01-17 18:45:21 +0300
committerAndrei Karas <akaras@inbox.ru>2013-01-17 18:45:21 +0300
commitbc9712cfb34a891a64bd28b76df0f9f4e5d01513 (patch)
treef8687ee78d213e5a90572fc06b642d24f9ad28de
parent37c0c88a7b96919470a0abed8e17b3a0352ca49d (diff)
downloadmanaverse-bc9712cfb34a891a64bd28b76df0f9f4e5d01513.tar.gz
manaverse-bc9712cfb34a891a64bd28b76df0f9f4e5d01513.tar.bz2
manaverse-bc9712cfb34a891a64bd28b76df0f9f4e5d01513.tar.xz
manaverse-bc9712cfb34a891a64bd28b76df0f9f4e5d01513.zip
Fix server type dropdown in new server dialog.
-rw-r--r--src/gui/editserverdialog.cpp2
-rw-r--r--src/gui/inventorywindow.cpp2
-rw-r--r--src/gui/logindialog.cpp2
-rw-r--r--src/gui/widgets/dropdown.cpp3
-rw-r--r--src/gui/widgets/dropdown.h1
-rw-r--r--src/gui/widgets/popuplist.cpp11
-rw-r--r--src/gui/widgets/popuplist.h4
7 files changed, 18 insertions, 7 deletions
diff --git a/src/gui/editserverdialog.cpp b/src/gui/editserverdialog.cpp
index 291ce9219..bdfbdd1d5 100644
--- a/src/gui/editserverdialog.cpp
+++ b/src/gui/editserverdialog.cpp
@@ -74,7 +74,7 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent,
mOkButton(new Button(this, _("OK"), "addServer", this)),
mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
mTypeListModel(new TypeListModel),
- mTypeField(new DropDown(this, mTypeListModel)),
+ mTypeField(new DropDown(this, mTypeListModel, false, true)),
mServerDialog(parent),
mServer(server),
mIndex(index)
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index f3380a3da..8d142328c 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -108,7 +108,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory):
mSlotsBar(new ProgressBar(this, 0.0f, 100, 0, Theme::PROG_INVY_SLOTS)),
mFilter(nullptr),
mSortModel(new SortListModel),
- mSortDropDown(new DropDown(this, mSortModel, false, this, "sort")),
+ mSortDropDown(new DropDown(this, mSortModel, false, false, this, "sort")),
mNameFilter(new TextField(this, "", true, this, "namefilter", true)),
mSortDropDownCell(nullptr),
mNameFilterCell(nullptr),
diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp
index 23c80e4d3..6adaaad5d 100644
--- a/src/gui/logindialog.cpp
+++ b/src/gui/logindialog.cpp
@@ -163,7 +163,7 @@ LoginDialog::LoginDialog(LoginData *const data, std::string serverName,
mLoginData->updateHost.c_str()));
mUpdateListModel = new UpdateListModel(mLoginData);
mUpdateHostDropDown = new DropDown(this, mUpdateListModel,
- false, this, "updateselect");
+ false, false, this, "updateselect");
const std::string str = serverConfig.getValue("updateHost2", "");
if (!str.empty())
mUpdateHostDropDown->setSelectedString(str);
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index a7eb819d7..d4fde01dc 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -60,6 +60,7 @@ static std::string const dropdownFiles[2] =
DropDown::DropDown(const Widget2 *const widget,
gcn::ListModel *const listModel,
bool extended,
+ bool modal,
gcn::ActionListener *const listener,
const std::string &eventId):
gcn::ActionListener(),
@@ -70,7 +71,7 @@ DropDown::DropDown(const Widget2 *const widget,
gcn::SelectionListener(),
Widget2(widget),
mExtended(extended),
- mPopup(new PopupList(this, listModel, extended)),
+ mPopup(new PopupList(this, listModel, extended, modal)),
mShadowColor(getThemeColor(Theme::DROPDOWN_SHADOW)),
mHighlightColor(getThemeColor(Theme::HIGHLIGHT)),
mPadding(1),
diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h
index ca8b77822..30ce6692b 100644
--- a/src/gui/widgets/dropdown.h
+++ b/src/gui/widgets/dropdown.h
@@ -71,6 +71,7 @@ class DropDown final : public gcn::ActionListener,
DropDown(const Widget2 *const widget,
gcn::ListModel *const listModel = nullptr,
bool extended = false,
+ bool modal = false,
gcn::ActionListener *const listener = nullptr,
const std::string &eventId = "");
diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp
index 22b479a20..ca9ef2c7d 100644
--- a/src/gui/widgets/popuplist.cpp
+++ b/src/gui/widgets/popuplist.cpp
@@ -32,14 +32,15 @@
PopupList::PopupList(DropDown *const widget,
gcn::ListModel *const listModel,
- bool extended):
+ bool extended, bool modal):
Popup("PopupList", "popuplist.xml"),
gcn::FocusListener(),
mListModel(listModel),
mListBox(extended ? new ExtendedListBox(widget, listModel, 0) :
new ListBox(widget, listModel)),
mScrollArea(new ScrollArea(mListBox, false)),
- mDropDown(widget)
+ mDropDown(widget),
+ mModal(modal)
{
setFocusable(true);
@@ -79,6 +80,8 @@ void PopupList::show(int x, int y)
setPosition(x, y);
setVisible(true);
requestMoveToTop();
+ if (mModal)
+ requestModalFocus();
}
void PopupList::widgetResized(const gcn::Event &event)
@@ -124,6 +127,8 @@ void PopupList::mousePressed(gcn::MouseEvent& mouseEvent A_UNUSED)
if (mDropDown)
mDropDown->updateSelection();
setVisible(false);
+ if (mModal)
+ releaseModalFocus();
}
void PopupList::focusGained(const gcn::Event& event A_UNUSED)
@@ -138,6 +143,8 @@ void PopupList::focusGained(const gcn::Event& event A_UNUSED)
if (mDropDown)
mDropDown->updateSelection();
setVisible(false);
+ if (mModal)
+ releaseModalFocus();
}
void PopupList::focusLost(const gcn::Event& event A_UNUSED)
diff --git a/src/gui/widgets/popuplist.h b/src/gui/widgets/popuplist.h
index d1f49bf5c..3e3c44449 100644
--- a/src/gui/widgets/popuplist.h
+++ b/src/gui/widgets/popuplist.h
@@ -39,7 +39,8 @@ class PopupList final : public Popup,
{
public:
PopupList(DropDown *const widget,
- gcn::ListModel *const listModel, bool extended);
+ gcn::ListModel *const listModel, bool extended,
+ bool modal = false);
~PopupList();
@@ -71,6 +72,7 @@ class PopupList final : public Popup,
ListBox *mListBox;
ScrollArea *mScrollArea;
DropDown *mDropDown;
+ bool mModal;
};
#endif