summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-03-17 15:54:50 +0300
committerAndrei Karas <akaras@inbox.ru>2014-03-17 15:54:50 +0300
commit37597422a0d458a224fed0258d093f7a7e400041 (patch)
tree61996595f7a39351635bdad0172deb5855aa8776
parent794ebb9ccd1b6605a03fee438abc1e4f2f7966c9 (diff)
downloadmv-37597422a0d458a224fed0258d093f7a7e400041.tar.gz
mv-37597422a0d458a224fed0258d093f7a7e400041.tar.bz2
mv-37597422a0d458a224fed0258d093f7a7e400041.tar.xz
mv-37597422a0d458a224fed0258d093f7a7e400041.zip
Exclude useless logic methods calls.
-rw-r--r--src/gui/widgets/basiccontainer.cpp51
-rw-r--r--src/gui/widgets/basiccontainer.h4
-rw-r--r--src/gui/widgets/browserbox.cpp2
-rw-r--r--src/gui/widgets/button.cpp1
-rw-r--r--src/gui/widgets/checkbox.cpp1
-rw-r--r--src/gui/widgets/dropdown.cpp1
-rw-r--r--src/gui/widgets/emotepage.cpp1
-rw-r--r--src/gui/widgets/guitable.cpp1
-rw-r--r--src/gui/widgets/icon.cpp2
-rw-r--r--src/gui/widgets/itemcontainer.cpp1
-rw-r--r--src/gui/widgets/label.cpp1
-rw-r--r--src/gui/widgets/playerbox.cpp1
-rw-r--r--src/gui/widgets/popuplist.cpp2
-rw-r--r--src/gui/widgets/radiobutton.cpp1
-rw-r--r--src/gui/widgets/shortcutcontainer.cpp1
-rw-r--r--src/gui/widgets/slider.cpp1
-rw-r--r--src/gui/widgets/sliderlist.cpp1
-rw-r--r--src/gui/widgets/tabstrip.cpp2
-rw-r--r--src/gui/widgets/textbox.cpp1
-rw-r--r--src/gui/widgets/textfield.cpp1
-rw-r--r--src/gui/widgets/textpreview.cpp1
-rw-r--r--src/gui/widgets/widget.cpp3
-rw-r--r--src/gui/widgets/widget.h7
-rw-r--r--src/gui/widgets/windowcontainer.cpp34
24 files changed, 98 insertions, 24 deletions
diff --git a/src/gui/widgets/basiccontainer.cpp b/src/gui/widgets/basiccontainer.cpp
index 7032cd981..60c6ac336 100644
--- a/src/gui/widgets/basiccontainer.cpp
+++ b/src/gui/widgets/basiccontainer.cpp
@@ -80,6 +80,15 @@ void BasicContainer::moveToTop(Widget* widget)
{
mWidgets.erase(iter);
mWidgets.push_back(widget);
+ break;
+ }
+ }
+ FOR_EACH (WidgetListIterator, iter, mLogicWidgets)
+ {
+ if (*iter == widget)
+ {
+ mLogicWidgets.erase(iter);
+ mLogicWidgets.push_back(widget);
return;
}
}
@@ -89,23 +98,32 @@ void BasicContainer::moveToBottom(Widget* widget)
{
WidgetListIterator iter = std::find(mWidgets.begin(),
mWidgets.end(), widget);
+ if (iter != mWidgets.end())
+ {
+ mWidgets.erase(iter);
+ mWidgets.insert(mWidgets.begin(), widget);
+ }
- if (iter == mWidgets.end())
- return;
-
- mWidgets.erase(iter);
- mWidgets.insert(mWidgets.begin(), widget);
+ WidgetListIterator iter2 = std::find(mLogicWidgets.begin(),
+ mLogicWidgets.end(), widget);
+ if (iter2 != mLogicWidgets.end())
+ {
+ mLogicWidgets.erase(iter2);
+ mLogicWidgets.insert(mLogicWidgets.begin(), widget);
+ }
}
void BasicContainer::death(const Event &event)
{
WidgetListIterator iter = std::find(mWidgets.begin(),
mWidgets.end(), event.getSource());
+ if (iter != mWidgets.end())
+ mWidgets.erase(iter);
- if (iter == mWidgets.end())
- return;
-
- mWidgets.erase(iter);
+ WidgetListIterator iter2 = std::find(mLogicWidgets.begin(),
+ mLogicWidgets.end(), event.getSource());
+ if (iter2 != mLogicWidgets.end())
+ mLogicWidgets.erase(iter2);
}
Rect BasicContainer::getChildrenArea()
@@ -215,9 +233,11 @@ void BasicContainer::_setFocusHandler(FocusHandler *const focusHandler)
(*iter)->_setFocusHandler(focusHandler);
}
-void BasicContainer::add(Widget* widget)
+void BasicContainer::add(Widget *const widget)
{
mWidgets.push_back(widget);
+ if (widget->isAllowLogic())
+ mLogicWidgets.push_back(widget);
if (!mInternalFocusHandler)
widget->_setFocusHandler(_getFocusHandler());
@@ -241,6 +261,14 @@ void BasicContainer::remove(Widget* widget)
return;
}
}
+ FOR_EACH (WidgetListIterator, iter, mLogicWidgets)
+ {
+ if (*iter == widget)
+ {
+ mLogicWidgets.erase(iter);
+ return;
+ }
+ }
}
void BasicContainer::clear()
@@ -254,6 +282,7 @@ void BasicContainer::clear()
}
mWidgets.clear();
+ mLogicWidgets.clear();
}
void BasicContainer::drawChildren(Graphics* graphics)
@@ -299,7 +328,7 @@ void BasicContainer::drawChildren(Graphics* graphics)
void BasicContainer::logicChildren()
{
BLOCK_START("BasicContainer::logicChildren")
- FOR_EACH (WidgetListConstIterator, iter, mWidgets)
+ FOR_EACH (WidgetListConstIterator, iter, mLogicWidgets)
(*iter)->logic();
BLOCK_END("BasicContainer::logicChildren")
}
diff --git a/src/gui/widgets/basiccontainer.h b/src/gui/widgets/basiccontainer.h
index 3e3976a70..2d8a9beee 100644
--- a/src/gui/widgets/basiccontainer.h
+++ b/src/gui/widgets/basiccontainer.h
@@ -140,7 +140,7 @@ class BasicContainer : public Widget,
* @param widget The widget to add.
* @see remove, clear
*/
- void add(Widget* widget);
+ void add(Widget *const widget);
/**
* Removes a widget from the basic container.
@@ -199,6 +199,8 @@ class BasicContainer : public Widget,
* Holds all widgets of the basic container.
*/
WidgetList mWidgets;
+
+ WidgetList mLogicWidgets;
};
#endif // GUI_WIDGETS_BASICCONTAINER_H
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 010d3d9f3..c344d8d41 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -83,6 +83,8 @@ BrowserBox::BrowserBox(const Widget2 *const widget,
mEnableKeys(false),
mEnableTabs(false)
{
+ mAllowLogic = false;
+
setFocusable(true);
addMouseListener(this);
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 8ac4251cf..a718fe70c 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -327,6 +327,7 @@ Button::Button(const Widget2 *const widget,
void Button::init()
{
+ mAllowLogic = false;
addMouseListener(this);
addKeyListener(this);
addFocusListener(this);
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index c44c88980..3816fe436 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -98,6 +98,7 @@ CheckBox::CheckBox(const Widget2 *const widget,
mDrawBox(true)
{
setCaption(caption);
+ mAllowLogic = false;
setFocusable(true);
addMouseListener(this);
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 53f4a623b..7173e04b4 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -78,6 +78,7 @@ DropDown::DropDown(const Widget2 *const widget,
mPushed(false),
mIsDragged(false)
{
+ mAllowLogic = false;
mPopup->postInit();
mFrameSize = 2;
mForegroundColor2 = getThemeColor(Theme::DROPDOWN_OUTLINE);
diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp
index 139082815..9000c147b 100644
--- a/src/gui/widgets/emotepage.cpp
+++ b/src/gui/widgets/emotepage.cpp
@@ -45,6 +45,7 @@ EmotePage::EmotePage(const Widget2 *const widget) :
{
addMouseListener(this);
addWidgetListener(this);
+ mAllowLogic = false;
}
EmotePage::~EmotePage()
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index dc097c031..c7964d3c6 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -110,6 +110,7 @@ GuiTable::GuiTable(const Widget2 *const widget,
mOpaque(opacity),
mSelectable(true)
{
+ mAllowLogic = false;
mBackgroundColor = getThemeColor(Theme::BACKGROUND);
setModel(initial_model);
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
index 9a86fc9bf..3ffac4a7d 100644
--- a/src/gui/widgets/icon.cpp
+++ b/src/gui/widgets/icon.cpp
@@ -39,6 +39,7 @@ Icon::Icon(const Widget2 *const widget,
const SDL_Rect &bounds = mImage->mBounds;
setSize(bounds.w, bounds.h);
}
+ mAllowLogic = false;
}
Icon::Icon(const Widget2 *const widget,
@@ -51,6 +52,7 @@ Icon::Icon(const Widget2 *const widget,
const SDL_Rect &bounds = mImage->mBounds;
setSize(bounds.w, bounds.h);
}
+ mAllowLogic = false;
}
Icon::~Icon()
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index ecabc226f..3fba41750 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -196,6 +196,7 @@ ItemContainer::ItemContainer(const Widget2 *const widget,
addKeyListener(this);
addMouseListener(this);
addWidgetListener(this);
+ mAllowLogic = false;
}
ItemContainer::~ItemContainer()
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
index 7318fc3d1..c37308a1e 100644
--- a/src/gui/widgets/label.cpp
+++ b/src/gui/widgets/label.cpp
@@ -112,6 +112,7 @@ Label::~Label()
void Label::init()
{
+ mAllowLogic = false;
mForegroundColor = getThemeColor(Theme::LABEL);
mForegroundColor2 = getThemeColor(Theme::LABEL_OUTLINE);
if (mInstances == 0)
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 6f68f8689..6a0fbd607 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -83,6 +83,7 @@ PlayerBox::~PlayerBox()
void PlayerBox::init(std::string name, std::string selectedName)
{
+ mAllowLogic = false;
setFrameSize(2);
addMouseListener(this);
diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp
index cfb973384..2636dac38 100644
--- a/src/gui/widgets/popuplist.cpp
+++ b/src/gui/widgets/popuplist.cpp
@@ -43,7 +43,7 @@ PopupList::PopupList(DropDown *const widget,
mModal(modal)
{
mListBox->postInit();
-
+ mAllowLogic = false;
setFocusable(true);
mListBox->setDistributeMousePressed(true);
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index 4841ececb..8abac91cf 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -98,6 +98,7 @@ RadioButton::RadioButton(const Widget2 *const widget,
mSpacing(2),
mHasMouse(false)
{
+ mAllowLogic = false;
setCaption(caption);
setGroup(group);
setSelected(marked);
diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp
index 0d9aa64a6..b1bb1e867 100644
--- a/src/gui/widgets/shortcutcontainer.cpp
+++ b/src/gui/widgets/shortcutcontainer.cpp
@@ -43,6 +43,7 @@ ShortcutContainer::ShortcutContainer(Widget2 *const widget) :
mVertexes(new ImageCollection),
mRedraw(true)
{
+ mAllowLogic = false;
}
ShortcutContainer::~ShortcutContainer()
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index c9ea9e6c2..6de889249 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -142,6 +142,7 @@ Slider::~Slider()
void Slider::init()
{
+ mAllowLogic = false;
setFocusable(true);
setFrameSize(1);
diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp
index 03f0c4ed2..6782e789c 100644
--- a/src/gui/widgets/sliderlist.cpp
+++ b/src/gui/widgets/sliderlist.cpp
@@ -46,6 +46,7 @@ SliderList::SliderList(const Widget2 *const widget,
mOldWidth(0),
mSelectedIndex(0)
{
+ mAllowLogic = false;
setHeight(sliderHeight);
}
diff --git a/src/gui/widgets/tabstrip.cpp b/src/gui/widgets/tabstrip.cpp
index 57520afce..06e2fd3b8 100644
--- a/src/gui/widgets/tabstrip.cpp
+++ b/src/gui/widgets/tabstrip.cpp
@@ -30,6 +30,7 @@ TabStrip::TabStrip(const Widget2 *const widget,
const int spacing) :
WidgetGroup(widget, group, height, spacing)
{
+ mAllowLogic = false;
}
TabStrip::TabStrip(const Widget2 *const widget,
@@ -37,6 +38,7 @@ TabStrip::TabStrip(const Widget2 *const widget,
const int spacing) :
WidgetGroup(widget, "", height, spacing)
{
+ mAllowLogic = false;
}
Widget *TabStrip::createWidget(const std::string &text) const
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index 5f565259b..5008da6ea 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -85,6 +85,7 @@ TextBox::TextBox(const Widget2 *const widget) :
mEditable(true),
mOpaque(true)
{
+ mAllowLogic = false;
setText("");
setFocusable(true);
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 0a1caa0e5..98a308e37 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -113,6 +113,7 @@ TextField::TextField(const Widget2 *restrict const widget,
mAllowSpecialActions(true),
mSendAlwaysEvents(sendAlwaysEvents)
{
+ mAllowLogic = false;
setFocusable(true);
addMouseListener(this);
addKeyListener(this);
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index ff0a647b8..6f358e956 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -48,6 +48,7 @@ TextPreview::TextPreview(const Widget2 *const widget,
mShadow(false),
mOutline(false)
{
+ mAllowLogic = false;
if (instances == 0)
{
if (theme)
diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp
index d1ca474c4..cd1ac750c 100644
--- a/src/gui/widgets/widget.cpp
+++ b/src/gui/widgets/widget.cpp
@@ -108,7 +108,8 @@ Widget::Widget(const Widget2 *const widget) :
mVisible(true),
mTabIn(true),
mTabOut(true),
- mEnabled(true)
+ mEnabled(true),
+ mAllowLogic(true)
{
mWidgets.push_back(this);
mWidgetsSet.insert(this);
diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h
index beff5113b..c2b1040db 100644
--- a/src/gui/widgets/widget.h
+++ b/src/gui/widgets/widget.h
@@ -148,7 +148,7 @@ class Widget : public Widget2
* @see setFrameSize, getFrameSize
* @since 0.8.0
*/
- virtual void drawFrame(Graphics* graphics)
+ virtual void drawFrame(Graphics* graphics A_UNUSED)
{ }
/**
@@ -1007,6 +1007,9 @@ class Widget : public Widget2
*/
virtual void showPart(const Rect &rectangle);
+ bool isAllowLogic() const
+ { return mAllowLogic; }
+
protected:
/**
* Distributes an action event to all action listeners
@@ -1215,6 +1218,8 @@ class Widget : public Widget2
*/
bool mEnabled;
+ bool mAllowLogic;
+
/**
* Holds the global font used by the widget.
*/
diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp
index a9b556410..20c3328a7 100644
--- a/src/gui/widgets/windowcontainer.cpp
+++ b/src/gui/widgets/windowcontainer.cpp
@@ -64,18 +64,34 @@ void WindowContainer::moveWidgetAfter(Widget *const after,
const WidgetListIterator widgetIter = std::find(
mWidgets.begin(), mWidgets.end(), widget);
- if (widgetIter == mWidgets.end())
- return;
+ if (widgetIter != mWidgets.end())
+ {
+ WidgetListIterator afterIter = std::find(
+ mWidgets.begin(), mWidgets.end(), after);
- WidgetListIterator afterIter = std::find(
- mWidgets.begin(), mWidgets.end(), after);
+ if (afterIter != mWidgets.end())
+ {
+ ++ afterIter;
+ mWidgets.erase(widgetIter);
+ mWidgets.insert(afterIter, widget);
+ }
+ }
- if (afterIter == mWidgets.end())
- return;
+ const WidgetListIterator widgetIter2 = std::find(
+ mLogicWidgets.begin(), mLogicWidgets.end(), widget);
- ++ afterIter;
- mWidgets.erase(widgetIter);
- mWidgets.insert(afterIter, widget);
+ if (widgetIter2 != mLogicWidgets.end())
+ {
+ WidgetListIterator afterIter = std::find(
+ mLogicWidgets.begin(), mLogicWidgets.end(), after);
+
+ if (afterIter != mLogicWidgets.end())
+ {
+ ++ afterIter;
+ mLogicWidgets.erase(widgetIter2);
+ mLogicWidgets.insert(afterIter, widget);
+ }
+ }
}
#ifdef USE_PROFILER