summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-07-23 00:10:43 +0300
committerAndrei Karas <akaras@inbox.ru>2012-07-23 00:10:43 +0300
commitd97189f055798b5b2051c1c5770a3def62747461 (patch)
treed66a891dba33d2ce1c882e0de7d6145bb2e0326b /src/gui
parent25dce1399e40f24809842303d48ef090439de1e5 (diff)
downloadmanaplus-d97189f055798b5b2051c1c5770a3def62747461.tar.gz
manaplus-d97189f055798b5b2051c1c5770a3def62747461.tar.bz2
manaplus-d97189f055798b5b2051c1c5770a3def62747461.tar.xz
manaplus-d97189f055798b5b2051c1c5770a3def62747461.zip
Improve perfomance in some object constructors.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/avatarlistbox.cpp9
-rw-r--r--src/gui/widgets/browserbox.cpp8
-rw-r--r--src/gui/widgets/chattab.cpp4
-rw-r--r--src/gui/widgets/chattab.h2
-rw-r--r--src/gui/widgets/desktop.cpp7
-rw-r--r--src/gui/widgets/dropdown.cpp6
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp9
-rw-r--r--src/gui/widgets/icon.cpp3
-rw-r--r--src/gui/widgets/itemcontainer.cpp6
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp11
-rw-r--r--src/gui/widgets/listbox.cpp2
-rw-r--r--src/gui/widgets/sliderlist.cpp2
-rw-r--r--src/gui/widgets/tab.cpp6
-rw-r--r--src/gui/widgets/textfield.cpp3
14 files changed, 33 insertions, 45 deletions
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index c648c56dd..914437281 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -50,8 +50,9 @@ Image *AvatarListBox::offlineIcon = nullptr;
AvatarListBox::AvatarListBox(AvatarListModel *model):
ListBox(model),
- mShowGender(false),
- mShowLevel(false)
+ mShowGender(config.getBoolValue("showgender")),
+ mShowLevel(config.getBoolValue("showlevel")),
+ mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT))
{
instances++;
@@ -63,13 +64,9 @@ AvatarListBox::AvatarListBox(AvatarListModel *model):
setWidth(200);
- mShowGender = config.getBoolValue("showgender");
- mShowLevel = config.getBoolValue("showlevel");
-
config.addListener("showgender", this);
config.addListener("showlevel", this);
- mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 6954f781f..534bd1d19 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -63,14 +63,14 @@ BrowserBox::BrowserBox(unsigned int mode, bool opaque):
mUpdateTime(-1),
mAlwaysUpdate(true),
mProcessVersion(false),
- mEnableImages(false)
+ mEnableImages(false),
+ mBackgroundColor(Theme::getThemeColor(Theme::BACKGROUND)),
+ mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)),
+ mHyperLinkColor(Theme::getThemeColor(Theme::HYPERLINK))
{
setFocusable(true);
addMouseListener(this);
- mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND);
- mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
- mHyperLinkColor = Theme::getThemeColor(Theme::HYPERLINK);
mColors[RED] = Theme::getThemeColor(Theme::RED);
mColors[GREEN] = Theme::getThemeColor(Theme::GREEN);
mColors[BLUE] = Theme::getThemeColor(Theme::BLUE);
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index f120cfb06..f67b75107 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -54,20 +54,20 @@
ChatTab::ChatTab(const std::string &name) :
Tab(),
+ mTextOutput(new BrowserBox(BrowserBox::AUTO_WRAP)),
+ mScrollArea(new ScrollArea(mTextOutput)),
mAllowHightlight(true),
mRemoveNames(false),
mNoAway(false)
{
setCaption(name);
- mTextOutput = new BrowserBox(BrowserBox::AUTO_WRAP);
mTextOutput->setOpaque(false);
mTextOutput->setMaxRow(config.getIntValue("ChatLogLength"));
if (chatWindow)
mTextOutput->setLinkHandler(chatWindow->mItemLinkHandler);
mTextOutput->setAlwaysUpdate(false);
- mScrollArea = new ScrollArea(mTextOutput);
mScrollArea->setScrollPolicy(gcn::ScrollArea::SHOW_NEVER,
gcn::ScrollArea::SHOW_ALWAYS);
mScrollArea->setScrollAmount(0, 1);
diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h
index e1e2c211d..3d591cf3c 100644
--- a/src/gui/widgets/chattab.h
+++ b/src/gui/widgets/chattab.h
@@ -184,8 +184,8 @@ class ChatTab : public Tab
void addRow(std::string &line);
- ScrollArea *mScrollArea;
BrowserBox *mTextOutput;
+ ScrollArea *mScrollArea;
bool mAllowHightlight;
bool mRemoveNames;
bool mNoAway;
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index d3a2e8c50..a25a9ef7e 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -41,7 +41,9 @@
#include "debug.h"
Desktop::Desktop() :
- mWallpaper(nullptr)
+ mWallpaper(nullptr),
+ mBackgroundColor(Theme::getThemeColor(Theme::BACKGROUND, 128)),
+ mBackgroundGrayColor(Theme::getThemeColor(Theme::BACKGROUND_GRAY))
{
addWidgetListener(this);
@@ -62,9 +64,6 @@ Desktop::Desktop() :
mVersionLabel->setBackgroundColor(
Theme::getThemeColor(Theme::BACKGROUND, 128));
add(mVersionLabel, 25, 2);
-
- mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND, 128);
- mBackgroundGrayColor = Theme::getThemeColor(Theme::BACKGROUND_GRAY);
}
Desktop::~Desktop()
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index a52f70926..dd9bbb4e5 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -58,7 +58,9 @@ DropDown::DropDown(gcn::ListModel *listModel, gcn::ActionListener* listener,
std::string eventId):
gcn::DropDown::DropDown(listModel,
new ScrollArea,
- new ListBox(listModel))
+ new ListBox(listModel)),
+ mShadowColor(Theme::getThemeColor(Theme::DROPDOWN_SHADOW)),
+ mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT))
{
setFrameSize(2);
@@ -101,8 +103,6 @@ DropDown::DropDown(gcn::ListModel *listModel, gcn::ActionListener* listener,
instances++;
- mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
- mShadowColor = Theme::getThemeColor(Theme::DROPDOWN_SHADOW);
setForegroundColor(Theme::getThemeColor(Theme::TEXT));
if (!eventId.empty())
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp
index fca1af17f..d70f153d7 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -48,13 +48,14 @@
DropShortcutContainer::DropShortcutContainer():
ShortcutContainer(),
mItemClicked(false),
- mItemMoved(nullptr)
+ mItemMoved(nullptr),
+ mItemPopup(new ItemPopup),
+ mEquipedColor(Theme::getThemeColor(Theme::ITEM_EQUIPPED)),
+ mUnEquipedColor(Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED))
{
addMouseListener(this);
addWidgetListener(this);
- mItemPopup = new ItemPopup;
-
mBackgroundImg = Theme::getImageFromThemeXml(
"item_shortcut_background.xml");
if (dropShortcut)
@@ -73,8 +74,6 @@ DropShortcutContainer::DropShortcutContainer():
mBoxHeight = 1;
mBoxWidth = 1;
}
- mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED);
- mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED);
}
DropShortcutContainer::~DropShortcutContainer()
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
index b35eb1d95..9cb42a9f7 100644
--- a/src/gui/widgets/icon.cpp
+++ b/src/gui/widgets/icon.cpp
@@ -30,9 +30,8 @@
#include "debug.h"
Icon::Icon(const std::string &file)
- : mImage(nullptr)
+ : mImage(ResourceManager::getInstance()->getImage(file))
{
- mImage = ResourceManager::getInstance()->getImage(file);
if (mImage)
setSize(mImage->mBounds.w, mImage->mBounds.h);
}
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index c5118ce44..6963bad31 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -157,6 +157,7 @@ ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity):
mInventory(inventory),
mGridColumns(1),
mGridRows(1),
+ mSelImg(Theme::getImageFromThemeXml("item_selection.xml")),
mSelectedIndex(-1),
mHighlightedIndex(-1),
mLastUsedSlot(-1),
@@ -173,11 +174,6 @@ ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity):
mUnEquipedColor(Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED))
{
setFocusable(true);
-
- mSelImg = Theme::getImageFromThemeXml("item_selection.xml");
- if (!mSelImg)
- logger->log1("Error: Unable to load selection.png");
-
addKeyListener(this);
addMouseListener(this);
addWidgetListener(this);
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 735cea43d..e27d5efd6 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -54,14 +54,15 @@ ItemShortcutContainer::ItemShortcutContainer(unsigned number):
ShortcutContainer(),
mItemClicked(false),
mItemMoved(nullptr),
- mNumber(number)
+ mNumber(number),
+ mItemPopup(new ItemPopup),
+ mSpellPopup(new SpellPopup),
+ mEquipedColor(Theme::getThemeColor(Theme::ITEM_EQUIPPED)),
+ mUnEquipedColor(Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED))
{
addMouseListener(this);
addWidgetListener(this);
- mItemPopup = new ItemPopup;
- mSpellPopup = new SpellPopup;
-
mBackgroundImg = Theme::getImageFromThemeXml(
"item_shortcut_background.xml");
if (itemShortcut[mNumber])
@@ -81,8 +82,6 @@ ItemShortcutContainer::ItemShortcutContainer(unsigned number):
mBoxWidth = 1;
}
setForegroundColor(Theme::getThemeColor(Theme::TEXT));
- mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED);
- mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED);
}
ItemShortcutContainer::~ItemShortcutContainer()
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index f803e91b4..8e5bc0c78 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -43,9 +43,9 @@ float ListBox::mAlpha = 1.0;
ListBox::ListBox(gcn::ListModel *listModel):
gcn::ListBox(listModel),
+ mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)),
mDistributeMousePressed(true)
{
- mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp
index 9dba00cee..50af87205 100644
--- a/src/gui/widgets/sliderlist.cpp
+++ b/src/gui/widgets/sliderlist.cpp
@@ -42,6 +42,7 @@ static const int sliderHeight = 30;
SliderList::SliderList(gcn::ListModel *listModel,
gcn::ActionListener* listener,
std::string eventId) :
+ mLabel(new Label),
mListModel(listModel),
mOldWidth(0),
mSelectedIndex(0)
@@ -53,7 +54,6 @@ SliderList::SliderList(gcn::ListModel *listModel,
mButtons[0] = new Button("<", mPrevEventId, this);
mButtons[1] = new Button(">", mNextEventId, this);
- mLabel = new Label("");
add(mButtons[0]);
add(mLabel);
add(mButtons[1]);
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index ebc288b43..3faa874ca 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -68,11 +68,11 @@ Tab::Tab() :
mTabColor(&Theme::getThemeColor(Theme::TAB)),
mVertexes(new GraphicsVertexes()),
mRedraw(true),
- mMode(0)
+ mMode(0),
+ mFlashColor(Theme::getThemeColor(Theme::TAB_FLASH)),
+ mPlayerFlashColor(Theme::getThemeColor(Theme::TAB_PLAYER_FLASH))
{
init();
- mFlashColor = Theme::getThemeColor(Theme::TAB_FLASH);
- mPlayerFlashColor = Theme::getThemeColor(Theme::TAB_PLAYER_FLASH);
}
Tab::~Tab()
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index f0df5eb57..1c054f04b 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -57,12 +57,11 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab,
mNumeric(false),
mMinimum(0),
mMaximum(0),
+ mLoseFocusOnTab(loseFocusOnTab),
mLastEventPaste(false)
{
setFrameSize(2);
- mLoseFocusOnTab = loseFocusOnTab;
-
setForegroundColor(Theme::getThemeColor(Theme::TEXT));
if (instances == 0)