From 9096d6ef3710118f98c46f6e7f7689d5aa11c7f4 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 25 Oct 2018 16:19:49 +0200 Subject: Initial commit --- src/LoginWindow.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/LoginWindow.cpp (limited to 'src/LoginWindow.cpp') diff --git a/src/LoginWindow.cpp b/src/LoginWindow.cpp new file mode 100644 index 0000000..4232982 --- /dev/null +++ b/src/LoginWindow.cpp @@ -0,0 +1,56 @@ +#include "../include/LoginWindow.hpp" +#include +#include +#include +#include +#include + +namespace dchat +{ + LoginWindow::LoginWindow() : + loginButton("Login") + { + Gtk::Label *username = Gtk::manage(new Gtk::Label()); + username->set_text("Username"); + username->set_halign(Gtk::ALIGN_START); + attach(*username, 0, 0, 1, 1); + + usernameInput.set_size_request(200); + attach_next_to(usernameInput, *username, Gtk::POS_BOTTOM, 3, 1); + + Gtk::Alignment *usernamePasswordSpacer = Gtk::manage(new Gtk::Alignment()); + usernamePasswordSpacer->set_size_request(-1, 35); + attach_next_to(*usernamePasswordSpacer, usernameInput, Gtk::POS_BOTTOM, 1, 1); + + Gtk::Label *password = Gtk::manage(new Gtk::Label()); + password->set_text("Password"); + password->set_halign(Gtk::ALIGN_START); + attach_next_to(*password, *usernamePasswordSpacer, Gtk::POS_BOTTOM, 1, 1); + + passwordInput.set_visibility(false); + passwordInput.set_size_request(200); + attach_next_to(passwordInput, *password, Gtk::POS_BOTTOM, 3, 1); + + Gtk::Alignment *loginButtonSpacerTop = Gtk::manage(new Gtk::Alignment()); + loginButtonSpacerTop->set_size_request(-1, 20); + attach_next_to(*loginButtonSpacerTop, passwordInput, Gtk::POS_BOTTOM, 1, 1); + + Gtk::Alignment *loginButtonSpacer = Gtk::manage(new Gtk::Alignment()); + attach_next_to(*loginButtonSpacer, *loginButtonSpacerTop, Gtk::POS_BOTTOM, 2, 1); + + loginButton.set_halign(Gtk::ALIGN_END); + attach_next_to(loginButton, *loginButtonSpacer, Gtk::POS_RIGHT, 1, 1); + + set_halign(Gtk::ALIGN_CENTER); + set_valign(Gtk::ALIGN_CENTER); + get_style_context()->add_class("login-window"); + } + + void LoginWindow::setLoginHandler(std::function loginHandler) + { + assert(loginHandler); + usernameInput.signal_activate().connect(loginHandler); + passwordInput.signal_activate().connect(loginHandler); + loginButton.signal_clicked().connect(loginHandler); + } +} \ No newline at end of file -- cgit v1.2.3