summaryrefslogtreecommitdiff
path: root/src/gui/inventorywindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-09-20 22:19:45 +0300
committerAndrei Karas <akaras@inbox.ru>2011-09-20 22:19:45 +0300
commit8138d0e61f633546263df94473e91d500ada9c0e (patch)
treecc0f9b2290964c017ad1c0981a429d733a406e3e /src/gui/inventorywindow.cpp
parent5f2ee9e2f8c8d313de85df08abdc2a7f7396995f (diff)
downloadplus-8138d0e61f633546263df94473e91d500ada9c0e.tar.gz
plus-8138d0e61f633546263df94473e91d500ada9c0e.tar.bz2
plus-8138d0e61f633546263df94473e91d500ada9c0e.tar.xz
plus-8138d0e61f633546263df94473e91d500ada9c0e.zip
Auto hide filter in invetory if window size too small.
Diffstat (limited to 'src/gui/inventorywindow.cpp')
-rw-r--r--src/gui/inventorywindow.cpp55
1 files changed, 43 insertions, 12 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index cd02a6732..35165a16a 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -99,7 +99,8 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
Window("Inventory", false, 0, "inventory.xml"),
mInventory(inventory),
mDropButton(0),
- mSplit(false)
+ mSplit(false),
+ mCompactMode(false)
{
if (inventory)
{
@@ -146,7 +147,6 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
mSortDropDown->setSelected(0);
mFilterLabel = new Label(_("Filter:"));
- mSorterLabel = new Label(_("Sort:"));
mNameFilter = new TextField("", true, this, "namefilter", true);
std::vector<std::string> tags = ItemDB::getTags();
@@ -181,13 +181,12 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
place(0, 0, mWeightLabel, 1).setPadding(3);
place(1, 0, mWeightBar, 3);
place(4, 0, mSlotsLabel, 1).setPadding(3);
- place(5, 0, mSlotsBar, 2);
- place(7, 0, mSorterLabel, 1);
- place(8, 0, mSortDropDown, 3);
+ mSlotsBarCell = &place(5, 0, mSlotsBar, 3);
+ mSortDropDownCell = &place(8, 0, mSortDropDown, 3);
place(0, 1, mFilterLabel, 1).setPadding(3);
- place(1, 1, mFilter, 7).setPadding(3);
- place(8, 1, mNameFilter, 3);
+ mFilterCell = &place(1, 1, mFilter, 8).setPadding(3);
+ mNameFilterCell = &place(8, 1, mNameFilter, 3);
place(0, 2, invenScroll, 11).setPadding(3);
place(0, 3, mUseButton);
@@ -206,13 +205,12 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
mCloseButton = new Button(_("Close"), "close", this);
place(0, 0, mSlotsLabel).setPadding(3);
- place(1, 0, mSlotsBar, 4);
- place(5, 0, mSorterLabel, 1);
- place(6, 0, mSortDropDown, 1);
+ mSlotsBarCell = &place(1, 0, mSlotsBar, 5);
+ mSortDropDownCell = &place(6, 0, mSortDropDown, 1);
place(0, 1, mFilterLabel, 1).setPadding(3);
- place(1, 1, mFilter, 5).setPadding(3);
- place(6, 1, mNameFilter, 1);
+ mFilterCell = &place(1, 1, mFilter, 6).setPadding(3);
+ mNameFilterCell = &place(6, 1, mNameFilter, 1);
place(0, 2, invenScroll, 7, 4);
place(0, 6, mStoreButton);
@@ -240,6 +238,7 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
loadWindowState();
slotsChanged(mInventory);
+ widgetResized(0);
if (!isMainInventory())
setVisible(true);
}
@@ -666,3 +665,35 @@ bool InventoryWindow::isAnyInputFocused()
}
return false;
}
+
+void InventoryWindow::widgetResized(const gcn::Event &event)
+{
+ Window::widgetResized(event);
+
+ if (!isMainInventory())
+ return;
+
+ if (getWidth() < 600)
+ {
+ if (!mCompactMode)
+ {
+ mSortDropDown->setVisible(false);
+ mNameFilter->setVisible(false);
+ mSortDropDownCell->setType(LayoutCell::NONE);
+ mNameFilterCell->setType(LayoutCell::NONE);
+ mFilterCell->setWidth(mFilterCell->getWidth() + 3);
+ mSlotsBarCell->setWidth(mSlotsBarCell->getWidth() + 3);
+ mCompactMode = true;
+ }
+ }
+ else if (mCompactMode)
+ {
+ mSortDropDown->setVisible(true);
+ mNameFilter->setVisible(true);
+ mSortDropDownCell->setType(LayoutCell::WIDGET);
+ mNameFilterCell->setType(LayoutCell::WIDGET);
+ mFilterCell->setWidth(mFilterCell->getWidth() - 3);
+ mSlotsBarCell->setWidth(mSlotsBarCell->getWidth() - 3);
+ mCompactMode = false;
+ }
+}