diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-01-05 15:47:31 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-01-05 15:47:31 +0300 |
commit | 5aa5429c62096034769ffdaef92a0fcb5db08301 (patch) | |
tree | 15fb060f619c30c4e7349e2d18f3cf6cfba05928 /src | |
parent | ad3a223908a77d42ee97ef28b598e3c831bee7d1 (diff) | |
download | manaverse-5aa5429c62096034769ffdaef92a0fcb5db08301.tar.gz manaverse-5aa5429c62096034769ffdaef92a0fcb5db08301.tar.bz2 manaverse-5aa5429c62096034769ffdaef92a0fcb5db08301.tar.xz manaverse-5aa5429c62096034769ffdaef92a0fcb5db08301.zip |
Allow set pressed item in widgetgroup and child objects.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/radiogroup.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/radiogroup.h | 3 | ||||
-rw-r--r-- | src/gui/widgets/tabstrip.cpp | 11 | ||||
-rw-r--r-- | src/gui/widgets/tabstrip.h | 9 | ||||
-rw-r--r-- | src/gui/widgets/widgetgroup.cpp | 10 | ||||
-rw-r--r-- | src/gui/widgets/widgetgroup.h | 9 |
6 files changed, 31 insertions, 14 deletions
diff --git a/src/gui/widgets/radiogroup.cpp b/src/gui/widgets/radiogroup.cpp index bfdb64f6e..b9aa16dae 100644 --- a/src/gui/widgets/radiogroup.cpp +++ b/src/gui/widgets/radiogroup.cpp @@ -31,7 +31,8 @@ RadioGroup::RadioGroup(const Widget2 *const widget, { } -Widget *RadioGroup::createWidget(const std::string &text) const +Widget *RadioGroup::createWidget(const std::string &text, + const bool pressed A_UNUSED) const { RadioButton *const widget = new RadioButton( this, text, mGroup, mCount == 0); diff --git a/src/gui/widgets/radiogroup.h b/src/gui/widgets/radiogroup.h index 77aa4228d..7cb1689c5 100644 --- a/src/gui/widgets/radiogroup.h +++ b/src/gui/widgets/radiogroup.h @@ -33,7 +33,8 @@ class RadioGroup final : public WidgetGroup A_DELETE_COPY(RadioGroup) - Widget *createWidget(const std::string &name) + Widget *createWidget(const std::string &name, + const bool pressed = false) const override final A_WARN_UNUSED; }; diff --git a/src/gui/widgets/tabstrip.cpp b/src/gui/widgets/tabstrip.cpp index 5dac11926..d3f334e8a 100644 --- a/src/gui/widgets/tabstrip.cpp +++ b/src/gui/widgets/tabstrip.cpp @@ -28,7 +28,8 @@ TabStrip::TabStrip(const Widget2 *const widget, const std::string &group, const int height, const int spacing) : - WidgetGroup(widget, group, height, spacing) + WidgetGroup(widget, group, height, spacing), + mPressFirst(true) { mAllowLogic = false; } @@ -36,18 +37,20 @@ TabStrip::TabStrip(const Widget2 *const widget, TabStrip::TabStrip(const Widget2 *const widget, const int height, const int spacing) : - WidgetGroup(widget, "", height, spacing) + WidgetGroup(widget, "", height, spacing), + mPressFirst(true) { mAllowLogic = false; } -Widget *TabStrip::createWidget(const std::string &text) const +Widget *TabStrip::createWidget(const std::string &text, + const bool pressed) const { Button *const widget = new Button(this); widget->setStick(true); widget->setCaption(text); widget->adjustSize(); - if (!mCount) + if ((!mCount && mPressFirst) || pressed) widget->setPressed(true); widget->setTag(static_cast<int>(mWidgets.size())); return widget; diff --git a/src/gui/widgets/tabstrip.h b/src/gui/widgets/tabstrip.h index 31877cb42..a041bad11 100644 --- a/src/gui/widgets/tabstrip.h +++ b/src/gui/widgets/tabstrip.h @@ -37,7 +37,8 @@ class TabStrip final : public WidgetGroup A_DELETE_COPY(TabStrip) - Widget *createWidget(const std::string &name) + Widget *createWidget(const std::string &name, + const bool pressed = false) const override final A_WARN_UNUSED; void action(const ActionEvent &event) override final; @@ -45,6 +46,12 @@ class TabStrip final : public WidgetGroup void nextTab(); void prevTab(); + + void setPressFirst(const bool press) + { mPressFirst = press; } + + protected: + bool mPressFirst; }; #endif // GUI_WIDGETS_TABSTRIP_H diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp index 1e5c81bed..3cddc625a 100644 --- a/src/gui/widgets/widgetgroup.cpp +++ b/src/gui/widgets/widgetgroup.cpp @@ -38,18 +38,20 @@ WidgetGroup::WidgetGroup(const Widget2 *const widget, addWidgetListener(this); } -void WidgetGroup::addButton(const std::string &tag) +void WidgetGroup::addButton(const std::string &tag, + const bool pressed) { - addButton(tag, tag); + addButton(tag, tag, pressed); } void WidgetGroup::addButton(const std::string &restrict text, - const std::string &restrict tag) + const std::string &restrict tag, + const bool pressed) { if (text.empty() || tag.empty()) return; - Widget *const widget = createWidget(text); + Widget *const widget = createWidget(text, pressed); if (widget) { widget->setActionEventId(mActionEventId + tag); diff --git a/src/gui/widgets/widgetgroup.h b/src/gui/widgets/widgetgroup.h index 463145dde..ef6c26629 100644 --- a/src/gui/widgets/widgetgroup.h +++ b/src/gui/widgets/widgetgroup.h @@ -35,10 +35,12 @@ class WidgetGroup notfinal : public Container, public: A_DELETE_COPY(WidgetGroup) - virtual void addButton(const std::string &tag); + virtual void addButton(const std::string &tag, + const bool pressed = false); virtual void addButton(const std::string &restrict text, - const std::string &restrict tag); + const std::string &restrict tag, + const bool pressed = false); void action(const ActionEvent &event) override; @@ -49,7 +51,8 @@ class WidgetGroup notfinal : public Container, void widgetResized(const Event &event) override final; - virtual Widget *createWidget(const std::string &name) + virtual Widget *createWidget(const std::string &name, + const bool pressed = false) const A_WARN_UNUSED = 0; protected: |