[apps/code] Choose console text size from GlobalPreferences

This commit is contained in:
Émilie Feral
2019-10-04 11:40:42 +02:00
committed by Léa Saviot
parent b3d45833d0
commit c2dabf6510
4 changed files with 11 additions and 10 deletions

View File

@@ -5,7 +5,8 @@
#include <apps/i18n.h>
#include <assert.h>
#include <escher/metric.h>
#include "../apps_container.h"
#include <apps/global_preferences.h>
#include <apps/apps_container.h>
extern "C" {
#include <stdlib.h>
@@ -27,7 +28,7 @@ ConsoleController::ConsoleController(Responder * parentResponder, App * pythonDe
TextFieldDelegate(),
MicroPython::ExecutionEnvironment(),
m_pythonDelegate(pythonDelegate),
m_rowHeight(k_font->glyphSize().height()),
m_rowHeight(GlobalPreferences::sharedGlobalPreferences()->font()->glyphSize().height()),
m_importScriptsWhenViewAppears(false),
m_selectableTableView(this, this, this, this),
m_editCell(this, pythonDelegate, this),

View File

@@ -16,8 +16,6 @@ class App;
class ConsoleController : public ViewController, public ListViewDataSource, public SelectableTableViewDataSource, public SelectableTableViewDelegate, public TextFieldDelegate, public MicroPython::ExecutionEnvironment {
public:
static constexpr const KDFont * k_font = KDFont::LargeFont;
ConsoleController(Responder * parentResponder, App * pythonDelegate, ScriptStore * scriptStore
#if EPSILON_GETOPT
, bool m_lockOnConsole

View File

@@ -2,6 +2,7 @@
#include "console_controller.h"
#include <escher/app.h>
#include <apps/i18n.h>
#include <apps/global_preferences.h>
#include <assert.h>
namespace Code {
@@ -9,8 +10,8 @@ namespace Code {
ConsoleEditCell::ConsoleEditCell(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, TextFieldDelegate * delegate) :
HighlightCell(),
Responder(parentResponder),
m_promptView(ConsoleController::k_font, nullptr, 0, 0.5),
m_textField(this, nullptr, TextField::maxBufferSize(), TextField::maxBufferSize(), inputEventHandlerDelegate, delegate, ConsoleController::k_font)
m_promptView(GlobalPreferences::sharedGlobalPreferences()->font(), nullptr, 0, 0.5),
m_textField(this, nullptr, TextField::maxBufferSize(), TextField::maxBufferSize(), inputEventHandlerDelegate, delegate, GlobalPreferences::sharedGlobalPreferences()->font())
{
}

View File

@@ -3,6 +3,7 @@
#include <kandinsky/point.h>
#include <kandinsky/coordinate.h>
#include <apps/i18n.h>
#include <apps/global_preferences.h>
namespace Code {
@@ -18,11 +19,11 @@ void ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::setLine(Consol
void ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(bounds(), KDColorWhite);
ctx->drawString(m_line->text(), KDPointZero, ConsoleController::k_font, textColor(m_line), isHighlighted()? Palette::Select : KDColorWhite);
ctx->drawString(m_line->text(), KDPointZero, GlobalPreferences::sharedGlobalPreferences()->font(), textColor(m_line), isHighlighted()? Palette::Select : KDColorWhite);
}
KDSize ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::minimalSizeForOptimalDisplay() const {
return ConsoleController::k_font->stringSize(m_line->text());
return GlobalPreferences::sharedGlobalPreferences()->font()->stringSize(m_line->text());
}
ConsoleLineCell::ScrollableConsoleLineView::ScrollableConsoleLineView(Responder * parentResponder) :
@@ -34,7 +35,7 @@ ConsoleLineCell::ScrollableConsoleLineView::ScrollableConsoleLineView(Responder
ConsoleLineCell::ConsoleLineCell(Responder * parentResponder) :
HighlightCell(),
Responder(parentResponder),
m_promptView(ConsoleController::k_font, I18n::Message::ConsolePrompt, 0, 0.5),
m_promptView(GlobalPreferences::sharedGlobalPreferences()->font(), I18n::Message::ConsolePrompt, 0, 0.5),
m_scrollableView(this),
m_line()
{
@@ -79,7 +80,7 @@ View * ConsoleLineCell::subviewAtIndex(int index) {
void ConsoleLineCell::layoutSubviews(bool force) {
if (m_line.isCommand()) {
KDSize promptSize = ConsoleController::k_font->stringSize(I18n::translate(I18n::Message::ConsolePrompt));
KDSize promptSize = GlobalPreferences::sharedGlobalPreferences()->font()->stringSize(I18n::translate(I18n::Message::ConsolePrompt));
m_promptView.setFrame(KDRect(KDPointZero, promptSize.width(), bounds().height()), force);
m_scrollableView.setFrame(KDRect(KDPoint(promptSize.width(), 0), bounds().width() - promptSize.width(), bounds().height()), force);
return;