diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-10-02 18:57:10 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-10-02 18:57:10 +0300 |
commit | f1e92aca00a4859047e83fab76220767b9a2f814 (patch) | |
tree | 8aaa9d6853c6a8e0e8fc568c6f981cbd889b0cc3 /src/gui/inventorywindow.cpp | |
parent | 70b520b1e876f9698bb95baa2d274ea289a0c6bd (diff) | |
parent | 99771a1fb50286fdb0b511f425312503e657eddc (diff) | |
download | plus-f1e92aca00a4859047e83fab76220767b9a2f814.tar.gz plus-f1e92aca00a4859047e83fab76220767b9a2f814.tar.bz2 plus-f1e92aca00a4859047e83fab76220767b9a2f814.tar.xz plus-f1e92aca00a4859047e83fab76220767b9a2f814.zip |
Merge branch 'master' into strippedstripped1.1.10.2
Conflicts:
packaging/debian/watch
Diffstat (limited to 'src/gui/inventorywindow.cpp')
-rw-r--r-- | src/gui/inventorywindow.cpp | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index cd02a6732..f52151698 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); } @@ -376,6 +375,13 @@ Item *InventoryWindow::getSelectedItem() const return mItems->getSelectedItem(); } +void InventoryWindow::widgetHidden(const gcn::Event &event) +{ + Window::widgetHidden(event); + if (mItems) + mItems->hidePopup(); +} + void InventoryWindow::mouseClicked(gcn::MouseEvent &event) { Window::mouseClicked(event); @@ -666,3 +672,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; + } +} |