From 34a02000cacc2c553d11e19c09d9d11b9c46eafd Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 14 Dec 2008 21:53:44 +0100 Subject: Fixed inconsistency in default window sizes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default window sizes were all too small, since they were specified in content size. On pressing "Reset Windows", the sizes would be interpreted as such and apply alright. The inconsistency is now removed, and the default window sizes are always the size of the whole widget now, not just the contents. Signed-off-by: Bjørn Lindeijer (cherry picked from eAthena branch, commit 72f5288682f46af1f7c04c002172178c880e060b) Conflicts: src/gui/chat.cpp src/gui/equipmentwindow.cpp src/gui/inventorywindow.cpp src/gui/ministatus.cpp src/gui/setup.cpp src/gui/skill.cpp src/gui/trade.cpp src/gui/window.cpp --- src/gui/equipmentwindow.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gui/equipmentwindow.cpp') diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index aee262d0..57f0899b 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -51,7 +51,6 @@ static const int boxPosition[][2] = { }; EquipmentWindow::EquipmentWindow(Equipment *equipment): - Window(_("Equipment")), mEquipment(equipment), mBackground(NULL), -- cgit v1.2.3-70-g09d2 From fcc90586d1d1631c31b2799fdaf410af1b073cf0 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Wed, 17 Dec 2008 22:13:24 +0100 Subject: Reintroduced window name property Still used in the eAthena client and it seems saner to me to have it. --- src/gui/buy.cpp | 3 ++- src/gui/chat.cpp | 3 ++- src/gui/debugwindow.cpp | 3 ++- src/gui/equipmentwindow.cpp | 3 ++- src/gui/guildwindow.cpp | 3 ++- src/gui/help.cpp | 1 + src/gui/inventorywindow.cpp | 3 ++- src/gui/itemshortcutwindow.cpp | 3 ++- src/gui/login.cpp | 7 ++----- src/gui/magic.cpp | 3 ++- src/gui/minimap.cpp | 5 +++-- src/gui/ministatus.cpp | 3 +-- src/gui/partywindow.cpp | 3 ++- src/gui/sell.cpp | 3 ++- src/gui/skill.cpp | 3 ++- src/gui/status.cpp | 5 +++-- src/gui/trade.cpp | 3 ++- src/gui/window.cpp | 7 ++++--- src/gui/window.h | 17 +++++++++++++---- 19 files changed, 51 insertions(+), 30 deletions(-) (limited to 'src/gui/equipmentwindow.cpp') diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index a948b136..008c7bb9 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -40,6 +40,7 @@ BuyDialog::BuyDialog(): Window(_("Buy")), mMoney(0), mAmountItems(0), mMaxItems(0) { + setWindowName("Buy"); setResizable(true); setMinWidth(260); setMinHeight(230); @@ -85,7 +86,7 @@ BuyDialog::BuyDialog(): Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); - loadWindowState("Buy"); + loadWindowState(); setLocationRelativeTo(getParent()); } diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 5bd661d6..888dd27d 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -52,6 +52,7 @@ ChatWindow::ChatWindow(): Window("Chat"), mTmpVisible(false) { + setWindowName("Chat"); setResizable(true); setDefaultSize(0, windowContainer->getHeight() - 123, 600, 123); setOpaque(false); @@ -88,7 +89,7 @@ ChatWindow::ChatWindow(): mChatInput->addKeyListener(this); mCurHist = mHistory.end(); - loadWindowState("Chat"); + loadWindowState(); } ChatWindow::~ChatWindow() diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index d92c3575..36e4c8e1 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -39,10 +39,11 @@ DebugWindow::DebugWindow(): Window("Debug") { + setWindowName("Debug"); setResizable(true); setCloseButton(true); setDefaultSize(0, 0, 400, 100); - loadWindowState("Debug"); + loadWindowState(); mFPSLabel = new gcn::Label("[0 FPS]"); mFPSLabel->setPosition(0,0); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 57f0899b..6848b4d8 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -56,9 +56,10 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment): mBackground(NULL), mSelected(-1) { + setWindowName("Equipment"); setCloseButton(true); setDefaultSize(5, 195, 216, 260); - loadWindowState("Equipment"); + loadWindowState(); mUnequip = new Button(_("Unequip"), "unequip", this); gcn::Rectangle const &area = getChildrenArea(); diff --git a/src/gui/guildwindow.cpp b/src/gui/guildwindow.cpp index ae9684df..0596c75e 100644 --- a/src/gui/guildwindow.cpp +++ b/src/gui/guildwindow.cpp @@ -49,6 +49,7 @@ GuildWindow::GuildWindow(): Window(_("Guild")), mFocus(false) { + setWindowName("Guild"); setCaption(_("Guild")); setResizable(false); setCloseButton(true); @@ -73,7 +74,7 @@ GuildWindow::GuildWindow(): layout.setColWidth(0, 48); layout.setColWidth(1, 65); - loadWindowState("Guild"); + loadWindowState(); } GuildWindow::~GuildWindow() diff --git a/src/gui/help.cpp b/src/gui/help.cpp index ffe9c02d..290679b9 100644 --- a/src/gui/help.cpp +++ b/src/gui/help.cpp @@ -31,6 +31,7 @@ HelpWindow::HelpWindow(): Window("Help") { setContentSize(455, 350); + setWindowName("Help"); mBrowserBox = new BrowserBox(); mBrowserBox->setOpaque(false); diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 92b635d8..1e3c4084 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -53,6 +53,7 @@ InventoryWindow::InventoryWindow(): Window(_("Inventory")), mSplit(false) { + setWindowName("Inventory"); setResizable(false); setCloseButton(true); // LEEOR/TODO: Since this window is not resizable, do we really need to set these @@ -82,7 +83,7 @@ InventoryWindow::InventoryWindow(): layout.setColWidth(2, 48); layout.setRowHeight(0, Layout::AUTO_SET); - loadWindowState("Inventory"); + loadWindowState(); } void InventoryWindow::logic() diff --git a/src/gui/itemshortcutwindow.cpp b/src/gui/itemshortcutwindow.cpp index 1a71b11e..e21f421b 100644 --- a/src/gui/itemshortcutwindow.cpp +++ b/src/gui/itemshortcutwindow.cpp @@ -28,6 +28,7 @@ static const int SCROLL_PADDING = 0; ItemShortcutWindow::ItemShortcutWindow() { + setWindowName("ItemShortcut"); // no title presented, title bar is padding so window can be moved. gcn::Window::setTitleBarHeight(gcn::Window::getPadding()); setShowTitle(false); @@ -49,7 +50,7 @@ ItemShortcutWindow::ItemShortcutWindow() add(mScrollArea); - loadWindowState("ItemShortcut"); + loadWindowState(); } ItemShortcutWindow::~ItemShortcutWindow() diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 24c55e37..b4289984 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -71,12 +71,9 @@ LoginDialog::LoginDialog(LoginData *loginData) : Window(_("Login")), mLoginData( setLocationRelativeTo(getParent()); setVisible(true); - if (mUserField->getText().empty()) - { + if (mUserField->getText().empty()) { mUserField->requestFocus(); - } - else - { + } else { mPassField->requestFocus(); } diff --git a/src/gui/magic.cpp b/src/gui/magic.cpp index ad63f914..2c81321b 100644 --- a/src/gui/magic.cpp +++ b/src/gui/magic.cpp @@ -35,6 +35,7 @@ MagicDialog::MagicDialog(): Window(_("Magic")) { + setWindowName("Magic"); setCloseButton(true); setDefaultSize(255, 30, 175, 225); @@ -53,7 +54,7 @@ MagicDialog::MagicDialog(): update(); setLocationRelativeTo(getParent()); - loadWindowState(_("Magic")); + loadWindowState(); } MagicDialog::~MagicDialog() diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 02d20d8e..f7749755 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -34,8 +34,9 @@ Minimap::Minimap(): Window(_("MiniMap")), mMapImage(NULL) { - setDefaultSize(0, 0, 100, 100); - loadWindowState("MiniMap"); + setWindowName("MiniMap"); + setDefaultSize(5, 25, 100, 100); + loadWindowState(); // LEEOR: The Window class needs to modified to accept // setAlignment calls. setAlignment(gcn::Graphics::CENTER); diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index 424c3558..86e5a8f1 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -32,8 +32,7 @@ #include "../utils/tostring.h" -MiniStatusWindow::MiniStatusWindow(): - Window() +MiniStatusWindow::MiniStatusWindow() { setResizable(false); setMovable(false); diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp index 262e3b2e..c4a1c780 100644 --- a/src/gui/partywindow.cpp +++ b/src/gui/partywindow.cpp @@ -29,6 +29,7 @@ PartyWindow::PartyWindow() : Window(_("Party")) { + setWindowName("Party"); setVisible(false); setResizable(false); setCaption(_("Party")); @@ -37,7 +38,7 @@ PartyWindow::PartyWindow() : Window(_("Party")) setMinHeight(200); setDefaultSize(620, 300, 110, 200); - loadWindowState("Party"); + loadWindowState(); } PartyWindow::~PartyWindow() diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 30e78368..24391458 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -44,6 +44,7 @@ SellDialog::SellDialog(): Window(_("Sell")), mMaxItems(0), mAmountItems(0) { + setWindowName("Sell"); setResizable(true); setMinWidth(260); setMinHeight(230); @@ -90,7 +91,7 @@ SellDialog::SellDialog(): Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); - loadWindowState("Sell"); + loadWindowState(); setLocationRelativeTo(getParent()); } diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 2eecca55..6d747641 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -43,6 +43,7 @@ SkillDialog::SkillDialog(): Window(_("Skills")) { + setWindowName("Skills"); setCloseButton(true); setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425); @@ -69,7 +70,7 @@ SkillDialog::SkillDialog(): update(); setLocationRelativeTo(getParent()); - loadWindowState(_("Skills")); + loadWindowState(); } SkillDialog::~SkillDialog() diff --git a/src/gui/status.cpp b/src/gui/status.cpp index 43f81135..283a771b 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -36,11 +36,12 @@ StatusWindow::StatusWindow(LocalPlayer *player): Window(player->getName()), mPlayer(player) { + setWindowName("Status"); setResizable(true); setCloseButton(true); setDefaultSize((windowContainer->getWidth() - 365) / 2, - (windowContainer->getHeight() - 255) / 2, 365, 280); - loadWindowState("Status"); + (windowContainer->getHeight() - 255) / 2, 365, 275); + loadWindowState(); // ---------------------- // Status Part diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index 38064f48..7d5051c7 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -53,6 +53,7 @@ TradeWindow::TradeWindow(): mPartnerInventory(new Inventory), mStatus(PREPARING) { + setWindowName("Trade"); setResizable(true); setDefaultSize(115, 197, 332, 209); @@ -102,7 +103,7 @@ TradeWindow::TradeWindow(): layout.setColWidth(0, Layout::AUTO_SET); layout.setColWidth(1, Layout::AUTO_SET); - loadWindowState("Trade"); + loadWindowState(); } TradeWindow::~TradeWindow() diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 9dc70189..c40f8a25 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -129,7 +129,7 @@ Window::~Window() { logger->log("UNLOAD: Window::~Window(\"%s\")", getCaption().c_str()); - const std::string &name = mConfigName; + const std::string &name = mWindowName; if (!name.empty()) { // Saving X, Y and Width and Height for resizables in the config @@ -466,9 +466,10 @@ void Window::mouseDragged(gcn::MouseEvent &event) } } -void Window::loadWindowState(const std::string &name) +void Window::loadWindowState() { - mConfigName = name; + const std::string &name = mWindowName; + assert(!name.empty()); setPosition((int) config.getValue(name + "WinX", mDefaultX), (int) config.getValue(name + "WinY", mDefaultY)); diff --git a/src/gui/window.h b/src/gui/window.h index 493bce37..6f49e062 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -153,8 +153,7 @@ class Window : public gcn::Window, gcn::WidgetListener * * @return The parent window or NULL if there is none. */ - Window* - getParentWindow() { return mParent; } + Window *getParentWindow() { return mParent; } /** * Schedule this window for deletion. It will be deleted at the start @@ -191,6 +190,16 @@ class Window : public gcn::Window, gcn::WidgetListener */ void mouseExited(gcn::MouseEvent &event); + /** + * Sets the name of the window. This is not the window title. + */ + void setWindowName(const std::string &name) { mWindowName = name; } + + /** + * Returns the name of the window. This is not the window title. + */ + const std::string &getWindowName() { return mWindowName; } + /** * Reads the position (and the size for resizable windows) in the * configuration based on the given string. @@ -198,7 +207,7 @@ class Window : public gcn::Window, gcn::WidgetListener * Don't forget to set these default values and resizable before * calling this function. */ - void loadWindowState(const std::string &); + void loadWindowState(); /** * Set the default win pos and size. @@ -267,7 +276,7 @@ class Window : public gcn::Window, gcn::WidgetListener ResizeGrip *mGrip; /**< Resize grip */ Window *mParent; /**< The parent window */ Layout *mLayout; /**< Layout handler */ - std::string mConfigName; /**< Name used for saving window-related data */ + std::string mWindowName; /**< Name of the window */ bool mShowTitle; /**< Window has a title bar */ bool mModal; /**< Window is modal */ bool mCloseButton; /**< Window has a close button */ -- cgit v1.2.3-70-g09d2