Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2011-08-28 18:17:56 +0000
committerStijn Buys <ingar@osirion.org>2011-08-28 18:17:56 +0000
commit3b75614be6d9f6e84a1b5818c5827dbc0ab5d516 (patch)
tree105b44e6d20bdcd7f951a13db2ccee9a950d1021 /src/client/chat.cc
parente99a43868a83d5931e1f7c4600c244484e1487e6 (diff)
Improved chat window layout, added title and close button.
Diffstat (limited to 'src/client/chat.cc')
-rw-r--r--src/client/chat.cc53
1 files changed, 43 insertions, 10 deletions
diff --git a/src/client/chat.cc b/src/client/chat.cc
index cf995cb..8a09883 100644
--- a/src/client/chat.cc
+++ b/src/client/chat.cc
@@ -24,7 +24,19 @@ Chat::Chat(ui::Widget *parent) : ui::Window(parent)
history.clear();
history.push_back("");
history_pos = history.rbegin();
-
+
+ // window title
+ chat_titlelabel = new ui::Label(this);
+ chat_titlelabel->set_label("title");
+ chat_titlelabel->set_background(false);
+ chat_titlelabel->set_border(false);
+ chat_titlelabel->set_font(ui::root()->font_large());
+ chat_titlelabel->set_alignment(ui::AlignCenter);
+ chat_titlelabel->set_text("CHAT");
+
+ // close button
+ chat_closebutton = new ui::IconButton(chat_titlelabel, "bitmaps/icons/window_close");
+
chat_scrollpane = new ui::ScrollPane(this, chat_log);
chat_scrollpane->set_border(false);
chat_scrollpane->set_label("text");
@@ -106,6 +118,7 @@ bool Chat::on_keypress(const int key, const unsigned int modifier)
} else {
return false;
}
+
case SDLK_RETURN:
if (chat_input->text().size()) {
// store input into history
@@ -134,6 +147,16 @@ bool Chat::on_keypress(const int key, const unsigned int modifier)
return true;
break;
+ case SDLK_TAB:
+ if (chat_input->text().size() && chat_input->text()[0] == '/') {
+ // command mode
+ chat_input->complete();
+ } else {
+ // TODO chat mode, switch channel
+ }
+ return true;
+ break;
+
case SDLK_UP:
upit = history_pos;
++upit;
@@ -202,28 +225,38 @@ void Chat::update_player_list()
void Chat::resize()
{
- const float fontmargin = ui::root()->font_large()->height();
+ const float padding = ui::root()->font_large()->height();
if (chat_small) {
chat_playerlist->hide();
chat_scrollpane->hide();
+ chat_titlelabel->hide();
} else {
chat_playerlist->show();
chat_scrollpane->show();
+ chat_titlelabel->show();
- // player names
- chat_playerlist->set_size(ui::UI::elementsize.width(), height() - fontmargin * 3.0f);
- chat_playerlist->set_location(width() - ui::UI::elementsize.width() - fontmargin, fontmargin);
+ // resize title label
+ chat_titlelabel->set_size(width() - padding * 2.0f, chat_titlelabel->font()->height());
+ chat_titlelabel->set_location(padding, padding);
- // chat text
- chat_scrollpane->set_size(width() - ui::UI::elementsize.width() - fontmargin * 3.0f, height() - fontmargin * 3.0f);
- chat_scrollpane->set_location(fontmargin, fontmargin);
+ // resize close button
+ chat_closebutton->set_size(chat_titlelabel->font()->height(), chat_titlelabel->font()->height());
+ chat_closebutton->set_location(chat_titlelabel->width() - chat_closebutton->width(), 0);
+
+ // resize player names listview
+ chat_playerlist->set_location(padding, chat_titlelabel->bottom() + padding);
+ chat_playerlist->set_size(ui::UI::elementsize.width() * 1.5f, height() - chat_playerlist->top() - padding * 2.0f);
+
+ // resize chat text pane
+ chat_scrollpane->set_location(chat_playerlist->right() + padding, padding);
+ chat_scrollpane->set_size(width() - chat_scrollpane->left() - padding, chat_playerlist->height());
}
// input bar
- chat_input->set_location(fontmargin, height() - fontmargin);
- chat_input->set_size(width() - 2.0f * fontmargin , fontmargin);
+ chat_input->set_location(padding, height() - padding);
+ chat_input->set_size(width() - 2.0f * padding , padding);
}