summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-08-05 03:13:43 +0300
committerAndrei Karas <akaras@inbox.ru>2012-08-05 03:13:43 +0300
commite3b9d60938b1299f2f66e68ff291060654c58d66 (patch)
tree28425cf579903d6735faa801a6968b56abdc7230
parent10c8e7da87de2219fad19fd899e97257164e4830 (diff)
downloadmanaverse-e3b9d60938b1299f2f66e68ff291060654c58d66.tar.gz
manaverse-e3b9d60938b1299f2f66e68ff291060654c58d66.tar.bz2
manaverse-e3b9d60938b1299f2f66e68ff291060654c58d66.tar.xz
manaverse-e3b9d60938b1299f2f66e68ff291060654c58d66.zip
Move some hardcoded paddings to themes.
-rw-r--r--src/gui/buyselldialog.cpp5
-rw-r--r--src/gui/chatwindow.cpp2
-rw-r--r--src/gui/confirmdialog.cpp8
-rw-r--r--src/gui/didyouknowwindow.cpp5
-rw-r--r--src/gui/editdialog.cpp3
-rw-r--r--src/gui/equipmentwindow.cpp5
-rw-r--r--src/gui/helpwindow.cpp5
-rw-r--r--src/gui/okdialog.cpp3
-rw-r--r--src/gui/setup.cpp5
-rw-r--r--src/gui/shortcutwindow.cpp12
-rw-r--r--src/gui/widgets/window.cpp18
-rw-r--r--src/gui/widgets/window.h8
12 files changed, 40 insertions, 39 deletions
diff --git a/src/gui/buyselldialog.cpp b/src/gui/buyselldialog.cpp
index 429f62a85..1afcf96a1 100644
--- a/src/gui/buyselldialog.cpp
+++ b/src/gui/buyselldialog.cpp
@@ -64,7 +64,8 @@ void BuySellDialog::init()
{
N_("Buy"), N_("Sell"), N_("Cancel"), nullptr
};
- int x = 10, y = 10;
+ const int buttonPadding = getOption("buttonpadding", 10);
+ int x = buttonPadding, y = buttonPadding;
for (const char **curBtn = buttonNames; *curBtn; curBtn++)
{
@@ -73,7 +74,7 @@ void BuySellDialog::init()
mBuyButton = btn; // For focus request
btn->setPosition(x, y);
add(btn);
- x += btn->getWidth() + 10;
+ x += btn->getWidth() + buttonPadding;
}
mBuyButton->requestFocus();
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 0229f9da5..21613bc73 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -176,7 +176,7 @@ ChatWindow::ChatWindow():
setupWindow->registerWindowForReset(this);
// no title presented, title bar is padding so window can be moved.
- gcn::Window::setTitleBarHeight(gcn::Window::getPadding() + 4);
+ setTitleBarHeight(getPadding() + getTitlePadding());
setShowTitle(false);
setResizable(true);
setDefaultVisible(true);
diff --git a/src/gui/confirmdialog.cpp b/src/gui/confirmdialog.cpp
index a2fb7b6cc..e4531ac3b 100644
--- a/src/gui/confirmdialog.cpp
+++ b/src/gui/confirmdialog.cpp
@@ -73,14 +73,14 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
// 8 is the padding that GUIChan adds to button widgets
// (top and bottom combined)
- yesButton->setPosition((width - inWidth) / 2, height + 8);
+ const int buttonPadding = getOption("buttonPadding", 8);
+ yesButton->setPosition((width - inWidth) / 2, height + buttonPadding);
noButton->setPosition(yesButton->getX() + yesButton->getWidth()
- + (2 * getPadding()),
- height + 8);
+ + (2 * getPadding()), height + buttonPadding);
if (ignoreButton)
{
ignoreButton->setPosition(noButton->getX() + noButton->getWidth()
- + (2 * getPadding()), height + 8);
+ + (2 * getPadding()), height + buttonPadding);
}
add(mTextBox);
diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp
index 4a957da39..d7c44ebaa 100644
--- a/src/gui/didyouknowwindow.cpp
+++ b/src/gui/didyouknowwindow.cpp
@@ -72,11 +72,6 @@ DidYouKnowWindow::DidYouKnowWindow():
mOpenAgainCheckBox = new CheckBox(_("Auto open this window"),
config.getBoolValue("showDidYouKnow"), this, "openagain");
- mScrollArea->setDimension(gcn::Rectangle(5, 5, 445,
- 335 - okButton->getHeight()));
- okButton->setPosition(450 - okButton->getWidth(),
- 345 - okButton->getHeight());
-
mBrowserBox->setLinkHandler(this);
mBrowserBox->setFont(gui->getHelpFont());
mBrowserBox->setProcessVersion(true);
diff --git a/src/gui/editdialog.cpp b/src/gui/editdialog.cpp
index 37033af64..78ce2f8ba 100644
--- a/src/gui/editdialog.cpp
+++ b/src/gui/editdialog.cpp
@@ -53,7 +53,8 @@ EditDialog::EditDialog(const std::string &title, const std::string &msg,
mTextField->setPosition(getPadding(), getPadding());
mTextField->setWidth(width - (2 * getPadding()));
- okButton->setPosition((width - okButton->getWidth()) / 2, height + 8);
+ okButton->setPosition((width - okButton->getWidth()) / 2,
+ height + getOption("buttonPadding", 8));
add(mTextField);
add(okButton);
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 6a0397a7e..417dca680 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -99,8 +99,9 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being,
mUnequip = new Button(_("Unequip"), "unequip", this);
const gcn::Rectangle &area = getChildrenArea();
- mUnequip->setPosition(area.width - mUnequip->getWidth() - 5,
- area.height - mUnequip->getHeight() - 5);
+ const int buttonPadding = getOption("buttonPadding", 5);
+ mUnequip->setPosition(area.width - mUnequip->getWidth() - buttonPadding,
+ area.height - mUnequip->getHeight() - buttonPadding);
mUnequip->setEnabled(false);
add(mPlayerBox);
diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp
index b6a8fcd81..151e8bb63 100644
--- a/src/gui/helpwindow.cpp
+++ b/src/gui/helpwindow.cpp
@@ -64,11 +64,6 @@ HelpWindow::HelpWindow():
mScrollArea = new ScrollArea(mBrowserBox, true, "help_background.xml");
Button *okButton = new Button(_("Close"), "close", this);
- mScrollArea->setDimension(gcn::Rectangle(5, 5, 445,
- 335 - okButton->getHeight()));
- okButton->setPosition(450 - okButton->getWidth(),
- 345 - okButton->getHeight());
-
mBrowserBox->setLinkHandler(this);
mBrowserBox->setFont(gui->getHelpFont());
mBrowserBox->setProcessVersion(true);
diff --git a/src/gui/okdialog.cpp b/src/gui/okdialog.cpp
index 3259cb6d6..30a6281eb 100644
--- a/src/gui/okdialog.cpp
+++ b/src/gui/okdialog.cpp
@@ -63,7 +63,8 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg,
// 8 is the padding that GUIChan adds to button widgets
// (top and bottom combined)
- okButton->setPosition((width - okButton->getWidth()) / 2, height + 8);
+ okButton->setPosition((width - okButton->getWidth()) / 2,
+ height + getOption("buttonPadding", 8));
add(mTextBox);
add(okButton);
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index b0d2f4ec0..8fbe012e6 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -76,11 +76,12 @@ Setup::Setup():
nullptr
};
int x = width;
+ const int buttonPadding = getOption("buttonPadding", 5);
for (const char **curBtn = buttonNames; *curBtn; ++ curBtn)
{
Button *btn = new Button(gettext(*curBtn), *curBtn, this);
- x -= btn->getWidth() + 5;
- btn->setPosition(x, height - btn->getHeight() - 5);
+ x -= btn->getWidth() + buttonPadding;
+ btn->setPosition(x, height - btn->getHeight() - buttonPadding);
add(btn);
// Store this button, as it needs to be enabled/disabled
diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp
index a051705b8..7c450855a 100644
--- a/src/gui/shortcutwindow.cpp
+++ b/src/gui/shortcutwindow.cpp
@@ -59,16 +59,8 @@ ShortcutWindow::ShortcutWindow(const std::string &title,
Window("Window", false, nullptr, skinFile)
{
setWindowName(title);
- // no title presented, title bar is padding so window can be moved.
- if (mSkin)
- {
- gcn::Window::setTitleBarHeight(gcn::Window::getPadding()
- + mSkin->getTitlePadding());
- }
- else
- {
- gcn::Window::setTitleBarHeight(gcn::Window::getPadding());
- }
+ setTitleBarHeight(getPadding() + getTitlePadding());
+
setShowTitle(false);
setResizable(true);
setDefaultVisible(false);
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index bfb4d883c..685d64155 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -1023,11 +1023,16 @@ gcn::Rectangle Window::getWindowArea()
getHeight() - getPadding() * 2);
}
-int Window::getOption(std::string name)
+int Window::getOption(std::string name, int def)
{
if (mSkin)
- return mSkin->getOption(name);
- return 0;
+ {
+ int val = mSkin->getOption(name);
+ if (val)
+ return val;
+ return def;
+ }
+ return def;
}
bool Window::getOptionBool(std::string name)
@@ -1036,3 +1041,10 @@ bool Window::getOptionBool(std::string name)
return mSkin->getOption(name) != 0;
return 0;
}
+
+int Window::getTitlePadding()
+{
+ if (mSkin)
+ mSkin->getTitlePadding();
+ return 4;
+}
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index 12c40859a..00e3a817f 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -399,12 +399,14 @@ class Window : public gcn::Window, gcn::WidgetListener
void setCaptionFont(gcn::Font *font)
{ mCaptionFont = font; }
- int getOption(std::string name);
+ protected:
+ bool canMove();
+
+ int getOption(std::string name, int def = 0);
bool getOptionBool(std::string name);
- protected:
- bool canMove();
+ int getTitlePadding();
Skin *mSkin; /**< Skin in use by this window */