Merge pull request #67 from mateoconlechuga/master

Add shift activated text (Fix #22)
This commit is contained in:
EmilieNumworks
2017-09-05 16:21:48 +02:00
committed by GitHub
9 changed files with 94 additions and 88 deletions

View File

@@ -13,7 +13,6 @@ include apps/code/Makefile
#include apps/picview/Makefile
app_objs += $(addprefix apps/,\
alpha_lock_view.o\
apps_container.o\
apps_window.o\
battery_timer.o\
@@ -29,6 +28,7 @@ app_objs += $(addprefix apps/,\
main.o\
math_toolbox.o\
node.o\
shift_alpha_lock_view.o\
suspend_timer.o\
title_bar_view.o\
toolbox_node.o\

View File

@@ -1,71 +0,0 @@
#include "alpha_lock_view.h"
AlphaLockView::AlphaLockView() :
View(),
m_alphaView(KDText::FontSize::Small, I18n::Message::Default, 1.0f, 0.5f, KDColorWhite, Palette::YellowDark),
m_status(Ion::Events::ShiftAlphaStatus::Default)
{
}
void AlphaLockView::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(bounds(), Palette::YellowDark);
}
bool AlphaLockView::setStatus(Ion::Events::ShiftAlphaStatus status) {
if (status != m_status) {
m_status = status;
switch (status) {
case Ion::Events::ShiftAlphaStatus::Alpha:
case Ion::Events::ShiftAlphaStatus::AlphaLock:
case Ion::Events::ShiftAlphaStatus::AlphaLockShift:
m_alphaView.setMessage(I18n::Message::Alpha);
break;
case Ion::Events::ShiftAlphaStatus::ShiftAlpha:
case Ion::Events::ShiftAlphaStatus::ShiftAlphaLock:
m_alphaView.setMessage(I18n::Message::CapitalAlpha);
break;
default:
m_alphaView.setMessage(I18n::Message::Default);
break;
}
markRectAsDirty(bounds());
return true;
}
return false;
}
KDSize AlphaLockView::minimalSizeForOptimalDisplay() const {
KDSize alphaSize = KDText::stringSize(I18n::translate(I18n::Message::Alpha));
KDSize lockSize = m_lockView.minimalSizeForOptimalDisplay();
KDCoordinate height = lockSize.height() > alphaSize.height() ? lockSize.height() : alphaSize.height();
return KDSize(alphaSize.width() + lockSize.width() + k_lockRightMargin, height);
}
int AlphaLockView::numberOfSubviews() const {
switch (m_status) {
case Ion::Events::ShiftAlphaStatus::Alpha:
case Ion::Events::ShiftAlphaStatus::ShiftAlpha:
return 1;
case Ion::Events::ShiftAlphaStatus::AlphaLock:
case Ion::Events::ShiftAlphaStatus::AlphaLockShift:
case Ion::Events::ShiftAlphaStatus::ShiftAlphaLock:
return 2;
default:
return 0;
}
}
View * AlphaLockView::subviewAtIndex(int index) {
if (index == 0) {
return &m_alphaView;
}
return &m_lockView;
}
void AlphaLockView::layoutSubviews() {
KDSize alphaSize = KDText::stringSize(I18n::translate(I18n::Message::Alpha), KDText::FontSize::Small);
m_alphaView.setFrame(KDRect(bounds().width() - alphaSize.width(), (bounds().height()- alphaSize.height())/2, alphaSize));
KDSize lockSize = m_lockView.minimalSizeForOptimalDisplay();
m_lockView.setFrame(KDRect(bounds().width() - alphaSize.width() - lockSize.width() - k_lockRightMargin, (bounds().height()- lockSize.height())/2, lockSize));
}

View File

@@ -31,7 +31,7 @@ void AppsWindow::refreshPreferences() {
}
bool AppsWindow::updateAlphaLock() {
return m_titleBarView.setAlphaLockStatus(Ion::Events::shiftAlphaStatus());
return m_titleBarView.setShiftAlphaLockStatus(Ion::Events::shiftAlphaStatus());
}
void AppsWindow::hideTitleBarView(bool hide) {

View File

@@ -316,12 +316,13 @@ constexpr static char leftIntegralFirstLegend[] = {'P', '(', 'X', Ion::Charset::
constexpr static char finiteIntegralLegend[] = {Ion::Charset::LessEqual, 'X', Ion::Charset::LessEqual, 0};
const char * universalMessages[241] {
const char * universalMessages[242] {
"",
"Python",
"PYTHON (BETA)",
"alpha",
"ALPHA",
"shift",
"x",
"y",
"n",

View File

@@ -152,7 +152,7 @@ namespace I18n {
ValueNotReachedBySequence,
NColumn,
/* Statistics */
/* Statistics */
StatsApp,
StatsAppCapital,
DataTab,
@@ -276,6 +276,7 @@ namespace I18n {
CodeAppCapital,
Alpha,
CapitalAlpha,
Shift,
X,
Y,
N,

View File

@@ -0,0 +1,75 @@
#include "shift_alpha_lock_view.h"
ShiftAlphaLockView::ShiftAlphaLockView() :
View(),
m_shiftAlphaView(KDText::FontSize::Small, I18n::Message::Default, 1.0f, 0.5f, KDColorWhite, Palette::YellowDark),
m_status(Ion::Events::ShiftAlphaStatus::Default)
{
}
void ShiftAlphaLockView::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(bounds(), Palette::YellowDark);
}
bool ShiftAlphaLockView::setStatus(Ion::Events::ShiftAlphaStatus status) {
if (status != m_status) {
m_status = status;
switch (m_status) {
case Ion::Events::ShiftAlphaStatus::Alpha:
case Ion::Events::ShiftAlphaStatus::AlphaLock:
case Ion::Events::ShiftAlphaStatus::AlphaLockShift:
m_shiftAlphaView.setMessage(I18n::Message::Alpha);
break;
case Ion::Events::ShiftAlphaStatus::ShiftAlpha:
case Ion::Events::ShiftAlphaStatus::ShiftAlphaLock:
m_shiftAlphaView.setMessage(I18n::Message::CapitalAlpha);
break;
case Ion::Events::ShiftAlphaStatus::Shift:
m_shiftAlphaView.setMessage(I18n::Message::Shift);
break;
case Ion::Events::ShiftAlphaStatus::Default:
m_shiftAlphaView.setMessage(I18n::Message::Default);
break;
}
markRectAsDirty(bounds());
return true;
}
return false;
}
KDSize ShiftAlphaLockView::minimalSizeForOptimalDisplay() const {
KDSize modifierSize = KDText::stringSize(I18n::translate(I18n::Message::Alpha), KDText::FontSize::Small);
KDSize lockSize = m_lockView.minimalSizeForOptimalDisplay();
KDCoordinate height = lockSize.height() > modifierSize.height() ? lockSize.height() : modifierSize.height();
return KDSize(modifierSize.width() + lockSize.width() + k_lockRightMargin, height);
}
int ShiftAlphaLockView::numberOfSubviews() const {
switch (m_status) {
case Ion::Events::ShiftAlphaStatus::Alpha:
case Ion::Events::ShiftAlphaStatus::Shift:
case Ion::Events::ShiftAlphaStatus::ShiftAlpha:
return 1;
case Ion::Events::ShiftAlphaStatus::AlphaLock:
case Ion::Events::ShiftAlphaStatus::AlphaLockShift:
case Ion::Events::ShiftAlphaStatus::ShiftAlphaLock:
return 2;
case Ion::Events::ShiftAlphaStatus::Default:
return 0;
}
}
View * ShiftAlphaLockView::subviewAtIndex(int index) {
if (index == 0) {
return &m_shiftAlphaView;
}
return &m_lockView;
}
void ShiftAlphaLockView::layoutSubviews() {
KDSize modifierSize = KDText::stringSize(I18n::translate(I18n::Message::Alpha), KDText::FontSize::Small);
m_shiftAlphaView.setFrame(KDRect(bounds().width() - modifierSize.width(), (bounds().height()- modifierSize.height())/2, modifierSize));
KDSize lockSize = m_lockView.minimalSizeForOptimalDisplay();
m_lockView.setFrame(KDRect(bounds().width() - modifierSize.width() - lockSize.width() - k_lockRightMargin, (bounds().height()- lockSize.height())/2, lockSize));
}

View File

@@ -1,13 +1,13 @@
#ifndef APPS_ALPHA_LOCK_VIEW_H
#define APPS_ALPHA_LOCK_VIEW_H
#ifndef APPS_SHIFT_ALPHA_LOCK_VIEW_H
#define APPS_SHIFT_ALPHA_LOCK_VIEW_H
#include <escher.h>
#include "lock_view.h"
#include "i18n.h"
class AlphaLockView : public View {
class ShiftAlphaLockView : public View {
public:
AlphaLockView();
ShiftAlphaLockView();
void drawRect(KDContext * ctx, KDRect rect) const override;
bool setStatus(Ion::Events::ShiftAlphaStatus status);
KDSize minimalSizeForOptimalDisplay() const override;
@@ -17,7 +17,7 @@ private:
void layoutSubviews() override;
View * subviewAtIndex(int index) override;
LockView m_lockView;
MessageTextView m_alphaView;
MessageTextView m_shiftAlphaView;
Ion::Events::ShiftAlphaStatus m_status;
};

View File

@@ -42,8 +42,8 @@ bool TitleBarView::setIsPlugged(bool isPlugged) {
return m_batteryView.setIsPlugged(isPlugged);
}
bool TitleBarView::setAlphaLockStatus(Ion::Events::ShiftAlphaStatus status) {
return m_alphaLockView.setStatus(status);
bool TitleBarView::setShiftAlphaLockStatus(Ion::Events::ShiftAlphaStatus status) {
return m_shiftAlphaLockView.setStatus(status);
}
int TitleBarView::numberOfSubviews() const {
@@ -61,7 +61,7 @@ View * TitleBarView::subviewAtIndex(int index) {
return &m_examModeIconView;
}
if (index == 3) {
return &m_alphaLockView;
return &m_shiftAlphaLockView;
}
return &m_batteryView;
}
@@ -81,8 +81,8 @@ void TitleBarView::layoutSubviews() {
} else {
m_examModeIconView.setFrame(KDRectZero);
}
KDSize alphaLockSize = m_alphaLockView.minimalSizeForOptimalDisplay();
m_alphaLockView.setFrame(KDRect(bounds().width()-batterySize.width()-k_batteryRightMargin-k_alphaRightMargin-alphaLockSize.width(), (bounds().height()- alphaLockSize.height())/2, alphaLockSize));
KDSize shiftAlphaLockSize = m_shiftAlphaLockView.minimalSizeForOptimalDisplay();
m_shiftAlphaLockView.setFrame(KDRect(bounds().width()-batterySize.width()-k_batteryRightMargin-k_alphaRightMargin-shiftAlphaLockSize.width(), (bounds().height()- shiftAlphaLockSize.height())/2, shiftAlphaLockSize));
}
void TitleBarView::refreshPreferences() {

View File

@@ -3,7 +3,7 @@
#include <escher.h>
#include "battery_view.h"
#include "alpha_lock_view.h"
#include "shift_alpha_lock_view.h"
#include "i18n.h"
class TitleBarView : public View {
@@ -15,7 +15,7 @@ public:
bool setChargeState(Ion::Battery::Charge chargeState);
bool setIsCharging(bool isCharging);
bool setIsPlugged(bool isPlugged);
bool setAlphaLockStatus(Ion::Events::ShiftAlphaStatus status);
bool setShiftAlphaLockStatus(Ion::Events::ShiftAlphaStatus status);
void refreshPreferences();
private:
constexpr static KDCoordinate k_batteryRightMargin = 5;
@@ -29,7 +29,7 @@ private:
View * subviewAtIndex(int index) override;
MessageTextView m_titleView;
BatteryView m_batteryView;
AlphaLockView m_alphaLockView;
ShiftAlphaLockView m_shiftAlphaLockView;
BufferTextView m_preferenceView;
ImageView m_examModeIconView;
};