mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[escher] create a class warning controller
Change-Id: I93dabe0d47a7b197cb32cf5ccac8411a181afbb7
This commit is contained in:
@@ -40,6 +40,7 @@ objs += $(addprefix escher/src/,\
|
||||
tiled_view.o\
|
||||
view.o\
|
||||
view_controller.o\
|
||||
warning_controller.o\
|
||||
window.o\
|
||||
)
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <escher/tiled_view.h>
|
||||
#include <escher/view.h>
|
||||
#include <escher/view_controller.h>
|
||||
#include <escher/warning_controller.h>
|
||||
#include <escher/window.h>
|
||||
|
||||
#endif
|
||||
|
||||
33
escher/include/escher/warning_controller.h
Normal file
33
escher/include/escher/warning_controller.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef ESCHER_WARNING_CONTROLLER_H
|
||||
#define ESCHER_WARNING_CONTROLLER_H
|
||||
|
||||
#include <escher/view_controller.h>
|
||||
#include <escher/pointer_text_view.h>
|
||||
#include <escher/solid_color_view.h>
|
||||
|
||||
class WarningController : public ViewController {
|
||||
public:
|
||||
WarningController(Responder * parentResponder);
|
||||
void setLabel(const char *);
|
||||
const char * title() const override;
|
||||
View * view() override;
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
private:
|
||||
class ContentView : public SolidColorView {
|
||||
public:
|
||||
ContentView();
|
||||
void setLabel(const char *);
|
||||
int numberOfSubviews() const override;
|
||||
View * subviewAtIndex(int index) override;
|
||||
void layoutSubviews() override;
|
||||
KDSize minimalSizeForOptimalDisplay() override;
|
||||
private:
|
||||
constexpr static KDCoordinate k_verticalMargin = 40;
|
||||
constexpr static KDCoordinate k_horizontalMargin = 20;
|
||||
PointerTextView m_textView;
|
||||
};
|
||||
|
||||
ContentView m_contentView;
|
||||
};
|
||||
|
||||
#endif
|
||||
52
escher/src/warning_controller.cpp
Normal file
52
escher/src/warning_controller.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include <escher/warning_controller.h>
|
||||
#include <escher/app.h>
|
||||
|
||||
WarningController::ContentView::ContentView() :
|
||||
SolidColorView(KDColorBlack),
|
||||
m_textView(PointerTextView("", 0.5f, 0.5f, KDColorWhite, KDColorBlack))
|
||||
{
|
||||
}
|
||||
|
||||
void WarningController::ContentView::setLabel(const char * label) {
|
||||
m_textView.setText(label);
|
||||
}
|
||||
|
||||
int WarningController::ContentView::numberOfSubviews() const {
|
||||
return 1;
|
||||
}
|
||||
|
||||
View * WarningController::ContentView::subviewAtIndex(int index) {
|
||||
return &m_textView;
|
||||
}
|
||||
|
||||
void WarningController::ContentView::layoutSubviews() {
|
||||
m_textView.setFrame(bounds());
|
||||
}
|
||||
|
||||
KDSize WarningController::ContentView::minimalSizeForOptimalDisplay() {
|
||||
KDSize textSize = m_textView.minimalSizeForOptimalDisplay();
|
||||
return KDSize(textSize.width() + k_horizontalMargin, textSize.height() + k_verticalMargin);
|
||||
}
|
||||
|
||||
WarningController::WarningController(Responder * parentResponder) :
|
||||
ViewController(parentResponder),
|
||||
m_contentView(ContentView())
|
||||
{
|
||||
}
|
||||
|
||||
void WarningController::setLabel(const char * label) {
|
||||
m_contentView.setLabel(label);
|
||||
}
|
||||
|
||||
const char * WarningController::title() const {
|
||||
return "Attention";
|
||||
}
|
||||
|
||||
View * WarningController::view() {
|
||||
return &m_contentView;
|
||||
}
|
||||
|
||||
bool WarningController::handleEvent(Ion::Events::Event event) {
|
||||
app()->dismissModalViewController();
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user