mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[escher] Make app() a global function
This way it can easily be reached by anyone, including non-responders. And it can easily be overwritten in namespaced apps.
This commit is contained in:
committed by
EmilieNumworks
parent
154baae6d3
commit
45875dd642
@@ -290,7 +290,7 @@ bool ConsoleController::textFieldDidReceiveEvent(TextField * textField, Ion::Eve
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return static_cast<App *>(textField->app())->textInputDidReceiveEvent(textField, event);
|
||||
return static_cast<App *>(app())->textInputDidReceiveEvent(textField, event);
|
||||
}
|
||||
|
||||
bool ConsoleController::textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) {
|
||||
|
||||
@@ -58,7 +58,7 @@ bool EditorController::textAreaDidReceiveEvent(TextArea * textArea, Ion::Events:
|
||||
saveScript();
|
||||
return false;
|
||||
}
|
||||
if (static_cast<App *>(textArea->app())->textInputDidReceiveEvent(textArea, event)) {
|
||||
if (static_cast<App *>(app())->textInputDidReceiveEvent(textArea, event)) {
|
||||
return true;
|
||||
}
|
||||
if (event == Ion::Events::EXE) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <apps/i18n.h>
|
||||
#include "../apps_container.h"
|
||||
#include <assert.h>
|
||||
#include <escher/app.h>
|
||||
|
||||
namespace HardwareTest {
|
||||
|
||||
@@ -34,8 +35,7 @@ bool PopUpController::handleEvent(Ion::Events::Event event) {
|
||||
PopUpController::ContentView::ContentView(Responder * parentResponder) :
|
||||
Responder(parentResponder),
|
||||
m_cancelButton(this, I18n::Message::Cancel, Invocation([](void * context, void * sender) {
|
||||
PopUpController::ContentView * view = (PopUpController::ContentView *)context;
|
||||
view->app()->dismissModalViewController();
|
||||
app()->dismissModalViewController();
|
||||
return true;
|
||||
}, this), KDFont::SmallFont),
|
||||
m_okButton(this, I18n::Message::Ok, Invocation([](void * context, void * sender) {
|
||||
|
||||
@@ -20,7 +20,7 @@ bool ExpressionFieldDelegateApp::layoutFieldShouldFinishEditing(LayoutField * la
|
||||
bool ExpressionFieldDelegateApp::layoutFieldDidReceiveEvent(LayoutField * layoutField, Ion::Events::Event event) {
|
||||
if (layoutField->isEditing() && layoutField->shouldFinishEditing(event)) {
|
||||
if (!layoutField->hasText()) {
|
||||
layoutField->app()->displayWarning(I18n::Message::SyntaxError);
|
||||
displayWarning(I18n::Message::SyntaxError);
|
||||
return true;
|
||||
}
|
||||
/* An acceptable layout has to be parsable and serialized in a fixed-size
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define SHARED_SIMPLE_INTERACTIVE_CURVE_VIEW_CONTROLLER_H
|
||||
|
||||
#include <escher/view_controller.h>
|
||||
#include <escher/app.h>
|
||||
#include "text_field_delegate.h"
|
||||
#include "interactive_curve_view_range.h"
|
||||
#include "curve_view_cursor.h"
|
||||
|
||||
@@ -25,7 +25,7 @@ bool TextFieldDelegateApp::textFieldShouldFinishEditing(TextField * textField, I
|
||||
bool TextFieldDelegateApp::textFieldDidReceiveEvent(TextField * textField, Ion::Events::Event event) {
|
||||
if (textField->isEditing() && textField->shouldFinishEditing(event)) {
|
||||
if (!isAcceptableText(textField->text())) {
|
||||
textField->app()->displayWarning(I18n::Message::SyntaxError);
|
||||
displayWarning(I18n::Message::SyntaxError);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <escher/timer.h>
|
||||
#include <escher/view_controller.h>
|
||||
#include <escher/warning_controller.h>
|
||||
#include <ion/storage.h>
|
||||
|
||||
/* An app is fed events and outputs drawing calls.
|
||||
*
|
||||
@@ -71,5 +72,8 @@ private:
|
||||
WarningController m_warningController;
|
||||
};
|
||||
|
||||
// Make sure App * app() is reachable by anyone including only app.h
|
||||
#include <escher/container.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -47,4 +47,8 @@ private:
|
||||
static Container * s_sharedContainer;
|
||||
};
|
||||
|
||||
App * app() {
|
||||
return Container::sharedContainer()->activeApp();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#ifndef ESCHER_RESPONDER_H
|
||||
#define ESCHER_RESPONDER_H
|
||||
|
||||
#include <ion.h>
|
||||
|
||||
class App;
|
||||
#include <ion/events.h>
|
||||
|
||||
class Responder {
|
||||
public:
|
||||
@@ -16,7 +14,6 @@ public:
|
||||
Responder * parentResponder() const;
|
||||
Responder * commonAncestorWith(Responder * responder);
|
||||
void setParentResponder(Responder * responder);
|
||||
App * app() const;
|
||||
private:
|
||||
Responder * m_parentResponder;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#ifndef ESCHER_WARNING_CONTROLLER_H
|
||||
#define ESCHER_WARNING_CONTROLLER_H
|
||||
|
||||
#include <escher/view_controller.h>
|
||||
#include <escher/i18n.h>
|
||||
#include <escher/message_text_view.h>
|
||||
#include <escher/solid_color_view.h>
|
||||
#include <escher/i18n.h>
|
||||
#include <escher/view_controller.h>
|
||||
|
||||
class WarningController : public ViewController {
|
||||
public:
|
||||
|
||||
@@ -101,7 +101,6 @@ void App::displayWarning(I18n::Message warningMessage1, I18n::Message warningMes
|
||||
|
||||
void App::didBecomeActive(Window * window) {
|
||||
View * view = m_modalViewController.view();
|
||||
assert(m_modalViewController.app() == this);
|
||||
m_modalViewController.initView();
|
||||
window->setContentView(view);
|
||||
m_modalViewController.viewWillAppear();
|
||||
|
||||
@@ -61,7 +61,3 @@ Responder * Responder::commonAncestorWith(Responder * responder) {
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
App * Responder::app() const {
|
||||
return Container::sharedContainer()->activeApp();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <escher/app.h>
|
||||
#include <escher/text_area.h>
|
||||
#include <escher/clipboard.h>
|
||||
#include <escher/text_input_helpers.h>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <escher/app.h>
|
||||
#include <escher/text_field.h>
|
||||
#include <escher/text_input_helpers.h>
|
||||
#include <escher/clipboard.h>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <escher/text_input.h>
|
||||
#include <ion/unicode/utf8_decoder.h>
|
||||
#include <ion/unicode/utf8_helper.h>
|
||||
#include <assert.h>
|
||||
|
||||
/* TextInput::ContentView */
|
||||
|
||||
Reference in New Issue
Block a user