#include "../include/ChatWindow.hpp" #include "../include/ChatMessage.hpp" #include namespace dchat { ChatWindow::ChatWindow() { setupTopBar(); Gtk::Paned *sidePanels = Gtk::manage(new Gtk::Paned()); sidePanels->set_name("side-panels"); sidePanels->set_border_width(0); attach(*sidePanels, 0, 1, 1, 2); setupLeftPanel(sidePanels); Gtk::Grid *rightPanel = Gtk::manage(new Gtk::Grid()); rightPanel->set_hexpand(true); sidePanels->add2(*rightPanel); setupMessageArea(rightPanel); setupChatInput(rightPanel); set_vexpand(true); set_hexpand(true); } void ChatWindow::setupTopBar() { topbar.set_name("top-bar"); topbar.set_hexpand(true); attach(topbar, 0, 0, 2, 1); topbarSearchBar.set_size_request(175); topbarSearchBar.set_name("top-bar-search"); topbarSearchBar.set_placeholder_text("Search..."); topbar.attach(topbarSearchBar, 0, 0, 1, 1); Gtk::Alignment *topbarSpacer = Gtk::manage(new Gtk::Alignment()); topbarSpacer->set_size_request(50); topbar.attach_next_to(*topbarSpacer, topbarSearchBar, Gtk::POS_RIGHT, 1, 1); currentChannelTitle.set_text("Linux"); currentChannelTitle.set_name("current-channel-title"); topbar.attach_next_to(currentChannelTitle, *topbarSpacer, Gtk::POS_RIGHT, 1, 1); } void ChatWindow::setupLeftPanel(Gtk::Paned *sidePanels) { Gtk::Paned *leftPanel = Gtk::manage(new Gtk::Paned(Gtk::ORIENTATION_VERTICAL)); leftPanel->set_size_request(200); leftPanel->set_name("left-panel"); leftPanel->set_vexpand(true); sidePanels->add1(*leftPanel); Gtk::Grid *leftPanelChannels = Gtk::manage(new Gtk::Grid()); leftPanelChannels->set_vexpand(true); leftPanel->add1(*leftPanelChannels); Gtk::Label *channelsTitle = Gtk::manage(new Gtk::Label()); channelsTitle->set_name("channels-title"); channelsTitle->set_text("Channels"); leftPanelChannels->attach(*channelsTitle, 0, 0, 1, 1); //// Gtk::Grid *leftPanelUsers = Gtk::manage(new Gtk::Grid()); leftPanelUsers->set_vexpand(true); leftPanel->add2(*leftPanelUsers); Gtk::Label *usersTitle = Gtk::manage(new Gtk::Label()); usersTitle->set_name("users-title"); usersTitle->set_text("Users"); leftPanelUsers->attach(*usersTitle, 0, 0, 1, 1); } void ChatWindow::setupMessageArea(Gtk::Grid *rightPanel) { chatArea.set_vexpand(true); rightPanel->attach(chatArea, 0, 0, 1, 2); Gtk::Grid *chatAreaLayout = Gtk::manage(new Gtk::Grid()); chatAreaLayout->set_name("chat-area-layout"); chatArea.add(*chatAreaLayout); for(int i = 0; i < 100; ++i) { ChatMessage *message = Gtk::manage(new ChatMessage("Arezu", "hellooooo" + std::to_string(i))); message->set_valign(Gtk::Align::ALIGN_START); message->set_hexpand(true); chatAreaLayout->attach(*message, 0, i, 1, 1); } } void ChatWindow::setupChatInput(Gtk::Grid *rightPanel) { Gtk::ScrolledWindow *chatScrollWindow = Gtk::manage(new Gtk::ScrolledWindow()); chatScrollWindow->set_name("chat-scroll-view"); rightPanel->attach_next_to(*chatScrollWindow, chatArea, Gtk::POS_BOTTOM, 1, 1); chatInput.set_hexpand(true); chatInput.set_name("chat-input"); chatInput.set_wrap_mode(Gtk::WrapMode::WRAP_WORD_CHAR); chatScrollWindow->add(chatInput); } }