2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-17 20:45:23 +00:00

Add MessageWindow class

This commit is contained in:
Jack Andersen
2016-01-02 13:07:40 -10:00
parent 26dffbd99e
commit 8dfafc81c2
11 changed files with 277 additions and 3 deletions

View File

@@ -9,6 +9,7 @@
#include "Table.hpp"
#include "ViewResources.hpp"
#include "IViewManager.hpp"
#include "MessageWindow.hpp"
#include <HECL/HECL.hpp>
namespace Specter
@@ -20,6 +21,7 @@ public:
enum class Type
{
SaveFile,
SaveDirectory,
OpenFile,
OpenDirectory,
OpenHECLProject
@@ -114,6 +116,8 @@ private:
}
} m_fileFieldBind;
std::unique_ptr<MessageWindow> m_confirmWindow;
struct FileListingDataBind : ITableDataBinding, ITableStateBinding
{
FileBrowser& m_fb;

View File

@@ -0,0 +1,78 @@
#ifndef SPECTER_MESSAGEWINDOW_HPP
#define SPECTER_MESSAGEWINDOW_HPP
#include "ModalWindow.hpp"
#include "MultiLineTextView.hpp"
#include "Button.hpp"
namespace Specter
{
class MessageWindow : public ModalWindow
{
public:
enum class Type
{
InfoOk,
ErrorOk,
ConfirmOkCancel
};
private:
Type m_type;
std::function<void(bool ok)> m_func;
std::unique_ptr<MultiLineTextView> m_text;
struct OKBinding : IButtonBinding
{
MessageWindow& m_mw;
std::string m_name;
OKBinding(MessageWindow& mw, std::string&& name) : m_mw(mw), m_name(std::move(name)) {}
const char* name() const {return m_name.c_str();}
void activated(const boo::SWindowCoord& coord)
{
m_mw.m_func(true);
}
} m_okBind;
ViewChild<std::unique_ptr<Button>> m_ok;
struct CancelBinding : IButtonBinding
{
MessageWindow& m_mw;
std::string m_name;
CancelBinding(MessageWindow& mw, std::string&& name) : m_mw(mw), m_name(std::move(name)) {}
const char* name() const {return m_name.c_str();}
void activated(const boo::SWindowCoord& coord)
{
m_mw.m_func(false);
}
} m_cancelBind;
ViewChild<std::unique_ptr<Button>> m_cancel;
public:
MessageWindow(ViewResources& res, View& parentView,
Type type, const std::string& message, std::function<void(bool ok)> func);
void updateContentOpacity(float opacity)
{
Zeus::CColor color = Zeus::CColor::lerp({1,1,1,0}, {1,1,1,1}, opacity);
ModalWindow::setMultiplyColor(color);
m_text->setMultiplyColor(color);
m_ok.m_view->setMultiplyColor(color);
m_cancel.m_view->setMultiplyColor(color);
}
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseMove(const boo::SWindowCoord&);
void mouseEnter(const boo::SWindowCoord&);
void mouseLeave(const boo::SWindowCoord&);
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);
void draw(boo::IGraphicsCommandQueue* gfxQ);
};
}
#endif // SPECTER_MESSAGEWINDOW_HPP

View File

@@ -59,6 +59,7 @@ protected:
virtual void updateContentOpacity(float opacity) {}
public:
ModalWindow(ViewResources& res, View& parentView, const RectangleConstraint& constraint, const Zeus::CColor& bgColor);
ModalWindow(ViewResources& res, View& parentView, const RectangleConstraint& constraint);
void think();
bool skipBuildInAnimation();

View File

@@ -37,6 +37,12 @@ public:
void colorGlyphs(const Zeus::CColor& newColor);
void setMultiplyColor(const Zeus::CColor& color)
{
for (std::unique_ptr<TextView>& l : m_lines)
l->setMultiplyColor(color);
}
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);
void draw(boo::IGraphicsCommandQueue* gfxQ);

View File

@@ -21,6 +21,7 @@ class ThemeData
Zeus::CColor m_tbBg = {0.4, 0.4, 0.4, 1.0};
Zeus::CColor m_tooltipBg = {0.1, 0.1, 0.1, 0.85};
Zeus::CColor m_splashBg = {0.075, 0.075, 0.075, 0.85};
Zeus::CColor m_splashErrorBg = {0.1, 0.01, 0.01, 0.85};
Zeus::CColor m_splash1 = {1.0, 1.0, 1.0, 1.0};
Zeus::CColor m_splash2 = {0.3, 0.3, 0.3, 1.0};
@@ -59,6 +60,7 @@ public:
virtual const Zeus::CColor& toolbarBackground() const {return m_tbBg;}
virtual const Zeus::CColor& tooltipBackground() const {return m_tooltipBg;}
virtual const Zeus::CColor& splashBackground() const {return m_splashBg;}
virtual const Zeus::CColor& splashErrorBackground() const {return m_splashErrorBg;}
virtual const Zeus::CColor& splash1() const {return m_splash1;}
virtual const Zeus::CColor& splash2() const {return m_splash2;}