summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-07 20:25:56 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-07 20:25:56 +0300
commitbd7052d90ce2c493f8f93d2be46625bb8297ad79 (patch)
tree4898d03f613629dcf56ae2b5a2160501a90f4388 /src/gui
parentf34f096ee0f3c2e66eec7dc024dd18a74698840f (diff)
downloadmv-bd7052d90ce2c493f8f93d2be46625bb8297ad79.tar.gz
mv-bd7052d90ce2c493f8f93d2be46625bb8297ad79.tar.bz2
mv-bd7052d90ce2c493f8f93d2be46625bb8297ad79.tar.xz
mv-bd7052d90ce2c493f8f93d2be46625bb8297ad79.zip
Add font tab into chat emotes window.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chatwindow.cpp12
-rw-r--r--src/gui/emotewindow.cpp61
-rw-r--r--src/gui/emotewindow.h9
3 files changed, 76 insertions, 6 deletions
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index ed8e6a1d3..b33a14a0e 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -511,6 +511,18 @@ void ChatWindow::action(const gcn::ActionEvent &event)
}
}
}
+ else if (eventId == "font")
+ {
+ if (emoteWindow)
+ {
+ const std::string str = emoteWindow->getSelectedFont();
+ if (!str.empty())
+ {
+ addInputText(str, false);
+ emoteWindow->clearFont();
+ }
+ }
+ }
else if (eventId == ACTION_COLOR_PICKER)
{
if (mColorPicker)
diff --git a/src/gui/emotewindow.cpp b/src/gui/emotewindow.cpp
index 14652a635..f01a9ca0d 100644
--- a/src/gui/emotewindow.cpp
+++ b/src/gui/emotewindow.cpp
@@ -27,6 +27,7 @@
#include "gui/widgets/colorpage.h"
#include "gui/widgets/emotepage.h"
#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/namesmodel.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/tabbedarea.h"
@@ -38,6 +39,16 @@
#include "debug.h"
+static const int fontSizeListSize = 2;
+
+static const char *const fontSizeList[] =
+{
+ // TRANSLATORS: font size
+ N_("Normal font"),
+ // TRANSLATORS: font size
+ N_("Bold font"),
+};
+
EmoteWindow::EmoteWindow() :
// TRANSLATORS: emotes window name
Window(_("Emotes"), false, nullptr, "emotes.xml"),
@@ -45,32 +56,45 @@ EmoteWindow::EmoteWindow() :
mEmotePage(new EmotePage(this)),
mColorModel(ColorModel::createDefault(this)),
mColorPage(new ColorPage(this, mColorModel, "colorpage.xml")),
- mScrollColorPage(new ScrollArea(mColorPage, false, "emotepage.xml"))
+ mScrollColorPage(new ScrollArea(mColorPage, false, "emotepage.xml")),
+ mFontModel(new NamesModel),
+ mFontPage(new ListBox(this, mFontModel, "")),
+ mScrollFontPage(new ScrollArea(mFontPage, false, "fontpage.xml"))
{
setShowTitle(false);
setResizable(true);
addMouseListener(this);
const int pad2 = mPadding * 2;
- const int sz = 150;
- setWidth(sz + pad2);
- setHeight(sz + pad2);
+ const int width = 200;
+ const int height = 150;
+ setWidth(width + pad2);
+ setHeight(height + pad2);
add(mTabs);
mTabs->setPosition(mPadding, mPadding);
- mTabs->setWidth(sz);
- mTabs->setHeight(sz);
+ mTabs->setWidth(width);
+ mTabs->setHeight(height);
center();
setTitleBarHeight(getPadding() + getTitlePadding());
mScrollColorPage->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
mScrollColorPage->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
+ mScrollFontPage->setVerticalScrollPolicy(ScrollArea::SHOW_NEVER);
+ mScrollFontPage->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
+
+ mFontModel->fillFromArray(&fontSizeList[0], fontSizeListSize);
+ mFontPage->setCenter(true);
+
// TRANSLATORS: emotes tab name
mTabs->addTab(_("Emotes"), mEmotePage);
// TRANSLATORS: emotes tab name
mTabs->addTab(_("Colors"), mScrollColorPage);
+ // TRANSLATORS: emotes tab name
+ mTabs->addTab(_("Fonts"), mScrollFontPage);
mEmotePage->setActionEventId("emote");
mColorPage->setActionEventId("color");
+ mFontPage->setActionEventId("font");
}
EmoteWindow::~EmoteWindow()
@@ -85,6 +109,12 @@ EmoteWindow::~EmoteWindow()
mColorModel = nullptr;
delete mScrollColorPage;
mScrollColorPage = nullptr;
+ delete mFontPage;
+ mFontPage = nullptr;
+ delete mFontModel;
+ mFontModel = nullptr;
+ delete mFontPage;
+ mScrollFontPage = nullptr;
}
void EmoteWindow::show()
@@ -135,10 +165,29 @@ void EmoteWindow::clearColor()
setVisible(false);
}
+std::string EmoteWindow::getSelectedFont() const
+{
+ const int index = mFontPage->getSelected();
+ if (index < 0)
+ return std::string();
+
+ if (!index)
+ return "##b";
+ else
+ return "##B";
+}
+
+void EmoteWindow::clearFont()
+{
+ mFontPage->setSelected(-1);
+ setVisible(false);
+}
+
void EmoteWindow::addListeners(gcn::ActionListener *const listener)
{
mEmotePage->addActionListener(listener);
mColorPage->addActionListener(listener);
+ mFontPage->addActionListener(listener);
}
void EmoteWindow::widgetResized(const gcn::Event &event)
diff --git a/src/gui/emotewindow.h b/src/gui/emotewindow.h
index fd9969630..db83b8b39 100644
--- a/src/gui/emotewindow.h
+++ b/src/gui/emotewindow.h
@@ -28,6 +28,8 @@
class ColorModel;
class ColorPage;
class EmotePage;
+class ListBox;
+class NamesModel;
class ScrollArea;
class TabbedArea;
@@ -52,6 +54,10 @@ class EmoteWindow final : public Window
void clearColor();
+ std::string getSelectedFont() const;
+
+ void clearFont();
+
void addListeners(gcn::ActionListener *const listener);
void widgetResized(const gcn::Event &event) override;
@@ -62,6 +68,9 @@ class EmoteWindow final : public Window
ColorModel *mColorModel;
ColorPage *mColorPage;
ScrollArea *mScrollColorPage;
+ NamesModel *mFontModel;
+ ListBox *mFontPage;
+ ScrollArea *mScrollFontPage;
};
extern EmoteWindow *emoteWindow;