diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-04-02 19:07:14 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-04-02 19:07:14 +0000 |
commit | 43d51d4a7c00bb425d004acf7eeb5e4aa4e969b0 (patch) | |
tree | 1a497ed7219d0450a0b33baf6a20d4b48f6b5404 /src/gui | |
parent | e89ecd460dd2aa14aa7fd01292628fb74cb34692 (diff) | |
download | mana-43d51d4a7c00bb425d004acf7eeb5e4aa4e969b0.tar.gz mana-43d51d4a7c00bb425d004acf7eeb5e4aa4e969b0.tar.bz2 mana-43d51d4a7c00bb425d004acf7eeb5e4aa4e969b0.tar.xz mana-43d51d4a7c00bb425d004acf7eeb5e4aa4e969b0.zip |
Added ConfigListener class to allow listening for changes to config options,
and added a GUI opacity slider to the setup window that utilizes this.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/setup.cpp | 20 | ||||
-rw-r--r-- | src/gui/setup.h | 1 | ||||
-rw-r--r-- | src/gui/window.cpp | 16 | ||||
-rw-r--r-- | src/gui/window.h | 8 |
4 files changed, 41 insertions, 4 deletions
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 4502dbac..85aa900d 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -107,7 +107,8 @@ Setup::Setup(): disabledRadio = new RadioButton("Disabled", "Modes", false); applyButton = new Button("Apply"); cancelButton = new Button("Cancel"); - //alphaSlider = new Slider(1.0); + alphaLabel = new gcn::Label("GUI opacity:"); + alphaSlider = new Slider(0.2, 1.0); // Set selections last_sel = 0; @@ -116,6 +117,7 @@ Setup::Setup(): // Set events applyButton->setEventId("apply"); cancelButton->setEventId("cancel"); + alphaSlider->setEventId("guialpha"); // Set dimensions/positions setContentSize(240, 216); @@ -132,10 +134,14 @@ Setup::Setup(): fsCheckBox->setPosition(120, 36); soundCheckBox->setPosition(10, 130); disabledRadio->setPosition(10, 140); + alphaLabel->setPosition(10, 157); + alphaSlider->setDimension(gcn::Rectangle( + alphaLabel->getWidth() + 20, 160, 100, 10)); // Listen for actions applyButton->addActionListener(this); cancelButton->addActionListener(this); + alphaSlider->addActionListener(this); // Assemble dialog add(scrollArea); @@ -146,7 +152,8 @@ Setup::Setup(): //add(disabledRadio); add(applyButton); add(cancelButton); - //add(alphaSlider); + add(alphaLabel); + add(alphaSlider); setLocationRelativeTo(getParent()); @@ -156,6 +163,7 @@ Setup::Setup(): fsCheckBox->setMarked(true); } soundCheckBox->setMarked(config.getValue("sound", 0)); + alphaSlider->setValue(config.getValue("guialpha", 0.8)); } Setup::~Setup() @@ -169,11 +177,17 @@ Setup::~Setup() delete displayLabel; delete applyButton; delete cancelButton; + delete alphaLabel; + delete alphaSlider; } void Setup::action(const std::string &eventId) { - if (eventId == "apply") + if (eventId == "guialpha") + { + config.setValue("guialpha", alphaSlider->getValue()); + } + else if (eventId == "apply") { setVisible(false); diff --git a/src/gui/setup.h b/src/gui/setup.h index a7ed422e..7a38bfd5 100644 --- a/src/gui/setup.h +++ b/src/gui/setup.h @@ -77,6 +77,7 @@ class Setup : public Window, public gcn::ActionListener { gcn::ListBox *modeList; gcn::Button *applyButton; gcn::Button *cancelButton; + gcn::Label *alphaLabel; gcn::Slider *alphaSlider; // Video selections diff --git a/src/gui/window.cpp b/src/gui/window.cpp index ab37dae8..c24b50ab 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -73,6 +73,7 @@ Window::Window(const std::string& caption, bool modal, Window *parent): // Set GUI alpha level dBackground->setAlpha(guiAlpha); dBorders->setAlpha(guiAlpha); + config.addListener("guialpha", this); } Window::~Window() @@ -84,6 +85,7 @@ Window::~Window() //release_bitmap(dMid); //release_bitmap(dRight); + config.removeListener("guialpha", this); delete chrome; } @@ -196,3 +198,17 @@ void Window::mouseMotion(int mx, int my) setPosition(x, y); } } + +void Window::optionChanged(const std::string &name) +{ + if (name == "guialpha") + { + guiAlpha = config.getValue("guialpha", 0.8); + + if (dBackground->getAlpha() != guiAlpha) + { + dBackground->setAlpha(guiAlpha); + dBorders->setAlpha(guiAlpha); + } + } +} diff --git a/src/gui/window.h b/src/gui/window.h index 126fe2f4..972c58cd 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -29,13 +29,14 @@ #include "windowcontainer.h" #include "../resources/image.h" #include "../graphics.h" +#include "../configuration.h" /** * A window. This window can be dragged around and has a title bar. * * \ingroup GUI */ -class Window : public gcn::Window +class Window : public gcn::Window, public ConfigListener { protected: gcn::Container *chrome; /**< Contained container */ @@ -134,6 +135,11 @@ class Window : public gcn::Window * dragged outside of the screen. */ void mouseMotion(int mx, int my); + + /** + * Called when an config option changes. + */ + void optionChanged(const std::string &name); }; #endif |