From 22f1b902386b87a774c98e972f6815b95f21a493 Mon Sep 17 00:00:00 2001 From: Kevin Whitaker <eyecreate@gmail.com> Date: Sat, 28 Jan 2017 16:51:14 -0500 Subject: [PATCH] Add interface class to represent player interface. Have simple hide/show animation between. Put up more interface elements on login interface to show inteded ui. --- CMakeLists.txt | 2 +- src/WebInterface.cpp | 19 +++++++++++++++++-- src/WebInterface.h | 1 + src/ui/LoginInterface.cpp | 25 +++++++++++++++++++++++-- src/ui/LoginInterface.h | 13 +++++++++++++ src/ui/PlayerInterface.cpp | 27 +++++++++++++++++++++++++++ src/ui/PlayerInterface.h | 33 +++++++++++++++++++++++++++++++++ 7 files changed, 115 insertions(+), 5 deletions(-) create mode 100644 src/ui/PlayerInterface.cpp create mode 100644 src/ui/PlayerInterface.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ee701b..67fbec5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") find_package(Wt REQUIRED) find_package(Groove REQUIRED) -add_executable(arbitrateor src/main.cpp src/WebInterface.cpp src/GroovePlayer.cpp src/ui/LoginInterface.cpp) +add_executable(arbitrateor src/main.cpp src/WebInterface.cpp src/GroovePlayer.cpp src/ui/LoginInterface.cpp src/ui/PlayerInterface.cpp) target_link_libraries(arbitrateor ${Wt_LIBRARIES} ${GROOVE_LIBRARY}) install(TARGETS arbitrateor RUNTIME DESTINATION bin) diff --git a/src/WebInterface.cpp b/src/WebInterface.cpp index 896ea69..3f8f09a 100644 --- a/src/WebInterface.cpp +++ b/src/WebInterface.cpp @@ -19,24 +19,39 @@ #include "WebInterface.h" #include "ui/LoginInterface.h" +#include "ui/PlayerInterface.h" #include <Wt/WText> +#include <Wt/WAnimation> struct WebInterface::internal { LoginInterface* loginUI; + PlayerInterface* playerUI; }; WebInterface::WebInterface(const Wt::WEnvironment& env) : Wt::WApplication(env) { priv_int = new internal; setTitle("Arbitrateor - Audio Jukebox"); + priv_int->playerUI = new PlayerInterface(this); + priv_int->playerUI->hide(); priv_int->loginUI = new LoginInterface(this); + priv_int->loginUI->animateShow(Wt::WAnimation(Wt::WAnimation::AnimationEffect::SlideInFromTop)); + root()->addWidget(priv_int->playerUI); root()->addWidget(priv_int->loginUI); } +WebInterface::~WebInterface() +{ + delete priv_int->playerUI; + delete priv_int->loginUI; + delete priv_int; +} + void WebInterface::loginCompleted() { //Login completed, now bring up main inteface. - root()->removeWidget(priv_int->loginUI); - root()->addWidget(new Wt::WText("you did it")); + priv_int->loginUI->animateHide(Wt::WAnimation(Wt::WAnimation::AnimationEffect::Fade)); + priv_int->playerUI->animateShow(Wt::WAnimation(Wt::WAnimation::AnimationEffect::Fade, Wt::WAnimation::TimingFunction::EaseIn, 500)); + //TODO: set up player to dynamically update? } diff --git a/src/WebInterface.h b/src/WebInterface.h index 012b9d4..ca5c0b5 100644 --- a/src/WebInterface.h +++ b/src/WebInterface.h @@ -27,6 +27,7 @@ class WebInterface : public Wt::WApplication { public: WebInterface(const Wt::WEnvironment& env); + ~WebInterface(); void loginCompleted(); private: struct internal; diff --git a/src/ui/LoginInterface.cpp b/src/ui/LoginInterface.cpp index c70ba6b..9ee626e 100644 --- a/src/ui/LoginInterface.cpp +++ b/src/ui/LoginInterface.cpp @@ -18,12 +18,33 @@ */ #include "LoginInterface.h" -#include <Wt/WText> LoginInterface::LoginInterface(WebInterface* app) { + this->app = app; + loginContainer = new Wt::WContainerWidget(); + loginLayout = new Wt::WVBoxLayout(); + loginContainer->setLayout(loginLayout); + usernameArea = new Wt::WHBoxLayout(); + passwordArea = new Wt::WHBoxLayout(); + usernameContainer = new Wt::WContainerWidget(); + passwordContainer = new Wt::WContainerWidget(); + usernameContainer->setLayout(usernameArea); + passwordContainer->setLayout(passwordArea); + usernameField = new Wt::WLineEdit(); + passwordField = new Wt::WLineEdit(); + passwordField->setEchoMode(Wt::WLineEdit::EchoMode::Password); + usernameArea->addWidget(new Wt::WText("Username:")); + usernameArea->addWidget(usernameField); + passwordArea->addWidget(new Wt::WText("Password:")); + passwordArea->addWidget(passwordField); + loginLayout->addWidget(new Wt::WText("Please Login to access.")); + loginLayout->addWidget(usernameContainer); + loginLayout->addWidget(passwordContainer); loginButton = new Wt::WPushButton("Login"); loginButton->clicked().connect(app, &WebInterface::loginCompleted); setContentAlignment(Wt::AlignmentFlag::AlignCenter); - addChild(loginButton); + loginLayout->addWidget(loginButton); + addChild(loginContainer); + loginContainer->setWidth(Wt::WLength(50, Wt::WLength::Percentage)); } diff --git a/src/ui/LoginInterface.h b/src/ui/LoginInterface.h index 0b0c63a..aaca2b4 100644 --- a/src/ui/LoginInterface.h +++ b/src/ui/LoginInterface.h @@ -22,6 +22,10 @@ #include <Wt/WContainerWidget> #include <Wt/WPushButton> +#include <Wt/WVBoxLayout> +#include <Wt/WHBoxLayout> +#include <Wt/WLineEdit> +#include <Wt/WText> #include "../WebInterface.h" class LoginInterface : public Wt::WContainerWidget @@ -30,6 +34,15 @@ public: LoginInterface(WebInterface* app); private: Wt::WPushButton* loginButton; + Wt::WVBoxLayout* loginLayout; + Wt::WContainerWidget* loginContainer; + Wt::WHBoxLayout* usernameArea; + Wt::WContainerWidget* usernameContainer; + Wt::WHBoxLayout* passwordArea; + Wt::WContainerWidget* passwordContainer; + Wt::WLineEdit* usernameField; + Wt::WLineEdit* passwordField; + WebInterface* app; }; #endif // LOGININTERFACE_H diff --git a/src/ui/PlayerInterface.cpp b/src/ui/PlayerInterface.cpp new file mode 100644 index 0000000..f6f7ff9 --- /dev/null +++ b/src/ui/PlayerInterface.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2017 Kevin Whitaker <eyecreate@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "PlayerInterface.h" +#include <Wt/WText> + +PlayerInterface::PlayerInterface(WebInterface* app) +{ + this->app = app; + addChild(new Wt::WText("You did it.")); +} diff --git a/src/ui/PlayerInterface.h b/src/ui/PlayerInterface.h new file mode 100644 index 0000000..84ed2d1 --- /dev/null +++ b/src/ui/PlayerInterface.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2017 Kevin Whitaker <eyecreate@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef PLAYERINTERFACE_H +#define PLAYERINTERFACE_H + +#include <Wt/WContainerWidget> +#include "../WebInterface.h" + +class PlayerInterface : public Wt::WContainerWidget +{ +public: + PlayerInterface(WebInterface* app); + WebInterface* app; +}; + +#endif // PLAYERINTERFACE_H -- GitLab