Compare commits

..

49 Commits

Author SHA1 Message Date
Laury
2abc1d116a [themes] Updated submodules for fast-themes 2022-02-11 18:45:36 +01:00
Laury
63d1e0ee4e [themes] Color with pointers 2022-02-11 18:43:50 +01:00
Laury
84d88a3e8d [Apps] Updated submodules 2021-10-31 21:58:49 +01:00
lolocomotive
00b5d4b9fe Make gutter view background the right width (#70) 2021-10-31 21:43:29 +01:00
Lauryy06
2aee07ae55 [github] Updated issue templates 2021-10-31 21:40:52 +01:00
Yaya-Cout
41b2b64d80 Fix somes Upsilon name in somes files (#61) 2021-10-28 22:23:10 +02:00
Mino1289
473b0bbfcb [apps/settings|code] Add a Flag to remove Code option in settings if code app is not compiled (#67) 2021-10-28 22:20:00 +02:00
Mino1289
58ef8cb95d [apps/code] Remove import of mathsup (residue of #50) (#63) 2021-10-28 19:15:53 +02:00
Mino1289
5dce215165 [build/config.mak] Update of base theme (#64) 2021-10-28 19:15:26 +02:00
lolocomotive
f2f44f0f6f Make use theme colors instead of hard-coded ones (#65) 2021-10-28 19:13:21 +02:00
Laury
fbe542e5bf [python] Fix bug in draw_string 2021-10-28 14:41:33 +02:00
Laury
0a1b3bcaee [theme] Added upsilon light theme 2021-10-28 14:38:32 +02:00
Laury
f6e937a927 [settings] Bug fix in code options controller 2021-10-27 19:35:19 +02:00
Laporte
c4ed8f84d3 Custom themes script (#46) 2021-10-27 19:30:35 +02:00
Yaya-Cout
8e1b311be0 [apps/settings] Fix gamma selector (#60) 2021-10-27 19:29:53 +02:00
lolocomotive
89e51166e7 Make battery background use appropriate colors (#59) 2021-10-27 10:10:14 +02:00
Mino1289
e4961563e9 [apps/code] Remove base python script and add mathsup.py (#50) 2021-10-25 16:27:21 +02:00
Laury
e72b0f633e [calculation] Fix bug in second degree list controller 2021-10-24 19:31:14 +02:00
Hector
0550b66c03 Dark Theme changes (#42)
* Dark Theme changes

* added reader icon for dark mode

* epsilon Dark Theme changes
2021-10-20 23:11:30 +02:00
Lauryy06
e41910e2f8 [workflow] Re-update SDK version of emscripten 2021-10-20 22:38:49 +02:00
Lauryy06
d91ae29607 [workflow] Change sdk of emscripten for tests 2021-10-20 22:36:18 +02:00
ArtichautCosmique
3b90969b42 [mpy] Enabled property/etc decorators (#52) 2021-10-20 22:26:01 +02:00
lolocomotive
bd207cb845 Replace hard-coded color values with Palette colors and use the correct palette colors (#51) 2021-10-20 22:25:27 +02:00
lolocomotive
917ba7ce83 Allow themes to override default colors (#49) 2021-10-20 22:20:19 +02:00
Laury
9c9758fcb6 [reader] update README 2021-10-15 14:50:03 +02:00
Laury
83ce9d5e86 [reader] Rich text support (look at README.md) 2021-10-15 14:47:00 +02:00
ArtichOwO
d4f0c7d3e8 Added sys to the code toolbox 2021-10-15 14:47:00 +02:00
ArtichOwO
2837b240e9 [mpy] Added sys module
Removed useless "path" and "argv"
2021-10-15 14:46:39 +02:00
ArtichautCosmique
0906dc919b [mpy/kandinsky] Fix draw_string() on new line + good colors (#47)
* [mpy/kandinsky] Use good colors

* [kandinsky/context_text] Avoid returning to pos x=0 on new line, use arg's x coordinate instead
2021-10-11 20:25:03 +02:00
Faustin
9cda9d9e59 [apps/code] Add a settings for autocomplete (#36) 2021-10-07 21:48:19 +02:00
Yaya-Cout
553f3fc682 [apps/settings] Use right key to enable setting (#35) 2021-10-07 20:36:03 +02:00
Mino1289
9fdedecbff [apps/toolbox] Order of submenus & New electricity constants (#34) 2021-10-06 18:26:17 +02:00
Lauryy06
83c63a7011 [readme] Update readme 2021-10-01 21:37:44 +02:00
Yolwoocle
9636964cb9 Better English translation (#32) 2021-09-29 18:31:10 +02:00
Yaya-Cout
69d6ad5205 Add get_keys in toolbox and fix setlocaltime description (#33) 2021-09-29 18:30:30 +02:00
Laury
f9a123cc08 [mpy/ulab] Added support of from and to bytes array methods 2021-09-28 20:50:34 +02:00
Lauryy06
56f735e302 [github] update metric-workflow.yml 2021-09-26 20:50:53 +02:00
ArtichautCosmique
0a5e9e0889 [apps/code][mpy][makefile] Fix size error on n0100 (#30) 2021-09-26 20:37:56 +02:00
apoleon33
8c949d7048 [build]changed color of upsilon logo in pimp.mak (#31) 2021-09-26 20:36:13 +02:00
Laporte
2f7edc5024 Update pimp.mak (#29)
* Update pimp.mak

Mise a jour du pimp.mak pour le nouveau slogan et le logo ascii.

* Update pimp.mak
2021-09-26 14:25:00 +02:00
Lauryy06
cd40938b26 [readme] Add a capital line 10 2021-09-25 19:52:14 +02:00
ArtichautCosmique
0b54bf13f4 [storage][apps/code] Change sizes (#28) 2021-09-25 19:49:26 +02:00
Laury
f5f11c6478 [poincare] Added simplification of equals 2021-09-25 19:32:23 +02:00
ArtichautCosmique
efda561425 [ion/device/flasher] Pimp my flasher (light & verbose) (#27) 2021-09-25 18:55:43 +02:00
Lauryy06
15c96cefa6 [readme] Update french readme 2021-09-25 10:29:29 +02:00
Lauryy06
400d03ebdb [readme] Addition of a "useful links" section 2021-09-25 10:25:57 +02:00
Lauryy06
6f48adde7d Merge pull request #25 from Mino1289/upsilon-dev-dev 2021-09-25 10:17:21 +02:00
Mino1289
3a573b1204 [apps/code] fix typo 2021-09-24 11:15:56 +02:00
Mino1289
48598296cf [apps/code] Increase of number of variables loaded in the variable box 2021-09-24 11:09:23 +02:00
304 changed files with 2555 additions and 1026 deletions

View File

@@ -1,6 +1,6 @@
---
name: Bug report
about: Omega is not working like it should? Let us know!
about: Upsilon is not working like it should? Let us know!
title: ''
labels: 'Status: Triage, Type: Bug'
assignees: ''
@@ -24,4 +24,4 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- Omega Version: [go to settings > about > Omega Version and type the version here]
- Upsilon Version: [go to settings > about > Upsilon Version and type the version here]

View File

@@ -1,6 +1,6 @@
---
name: Feature request
about: Suggest an idea for Omega
about: Suggest an idea for Upsilon
title: ''
labels: 'Status: Triage, Type: Feature'
assignees: ''

View File

@@ -1,28 +0,0 @@
---
name: OMEGA BETA ONLY - Bug report
about: Omega 1.21 is not working like it should? Let us know!
title: "[BETA-1.21] …"
labels: 'Status: Triage, Type: Bug'
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- Omega Version: [go to settings > about > Omega Version and type the version here]
- Discord username: ..........#....

View File

@@ -1,6 +1,6 @@
---
name: Problems during installation
about: Need help to install Omega?
about: Need help to install Upsilon?
title: ''
labels: 'Status: Triage, Type: Installation issue'
assignees: ''
@@ -16,4 +16,4 @@ Copy/paste the logs here (If you have some)
```
**Environment**
- Omega Version: {go to settings > about > Omega Version and type the version here}
- Upsilon Version: {go to settings > about > Upsilon Version and type the version here}

View File

@@ -140,7 +140,7 @@ jobs:
steps:
- uses: numworks/setup-emscripten@v1
with:
sdk: latest-upstream
sdk: 1.40.1-fastcomp
- uses: actions/checkout@v2
with:
submodules: 'recursive'

View File

@@ -31,7 +31,6 @@ jobs:
- name: Add comment
uses: actions/github-script@v3.0.0
with:
github-token: ${{ secrets.OMEGA_ROBOT_TOKEN }}
script: |
await github.issues.createComment({
owner: context.repo.owner,

2
.gitmodules vendored
View File

@@ -1,6 +1,6 @@
[submodule "apps/rpn"]
path = apps/rpn
url = https://github.com/Omega-Numworks/Omega-RPN.git
url = https://github.com/Lauryy06/Upsilon-RPN.git
[submodule "apps/atomic"]
path = apps/atomic
url = https://github.com/Lauryy06/atomic

View File

@@ -13,7 +13,18 @@ include build/variants.mak
include build/helpers.mk
ifeq (${MODEL}, n0100)
EPSILON_APPS := $(filter-out reader,$(EPSILON_APPS))
ifeq ($(filter reader,$(apps_list)),)
$(warning reader app included, removing it on n0100. )
EPSILON_APPS := $(filter-out reader,$(EPSILON_APPS))
endif
ifneq ($(words $(EPSILON_I18N)), 1)
$(warning Only use 1 language on n0100, defaulting to en. )
EPSILON_I18N := en
endif
ifeq ($(INCLUDE_ULAB), 1)
$(warning Removing uLab on n0100. )
INCLUDE_ULAB := 0
endif
endif
ifeq (${MODEL}, n0110)
@@ -26,6 +37,10 @@ ifdef FORCE_EXTERNAL
apps_list = ${EPSILON_APPS}
endif
ifeq ($(INCLUDE_ULAB), 1)
SFLAGS += -DINCLUDE_ULAB
endif
ifdef HOME_DISPLAY_EXTERNALS
ifneq ($(filter external,$(apps_list)),)
SFLAGS += -DHOME_DISPLAY_EXTERNALS

View File

@@ -126,7 +126,7 @@ Vous aurez besoin de devkitPro et de devkitARM disponible dans votre `$PATH` (in
```bash
git clone --recursive https://github.com/Lauryy06/Upsilon.git
cd Upsilon
git checkout --recursive omega-dev
git checkout --recursive upsilon-dev
make PLATFORM=simulator TARGET=3ds -j
```
@@ -143,6 +143,10 @@ Si vous avez besoin d'aide, n'hésitez pas à rejoindre notre serveur discord :
<a href="https://discord.gg/Q9buEMduXG"><p align="center"><img alt="Omega Banner Discord" src="https://user-images.githubusercontent.com/12123721/86287349-54ef5800-bbe8-11ea-80c1-34eb1f93eebd.png" /></p></a>
---
## Liens utiles
* [Upsilon external (pour installer des applications supplémentaires et des fonds d'écran)](https://lauryy06.github.io/Upsilon-External/)
* [Documentation d'ulab](https://micropython-ulab.readthedocs.io/en/latest/)
## Contribution
Pour contribuer, merci de lire le [Wiki d'Omega](https://github.com/Omega-Numworks/Omega/wiki/Contributing), les mêmes règles s'appliquent ici.

View File

@@ -7,7 +7,7 @@
<a href="https://discord.gg/Q9buEMduXG"><img alt="Discord" src="https://img.shields.io/discord/663420259851567114?color=blue&labelColor=292929&label=chat%20-%20discord&logo=discord&style=for-the-badge" /></a>
</p>
> Vous ne comprenez pas l'anglais ? vous êtes francophone ? Regardez le [*LISEZ-MOI* français](./README.fr.md) !
> Vous ne comprenez pas l'anglais ? Vous êtes francophone ? Regardez le [*LISEZ-MOI* français](./README.fr.md) !
## About
@@ -18,7 +18,7 @@ Upsilon is a fork of Omega, an user-made OS that runs on the Numworks calculator
### Some new features
- Enhancements for the Kandinsky python module
- A support for wallpapers
- Support for wallpapers
- Exernal apps
- A custom theme
- Operator overload for python
@@ -240,7 +240,7 @@ You need devkitPro and devkitARM installed and in your path (instructions [here]
```bash
git clone --recursive https://github.com/Lauryy06/Upsilon.git
cd Upsilon
git checkout --recursive omega-dev
git checkout --recursive upsilon-dev
make PLATFORM=simulator TARGET=3ds -j
```
You can then put epsilon.3dsx on a SD card to run it from the HBC or use 3dslink to launch it over the network:
@@ -259,15 +259,18 @@ Don't forget to put your pseudo instead of `{your pseudo, max 15 char}`. If you
<br>
If you need help, you can join our Discord server here : https://discord.gg/Q9buEMduXG
If you need help, you can join our Discord server here : https://discord.gg/NFvzdCBTQn
<a href="https://discord.gg/Q9buEMduXG"><p align="center"><img alt="Omega Banner Discord" src="https://user-images.githubusercontent.com/12123721/86287349-54ef5800-bbe8-11ea-80c1-34eb1f93eebd.png" /></p></a>
<a href="https://discord.gg/NFvzdCBTQn"><p align="center"><img alt="Omega Banner Discord" src="https://user-images.githubusercontent.com/12123721/86287349-54ef5800-bbe8-11ea-80c1-34eb1f93eebd.png" /></p></a>
---
## Useful links
* [Upsilon external (to install additional apps and wallpapers)](https://lauryy06.github.io/Upsilon-External/)
* [Ulab documentation](https://micropython-ulab.readthedocs.io/en/latest/)
## Contributing
To contribute, please refer to [Omega's Wiki](https://github.com/Omega-Numworks/Omega/wiki/Contributing), the same rules apply here.
## Related repositories
Here are the main links toward Omega's different websites and repositories, that have been used for the creation of Upsilon.

View File

@@ -66,8 +66,8 @@ private:
bool updateAlphaLock();
static I18n::Message k_promptMessages[];
static KDColor k_promptFGColors[];
static KDColor k_promptBGColors[];
static KDColor const * k_promptFGColors[];
static KDColor const * k_promptBGColors[];
static int k_promptNumberOfMessages;
AppsWindow m_window;
EmptyBatteryWindow m_emptyBatteryWindow;

View File

@@ -11,14 +11,14 @@ I18n::Message AppsContainer::k_promptMessages[] = {
I18n::Message::BetaVersionMessage6};
KDColor AppsContainer::k_promptFGColors[] = {
KDColorBlack,
KDColorBlack,
KDColorBlack,
KDColorBlack,
KDColorWhite,
KDColorBlack,
KDColorBlack,
Palette::AccentText};
&KDColorBlack,
&KDColorBlack,
&KDColorBlack,
&KDColorBlack,
&KDColorWhite,
&KDColorBlack,
&KDColorBlack,
*Palette::AccentText};
KDColor AppsContainer::k_promptBGColors[] = {
KDColorWhite,

View File

@@ -2,8 +2,8 @@
I18n::Message AppsContainer::k_promptMessages[] = {};
KDColor AppsContainer::k_promptFGColors[] = {};
KDColor AppsContainer::k_promptBGColors[] = {};
KDColor const * AppsContainer::k_promptFGColors[] = {};
KDColor const * AppsContainer::k_promptBGColors[] = {};
int AppsContainer::k_promptNumberOfMessages = 0;

View File

@@ -8,15 +8,15 @@ I18n::Message AppsContainer::k_promptMessages[] = {
I18n::Message::UpdateMessage3,
I18n::Message::UpdateMessage4};
KDColor AppsContainer::k_promptFGColors[] = {
KDColorBlack,
KDColorBlack,
KDColorBlack,
KDColorWhite,
KDColorBlack,
Palette::AccentText};
KDColor const * AppsContainer::k_promptFGColors[] = {
&KDColorBlack,
&KDColorBlack,
&KDColorBlack,
&KDColorWhite,
&KDColorBlack,
*Palette::AccentText};
KDColor AppsContainer::k_promptBGColors[] = {
KDColor const * AppsContainer::k_promptBGColors[] = {
KDColorWhite,
KDColorWhite,
KDColorWhite,

View File

@@ -60,43 +60,43 @@ void BatteryView::drawRect(KDContext * ctx, KDRect rect) const {
*'content' depends on the charge */
// Draw the left part
ctx->fillRect(KDRect(0, 0, k_elementWidth, k_batteryHeight), Palette::Battery);
ctx->fillRect(KDRect(0, 0, k_elementWidth, k_batteryHeight), *Palette::Battery);
// Draw the middle part
constexpr KDCoordinate batteryInsideX = k_elementWidth+k_separatorThickness;
constexpr KDCoordinate batteryInsideWidth = k_batteryWidth-3*k_elementWidth-2*k_separatorThickness;
if (m_isCharging) {
// Charging: Yellow background with flash
ctx->fillRect(KDRect(batteryInsideX, 0, batteryInsideWidth, k_batteryHeight), Palette::BatteryInCharge);
ctx->fillRect(KDRect(batteryInsideX, 0, batteryInsideWidth, k_batteryHeight), *Palette::BatteryInCharge);
KDRect frame((k_batteryWidth-k_flashWidth)/2, 0, k_flashWidth, k_flashHeight);
KDColor flashWorkingBuffer[BatteryView::k_flashHeight*BatteryView::k_flashWidth];
ctx->blendRectWithMask(frame, Palette::Battery, (const uint8_t *)flashMask, flashWorkingBuffer);
ctx->blendRectWithMask(frame, *Palette::Battery, (const uint8_t *)flashMask, flashWorkingBuffer);
} else if (m_chargeState == Ion::Battery::Charge::LOW) {
assert(!m_isPlugged);
// Low: Quite empty battery
ctx->fillRect(KDRect(batteryInsideX, 0, 2*k_elementWidth, k_batteryHeight), Palette::BatteryLow);
ctx->fillRect(KDRect(3*k_elementWidth+k_separatorThickness, 0, k_batteryWidth-5*k_elementWidth-2*k_separatorThickness, k_batteryHeight), Palette::BatteryInCharge);
ctx->fillRect(KDRect(batteryInsideX, 0, 2*k_elementWidth, k_batteryHeight), *Palette::BatteryLow);
ctx->fillRect(KDRect(3*k_elementWidth+k_separatorThickness, 0, k_batteryWidth-5*k_elementWidth-2*k_separatorThickness, k_batteryHeight), KDColor::blend(*Palette::Toolbar, *Palette::Battery, 128));
} else if (m_chargeState == Ion::Battery::Charge::SOMEWHERE_INBETWEEN) {
assert(!m_isPlugged);
// Middle: Half full battery
constexpr KDCoordinate middleChargeWidth = batteryInsideWidth/2;
ctx->fillRect(KDRect(batteryInsideX, 0, middleChargeWidth, k_batteryHeight), Palette::Battery);
ctx->fillRect(KDRect(batteryInsideX+middleChargeWidth, 0, middleChargeWidth, k_batteryHeight), Palette::BatteryInCharge);
ctx->fillRect(KDRect(batteryInsideX, 0, middleChargeWidth, k_batteryHeight), *Palette::Battery);
ctx->fillRect(KDRect(batteryInsideX+middleChargeWidth, 0, middleChargeWidth, k_batteryHeight), KDColor::blend(*Palette::Toolbar, *Palette::Battery, 128));
} else {
assert(m_chargeState == Ion::Battery::Charge::FULL);
// Full but not plugged: Full battery
ctx->fillRect(KDRect(batteryInsideX, 0, batteryInsideWidth, k_batteryHeight), Palette::Battery);
ctx->fillRect(KDRect(batteryInsideX, 0, batteryInsideWidth, k_batteryHeight), *Palette::Battery);
if (m_isPlugged) {
// Plugged and full: Full battery with tick
KDRect frame((k_batteryWidth-k_tickWidth)/2, (k_batteryHeight-k_tickHeight)/2, k_tickWidth, k_tickHeight);
KDColor tickWorkingBuffer[BatteryView::k_tickHeight*BatteryView::k_tickWidth];
ctx->blendRectWithMask(frame, Palette::Toolbar, (const uint8_t *)tickMask, tickWorkingBuffer);
ctx->blendRectWithMask(frame, *Palette::Toolbar, (const uint8_t *)tickMask, tickWorkingBuffer);
}
}
// Draw the right part
ctx->fillRect(KDRect(k_batteryWidth-2*k_elementWidth, 0, k_elementWidth, k_batteryHeight), Palette::Battery);
ctx->fillRect(KDRect(k_batteryWidth-k_elementWidth, (k_batteryHeight-k_capHeight)/2, k_elementWidth, k_capHeight), Palette::Battery);
ctx->fillRect(KDRect(k_batteryWidth-2*k_elementWidth, 0, k_elementWidth, k_batteryHeight), *Palette::Battery);
ctx->fillRect(KDRect(k_batteryWidth-k_elementWidth, (k_batteryHeight-k_capHeight)/2, k_elementWidth, k_capHeight), *Palette::Battery);
}
KDSize BatteryView::minimalSizeForOptimalDisplay() const {

View File

@@ -13,7 +13,7 @@ ComplexGraphView::ComplexGraphView(ComplexModel * complexModel) :
}
void ComplexGraphView::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(rect, Palette::BackgroundApps);
ctx->fillRect(rect, *Palette::BackgroundApps);
// Draw grid, axes and graduations
drawGrid(ctx, rect);
@@ -26,7 +26,7 @@ void ComplexGraphView::drawRect(KDContext * ctx, KDRect rect) const {
assert(!std::isnan(real) && !std::isnan(imag) && !std::isinf(real) && !std::isinf(imag));
// Draw the segment from the origin to the dot (real, imag)
drawSegment(ctx, rect, 0.0f, 0.0f, m_complex->real(), m_complex->imag(), Palette::SecondaryText, false);
drawSegment(ctx, rect, 0.0f, 0.0f, m_complex->real(), m_complex->imag(), *Palette::SecondaryText, false);
/* Draw the partial ellipse indicating the angle θ
* - the ellipse parameters are a = |real|/5 and b = |imag|/5,
@@ -59,27 +59,27 @@ void ComplexGraphView::drawRect(KDContext * ctx, KDRect rect) const {
float a = parameters.real();
float b = parameters.imag();
return Poincare::Coordinate2D<float>(a*std::cos(t*th), b*std::sin(t*th));
}, &parameters, &th, false, Palette::SecondaryText, false);
}, &parameters, &th, false, *Palette::SecondaryText, false);
// Draw dashed segment to indicate real and imaginary
drawHorizontalOrVerticalSegment(ctx, rect, Axis::Vertical, real, 0.0f, imag, Palette::CalculationTrigoAndComplexForeground, 1, 3);
drawHorizontalOrVerticalSegment(ctx, rect, Axis::Horizontal, imag, 0.0f, real, Palette::CalculationTrigoAndComplexForeground, 1, 3);
drawHorizontalOrVerticalSegment(ctx, rect, Axis::Vertical, real, 0.0f, imag, *Palette::CalculationTrigoAndComplexForeground, 1, 3);
drawHorizontalOrVerticalSegment(ctx, rect, Axis::Horizontal, imag, 0.0f, real, *Palette::CalculationTrigoAndComplexForeground, 1, 3);
// Draw complex position on the plan
drawDot(ctx, rect, real, imag, Palette::CalculationTrigoAndComplexForeground, Size::Large);
drawDot(ctx, rect, real, imag, *Palette::CalculationTrigoAndComplexForeground, Size::Large);
// Draw labels
// 're(z)' label
drawLabel(ctx, rect, real, 0.0f, "re(z)", Palette::CalculationTrigoAndComplexForeground, CurveView::RelativePosition::None, imag >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After);
drawLabel(ctx, rect, real, 0.0f, "re(z)", *Palette::CalculationTrigoAndComplexForeground, CurveView::RelativePosition::None, imag >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After);
// 'im(z)' label
drawLabel(ctx, rect, 0.0f, imag, "im(z)", Palette::CalculationTrigoAndComplexForeground, real >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After, CurveView::RelativePosition::None);
drawLabel(ctx, rect, 0.0f, imag, "im(z)", *Palette::CalculationTrigoAndComplexForeground, real >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After, CurveView::RelativePosition::None);
// '|z|' label, the relative horizontal position of this label depends on the quadrant
CurveView::RelativePosition verticalPosition = real*imag < 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After;
if (real == 0.0f) {
// Edge case: pure imaginary
verticalPosition = CurveView::RelativePosition::None;
}
drawLabel(ctx, rect, real/2.0f, imag/2.0f, "|z|", Palette::CalculationTrigoAndComplexForeground, CurveView::RelativePosition::None, verticalPosition);
drawLabel(ctx, rect, real/2.0f, imag/2.0f, "|z|", *Palette::CalculationTrigoAndComplexForeground, CurveView::RelativePosition::None, verticalPosition);
// 'arg(z)' label, the absolute and relative horizontal/vertical positions of this label depends on the quadrant
CurveView::RelativePosition horizontalPosition = real >= 0.0f ? CurveView::RelativePosition::After : CurveView::RelativePosition::None;
verticalPosition = imag >= 0.0f ? CurveView::RelativePosition::After : CurveView::RelativePosition::Before;
@@ -88,7 +88,7 @@ void ComplexGraphView::drawRect(KDContext * ctx, KDRect rect) const {
* and for the left half plan, we position the label at the half angle. The
* relative position is chosen accordingly. */
float anglePositionRatio = real >= 0.0f ? 0.0f : 0.5f;
drawLabel(ctx, rect, a*std::cos(anglePositionRatio*th), b*std::sin(anglePositionRatio*th), "arg(z)", Palette::CalculationTrigoAndComplexForeground, horizontalPosition, verticalPosition);
drawLabel(ctx, rect, a*std::cos(anglePositionRatio*th), b*std::sin(anglePositionRatio*th), "arg(z)", *Palette::CalculationTrigoAndComplexForeground, horizontalPosition, verticalPosition);
}
}

View File

@@ -15,7 +15,7 @@ void ExpressionWithEqualSignView::drawRect(KDContext * ctx, KDRect rect) const {
// Do not color the whole background to avoid coloring behind the equal symbol
KDSize expressionSize = ExpressionView::minimalSizeForOptimalDisplay();
ctx->fillRect(KDRect(0, 0, expressionSize), m_backgroundColor);
m_layout.draw(ctx, drawingOrigin(), m_textColor, m_backgroundColor, m_selectionStart, m_selectionEnd, Palette::Select);
m_layout.draw(ctx, drawingOrigin(), m_textColor, m_backgroundColor, m_selectionStart, m_selectionEnd, *Palette::Select);
}
View * ExpressionWithEqualSignView::subviewAtIndex(int index) {

View File

@@ -11,7 +11,7 @@ namespace Calculation {
class ExpressionWithEqualSignView : public ExpressionView {
public:
ExpressionWithEqualSignView() :
m_equalSign(KDFont::LargeFont, I18n::Message::Equal, 0.5f, 0.5f, Palette::PrimaryText)
m_equalSign(KDFont::LargeFont, I18n::Message::Equal, 0.5f, 0.5f, *Palette::PrimaryText)
{}
KDSize minimalSizeForOptimalDisplay() const override;
void drawRect(KDContext * ctx, KDRect rect) const override;

View File

@@ -10,7 +10,7 @@ void IllustrationCell::layoutSubviews(bool force) {
}
void IllustrationCell::drawRect(KDContext * ctx, KDRect rect) const {
drawBorderOfRect(ctx, bounds(), Palette::ListCellBorder);
drawBorderOfRect(ctx, bounds(), *Palette::ListCellBorder);
}
}

View File

@@ -22,7 +22,7 @@ void ListController::InnerListController::didBecomeFirstResponder() {
/* List Controller */
ListController::ListController(EditExpressionController * editExpressionController, SelectableTableViewDelegate * delegate) :
StackViewController(nullptr, &m_listController, Palette::ToolboxHeaderText, Palette::ToolboxHeaderBackground, Palette::ToolboxHeaderBorder),
StackViewController(nullptr, &m_listController, *Palette::ToolboxHeaderText, *Palette::ToolboxHeaderBackground, *Palette::ToolboxHeaderBorder),
m_listController(this, delegate),
m_editExpressionController(editExpressionController)
{

View File

@@ -17,7 +17,7 @@ public:
static constexpr KDCoordinate k_margin = Metric::CommonSmallMargin;
ScrollableThreeExpressionsView(Responder * parentResponder) : Shared::AbstractScrollableMultipleExpressionsView(parentResponder, &m_contentCell), m_contentCell() {
setMargins(k_margin, k_margin, k_margin, k_margin); // Left Right margins are already added by TableCell
setBackgroundColor(Palette::BackgroundApps);
setBackgroundColor(*Palette::BackgroundApps);
}
void resetMemoization();
void setCalculation(Calculation * calculation, bool canChangeDisplayOutput);
@@ -28,7 +28,7 @@ private:
class ContentCell : public Shared::AbstractScrollableMultipleExpressionsView::ContentCell {
public:
ContentCell() : m_leftExpressionView() {}
KDColor backgroundColor() const override { return Palette::BackgroundApps; }
KDColor backgroundColor() const override { return *Palette::BackgroundApps; }
void setEven(bool even) override { return; }
ExpressionView * leftExpressionView() const override { return const_cast<ExpressionWithEqualSignView *>(&m_leftExpressionView); }
private:

View File

@@ -29,6 +29,12 @@ void SecondDegreeListController::setExpression(Poincare::Expression e) {
Context * context = App::app()->localContext();
Preferences * preferences = Preferences::sharedPreferences();
Poincare::ExpressionNode::ReductionContext reductionContext = Poincare::ExpressionNode::ReductionContext(context,
preferences->complexFormat(), preferences->angleUnit(),
GlobalPreferences::sharedGlobalPreferences()->unitFormat(),
ExpressionNode::ReductionTarget::SystemForApproximation,
ExpressionNode::SymbolicComputation::ReplaceAllDefinedSymbolsWithDefinition,
Poincare::ExpressionNode::UnitConversion::Default);
PoincareHelpers::Reduce(&m_expression, context, ExpressionNode::ReductionTarget::SystemForAnalysis);
@@ -46,60 +52,108 @@ void SecondDegreeListController::setExpression(Poincare::Expression e) {
Expression a = polynomialCoefficients[2];
Expression b = polynomialCoefficients[1];
Expression c = polynomialCoefficients[0];
bool aIsNotOne = !(a.type() == ExpressionNode::Type::Rational && static_cast<const Rational &>(a).isOne());
Expression delta = Subtraction::Builder(Power::Builder(b.clone(), Rational::Builder(2)), Multiplication::Builder(Rational::Builder(4), a.clone(), c.clone()));
PoincareHelpers::Simplify(&delta, context, ExpressionNode::ReductionTarget::SystemForApproximation);
Expression alpha = Opposite::Builder(Division::Builder(b.clone(), Multiplication::Builder(Rational::Builder(2), a.clone())));
PoincareHelpers::Simplify(&alpha, context, ExpressionNode::ReductionTarget::User);
// Alpha is -b/2a, but because after we use -α, we immediately store -α=-(-b/2a)=b/2a.
Expression minusAlpha = Division::Builder(b.clone(), Multiplication::Builder(Rational::Builder(2), a.clone()));
PoincareHelpers::Reduce(&minusAlpha, context, ExpressionNode::ReductionTarget::SystemForApproximation);
Expression beta = Opposite::Builder(Division::Builder(delta.clone(), Multiplication::Builder(Rational::Builder(4), a.clone())));
PoincareHelpers::Simplify(&beta, context, ExpressionNode::ReductionTarget::User);
// Same thing for β
Expression minusBeta = Division::Builder(delta.clone(), Multiplication::Builder(Rational::Builder(4), a.clone()));
PoincareHelpers::Reduce(&minusBeta, context, ExpressionNode::ReductionTarget::SystemForApproximation);
enum MultiplicationTypeForA {
Nothing,
Minus,
Parenthesis,
Normal
};
MultiplicationTypeForA multiplicationTypeForA;
if (a.type() == ExpressionNode::Type::Rational && static_cast<const Rational &>(a).isOne()) {
multiplicationTypeForA = MultiplicationTypeForA::Nothing;
}
else if(a.type() == ExpressionNode::Type::Rational && static_cast<const Rational &>(a).isMinusOne()){
multiplicationTypeForA = MultiplicationTypeForA::Minus;
}
else if (a.type() == ExpressionNode::Type::Addition) {
multiplicationTypeForA = MultiplicationTypeForA::Parenthesis;
}
else {
multiplicationTypeForA = MultiplicationTypeForA::Normal;
}
PoincareHelpers::Simplify(&a, context, ExpressionNode::ReductionTarget::User);
/*
* Because when can't apply reduce or simplify to keep the canonised
* we must beautify the expression manually
* Because when can't apply reduce or simplify to keep the
* canonized form we must beautify the expression manually
*/
Expression canonised;
if (alpha.type() == ExpressionNode::Type::Opposite) {
canonised = Addition::Builder(Symbol::Builder("x", strlen("x")), alpha.childAtIndex(0).clone());
}
else {
canonised = Subtraction::Builder(Symbol::Builder("x", strlen("x")), alpha.clone());
}
canonised = Power::Builder(Parenthesis::Builder(canonised.clone()), Rational::Builder(2));
if (aIsNotOne) {
canonised = Multiplication::Builder(a.clone(), canonised.clone());
}
if (beta.type() == ExpressionNode::Type::Opposite) {
canonised = Subtraction::Builder(canonised.clone(), beta.childAtIndex(0).clone());
}
else {
canonised = Addition::Builder(canonised.clone(), beta.clone());
}
Expression xMinusAlphaPowerTwo;
Expression alpha = getOppositeIfExists(minusAlpha, &reductionContext);
if (alpha.isUninitialized()) {
PoincareHelpers::Simplify(&minusAlpha, context, ExpressionNode::ReductionTarget::User);
xMinusAlphaPowerTwo = Power::Builder(Parenthesis::Builder(Addition::Builder(Symbol::Builder("x", strlen("x")), minusAlpha)), Rational::Builder(2));
}
else {
PoincareHelpers::Simplify(&alpha, context, ExpressionNode::ReductionTarget::User);
xMinusAlphaPowerTwo = Power::Builder(Parenthesis::Builder(Subtraction::Builder(Symbol::Builder("x", strlen("x")), alpha)), Rational::Builder(2));
}
Expression xMinusAlphaPowerTwoWithFactor;
switch (multiplicationTypeForA)
{
case MultiplicationTypeForA::Nothing:
xMinusAlphaPowerTwoWithFactor = xMinusAlphaPowerTwo;
break;
case MultiplicationTypeForA::Minus:
xMinusAlphaPowerTwoWithFactor = Multiplication::Builder(a.clone(), xMinusAlphaPowerTwo);
break;
case MultiplicationTypeForA::Parenthesis:
xMinusAlphaPowerTwoWithFactor = Multiplication::Builder(Parenthesis::Builder(a.clone()), xMinusAlphaPowerTwo);
break;
case MultiplicationTypeForA::Normal:
xMinusAlphaPowerTwoWithFactor = Multiplication::Builder(a.clone(), xMinusAlphaPowerTwo);
break;
default:
assert(false);
break;
}
Expression canonized;
Expression beta = getOppositeIfExists(minusBeta, &reductionContext);
if (beta.isUninitialized()) {
PoincareHelpers::Simplify(&minusBeta, context, ExpressionNode::ReductionTarget::User);
canonized = Subtraction::Builder(xMinusAlphaPowerTwoWithFactor, minusBeta);
}
else {
PoincareHelpers::Simplify(&beta, context, ExpressionNode::ReductionTarget::User);
canonized = Addition::Builder(xMinusAlphaPowerTwoWithFactor, beta);
}
Expression x0;
Expression x1;
if (delta.nullStatus(context) == ExpressionNode::NullStatus::Null) {
// x0 = x1 = -b/(2a)
x0 = Division::Builder(Opposite::Builder(b), Multiplication::Builder(Rational::Builder(2), a));
x0 = Division::Builder(Opposite::Builder(b.clone()), Multiplication::Builder(Rational::Builder(2), a.clone()));
m_numberOfSolutions = 1;
PoincareHelpers::Simplify(&x0, context, ExpressionNode::ReductionTarget::User);
PoincareHelpers::Simplify(&x0, context, ExpressionNode::ReductionTarget::SystemForApproximation);
}
else {
// x0 = (-b-sqrt(delta))/(2a)
x0 = Division::Builder(Subtraction::Builder(Opposite::Builder(b.clone()), SquareRoot::Builder(delta.clone())), Multiplication::Builder(Rational::Builder(2), a.clone()));
// x1 = (-b+sqrt(delta))/(2a)
x1 = Division::Builder(Addition::Builder(Opposite::Builder(b), SquareRoot::Builder(delta.clone())), Multiplication::Builder(Rational::Builder(2), a));
x1 = Division::Builder(Addition::Builder(Opposite::Builder(b.clone()), SquareRoot::Builder(delta.clone())), Multiplication::Builder(Rational::Builder(2), a.clone()));
m_numberOfSolutions = 2;
PoincareHelpers::Simplify(&x0, context, ExpressionNode::ReductionTarget::User);
PoincareHelpers::Simplify(&x1, context, ExpressionNode::ReductionTarget::User);
PoincareHelpers::Simplify(&x0, context, ExpressionNode::ReductionTarget::SystemForApproximation);
PoincareHelpers::Simplify(&x1, context, ExpressionNode::ReductionTarget::SystemForApproximation);
if (x0.type() == ExpressionNode::Type::Unreal) {
assert(x1.type() == ExpressionNode::Type::Unreal);
m_numberOfSolutions = 0;
@@ -109,40 +163,87 @@ void SecondDegreeListController::setExpression(Poincare::Expression e) {
Expression factorized;
if (m_numberOfSolutions == 2) {
Expression firstFactor;
Expression secondFactor;
Expression x0Opposite = getOppositeIfExists(x0, &reductionContext);
if (x0Opposite.isUninitialized()) {
PoincareHelpers::Simplify(&x0, context, ExpressionNode::ReductionTarget::User);
firstFactor = Subtraction::Builder(Symbol::Builder("x", strlen("x")), x0);
}
else {
PoincareHelpers::Simplify(&x0Opposite, context, ExpressionNode::ReductionTarget::User);
firstFactor = Addition::Builder(Symbol::Builder("x", strlen("x")), x0Opposite);
}
if (x0.type() == ExpressionNode::Type::Opposite) {
factorized = Parenthesis::Builder(Addition::Builder(Symbol::Builder("x", strlen("x")), x0.childAtIndex(0).clone()));
}
else {
factorized = Parenthesis::Builder(Subtraction::Builder(Symbol::Builder("x", strlen("x")), x0.clone()));
}
if (x1.type() == ExpressionNode::Type::Opposite) {
factorized = Multiplication::Builder(factorized.clone(), Parenthesis::Builder(Addition::Builder(Symbol::Builder("x", strlen("x")), x1.childAtIndex(0).clone())));
Expression x1Opposite = getOppositeIfExists(x1, &reductionContext);
if (x1Opposite.isUninitialized()) {
PoincareHelpers::Simplify(&x1, context, ExpressionNode::ReductionTarget::User);
secondFactor = Subtraction::Builder(Symbol::Builder("x", strlen("x")), x1);
}
else {
factorized = Multiplication::Builder(factorized.clone(), Parenthesis::Builder(Subtraction::Builder(Symbol::Builder("x", strlen("x")), x1.clone())));
PoincareHelpers::Simplify(&x1Opposite, context, ExpressionNode::ReductionTarget::User);
secondFactor = Addition::Builder(Symbol::Builder("x", strlen("x")), x1Opposite);
}
if (aIsNotOne) {
factorized = Multiplication::Builder(a.clone(), factorized.clone());
Expression solutionProduct = Multiplication::Builder(Parenthesis::Builder(firstFactor), Parenthesis::Builder(secondFactor));
switch (multiplicationTypeForA)
{
case MultiplicationTypeForA::Nothing:
factorized = solutionProduct;
break;
case MultiplicationTypeForA::Minus:
factorized = Multiplication::Builder(a.clone(), solutionProduct);
break;
case MultiplicationTypeForA::Parenthesis:
factorized = Multiplication::Builder(Parenthesis::Builder(a.clone()), solutionProduct);
break;
case MultiplicationTypeForA::Normal:
factorized = Multiplication::Builder(a.clone(), solutionProduct);
break;
default:
assert(false);
break;
}
}
else if (m_numberOfSolutions == 1) {
if (x0.type() == ExpressionNode::Type::Opposite) {
factorized = Power::Builder(Parenthesis::Builder(Addition::Builder(Symbol::Builder("x", strlen("x")), x0.childAtIndex(0).clone())), Rational::Builder(2));
Expression x0Opposite = getOppositeIfExists(x0, &reductionContext);
Expression factor;
if (x0Opposite.isUninitialized()) {
PoincareHelpers::Simplify(&x0, context, ExpressionNode::ReductionTarget::User);
factor = Subtraction::Builder(Symbol::Builder("x", strlen("x")), x0);
}
else {
factorized = Power::Builder(Parenthesis::Builder(Subtraction::Builder(Symbol::Builder("x", strlen("x")), x0.clone())), Rational::Builder(2));
PoincareHelpers::Simplify(&x0Opposite, context, ExpressionNode::ReductionTarget::User);
factor = Addition::Builder(Symbol::Builder("x", strlen("x")), x0Opposite);
}
if (aIsNotOne) {
factorized = Multiplication::Builder(a.clone(), factorized.clone());
Expression solutionProduct = Power::Builder(Parenthesis::Builder(factor), Rational::Builder(2));
switch (multiplicationTypeForA)
{
case MultiplicationTypeForA::Nothing:
factorized = solutionProduct;
break;
case MultiplicationTypeForA::Minus:
factorized = Multiplication::Builder(a.clone(), solutionProduct);
break;
case MultiplicationTypeForA::Parenthesis:
factorized = Multiplication::Builder(Parenthesis::Builder(a.clone()), solutionProduct);
break;
case MultiplicationTypeForA::Normal:
factorized = Multiplication::Builder(a.clone(), solutionProduct);
break;
default:
assert(false);
break;
}
}
PoincareHelpers::Simplify(&delta, context, ExpressionNode::ReductionTarget::User);
m_layouts[0] = PoincareHelpers::CreateLayout(canonised);
m_layouts[0] = PoincareHelpers::CreateLayout(canonized);
if (m_numberOfSolutions > 0) {
m_layouts[1] = PoincareHelpers::CreateLayout(factorized);
m_layouts[2] = PoincareHelpers::CreateLayout(delta);
@@ -156,6 +257,27 @@ void SecondDegreeListController::setExpression(Poincare::Expression e) {
}
}
Expression SecondDegreeListController::getOppositeIfExists(Expression e, Poincare::ExpressionNode::ReductionContext * reductionContext) {
if (e.isNumber() && e.sign(reductionContext->context()) == ExpressionNode::Sign::Negative) {
Number n = static_cast<Number&>(e);
return std::move(n.setSign(ExpressionNode::Sign::Positive));
}
else if (e.type() == ExpressionNode::Type::Multiplication && e.numberOfChildren() > 0 && e.childAtIndex(0).isNumber() && e.childAtIndex(0).sign(reductionContext->context()) == ExpressionNode::Sign::Negative) {
Multiplication m = static_cast<Multiplication&>(e);
if (m.childAtIndex(0).type() == ExpressionNode::Type::Rational && static_cast<Rational&>(e).isMinusOne()) {
// The negative numeral factor is -1, we just remove it
m.removeChildAtIndexInPlace(0);
} else {
Expression firstChild = m.childAtIndex(0);
Number n = static_cast<Number&>(firstChild);
m.childAtIndex(0).setChildrenInPlace(n.setSign(ExpressionNode::Sign::Positive));
}
PoincareHelpers::Simplify(&m, reductionContext->context(), ExpressionNode::ReductionTarget::User);
return std::move(m);
}
return Expression();
}
I18n::Message SecondDegreeListController::messageAtIndex(int index) {
if (m_numberOfSolutions > 0) {
if (index == 0) {

View File

@@ -14,6 +14,7 @@ public:
void setExpression(Poincare::Expression e) override;
private:
Poincare::Expression getOppositeIfExists(Poincare::Expression e, Poincare::ExpressionNode::ReductionContext * reductionContext);
I18n::Message messageAtIndex(int index) override;
int m_numberOfSolutions;
};

View File

@@ -15,24 +15,24 @@ TrigonometryGraphView::TrigonometryGraphView(TrigonometryModel * model) :
void TrigonometryGraphView::drawRect(KDContext * ctx, KDRect rect) const {
float s = std::sin(m_model->angle());
float c = std::cos(m_model->angle());
ctx->fillRect(rect, Palette::BackgroundApps);
ctx->fillRect(rect, *Palette::BackgroundApps);
drawGrid(ctx, rect);
drawAxes(ctx, rect);
// Draw the circle
drawCurve(ctx, rect, 0.0f, 2.0f*M_PI, M_PI/180.0f, [](float t, void * model, void * context) {
return Poincare::Coordinate2D<float>(std::cos(t), std::sin(t));
}, nullptr, nullptr, true, Palette::SecondaryText, false);
}, nullptr, nullptr, true, *Palette::SecondaryText, false);
// Draw dashed segment to indicate sine and cosine
drawHorizontalOrVerticalSegment(ctx, rect, Axis::Vertical, c, 0.0f, s, Palette::CalculationTrigoAndComplexForeground, 1, 3);
drawHorizontalOrVerticalSegment(ctx, rect, Axis::Horizontal, s, 0.0f, c, Palette::CalculationTrigoAndComplexForeground, 1, 3);
drawHorizontalOrVerticalSegment(ctx, rect, Axis::Vertical, c, 0.0f, s, *Palette::CalculationTrigoAndComplexForeground, 1, 3);
drawHorizontalOrVerticalSegment(ctx, rect, Axis::Horizontal, s, 0.0f, c, *Palette::CalculationTrigoAndComplexForeground, 1, 3);
// Draw angle position on the circle
drawDot(ctx, rect, c, s, Palette::CalculationTrigoAndComplexForeground, Size::Large);
drawDot(ctx, rect, c, s, *Palette::CalculationTrigoAndComplexForeground, Size::Large);
// Draw graduations
drawLabelsAndGraduations(ctx, rect, Axis::Vertical, false, true);
drawLabelsAndGraduations(ctx, rect, Axis::Horizontal, false, true);
// Draw labels
drawLabel(ctx, rect, 0.0f, s, "sin(θ)", Palette::CalculationTrigoAndComplexForeground, c >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After, CurveView::RelativePosition::None);
drawLabel(ctx, rect, c, 0.0f, "cos(θ)", Palette::CalculationTrigoAndComplexForeground, CurveView::RelativePosition::None, s >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After);
drawLabel(ctx, rect, 0.0f, s, "sin(θ)", *Palette::CalculationTrigoAndComplexForeground, c >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After, CurveView::RelativePosition::None);
drawLabel(ctx, rect, c, 0.0f, "cos(θ)", *Palette::CalculationTrigoAndComplexForeground, CurveView::RelativePosition::None, s >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After);
}
}

View File

@@ -81,7 +81,7 @@ void HistoryViewCell::reloadSubviewHighlight() {
m_ellipsis.setHighlighted(false);
if (isHighlighted()) {
if (m_dataSource->selectedSubviewType() == HistoryViewCellDataSource::SubviewType::Input) {
m_inputView.setExpressionBackgroundColor(Palette::ListCellBackgroundSelected);
m_inputView.setExpressionBackgroundColor(*Palette::Select);
} else if (m_dataSource->selectedSubviewType() == HistoryViewCellDataSource::SubviewType::Output) {
m_scrollableOutputView.evenOddCell()->setHighlighted(true);
} else {

View File

@@ -49,7 +49,7 @@ public:
return this;
}
Poincare::Layout layout() const override;
KDColor backgroundColor() const override { return m_even ? Palette::CalculationBackgroundEven : Palette::CalculationBackgroundOdd; }
KDColor backgroundColor() const override { return m_even ? *Palette::CalculationBackgroundEven : *Palette::CalculationBackgroundOdd; }
void resetMemoization();
void setCalculation(Calculation * calculation, bool expanded, bool canChangeDisplayOutput = false);
int numberOfSubviews() const override { return 2 + displayedEllipsis(); }

View File

@@ -1,6 +1,8 @@
apps += Code::App
app_headers += apps/code/app.h
SFLAGS += -DHAS_CODE
app_code_src = $(addprefix apps/code/,\
app.cpp \
console_controller.cpp \

View File

@@ -75,7 +75,7 @@ public:
VariableBoxController * variableBoxController() { return &m_variableBoxController; }
static constexpr int k_pythonHeapSize = 100000;
static constexpr int k_pythonHeapSize = 67000;
private:
/* Python delegate:

View File

@@ -62,6 +62,7 @@ PythonFloor = "Abrunden"
PythonFmod = "a modulo b"
PythonFrExp = "Mantisse und Exponent von x: (m,e)"
PythonGamma = "Gamma-Funktion"
PythonGetKeys = "Gedrückte Tasten erhalten"
PythonGetPalette = "Themenpalette erhalten"
PythonGetPixel = "Farbe von Pixel (x,y) zurückgeben"
PythonGetrandbits = "Ganzzahl mit k Zufallsbits"
@@ -77,11 +78,19 @@ PythonImportMatplotlibPyplot = "Matplotlib.pyplot-Modul importieren"
PythonImportNumpy = "Ulab.numpy-Modul importieren"
PythonImportScipy = "Ulab.scipy-Modul importieren"
PythonImportOs = "OS-Modul importieren"
PythonImportSys = "SYS-Modul importieren"
PythonOsUname = "Informationen über das System holen"
PythonOsGetlogin = "Benutzernamen holen"
PythonOsRemove = "Datei namens Dateiname entfernen"
PythonOsRename = "Datei umbenennen von Alt nach Neu"
PythonOsListdir = "Dateien im Speicher auflisten"
PythonSysExit = "Terminate current program"
PythonSysPrintexception = "Print exception"
PythonSysByteorder = "The byte order of the system"
PythonSysImplementation = "Information about Python"
PythonSysModules = "Dictionary of loaded modules"
PythonSysVersion = "Python language version (string)"
PythonSysVersioninfo = "Python language version (tuple)"
PythonImportTime = "Time-Modul importieren"
PythonImportTurtle = "Turtle-Modul importieren"
PythonIndex = "Index des ersten x-Vorkommens"
@@ -145,7 +154,7 @@ PythonSleep = "Ausführung aussetzen für t Sekunden"
PythonLocalTime = "Zeit in Tupel umwandeln"
PythonMktime = "Tupel in Zeit umwandeln"
PythonTime = "Abrufen des aktuellen Zeitstempels"
PythonSetLocaltime = "Zeit aus einem Tupel von localtime()"
PythonSetLocaltime = "Zeit aus einem Tupel einstellen"
PythonRTCmode = "Aktuellen RTC-Modus abrufen"
PythonSetRTCmode = "RTC-Modus festlegen"
PythonSort = "Die Liste sortieren"

View File

@@ -62,6 +62,7 @@ PythonFloor = "Floor"
PythonFmod = "a modulo b"
PythonFrExp = "Mantissa and exponent of x: (m,e)"
PythonGamma = "Gamma function"
PythonGetKeys = "Get keys pressed"
PythonGetPalette = "Get theme palette"
PythonGetPixel = "Return pixel (x,y) color"
PythonGetrandbits = "Integer with k random bits"
@@ -139,7 +140,7 @@ PythonSleep = "Suspend the execution for t seconds"
PythonLocalTime = "Convert time into tuple"
PythonMktime = "Convert tuple into time"
PythonTime = "Get the current timestamp"
PythonSetLocaltime = "Set time from a tuple of localtime()"
PythonSetLocaltime = "Set time from a tuple"
PythonRTCmode = "Get current RTC mode"
PythonSetRTCmode = "Set RTC mode"
PythonSort = "Sort the list"
@@ -175,11 +176,19 @@ PythonTurtleWrite = "Display a text"
PythonUniform = "Floating point number in [a,b]"
PythonImportTime = "Import time module"
PythonImportOs = "Import os module"
PythonImportSys = "Import sys module"
PythonOsUname = "Get infos about the system"
PythonOsGetlogin = "Get username"
PythonOsRemove = "Remove file named filename"
PythonOsRename = "Rename file oldname to newname"
PythonOsListdir = "List files in memory"
PythonSysExit = "Terminate current program"
PythonSysPrintexception = "Print exception"
PythonSysByteorder = "The byte order of the system"
PythonSysImplementation = "Information about Python"
PythonSysModules = "Dictionary of loaded modules"
PythonSysVersion = "Python language version (string)"
PythonSysVersioninfo = "Python language version (tuple)"
PythonTimePrefix = "time module function prefix"
PythonTimeSleep = "Wait for n second"
PythonMonotonic = "Return monotonic time"

View File

@@ -62,6 +62,7 @@ PythonFloor = "Floor"
PythonFmod = "a modulo b"
PythonFrExp = "Mantissa and exponent of x: (m,e)"
PythonGamma = "Gamma function"
PythonGetKeys = "Obtener teclas presionadas"
PythonGetPalette = "Get theme palette"
PythonGetPixel = "Return pixel (x,y) color"
PythonGetrandbits = "Integer with k random bits"
@@ -139,7 +140,7 @@ PythonSleep = "Suspend the execution for t seconds"
PythonLocalTime = "Convertir el tiempo en tupla"
PythonMktime = "Convertir tupla en tiempo"
PythonTime = "Obtener la marca de tiempo actual"
PythonSetLocaltime = "Establecer tiempo desde una tupla de localtime()"
PythonSetLocaltime = "Establecer tiempo desde una tupla"
PythonRTCmode = "Obtener el modo RTC actual"
PythonSetRTCmode = "Establecer modo RTC"
PythonSort = "Sort the list"
@@ -175,11 +176,19 @@ PythonTurtleWrite = "Display a text"
PythonUniform = "Floating point number in [a,b]"
PythonImportTime = "Import time module"
PythonImportOs = "Import os module"
PythonImportSys = "Import sys module"
PythonOsUname = " Información del sistema "
PythonOsGetlogin = "Get username"
PythonOsRemove = "Eliminar un archivo"
PythonOsRename = "Renombrar archivo"
PythonOsListdir = "Archivos de la lista"
PythonSysExit = "Terminate current program"
PythonSysPrintexception = "Print exception"
PythonSysByteorder = "The byte order of the system"
PythonSysImplementation = "Information about Python"
PythonSysModules = "Dictionary of loaded modules"
PythonSysVersion = "Python language version (string)"
PythonSysVersioninfo = "Python language version (tuple)"
PythonTimePrefix = "time module function prefix"
PythonTimeSleep = "Esperar n segundos"
PythonMonotonic = "Tiempo monótono de retorno"

View File

@@ -62,6 +62,7 @@ PythonFloor = "Partie entière"
PythonFmod = "a modulo b"
PythonFrExp = "Mantisse et exposant de x : (m,e)"
PythonGamma = "Fonction gamma"
PythonGetKeys = "Obtenir les touches pressées"
PythonGetPalette = "Obtient la palette du thème"
PythonGetPixel = "Renvoie la couleur du pixel (x,y)"
PythonGetrandbits = "Nombre aléatoire sur k bits"
@@ -139,7 +140,7 @@ PythonSleep = "Suspend l'exécution t secondes"
PythonLocalTime = "Convertir le temps en tuple"
PythonMktime = "Convertir le tuple en temps"
PythonTime = "Obtenir l'horodatage actuel"
PythonSetLocaltime = "Définir l'heure à partir d'un tuple de localtime()"
PythonSetLocaltime = "Définir l'heure à partir d'un tuple"
PythonRTCmode = "Obtenir le mode RTC actuel"
PythonSetRTCmode = "Définir le mode RTC"
PythonSort = "Trie la liste"
@@ -175,11 +176,19 @@ PythonTurtleWrite = "Affiche un texte"
PythonUniform = "Nombre décimal dans [a,b]"
PythonImportTime = "Importation du module temps"
PythonImportOs = "Importation du module os"
PythonImportSys = "Importation du module sys"
PythonOsUname = "Donne des infos sur le système"
PythonOsGetlogin = "Donne le nom d'utilisateur"
PythonOsRemove = "Supprime le fichier nommé filename"
PythonOsRename = "Renomme oldname en newname"
PythonOsListdir = "Liste les fichiers"
PythonSysExit = "Termine le programme"
PythonSysPrintexception = "Imprime une exception"
PythonSysByteorder = "L'ordre des octets du système"
PythonSysImplementation = "Information sur Python"
PythonSysModules = "Dictionnaire des modules chargés"
PythonSysVersion = "Version du langage Python (string)"
PythonSysVersioninfo = "Version du langage Python (tuple)"
PythonTimePrefix = "Préfixe fonction du module temps"
PythonTimeSleep = "Attendre n secondes"
PythonMonotonic = "Retourne le temps monotone"

View File

@@ -62,6 +62,7 @@ PythonFloor = "Egész része"
PythonFmod = "a modulo b"
PythonFrExp = "X mantissája és kiállítója"
PythonGamma = "Gamma funkció"
PythonGetKeys = "Billentyűk lenyomva"
PythonGetPalette = "Téma paletta beszerzése"
PythonGetPixel = "Visszatéríti (x,y) színét"
PythonGetrandbits = "Váletlenszám visszatérítése k biten"
@@ -139,7 +140,7 @@ PythonSleep = "t másodpercre meg állitani a programmot"
PythonLocalTime = "Idő konvertálása csomóvá"
PythonMktime = "A tuple konvertálása az időben"
PythonTime = "Az aktuális időbélyeg letöltése"
PythonSetLocaltime = "Állítsd be az időt egy tufából a localtime()"
PythonSetLocaltime = "Idő beállítása egy csomóból"
PythonRTCmode = "Aktuális RTC mód"
PythonSetRTCmode = "RTC mód beállítása"
PythonSort = "A listát rendezni"
@@ -199,3 +200,11 @@ PythonOsGetlogin = "Get username"
PythonOsRemove = "Fájl törlése"
PythonOsRename = "Fájl átnevezése"
PythonOsListdir = "Fájlok listája"
PythonImportSys = "sys modul importálása"
PythonSysExit = "Terminate current program"
PythonSysPrintexception = "Print exception"
PythonSysByteorder = "The byte order of the system"
PythonSysImplementation = "Information about Python"
PythonSysModules = "Dictionary of loaded modules"
PythonSysVersion = "Python language version (string)"
PythonSysVersioninfo = "Python language version (tuple)"

View File

@@ -62,6 +62,7 @@ PythonFloor = "Parte intera"
PythonFmod = "a modulo b"
PythonFrExp = "Mantissa ed esponente di x : (m,e)"
PythonGamma = "Funzione gamma"
PythonGetKeys = "Premere i tasti"
PythonGetPalette = "Ottieni la tavolozza del tema"
PythonGetPixel = "Restituisce colore del pixel(x,y)"
PythonGetrandbits = "Numero aleatorio con k bit"
@@ -84,6 +85,14 @@ PythonOsGetlogin = "Get username"
PythonOsRemove = "Rimuovere un file"
PythonOsRename = "Rinomina file"
PythonOsListdir = "Elenca file"
PythonImportSys = "Importa modulo sys"
PythonSysExit = "Terminate current program"
PythonSysPrintexception = "Print exception"
PythonSysByteorder = "The byte order of the system"
PythonSysImplementation = "Information about Python"
PythonSysModules = "Dictionary of loaded modules"
PythonSysVersion = "Python language version (string)"
PythonSysVersioninfo = "Python language version (tuple)"
PythonIndex = "Indice prima occorrenza di x"
PythonInput = "Inserire un valore"
PythonInsert = "Inserire x in posizione i-esima"
@@ -145,7 +154,7 @@ PythonSleep = "Sospende l'esecuzione t secondi"
PythonLocalTime = "Converti il tempo in tuple"
PythonMktime = "Converti tuple in tempo"
PythonTime = "Ottieni il timestamp corrente"
PythonSetLocaltime = "Imposta il tempo da una tupla di localtime()"
PythonSetLocaltime = "Imposta il tempo da una tupla"
PythonRTCmode = "Ottieni la modalità RTC corrente"
PythonSetRTCmode = "Imposta modalità RTC"
PythonSort = "Ordina l'elenco"

View File

@@ -62,6 +62,7 @@ PythonFloor = "Vloer"
PythonFmod = "a modulo b"
PythonFrExp = "Mantisse en exponent van x: (m,e)"
PythonGamma = "Gammafunctie"
PythonGetKeys = "Get toetsen ingedrukt"
PythonGetPalette = "Thema palet krijgen"
PythonGetPixel = "Geef pixel (x,y) kleur (rgb)"
PythonGetrandbits = "Integer met k willekeurige bits"
@@ -83,6 +84,15 @@ PythonOsGetlogin = "Get username"
PythonOsRemove = "Een bestand verwijderen"
PythonOsRename = "Hernoem bestand"
PythonOsListdir = "Lijstbestanden"
PythonImportSys = "Importeer sys module"
PythonImportSys = "Importeer sys module"
PythonSysExit = "Terminate current program"
PythonSysPrintexception = "Print exception"
PythonSysByteorder = "The byte order of the system"
PythonSysImplementation = "Information about Python"
PythonSysModules = "Dictionary of loaded modules"
PythonSysVersion = "Python language version (string)"
PythonSysVersioninfo = "Python language version (tuple)"
PythonImportTurtle = "Importeer turtle module"
PythonIndex = "Index van de eerste x aanwezigheden"
PythonInput = "Wijs een waarde toe"
@@ -145,7 +155,7 @@ PythonSleep = "Stel executie voor t seconden uit"
PythonLocalTime = "Zet tijd om in tuple"
PythonMktime = "Tuple omzetten in tijd"
PythonTime = "Haal de huidige tijdstempel"
PythonSetLocaltime = "Stel de tijd in vanaf een tuple van localtime()"
PythonSetLocaltime = "Stel de tijd in vanaf een tuple"
PythonRTCmode = "Huidige RTC-modus kregen"
PythonSetRTCmode = "RTC-modus instellen"
PythonSort = "Sorteer de lijst"

View File

@@ -62,6 +62,7 @@ PythonFloor = "Parte inteira"
PythonFmod = "a módulo b"
PythonFrExp = "Coeficiente e expoente de x: (m, e)"
PythonGamma = "Função gama"
PythonGetKeys = "Obter teclas pressionadas"
PythonGetPalette = "Obter paleta temática"
PythonGetPixel = "Devolve a cor do pixel (x,y)"
PythonGetrandbits = "Número inteiro aleatório com k bits"
@@ -139,7 +140,7 @@ PythonSleep = "Suspender a execução por t segundos"
PythonLocalTime = "Convert o tempo em tupla"
PythonMktime = "Convert tuple em tempo"
PythonTime = "Obter o estamp de tempo atual"
PythonSetLocaltime = "Definir tempo a partir de uma tupla de localtime()"
PythonSetLocaltime = "Definir tempo a partir de uma tupla"
PythonRTCmode = "Obter o modo RTC atual"
PythonSetRTCmode = "Definir o modo RTC"
PythonSort = "Ordenar a lista"
@@ -180,6 +181,14 @@ PythonOsGetlogin = "Get username"
PythonOsRemove = "Remover um ficheiro"
PythonOsRename = "Renomear ficheiro"
PythonOsListdir = "Listar ficheiros"
PythonImportSys = "Import sys module"
PythonSysExit = "Terminate current program"
PythonSysPrintexception = "Print exception"
PythonSysByteorder = "The byte order of the system"
PythonSysImplementation = "Information about Python"
PythonSysModules = "Dictionary of loaded modules"
PythonSysVersion = "Python language version (string)"
PythonSysVersioninfo = "Python language version (tuple)"
PythonTimePrefix = "time module function prefix"
PythonTimeSleep = "Wait for n second"
PythonMonotonic = "Return monotonic time"

View File

@@ -69,6 +69,7 @@ PythonCommandFloor = "floor(x)"
PythonCommandFmod = "fmod(a,b)"
PythonCommandFrExp = "frexp(x)"
PythonCommandGamma = "gamma(x)"
PythonCommandGetKeys = "get_keys()"
PythonCommandGetPalette = "get_palette()"
PythonCommandGetPixel = "get_pixel(x,y)"
PythonCommandGetrandbits = "getrandbits(k)"
@@ -95,6 +96,8 @@ PythonCommandImportFromScipy = "from ulab import scipy as spy"
PythonCommandImportRandom = "import random"
PythonCommandImportOs = "import os"
PythonCommandImportFromOs = "from os import *"
PythonCommandImportSys = "import sys"
PythonCommandImportFromSys = "from sys import *"
PythonCommandImportTime = "import time"
PythonCommandImportTurtle = "import turtle"
PythonCommandIndex = "list.index(x)"
@@ -204,6 +207,9 @@ PythonCommandNumpyTranspose = "ndarray.transpose()"
PythonCommandNumpyTransposeWithoutArg = ".transpose()"
PythonCommandNumpySort = "ndarray.sort()"
PythonCommandNumpySortWithoutArg = ".sort()"
PythonCommandNumpyFromBuffer = "ndarray.frombuffer(b)"
PythonCommandNumpyToBytes = "ndarray.tobytes()"
PythonCommandNumpyToBytesWithoutArg = ".tobytes()"
PythonCommandNumpySetPrintOptions = "np.set_printoptions()"
PythonCommandNumpyGetPrintOptions = "np.get_printoptions()"
PythonCommandNumpyNdinfo = "np.ndinfo(a)"
@@ -369,6 +375,14 @@ PythonOsCommandRename = "rename(oldname, newname)"
PythonOsCommandRemoveWithoutArg = "remove(\x11)"
PythonOsCommandRenameWithoutArg = "rename(\x11,)"
PythonOsCommandListdir = "listdir()"
PythonSysCommandExit = "exit()"
PythonSysCommandPrintexception = "print_exception(exc)"
PythonSysCommandPrintexceptionWithoutArg = "print_exception(\x11)"
PythonSysCommandByteorder = "byteorder"
PythonSysCommandImplementation = "implementation"
PythonSysCommandModules = "modules"
PythonSysCommandVersion = "version"
PythonSysCommandVersioninfo = "version_info"
PythonTurtleCommandBackward = "backward(x)"
PythonTurtleCommandCircle = "circle(r)"
PythonTurtleCommandColor = "color('c')"

View File

@@ -40,7 +40,7 @@ ConsoleController::ConsoleController(Responder * parentResponder, App * pythonDe
#endif
{
m_selectableTableView.setMargins(0, Metric::CommonRightMargin, 0, Metric::TitleBarExternHorizontalMargin);
m_selectableTableView.setBackgroundColor(Palette::CodeBackground);
m_selectableTableView.setBackgroundColor(*Palette::CodeBackground);
m_editCell.setPrompt(sStandardPromptText);
for (int i = 0; i < k_numberOfLineCells; i++) {
m_cells[i].setParentResponder(&m_selectableTableView);

View File

@@ -18,8 +18,8 @@ void ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::setLine(Consol
}
void ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(bounds(), Palette::CodeBackground);
ctx->drawString(m_line->text(), KDPointZero, GlobalPreferences::sharedGlobalPreferences()->font(), textColor(m_line), isHighlighted()? Palette::Select : Palette::BackgroundApps);
ctx->fillRect(bounds(), *Palette::CodeBackground);
ctx->drawString(m_line->text(), KDPointZero, GlobalPreferences::sharedGlobalPreferences()->font(), textColor(m_line), isHighlighted()? *Palette::Select : *Palette::BackgroundApps);
}
KDSize ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::minimalSizeForOptimalDisplay() const {

View File

@@ -53,7 +53,7 @@ private:
ConsoleLineView m_consoleLineView;
};
static KDColor textColor(ConsoleLine * line) {
return line->isFromCurrentSession() ? Palette::CodeText : Palette::SecondaryText;
return line->isFromCurrentSession() ? *Palette::CodeText : *Palette::SecondaryText;
}
MessageTextView m_promptView;
ScrollableConsoleLineView m_scrollableView;

View File

@@ -57,8 +57,8 @@ void EditorView::layoutSubviews(bool force) {
/* EditorView::GutterView */
void EditorView::GutterView::drawRect(KDContext * ctx, KDRect rect) const {
KDColor textColor = Palette::PrimaryText;
KDColor backgroundColor = Palette::CodeGutterViewBackground;
KDColor textColor = *Palette::PrimaryText;
KDColor backgroundColor = *Palette::CodeGutterViewBackground;
ctx->fillRect(rect, backgroundColor);
@@ -102,7 +102,7 @@ void EditorView::GutterView::setOffset(KDCoordinate offset) {
KDSize EditorView::GutterView::minimalSizeForOptimalDisplay() const {
int numberOfChars = 2; // TODO: Could be computed
return KDSize(2 * k_margin + numberOfChars * Poincare::Preferences::sharedPreferences()->KDPythonFont()->glyphSize().width(), 0);
return KDSize(2 * k_margin + numberOfChars * m_font->glyphSize().width(), 0);
}
}

View File

@@ -3,6 +3,7 @@
#include <escher/palette.h>
#include <ion/unicode/utf8_helper.h>
#include <python/port/port.h>
#include "../global_preferences.h"
extern "C" {
#include "py/nlr.h"
@@ -13,22 +14,12 @@ extern "C" {
namespace Code {
constexpr KDColor CommentColor = Palette::CodeComment;
constexpr KDColor NumberColor = Palette::CodeNumber;
constexpr KDColor KeywordColor = Palette::CodeKeyword;
// constexpr KDColor BuiltinColor = KDColor::RGB24(0x0086B3);
constexpr KDColor OperatorColor = Palette::CodeOperator;
constexpr KDColor StringColor = Palette::CodeString;
constexpr KDColor BackgroundColor = Palette::CodeBackground;
constexpr KDColor HighlightColor = Palette::CodeBackgroundSelected;
constexpr KDColor AutocompleteColor = KDColor::RGB24(0xC6C6C6); // TODO Palette change
static inline KDColor TokenColor(mp_token_kind_t tokenKind) {
if (tokenKind == MP_TOKEN_STRING) {
return StringColor;
return *Palette::CodeString;
}
if (tokenKind == MP_TOKEN_INTEGER || tokenKind == MP_TOKEN_FLOAT_OR_IMAG) {
return NumberColor;
return *Palette::CodeNumber;
}
static_assert(MP_TOKEN_ELLIPSIS + 1 == MP_TOKEN_KW_FALSE
&& MP_TOKEN_KW_FALSE + 1 == MP_TOKEN_KW_NONE
@@ -68,7 +59,7 @@ static inline KDColor TokenColor(mp_token_kind_t tokenKind) {
&& MP_TOKEN_KW_YIELD + 1 == MP_TOKEN_OP_TILDE,
"MP_TOKEN order changed, so Code::PythonTextArea::TokenColor might need to change too.");
if (tokenKind >= MP_TOKEN_KW_FALSE && tokenKind <= MP_TOKEN_KW_YIELD) {
return KeywordColor;
return *Palette::CodeKeyword;
}
static_assert(MP_TOKEN_OP_TILDE + 1 == MP_TOKEN_OP_LESS
&& MP_TOKEN_OP_LESS + 1 == MP_TOKEN_OP_MORE
@@ -120,9 +111,9 @@ static inline KDColor TokenColor(mp_token_kind_t tokenKind) {
|| tokenKind == MP_TOKEN_DEL_EQUAL
|| tokenKind == MP_TOKEN_DEL_MINUS_MORE)
{
return OperatorColor;
return *Palette::CodeOperator;
}
return Palette::CodeText;
return *Palette::CodeText;
}
static inline size_t TokenLength(mp_lexer_t * lex, const char * tokenPosition) {
@@ -215,7 +206,7 @@ void PythonTextArea::ContentView::unloadSyntaxHighlighter() {
}
void PythonTextArea::ContentView::clearRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(rect, BackgroundColor);
ctx->fillRect(rect, *Palette::CodeBackground);
}
#define LOG_DRAWING 0
@@ -245,11 +236,11 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
fromColumn,
spacesStart,
std::min(text + byteLength, firstNonSpace) - spacesStart,
StringColor,
BackgroundColor,
*Palette::CodeString,
*Palette::CodeBackground,
selectionStart,
selectionEnd,
HighlightColor);
*Palette::CodeBackgroundSelected);
}
if (UTF8Helper::CodePointIs(firstNonSpace, UCodePointNull)) {
return;
@@ -275,17 +266,17 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
UTF8Helper::GlyphOffsetAtCodePoint(text, tokenEnd),
tokenEnd,
std::min(text + byteLength, tokenFrom) - tokenEnd,
StringColor,
BackgroundColor,
*Palette::CodeString,
*Palette::CodeBackground,
selectionStart,
selectionEnd,
HighlightColor);
*Palette::CodeBackgroundSelected);
}
tokenLength = TokenLength(lex, tokenFrom);
tokenEnd = tokenFrom + tokenLength;
// If the token is being autocompleted, use DefaultColor
KDColor color = (tokenFrom <= autocompleteStart && autocompleteStart < tokenEnd) ? Palette::CodeText : TokenColor(lex->tok_kind);
KDColor color = (tokenFrom <= autocompleteStart && autocompleteStart < tokenEnd) ? *Palette::CodeText : TokenColor(lex->tok_kind);
LOG_DRAW("Draw \"%.*s\" for token %d\n", tokenLength, tokenFrom, lex->tok_kind);
drawStringAt(ctx, line,
@@ -293,10 +284,10 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
tokenFrom,
tokenLength,
color,
BackgroundColor,
*Palette::CodeBackground,
selectionStart,
selectionEnd,
HighlightColor);
*Palette::CodeBackgroundSelected);
mp_lexer_to_next(lex);
LOG_DRAW("Pop token %d\n", lex->tok_kind);
@@ -304,18 +295,18 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
tokenFrom += tokenLength;
// Even if the token is being autocompleted, use CommentColor
// Even if the token is being autocompleted, use *Palette::CodeComment
if (tokenFrom < text + byteLength) {
LOG_DRAW("Draw comment \"%.*s\" from %d\n", byteLength - (tokenFrom - text), firstNonSpace, tokenFrom);
drawStringAt(ctx, line,
UTF8Helper::GlyphOffsetAtCodePoint(text, tokenFrom),
tokenFrom,
text + byteLength - tokenFrom,
CommentColor,
BackgroundColor,
*Palette::CodeComment,
*Palette::CodeBackground,
selectionStart,
selectionEnd,
HighlightColor);
*Palette::CodeBackgroundSelected);
}
mp_lexer_free(lex);
@@ -331,11 +322,11 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
UTF8Helper::GlyphOffsetAtCodePoint(text, autocompleteStart),
autocompleteStart,
std::min(text + byteLength, m_autocompletionEnd) - autocompleteStart,
AutocompleteColor,
BackgroundColor,
KDColor::RGB24(0xC6C6C6),
*Palette::CodeBackground,
nullptr,
nullptr,
HighlightColor);
*Palette::CodeBackgroundSelected);
}
}
@@ -444,6 +435,11 @@ void PythonTextArea::addAutocompletion() {
}
bool PythonTextArea::addAutocompletionTextAtIndex(int nextIndex, int * currentIndexToUpdate) {
// If Autocomplete disable, skip this step
if(!GlobalPreferences::sharedGlobalPreferences()->autocomplete()) {
return false;
}
// The variable box should be loaded at this point
const char * autocompletionTokenBeginning = nullptr;
const char * autocompletionLocation = const_cast<char *>(cursorLocation());

View File

@@ -135,7 +135,9 @@ const ToolboxMessageTree MatplotlibPyplotModuleChildren[] = {
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandColorGray, I18n::Message::PythonColorGray, false)
};
const ToolboxMessageTree NumpyNdarrayModuleChildren[] = {
#if defined(INCLUDE_ULAB)
const ToolboxMessageTree NumpyNdarrayModuleChildren[] = {
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyArray),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyArange),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyConcatenate),
@@ -147,15 +149,17 @@ const ToolboxMessageTree MatplotlibPyplotModuleChildren[] = {
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyFull),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyLinspace),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyLogspace),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyCopy),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyDtype),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyFlat),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyFlatten),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyShape),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyReshape),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpySize),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyTranspose),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpySort),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyFromBuffer),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyCopy, I18n::Message::Default, false, I18n::Message::PythonCommandNumpyCopyWithoutArg),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyDtype, I18n::Message::Default, false, I18n::Message::PythonCommandNumpyDtypeWithoutArg),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyFlat, I18n::Message::Default, false, I18n::Message::PythonCommandNumpyFlatWithoutArg),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyFlatten, I18n::Message::Default, false, I18n::Message::PythonCommandNumpyFlattenWithoutArg),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyShape, I18n::Message::Default, false, I18n::Message::PythonCommandNumpyShapeWithoutArg),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyReshape, I18n::Message::Default, false, I18n::Message::PythonCommandNumpyReshapeWithoutArg),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpySize, I18n::Message::Default, false, I18n::Message::PythonCommandNumpySizeWithoutArg),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyTranspose, I18n::Message::Default, false, I18n::Message::PythonCommandNumpyTransposeWithoutArg),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpySort, I18n::Message::Default, false, I18n::Message::PythonCommandNumpySortWithoutArg),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyToBytes, I18n::Message::Default, false, I18n::Message::PythonCommandNumpyToBytesWithoutArg)
};
const ToolboxMessageTree NumpyFunctionsModuleChildren[] = {
@@ -254,7 +258,6 @@ const ToolboxMessageTree NumpyModuleChildren[] = {
ToolboxMessageTree::Node(I18n::Message::NumpyLinalgModule, NumpyLinalgModuleChildren)
};
#if !defined(DEVICE_N0100)
const ToolboxMessageTree ScipyLinalgModuleChildren[] = {
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandScipyLinalgFunction, I18n::Message::PythonScipyLinalgFunction, false, I18n::Message::PythonCommandScipyLinalgFunctionWithoutArg),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandScipyLinalgChoSolve),
@@ -291,16 +294,14 @@ const ToolboxMessageTree ScipyModuleChildren[] = {
ToolboxMessageTree::Node(I18n::Message::ScipySpecialModule, ScipySpecialModuleChildren),
};
#endif
const ToolboxMessageTree UlabModuleChildren[] = {
ToolboxMessageTree::Node(I18n::Message::NumpyModule, NumpyModuleChildren),
#if !defined(DEVICE_N0100)
ToolboxMessageTree::Node(I18n::Message::ScipyModule, ScipyModuleChildren),
#endif
ToolboxMessageTree::Leaf(I18n::Message::UlabDocumentation, I18n::Message::UlabDocumentationLink)
};
#endif
const ToolboxMessageTree TurtleModuleChildren[] = {
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandImportTurtle, I18n::Message::PythonImportTurtle, false),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandImportFromTurtle, I18n::Message::PythonImportTurtle, false),
@@ -364,8 +365,8 @@ const ToolboxMessageTree KandinskyModuleChildren[] = {
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandFillRect, I18n::Message::PythonFillRect),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandFillCircle, I18n::Message::PythonFillCircle),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandFillPolygon, I18n::Message::PythonFillPolygon),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandGetPalette, I18n::Message::PythonGetPalette)
};
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandGetKeys, I18n::Message::PythonGetKeys),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandGetPalette, I18n::Message::PythonGetPalette)};
const ToolboxMessageTree IonModuleChildren[] = {
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandImportIon, I18n::Message::PythonImportIon, false),
@@ -402,16 +403,31 @@ const ToolboxMessageTree OsModuleChildren[] = {
ToolboxMessageTree::Leaf(I18n::Message::PythonOsCommandListdir, I18n::Message::PythonOsListdir, false)
};
const ToolboxMessageTree SysModuleChildren[] = {
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandImportSys, I18n::Message::PythonImportSys, false),
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandImportFromSys, I18n::Message::PythonImportSys, false),
ToolboxMessageTree::Leaf(I18n::Message::PythonSysCommandExit, I18n::Message::PythonSysExit, false),
ToolboxMessageTree::Leaf(I18n::Message::PythonSysCommandPrintexception, I18n::Message::PythonSysPrintexception, false, I18n::Message::PythonSysCommandPrintexceptionWithoutArg),
ToolboxMessageTree::Leaf(I18n::Message::PythonSysCommandByteorder, I18n::Message::PythonSysByteorder, false),
ToolboxMessageTree::Leaf(I18n::Message::PythonSysCommandImplementation, I18n::Message::PythonSysImplementation, false),
ToolboxMessageTree::Leaf(I18n::Message::PythonSysCommandModules, I18n::Message::PythonSysModules, false),
ToolboxMessageTree::Leaf(I18n::Message::PythonSysCommandVersion, I18n::Message::PythonSysVersion, false),
ToolboxMessageTree::Leaf(I18n::Message::PythonSysCommandVersioninfo, I18n::Message::PythonSysVersioninfo, false)
};
const ToolboxMessageTree modulesChildren[] = {
ToolboxMessageTree::Node(I18n::Message::MathModule, MathModuleChildren),
ToolboxMessageTree::Node(I18n::Message::CmathModule, CMathModuleChildren),
ToolboxMessageTree::Node(I18n::Message::MatplotlibPyplotModule, MatplotlibPyplotModuleChildren),
#if defined(INCLUDE_ULAB)
ToolboxMessageTree::Node(I18n::Message::UlabModule, UlabModuleChildren),
#endif
ToolboxMessageTree::Node(I18n::Message::TurtleModule, TurtleModuleChildren),
ToolboxMessageTree::Node(I18n::Message::RandomModule, RandomModuleChildren),
ToolboxMessageTree::Node(I18n::Message::KandinskyModule, KandinskyModuleChildren),
ToolboxMessageTree::Node(I18n::Message::IonModule, IonModuleChildren),
ToolboxMessageTree::Node(I18n::Message::OsModule, OsModuleChildren),
ToolboxMessageTree::Node(I18n::Message::SysModule, SysModuleChildren),
ToolboxMessageTree::Node(I18n::Message::TimeModule, TimeModuleChildren)
};
@@ -678,9 +694,11 @@ KDCoordinate PythonToolbox::rowHeight(int j) {
bool PythonToolbox::selectLeaf(int selectedRow) {
ToolboxMessageTree * node = (ToolboxMessageTree *)m_messageTreeModel->childAtIndex(selectedRow);
#if defined(INCLUDE_ULAB)
if(node->text() == I18n::Message::UlabDocumentationLink){
return true;
}
#endif
m_selectableTableView.deselectTable();
if(node->insertedText() == I18n::Message::IonSelector){
m_ionKeys.setSender(sender());

View File

@@ -9,7 +9,7 @@ namespace Code {
SandboxController::SandboxController(Responder * parentResponder) :
ViewController(parentResponder),
m_solidColorView(Palette::CodeBackground)
m_solidColorView(*Palette::CodeBackground)
{
}

View File

@@ -8,12 +8,12 @@ constexpr char ScriptNodeCell::k_parentheses[];
constexpr char ScriptNodeCell::k_parenthesesWithEmpty[];
void ScriptNodeCell::ScriptNodeView::drawRect(KDContext * ctx, KDRect rect) const {
const KDColor backgroundColor = isHighlighted()? Palette::CodeBackgroundSelected : Palette::CodeBackground;
const KDColor backgroundColor = isHighlighted()? *Palette::CodeBackgroundSelected : *Palette::CodeBackground;
// If it exists, draw the description name.
const char * descriptionName = m_scriptNode->description();
if (descriptionName != nullptr) {
ctx->drawString(descriptionName, KDPoint(0, m_frame.height() - k_bottomMargin - k_font->glyphSize().height()), k_font, Palette::GrayDark, backgroundColor);
ctx->drawString(descriptionName, KDPoint(0, m_frame.height() - k_bottomMargin - k_font->glyphSize().height()), k_font, *Palette::GrayDark, backgroundColor);
}
// Draw the node name
@@ -21,10 +21,10 @@ void ScriptNodeCell::ScriptNodeView::drawRect(KDContext * ctx, KDRect rect) cons
const int nodeNameLength = m_scriptNode->nameLength();
KDSize nameSize = k_font->stringSize(nodeName, nodeNameLength);
const KDCoordinate nodeNameY = k_topMargin;
ctx->drawString(nodeName, KDPoint(0, nodeNameY), k_font, KDColorBlack, backgroundColor, nodeNameLength);
ctx->drawString(nodeName, KDPoint(0, nodeNameY), k_font, *Palette::PrimaryText, backgroundColor, nodeNameLength);
// If it is needed, draw the parentheses
if (m_scriptNode->type() == ScriptNode::Type::WithParentheses) {
ctx->drawString(ScriptNodeCell::k_parentheses, KDPoint(nameSize.width(), nodeNameY), k_font, KDColorBlack, backgroundColor);
ctx->drawString(ScriptNodeCell::k_parentheses, KDPoint(nameSize.width(), nodeNameY), k_font, *Palette::PrimaryText, backgroundColor);
}
/* If it exists, draw the source name. If it did not fit, we would have put
@@ -32,7 +32,7 @@ void ScriptNodeCell::ScriptNodeView::drawRect(KDContext * ctx, KDRect rect) cons
const char * sourceName = m_scriptNode->nodeSourceName();
if (sourceName != nullptr) {
KDSize sourceNameSize = k_font->stringSize(sourceName);
ctx->drawString(sourceName, KDPoint(m_frame.width() - sourceNameSize.width(), nodeNameY), k_font, Palette::CodeText, backgroundColor);
ctx->drawString(sourceName, KDPoint(m_frame.width() - sourceNameSize.width(), nodeNameY), k_font, *Palette::CodeText, backgroundColor);
}
}

View File

@@ -100,7 +100,7 @@ void ScriptParameterController::willDisplayCellForIndex(HighlightCell * cell, in
MessageTableCellWithBuffer * myCell = (MessageTableCellWithBuffer *)cell;
GetScriptSize(myCell);
myCell->setAccessoryFont(KDFont::SmallFont);
myCell->setAccessoryTextColor(Palette::SecondaryText);
myCell->setAccessoryTextColor(*Palette::SecondaryText);
}
}

View File

@@ -8,11 +8,9 @@ bool ScriptStore::ScriptNameIsFree(const char * baseName) {
return ScriptBaseNamed(baseName).isNull();
}
// Here we add "base" script
ScriptStore::ScriptStore() {
addScriptFromTemplate(ScriptTemplate::Squares());
addScriptFromTemplate(ScriptTemplate::Parabola());
addScriptFromTemplate(ScriptTemplate::Mandelbrot());
addScriptFromTemplate(ScriptTemplate::Polynomial());
}
void ScriptStore::deleteAllScripts() {

View File

@@ -5,103 +5,9 @@ namespace Code {
constexpr ScriptTemplate emptyScriptTemplate(".py", "\x01" R"(from math import *
)");
constexpr ScriptTemplate squaresScriptTemplate("squares.py", "\x01" R"(from math import *
from turtle import *
def squares(angle=0.5):
reset()
L=330
speed(10)
penup()
goto(-L/2,-L/2)
pendown()
for i in range(660):
forward(L)
left(90+angle)
L=L-L*sin(angle*pi/180)
hideturtle())");
constexpr ScriptTemplate mandelbrotScriptTemplate("mandelbrot.py", "\x01" R"(# This script draws a Mandelbrot fractal set
# N_iteration: degree of precision
import kandinsky
def mandelbrot(N_iteration):
for x in range(320):
for y in range(222):
# Compute the mandelbrot sequence for the point c = (c_r, c_i) with start value z = (z_r, z_i)
z = complex(0,0)
# Rescale to fit the drawing screen 320x222
c = complex(3.5*x/319-2.5, -2.5*y/221+1.25)
i = 0
while (i < N_iteration) and abs(z) < 2:
i = i + 1
z = z*z+c
# Choose the color of the dot from the Mandelbrot sequence
rgb = int(255*i/N_iteration)
col = kandinsky.color(int(rgb*0.82),int(rgb*0.13),int(rgb*0.18))
# Draw a pixel colored in 'col' at position (x,y)
kandinsky.set_pixel(x,y,col))");
constexpr ScriptTemplate polynomialScriptTemplate("polynomial.py", "\x01" R"(from math import *
# roots(a,b,c) computes the solutions of the equation a*x**2+b*x+c=0
def roots(a,b,c):
delta = b*b-4*a*c
if delta == 0:
return -b/(2*a)
elif delta > 0:
x_1 = (-b-sqrt(delta))/(2*a)
x_2 = (-b+sqrt(delta))/(2*a)
return x_1, x_2
else:
return None)");
constexpr ScriptTemplate parabolaScriptTemplate("parabola.py", "\x01" R"(from matplotlib.pyplot import *
from math import *
g=9.81
def x(t,v_0,alpha):
return v_0*cos(alpha)*t
def y(t,v_0,alpha,h_0):
return -0.5*g*t**2+v_0*sin(alpha)*t+h_0
def vx(v_0,alpha):
return v_0*cos(alpha)
def vy(t,v_0,alpha):
return -g*t+v_0*sin(alpha)
def t_max(v_0,alpha,h_0):
return (v_0*sin(alpha)+sqrt((v_0**2)*(sin(alpha)**2)+2*g*h_0))/g
def simulation(v_0=15,alpha=pi/4,h_0=2):
tMax=t_max(v_0,alpha,h_0)
accuracy=1/10**(floor(log10(tMax))-1)
T_MAX=floor(tMax*accuracy)+1
X=[x(t/accuracy,v_0,alpha) for t in range(T_MAX)]
Y=[y(t/accuracy,v_0,alpha,h_0) for t in range(T_MAX)]
VX=[vx(v_0,alpha) for t in range(T_MAX)]
VY=[vy(t/accuracy,v_0,alpha) for t in range(T_MAX)]
for i in range(T_MAX):
arrow(X[i],Y[i],VX[i]/accuracy,VY[i]/accuracy)
grid()
show())");
const ScriptTemplate * ScriptTemplate::Empty() {
return &emptyScriptTemplate;
}
const ScriptTemplate * ScriptTemplate::Squares() {
return &squaresScriptTemplate;
}
const ScriptTemplate * ScriptTemplate::Mandelbrot() {
return &mandelbrotScriptTemplate;
}
const ScriptTemplate * ScriptTemplate::Polynomial() {
return &polynomialScriptTemplate;
}
const ScriptTemplate * ScriptTemplate::Parabola() {
return &parabolaScriptTemplate;
}
}

View File

@@ -9,10 +9,6 @@ class ScriptTemplate {
public:
constexpr ScriptTemplate(const char * name, const char * value) : m_name(name), m_value(value) {}
static const ScriptTemplate * Empty();
static const ScriptTemplate * Squares();
static const ScriptTemplate * Mandelbrot();
static const ScriptTemplate * Polynomial();
static const ScriptTemplate * Parabola();
const char * name() const { return m_name; }
const char * content() const { return m_value + Script::StatusSize(); }
const char * value() const { return m_value; }

View File

@@ -13,6 +13,7 @@ ScipySignalModule = "signal"
ScipySpecialModule = "special"
NumpyNdarray = "ndarray"
OsModule = "os"
SysModule = "sys"
TimeModule = "time"
TurtleModule = "turtle"
UlabModule = "ulab"

View File

@@ -37,10 +37,10 @@ namespace Code {
}
void toolboxIonKeys::toolboxIonView::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(rect, Palette::GrayBright);
ctx->strokeRect(rect, Palette::GrayDark);
ctx->drawString(I18n::translate(I18n::Message::PressAKey),KDPoint(rect.left()+80, rect.top()+20));
ctx->fillRect(rect, *Palette::WallScreen);
ctx->strokeRect(rect, *Palette::ListCellBorder);
ctx->drawString(I18n::translate(I18n::Message::PressAKey),KDPoint(rect.left()+80, rect.top()+20),KDFont::LargeFont,*Palette::PrimaryText,*Palette::WallScreen);
}
View * toolboxIonKeys::view(){

View File

@@ -44,8 +44,8 @@ VariableBoxController::VariableBoxController(ScriptStore * scriptStore) :
m_importedNodesCount(0)
{
for (int i = 0; i < k_scriptOriginsCount; i++) {
m_subtitleCells[i].setBackgroundColor(Palette::WallScreen);
m_subtitleCells[i].setTextColor(Palette::SecondaryText);
m_subtitleCells[i].setBackgroundColor(*Palette::WallScreen);
m_subtitleCells[i].setTextColor(*Palette::SecondaryText);
}
}

View File

@@ -43,9 +43,9 @@ public:
private:
constexpr static size_t k_maxNumberOfDisplayedItems = (Ion::Display::Height - Metric::TitleBarHeight - Metric::PopUpTopMargin) / ScriptNodeCell::k_simpleItemHeight + 2; // +2 if the cells are cropped on top and at the bottom
constexpr static size_t k_maxScriptNodesCount = 32; // Chosen without particular reasons
constexpr static size_t k_maxScriptNodesCount = 64; // Chosen without particular reasons (Number of functions in the variables box)
constexpr static int k_totalBuiltinNodesCount = 107;
constexpr static uint8_t k_scriptOriginsCount = 3;
constexpr static uint8_t k_scriptOriginsCount = 8; // Number of scripts loaded in the variable box
constexpr static uint8_t k_subtitleCellType = NodeCellType; // We don't care as it is not selectable
constexpr static uint8_t k_itemCellType = LeafCellType; // So that upper class NestedMenuController knows it's a leaf
constexpr static KDCoordinate k_subtitleRowHeight = 23;

View File

@@ -90,40 +90,40 @@ void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) {
#if defined(DEVICE_N0100) && !defined(EXTERNAL_BUILTIN)
if(index == 0){
myTextCell->setText(I18n::translate(I18n::Message::ExternalNotCompatible));
myTextCell->setTextColor(Palette::Red);
myTextCell->setTextColor(*Palette::Red);
} else {
myTextCell->setText(I18n::translate(I18n::Message::WithN0100));
myTextCell->setTextColor(Palette::Red);
myTextCell->setTextColor(*Palette::Red);
}
#else
if(index == k_numberOfCells-1){
myTextCell->setText(I18n::translate(I18n::Message::URL));
myTextCell->setTextColor(Palette::AccentText);
myTextCell->setTextColor(*Palette::AccentText);
return;
}
if(index == k_numberOfCells-2){
myTextCell->setText(I18n::translate(I18n::Message::GetMoreAppsAt));
myTextCell->setTextColor(Palette::AccentText);
myTextCell->setTextColor(*Palette::AccentText);
return;
}
if(index == 0 && numberOfFiles() == 0){
myTextCell->setText(I18n::translate(I18n::Message::NoAppsInstalled));
myTextCell->setTextColor(Palette::Red);
myTextCell->setTextColor(*Palette::Red);
}
if(numberOfFiles() > 0){
if(fileAtIndex(index, f)) {
myTextCell->setText(f.name);
myTextCell->setTextColor(f.isExecutable ? Palette::PrimaryText : Palette::Palette::SecondaryText);
myTextCell->setTextColor(f.isExecutable ? *Palette::PrimaryText : *Palette::Palette::SecondaryText);
}
}
#endif
#else
if(index == 0){
myTextCell->setText(I18n::translate(I18n::Message::ExternalNotCompatible));
myTextCell->setTextColor(Palette::Red);
myTextCell->setTextColor(*Palette::Red);
} else {
myTextCell->setText(I18n::translate(I18n::Message::WithSimulator));
myTextCell->setTextColor(Palette::Red);
myTextCell->setTextColor(*Palette::Red);
}
#endif
}

View File

@@ -19,7 +19,7 @@ const char * PointerTextTableCell::text() const {
void PointerTextTableCell::setHighlighted(bool highlight) {
HighlightCell::setHighlighted(highlight);
KDColor backgroundColor = highlight? Palette::ListCellBackgroundSelected : Palette::ListCellBackground;
KDColor backgroundColor = highlight? *Palette::ListCellBackgroundSelected : *Palette::ListCellBackground;
m_pointerTextView.setBackgroundColor(backgroundColor);
}

View File

@@ -30,6 +30,8 @@ public:
void setTempExamMode(ExamMode examMode);
bool showPopUp() const { return m_showPopUp; }
void setShowPopUp(bool showPopUp) { m_showPopUp = showPopUp; }
bool autocomplete() const { return m_autoComplete; }
void setAutocomplete(bool autocomple) { m_autoComplete = autocomple; }
int brightnessLevel() const { return m_brightnessLevel; }
void setBrightnessLevel(int brightnessLevel);
const KDFont * font() const { return m_font; }
@@ -44,6 +46,7 @@ private:
m_examMode(ExamMode::Unknown),
m_tempExamMode(ExamMode::Standard),
m_showPopUp(true),
m_autoComplete(true),
m_brightnessLevel(Ion::Backlight::MaxBrightness),
m_font(KDFont::LargeFont) {}
I18n::Language m_language;
@@ -53,6 +56,7 @@ private:
mutable ExamMode m_examMode;
mutable ExamMode m_tempExamMode;
bool m_showPopUp;
bool m_autoComplete;
int m_brightnessLevel;
const KDFont * m_font;
};

View File

@@ -75,7 +75,7 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
// To represent the tangent, we draw segment from and to abscissas at the extremity of the drawn rect
float minAbscissa = pixelToFloat(Axis::Horizontal, rect.left());
float maxAbscissa = pixelToFloat(Axis::Horizontal, rect.right());
drawSegment(ctx, rect, minAbscissa, tangentParameterA*minAbscissa+tangentParameterB, maxAbscissa, tangentParameterA*maxAbscissa+tangentParameterB, Palette::GraphTangent, false);
drawSegment(ctx, rect, minAbscissa, tangentParameterA*minAbscissa+tangentParameterB, maxAbscissa, tangentParameterA*maxAbscissa+tangentParameterB, *Palette::GraphTangent, false);
}
} else if (type == Shared::ContinuousFunction::PlotType::Polar) {
// Polar

View File

@@ -167,7 +167,7 @@ void ListController::willDisplayTitleCellAtIndex(HighlightCell * cell, int j) {
// Set name and color if the name is not being edited
ExpiringPointer<ContinuousFunction> function = modelStore()->modelForRecord(modelStore()->recordAtIndex(j));
setFunctionNameInTextField(function, titleCell->textField());
KDColor functionNameColor = function->isActive() ? function->color() : Palette::SecondaryText;
KDColor functionNameColor = function->isActive() ? function->color() : *Palette::SecondaryText;
titleCell->setColor(functionNameColor);
}
}
@@ -178,7 +178,7 @@ void ListController::willDisplayExpressionCellAtIndex(HighlightCell * cell, int
Shared::FunctionListController::willDisplayExpressionCellAtIndex(cell, j);
FunctionExpressionCell * myCell = (FunctionExpressionCell *)cell;
ExpiringPointer<ContinuousFunction> f = modelStore()->modelForRecord(modelStore()->recordAtIndex(j));
KDColor textColor = f->isActive() ? Palette::PrimaryText : Palette::SecondaryText;
KDColor textColor = f->isActive() ? *Palette::PrimaryText : *Palette::SecondaryText;
myCell->setTextColor(textColor);
}

View File

@@ -17,8 +17,8 @@ public:
const KDFont * size = KDFont::LargeFont,
float horizontalAlignment = 0.0f,
float verticalAlignment = 0.5f,
KDColor textColor = Palette::PrimaryText,
KDColor backgroundColor = Palette::BackgroundHard) :
KDColor textColor = *Palette::PrimaryText,
KDColor backgroundColor = *Palette::BackgroundHard) :
TextFieldWithExtension(extensionLength, parentResponder, textBuffer, textBufferSize, draftTextBufferSize, inputEventHandlerDelegate, delegate, size, horizontalAlignment, verticalAlignment, textColor, backgroundColor) {}
void setDraftTextBufferSize(size_t size) { m_contentView.setDraftTextBufferSize(size); }
};

View File

@@ -30,7 +30,7 @@ const uint8_t arrowDownMask[10][9] = {
ArrowView::ArrowView() :
m_directionIsUp(true),
m_color(Palette::PrimaryText)
m_color(*Palette::PrimaryText)
{
}
@@ -50,7 +50,7 @@ void ArrowView::setColor(KDColor color) {
void ArrowView::drawRect(KDContext * ctx, KDRect rect) const {
KDColor arrowWorkingBuffer[10*9];
ctx->fillRect(bounds(), Palette::BackgroundHard);
ctx->fillRect(bounds(), *Palette::BackgroundHard);
KDCoordinate startLine = m_directionIsUp ? k_arrowHeight : 0;
KDCoordinate startArrow = m_directionIsUp ? 0 : bounds().height()-k_arrowHeight;
ctx->fillRect(KDRect((Ion::Display::Width-k_arrowThickness)/2, startLine, k_arrowThickness, bounds().height()-k_arrowHeight), m_color);

View File

@@ -59,7 +59,7 @@ void KeyboardView::drawKey(int keyIndex, KDContext * ctx, KDRect rect) const {
KDColor KeyboardView::keyColor(Ion::Keyboard::Key key) const {
if (!m_keyboardModel.belongsToTestedKeysSubset(key)) {
return Palette::ListCellBorder;
return *Palette::ListCellBorder;
}
if (m_keyboardModel.testedKey() == key) {
return KDColorBlue;

View File

@@ -7,7 +7,7 @@ namespace Home {
AppCell::AppCell() :
HighlightCell(),
m_nameView(KDFont::SmallFont, (I18n::Message)0, 0.5f, 0.5f, Palette::HomeCellText, Palette::HomeCellBackground),
m_nameView(KDFont::SmallFont, (I18n::Message)0, 0.5f, 0.5f, *Palette::HomeCellText, *Palette::HomeCellBackground),
m_backgroundView(nullptr),
m_visible(true), m_external_app(false)
{
@@ -39,7 +39,7 @@ void AppCell::setExtAppDescriptor(const char* name, const uint8_t *icon, size_t
m_iconView.setImage(icon, iconLength);
m_iconView.setImage(nullptr);
m_nameView.setText(name);
m_nameView.setTextColor(Palette::HomeCellTextExternal);
m_nameView.setTextColor(*Palette::HomeCellTextExternal);
m_nameView.setMessage(I18n::Message::Default);
layoutSubviews();
}
@@ -49,7 +49,7 @@ void AppCell::setExtAppDescriptor(const char* name, const Image* icon) {
m_iconView.setImage(icon);
m_iconView.setImage(nullptr, 0);
m_nameView.setText(name);
m_nameView.setTextColor(Palette::HomeCellTextExternal);
m_nameView.setTextColor(*Palette::HomeCellTextExternal);
m_nameView.setMessage(I18n::Message::Default);
layoutSubviews();
}
@@ -59,7 +59,7 @@ void AppCell::setAppDescriptor(::App::Descriptor * descriptor) {
m_iconView.setImage(descriptor->icon());
m_iconView.setImage(nullptr, 0);
m_nameView.setMessage(descriptor->name());
m_nameView.setTextColor(Palette::HomeCellText);
m_nameView.setTextColor(*Palette::HomeCellText);
m_nameView.setText(nullptr);
layoutSubviews();
}
@@ -76,8 +76,8 @@ void AppCell::setBackgroundView(const BackgroundView * backgroundView) {
}
void AppCell::reloadCell() {
m_nameView.setTextColor(isHighlighted() ? (m_external_app ? Palette::HomeCellTextExternalActive : Palette::HomeCellTextActive) : (m_external_app ? Palette::HomeCellTextExternal : Palette::HomeCellText));
m_nameView.setBackgroundColor(isHighlighted() ? Palette::HomeCellBackgroundActive : Palette::HomeCellBackground);
m_nameView.setTextColor(isHighlighted() ? (m_external_app ? *Palette::HomeCellTextExternalActive : *Palette::HomeCellTextActive) : (m_external_app ? *Palette::HomeCellTextExternal : *Palette::HomeCellText));
m_nameView.setBackgroundColor(isHighlighted() ? *Palette::HomeCellBackgroundActive : *Palette::HomeCellBackground);
}
}

View File

@@ -73,7 +73,7 @@ Controller::Controller(Responder * parentResponder, SelectableTableViewDataSourc
m_cells[i].setBackgroundView(m_view.backgroundView());
}
m_view.backgroundView()->setDefaultColor(Palette::HomeBackground);
m_view.backgroundView()->setDefaultColor(*Palette::HomeBackground);
#ifdef HOME_DISPLAY_EXTERNALS

View File

@@ -15,7 +15,7 @@ const uint8_t lockMask[LockView::k_lockHeight][LockView::k_lockWidth] = {
void LockView::drawRect(KDContext * ctx, KDRect rect) const {
KDRect frame((bounds().width() - k_lockWidth)/2, (bounds().height()-k_lockHeight)/2, k_lockWidth, k_lockHeight);
KDColor lockWorkingBuffer[LockView::k_lockHeight*LockView::k_lockWidth];
ctx->blendRectWithMask(frame, Palette::ToolbarText, (const uint8_t *)lockMask, lockWorkingBuffer);
ctx->blendRectWithMask(frame, *Palette::ToolbarText, (const uint8_t *)lockMask, lockWorkingBuffer);
}
KDSize LockView::minimalSizeForOptimalDisplay() const {

View File

@@ -711,6 +711,54 @@ const ToolboxMessageTree Electromagnetism[] = {
};
const ToolboxMessageTree Resistivity[] = {
ToolboxMessageTree::Leaf(I18n::Message::Silver, I18n::Message::Rstvt_Silver, false, I18n::Message::Rstvt_Silver),
ToolboxMessageTree::Leaf(I18n::Message::Copper, I18n::Message::Rstvt_Copper, false, I18n::Message::Rstvt_Copper),
ToolboxMessageTree::Leaf(I18n::Message::Gold, I18n::Message::Rstvt_Gold, false, I18n::Message::Rstvt_Gold),
ToolboxMessageTree::Leaf(I18n::Message::Aluminium, I18n::Message::Rstvt_Aluminium, false, I18n::Message::Rstvt_Aluminium),
ToolboxMessageTree::Leaf(I18n::Message::Calcium, I18n::Message::Rstvt_Calcium, false, I18n::Message::Rstvt_Calcium),
ToolboxMessageTree::Leaf(I18n::Message::Tungsten, I18n::Message::Rstvt_Tungsten, false, I18n::Message::Rstvt_Tungsten),
ToolboxMessageTree::Leaf(I18n::Message::Zinc, I18n::Message::Rstvt_Zinc, false, I18n::Message::Rstvt_Zinc),
ToolboxMessageTree::Leaf(I18n::Message::Cobalt, I18n::Message::Rstvt_Cobalt, false, I18n::Message::Rstvt_Cobalt),
ToolboxMessageTree::Leaf(I18n::Message::Nickel, I18n::Message::Rstvt_Nickel, false, I18n::Message::Rstvt_Nickel),
ToolboxMessageTree::Leaf(I18n::Message::Lithium, I18n::Message::Rstvt_Lithium, false, I18n::Message::Rstvt_Lithium),
ToolboxMessageTree::Leaf(I18n::Message::Iron, I18n::Message::Rstvt_Iron, false, I18n::Message::Rstvt_Iron),
ToolboxMessageTree::Leaf(I18n::Message::Platinum, I18n::Message::Rstvt_Platinum, false, I18n::Message::Rstvt_Platinum),
ToolboxMessageTree::Leaf(I18n::Message::Tin, I18n::Message::Rstvt_Tin, false, I18n::Message::Rstvt_Tin),
ToolboxMessageTree::Leaf(I18n::Message::Sea_water, I18n::Message::Rstvt_Sea_water, false, I18n::Message::Rstvt_Sea_water),
ToolboxMessageTree::Leaf(I18n::Message::Water, I18n::Message::Rstvt_Water, false, I18n::Message::Rstvt_Water),
ToolboxMessageTree::Leaf(I18n::Message::Air, I18n::Message::Rstvt_Air, false, I18n::Message::Rstvt_Air),
ToolboxMessageTree::Leaf(I18n::Message::Wood, I18n::Message::Rstvt_Wood, false, I18n::Message::Rstvt_Wood),
ToolboxMessageTree::Leaf(I18n::Message::Glass, I18n::Message::Rstvt_Glass, false, I18n::Message::Rstvt_Glass)
};
const ToolboxMessageTree Conductivity[] = {
ToolboxMessageTree::Leaf(I18n::Message::Silver, I18n::Message::Cndcvt_Silver, false, I18n::Message::Cndcvt_Silver),
ToolboxMessageTree::Leaf(I18n::Message::Copper, I18n::Message::Cndcvt_Copper, false, I18n::Message::Cndcvt_Copper),
ToolboxMessageTree::Leaf(I18n::Message::Gold, I18n::Message::Cndcvt_Gold, false, I18n::Message::Cndcvt_Gold),
ToolboxMessageTree::Leaf(I18n::Message::Aluminium, I18n::Message::Cndcvt_Aluminium, false, I18n::Message::Cndcvt_Aluminium),
ToolboxMessageTree::Leaf(I18n::Message::Calcium, I18n::Message::Cndcvt_Calcium, false, I18n::Message::Cndcvt_Calcium),
ToolboxMessageTree::Leaf(I18n::Message::Tungsten, I18n::Message::Cndcvt_Tungsten, false, I18n::Message::Cndcvt_Tungsten),
ToolboxMessageTree::Leaf(I18n::Message::Zinc, I18n::Message::Cndcvt_Zinc, false, I18n::Message::Cndcvt_Zinc),
ToolboxMessageTree::Leaf(I18n::Message::Cobalt, I18n::Message::Cndcvt_Cobalt, false, I18n::Message::Cndcvt_Cobalt),
ToolboxMessageTree::Leaf(I18n::Message::Nickel, I18n::Message::Cndcvt_Nickel, false, I18n::Message::Cndcvt_Nickel),
ToolboxMessageTree::Leaf(I18n::Message::Lithium, I18n::Message::Cndcvt_Lithium, false, I18n::Message::Cndcvt_Lithium),
ToolboxMessageTree::Leaf(I18n::Message::Iron, I18n::Message::Cndcvt_Iron, false, I18n::Message::Cndcvt_Iron),
ToolboxMessageTree::Leaf(I18n::Message::Platinum, I18n::Message::Cndcvt_Platinum, false, I18n::Message::Cndcvt_Platinum),
ToolboxMessageTree::Leaf(I18n::Message::Tin, I18n::Message::Cndcvt_Tin, false, I18n::Message::Cndcvt_Tin),
ToolboxMessageTree::Leaf(I18n::Message::Sea_water, I18n::Message::Cndcvt_Sea_water, false, I18n::Message::Cndcvt_Sea_water),
ToolboxMessageTree::Leaf(I18n::Message::Water, I18n::Message::Cndcvt_Water, false, I18n::Message::Cndcvt_Water),
ToolboxMessageTree::Leaf(I18n::Message::Air, I18n::Message::Cndcvt_Air, false, I18n::Message::Cndcvt_Air),
ToolboxMessageTree::Leaf(I18n::Message::Wood, I18n::Message::Cndcvt_Wood, false, I18n::Message::Cndcvt_Wood),
ToolboxMessageTree::Leaf(I18n::Message::Glass, I18n::Message::Cndcvt_Glass, false, I18n::Message::Cndcvt_Glass)
};
const ToolboxMessageTree Electricity[] = {
ToolboxMessageTree::Leaf(I18n::Message::ElementalChargeTag, I18n::Message::ElementalCharge, false, I18n::Message::ElementalCharge),
ToolboxMessageTree::Node(I18n::Message::ResistivityConstants, Resistivity),
ToolboxMessageTree::Node(I18n::Message::ConductivityConstants, Conductivity)
};
const ToolboxMessageTree ParticleMass[] = {
ToolboxMessageTree::Leaf(I18n::Message::ElectronMassTag, I18n::Message::ElectronMass, false, I18n::Message::ElectronMass),
ToolboxMessageTree::Leaf(I18n::Message::MuonMassTag, I18n::Message::MuonMass, false, I18n::Message::MuonMass),
@@ -788,6 +836,7 @@ const ToolboxMessageTree PlanckUnits[] = {
const ToolboxMessageTree Physics[] = {
ToolboxMessageTree::Node(I18n::Message::FundamentalConstants, FundamentalConstants),
ToolboxMessageTree::Node(I18n::Message::Electromagnetism, Electromagnetism),
ToolboxMessageTree::Node(I18n::Message::Electricity, Electricity),
ToolboxMessageTree::Node(I18n::Message::NuclearConstants, Nuclear),
ToolboxMessageTree::Node(I18n::Message::Thermodynamics, Thermodynamics),
ToolboxMessageTree::Node(I18n::Message::Gravitation, Gravitation),
@@ -805,15 +854,15 @@ const ToolboxMessageTree menu[] = {
ToolboxMessageTree::Leaf(I18n::Message::LogCommandWithArg, I18n::Message::BasedLogarithm),
ToolboxMessageTree::Node(I18n::Message::Calculation, calculChildren),
ToolboxMessageTree::Node(I18n::Message::ComplexNumber, complexChildren),
ToolboxMessageTree::Node(I18n::Message::Combinatorics, combinatoricsChildren),
ToolboxMessageTree::Node(I18n::Message::Probability, probabilityChildren),
ToolboxMessageTree::Node(I18n::Message::Unit, unitChildren),
ToolboxMessageTree::Node(I18n::Message::Arithmetic, arithmeticChildren),
ToolboxMessageTree::Node(I18n::Message::Matrices, matricesChildren),
ToolboxMessageTree::Node(I18n::Message::Probability, probabilityChildren),
ToolboxMessageTree::Node(I18n::Message::Vectors, vectorsChildren),
#if LIST_ARE_DEFINED
ToolboxMessageTree::Node(I18n::Message::Lists,listsChildren),
#endif
ToolboxMessageTree::Node(I18n::Message::Unit, unitChildren),
ToolboxMessageTree::Node(I18n::Message::Combinatorics, combinatoricsChildren),
ToolboxMessageTree::Node(I18n::Message::RandomAndApproximation, randomAndApproximationChildren),
ToolboxMessageTree::Node(I18n::Message::HyperbolicTrigonometry, trigonometryChildren),
ToolboxMessageTree::Node(I18n::Message::Fluctuation, predictionChildren),

View File

@@ -5,7 +5,7 @@
MathVariableBoxEmptyController::MathVariableBoxEmptyView::MathVariableBoxEmptyView() :
ModalViewEmptyView(),
m_layoutExample(0.5f, 0.5f, KDColorBlack, Palette::WallScreen)
m_layoutExample(0.5f, 0.5f, *Palette::PrimaryText, *Palette::WallScreen)
{
initMessageViews();
}

View File

@@ -11,7 +11,7 @@ LogoView::LogoView() :
}
void LogoView::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(bounds(), Palette::BackgroundHard);
ctx->fillRect(bounds(), *Palette::BackgroundHard);
}
int LogoView::numberOfSubviews() const {

View File

@@ -4,7 +4,7 @@
namespace OnBoarding {
PromptController::MessageViewWithSkip::MessageViewWithSkip(I18n::Message * messages, KDColor * fgcolors, KDColor * bgcolors, uint8_t numberOfMessages) :
PromptController::MessageViewWithSkip::MessageViewWithSkip(I18n::Message * messages, KDColor const * fgcolors[], KDColor const * bgcolors[], uint8_t numberOfMessages) :
MessageView(messages, fgcolors, bgcolors, numberOfMessages),
m_skipView(KDFont::SmallFont, I18n::Message::Skip, 1.0f, 0.5f),
m_okView()
@@ -42,7 +42,7 @@ void PromptController::MessageViewWithSkip::layoutSubviews(bool force) {
m_okView.setFrame(KDRect(width - okSize.width()-k_okMargin, height-okSize.height()-k_okMargin, okSize), force);
}
PromptController::PromptController(I18n::Message * messages, KDColor * fgcolors, KDColor * bgcolors, uint8_t numberOfMessages) :
PromptController::PromptController(I18n::Message * messages, KDColor const * fgcolors[], KDColor const * bgcolors[], uint8_t numberOfMessages) :
ViewController(nullptr),
m_messageViewWithSkip(messages, fgcolors, bgcolors, numberOfMessages)
{

View File

@@ -10,13 +10,13 @@ namespace OnBoarding {
class PromptController : public ViewController {
public:
PromptController(I18n::Message * messages, KDColor * fgcolors, KDColor * bgcolors, uint8_t numberOfMessages);
PromptController(I18n::Message * messages, KDColor const * fgcolors[], KDColor const * bgcolors[], uint8_t numberOfMessages);
View * view() override { return &m_messageViewWithSkip; }
bool handleEvent(Ion::Events::Event event) override;
private:
class MessageViewWithSkip : public MessageView {
public:
MessageViewWithSkip(I18n::Message * messages, KDColor * fgcolors, KDColor * bgcolors, uint8_t numberOfMessages);
MessageViewWithSkip(I18n::Message * messages, KDColor const * fgcolors[], KDColor const * bgcolors[], uint8_t numberOfMessages);
protected:
int numberOfSubviews() const override;
View * subviewAtIndex(int index) override;

View File

@@ -85,11 +85,11 @@ App::App(Snapshot * snapshot) :
{
switch (snapshot->activePage()) {
case Snapshot::Page::Parameters:
m_stackViewController.push(&m_parametersController, Palette::BannerFirstText, Palette::BannerFirstBackground, Palette::BannerFirstBorder);
m_stackViewController.push(&m_parametersController, *Palette::BannerFirstText, *Palette::BannerFirstBackground, *Palette::BannerFirstBorder);
break;
case Snapshot::Page::Calculations:
m_stackViewController.push(&m_parametersController, Palette::BannerFirstText, Palette::BannerFirstBackground, Palette::BannerFirstBorder);
m_stackViewController.push(&m_calculationController, Palette::BannerSecondText, Palette::BannerSecondBackground, Palette::BannerSecondBorder);
m_stackViewController.push(&m_parametersController, *Palette::BannerFirstText, *Palette::BannerFirstBackground, *Palette::BannerFirstBorder);
m_stackViewController.push(&m_calculationController, *Palette::BannerSecondText, *Palette::BannerSecondBackground, *Palette::BannerSecondBorder);
default:
break;
}

View File

@@ -38,10 +38,10 @@ KDSize CalculationCell::minimalSizeForOptimalDisplay() const {
}
void CalculationCell::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(bounds(), Palette::BackgroundHard);
ctx->fillRect(bounds(), *Palette::BackgroundHard);
if (m_isResponder) {
KDSize textSize = m_text.minimalSizeForOptimalDisplay();
ctx->strokeRect(KDRect(2*k_margin+textSize.width(), 0, calculationCellWidth()+2*ResponderImageCell::k_outline, ImageCell::k_height+2*ResponderImageCell::k_outline), Palette::ProbabilityCellBorder);
ctx->strokeRect(KDRect(2*k_margin+textSize.width(), 0, calculationCellWidth()+2*ResponderImageCell::k_outline, ImageCell::k_height+2*ResponderImageCell::k_outline), *Palette::ProbabilityCellBorder);
}
}

View File

@@ -26,7 +26,7 @@ namespace Probability {
constexpr int CalculationController::k_titleBufferSize;
CalculationController::ContentView::ContentView(SelectableTableView * selectableTableView, Distribution * distribution, Calculation * calculation) :
m_titleView(KDFont::SmallFont, I18n::Message::ComputeProbability, 0.5f, 0.5f, Palette::SecondaryText, Palette::BackgroundApps),
m_titleView(KDFont::SmallFont, I18n::Message::ComputeProbability, 0.5f, 0.5f, *Palette::SecondaryText, *Palette::BackgroundApps),
m_selectableTableView(selectableTableView),
m_distributionCurveView(distribution, calculation)
{
@@ -68,7 +68,7 @@ CalculationController::CalculationController(Responder * parentResponder, InputE
m_selectableTableView.setMargins(k_tableMargin);
m_selectableTableView.setVerticalCellOverlap(0);
m_selectableTableView.setDecoratorType(ScrollView::Decorator::Type::None);
m_selectableTableView.setBackgroundColor(Palette::BackgroundHard);
m_selectableTableView.setBackgroundColor(*Palette::BackgroundHard);
for (int i = 0; i < k_numberOfCalculationCells; i++) {

View File

@@ -5,7 +5,7 @@ namespace Probability {
Cell::Cell() :
HighlightCell(),
m_labelView(KDFont::LargeFont, (I18n::Message)0, 0, 0.5, Palette::PrimaryText, Palette::BackgroundHard),
m_labelView(KDFont::LargeFont, (I18n::Message)0, 0, 0.5, *Palette::PrimaryText, *Palette::BackgroundHard),
m_icon(nullptr),
m_focusedIcon(nullptr)
{
@@ -36,7 +36,7 @@ void Cell::layoutSubviews(bool force) {
void Cell::reloadCell() {
HighlightCell::reloadCell();
KDColor backgroundColor = isHighlighted()? Palette::ListCellBackgroundSelected : Palette::ListCellBackground;
KDColor backgroundColor = isHighlighted()? *Palette::ListCellBackgroundSelected : *Palette::ListCellBackground;
m_labelView.setBackgroundColor(backgroundColor);
if (isHighlighted()) {
m_iconView.setImage(m_focusedIcon);
@@ -57,12 +57,12 @@ void Cell::setImage(const Image * image, const Image * focusedImage) {
void Cell::drawRect(KDContext * ctx, KDRect rect) const {
KDCoordinate width = bounds().width();
KDCoordinate height = bounds().height();
KDColor backgroundColor = isHighlighted() ? Palette::ListCellBackgroundSelected : Palette::ListCellBackground;
KDColor backgroundColor = isHighlighted() ? *Palette::ListCellBackgroundSelected : *Palette::ListCellBackground;
ctx->fillRect(KDRect(1, 1, width-2, height-1), backgroundColor);
ctx->fillRect(KDRect(0, 0, width, 1), Palette::ProbabilityCellBorder);
ctx->fillRect(KDRect(0, 1, 1, height-1), Palette::ProbabilityCellBorder);
ctx->fillRect(KDRect(width-1, 1, 1, height-1), Palette::ProbabilityCellBorder);
ctx->fillRect(KDRect(0, height-1, width, 1), Palette::ProbabilityCellBorder);
ctx->fillRect(KDRect(0, 0, width, 1), *Palette::ProbabilityCellBorder);
ctx->fillRect(KDRect(0, 1, 1, height-1), *Palette::ProbabilityCellBorder);
ctx->fillRect(KDRect(width-1, 1, 1, height-1), *Palette::ProbabilityCellBorder);
ctx->fillRect(KDRect(0, height-1, width, 1), *Palette::ProbabilityCellBorder);
}
}

View File

@@ -90,7 +90,7 @@ bool Probability::DistributionController::handleEvent(Ion::Events::Event event)
if (event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Right) {
StackViewController * stack = (StackViewController *)parentResponder();
setDistributionAccordingToIndex(selectedRow());
stack->push(m_parametersController, Palette::BannerFirstText, Palette::BannerFirstBackground, Palette::BannerFirstBorder);
stack->push(m_parametersController, *Palette::BannerFirstText, *Palette::BannerFirstBackground, *Palette::BannerFirstBorder);
return true;
}
return false;

View File

@@ -26,7 +26,7 @@ private:
class ContentView : public View {
public:
ContentView(SelectableTableView * selectableTableView) :
m_titleView(KDFont::SmallFont, I18n::Message::ChooseDistribution, 0.5f, 0.5f, Palette::SecondaryText, Palette::BackgroundApps),
m_titleView(KDFont::SmallFont, I18n::Message::ChooseDistribution, 0.5f, 0.5f, *Palette::SecondaryText, *Palette::BackgroundApps),
m_selectableTableView(selectableTableView)
{}
constexpr static KDCoordinate k_titleMargin = 8;

View File

@@ -6,7 +6,7 @@ using namespace Shared;
namespace Probability {
constexpr KDColor DistributionCurveView::k_backgroundColor;
KDColor const * DistributionCurveView::k_backgroundColor = Palette::BackgroundApps;
void DistributionCurveView::reload() {
CurveView::reload();
@@ -16,9 +16,9 @@ void DistributionCurveView::reload() {
void DistributionCurveView::drawRect(KDContext * ctx, KDRect rect) const {
float lowerBound = m_calculation->lowerBound();
float upperBound = m_calculation->upperBound();
ctx->fillRect(bounds(), k_backgroundColor);
ctx->fillRect(bounds(), *k_backgroundColor);
drawAxis(ctx, rect, Axis::Horizontal);
drawLabelsAndGraduations(ctx, rect, Axis::Horizontal, false, false, false, 0, k_backgroundColor);
drawLabelsAndGraduations(ctx, rect, Axis::Horizontal, false, false, false, 0, *k_backgroundColor);
if (m_distribution->type() == Distribution::Type::Normal) {
/* Special case for the normal distribution, which has always the same curve
* We indicate the pixels from and to which we color under the curve, not
@@ -29,9 +29,9 @@ void DistributionCurveView::drawRect(KDContext * ctx, KDRect rect) const {
return;
}
if (m_distribution->isContinuous()) {
drawCartesianCurve(ctx, rect, -INFINITY, INFINITY, EvaluateXYAtAbscissa, m_distribution, nullptr, Palette::ProbabilityCurve, true, true, lowerBound, upperBound);
drawCartesianCurve(ctx, rect, -INFINITY, INFINITY, EvaluateXYAtAbscissa, m_distribution, nullptr, *Palette::ProbabilityCurve, true, true, lowerBound, upperBound);
} else {
drawHistogram(ctx, rect, EvaluateAtAbscissa, m_distribution, nullptr, 0, 1, false, Palette::ProbabilityHistogramBar, Palette::ProbabilityCurve, lowerBound, upperBound+0.5f);
drawHistogram(ctx, rect, EvaluateAtAbscissa, m_distribution, nullptr, 0, 1, false, *Palette::ProbabilityHistogramBar, *Palette::ProbabilityCurve, lowerBound, upperBound+0.5f);
}
}
@@ -59,7 +59,7 @@ void DistributionCurveView::drawStandardNormal(KDContext * ctx, KDRect rect, flo
// Draw a centered reduced normal curve
NormalDistribution n;
constCastedThis->setCurveViewRange(&n);
drawCartesianCurve(ctx, rect, -INFINITY, INFINITY, EvaluateXYAtAbscissa, &n, nullptr, Palette::ProbabilityCurve, true, true, pixelToFloat(Axis::Horizontal, colorLowerBoundPixel), pixelToFloat(Axis::Horizontal, colorUpperBoundPixel));
drawCartesianCurve(ctx, rect, -INFINITY, INFINITY, EvaluateXYAtAbscissa, &n, nullptr, *Palette::ProbabilityCurve, true, true, pixelToFloat(Axis::Horizontal, colorLowerBoundPixel), pixelToFloat(Axis::Horizontal, colorUpperBoundPixel));
// Put back the previous curve view range
constCastedThis->setCurveViewRange(previousRange);

View File

@@ -30,7 +30,7 @@ protected:
private:
static float EvaluateAtAbscissa(float abscissa, void * model, void * context);
static Poincare::Coordinate2D<float> EvaluateXYAtAbscissa(float abscissa, void * model, void * context);
static constexpr KDColor k_backgroundColor = Palette::BackgroundApps;
static KDColor const * k_backgroundColor;
void drawStandardNormal(KDContext * ctx, KDRect rect, float colorLowerBound, float colorUpperBound) const;
char m_labels[k_maxNumberOfXLabels][k_labelBufferMaxSize];
Distribution * m_distribution;

View File

@@ -8,16 +8,16 @@ namespace Probability {
ParametersController::ContentView::ContentView(SelectableTableView * selectableTableView) :
m_numberOfParameters(1),
m_titleView(KDFont::SmallFont, I18n::Message::ChooseParameters, 0.5f, 0.5f, Palette::SecondaryText, Palette::BackgroundApps),
m_firstParameterDefinition(KDFont::SmallFont, (I18n::Message)0, 0.5f, 0.5f, Palette::PrimaryText, Palette::BackgroundApps),
m_secondParameterDefinition(KDFont::SmallFont, (I18n::Message)0, 0.5f, 0.5f, Palette::PrimaryText, Palette::BackgroundApps),
m_titleView(KDFont::SmallFont, I18n::Message::ChooseParameters, 0.5f, 0.5f, *Palette::SecondaryText, *Palette::BackgroundApps),
m_firstParameterDefinition(KDFont::SmallFont, (I18n::Message)0, 0.5f, 0.5f, *Palette::PrimaryText, *Palette::BackgroundApps),
m_secondParameterDefinition(KDFont::SmallFont, (I18n::Message)0, 0.5f, 0.5f, *Palette::PrimaryText, *Palette::BackgroundApps),
m_selectableTableView(selectableTableView)
{
}
void ParametersController::ContentView::drawRect(KDContext * ctx, KDRect rect) const {
int tableHeight = m_selectableTableView->minimalSizeForOptimalDisplay().height();
ctx->fillRect(KDRect(0, tableHeight, bounds().width(), bounds().height() - tableHeight), Palette::BackgroundApps);
ctx->fillRect(KDRect(0, tableHeight, bounds().width(), bounds().height() - tableHeight), *Palette::BackgroundApps);
}
MessageTextView * ParametersController::ContentView::parameterDefinitionAtIndex(int index) {
@@ -161,7 +161,7 @@ bool ParametersController::textFieldDidFinishEditing(TextField * textField, cons
void ParametersController::buttonAction() {
StackViewController * stack = stackController();
stack->push(m_calculationController, Palette::BannerSecondText, Palette::BannerSecondBackground, Palette::BannerSecondBorder);
stack->push(m_calculationController, *Palette::BannerSecondText, *Palette::BannerSecondBackground, *Palette::BannerSecondBorder);
}
}

View File

@@ -11,8 +11,8 @@ ResponderImageCell::ResponderImageCell(Responder * parentResponder, Distribution
}
void ResponderImageCell::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(bounds(), Palette::BackgroundHard);
ctx->strokeRect(KDRect(0, 0, ImageCell::k_width+2*k_outline, ImageCell::k_height+2*k_outline), Palette::ProbabilityCellBorder);
ctx->fillRect(bounds(), *Palette::BackgroundHard);
ctx->strokeRect(KDRect(0, 0, ImageCell::k_width+2*k_outline, ImageCell::k_height+2*k_outline), *Palette::ProbabilityCellBorder);
}
KDSize ResponderImageCell::minimalSizeForOptimalDisplay() const {

27
apps/reader/README.md Normal file
View File

@@ -0,0 +1,27 @@
# Thanks
Thanks to [Gabriel79](https://github.com/Gabriel79) for the original reader app, his source code available [here](https://github.com/Gabriel79/OmegaWithReaderTutorial) and the [tutorial](https://www.codingame.com/playgrounds/55846/reader-faire-une-application-pour-omega-sur-numworks/introduction) to code it !
---
# Rich text format
Reader app supports now a rich text format :
* `$` around a mathematical expression **without spaces** to render it
* `%` around a color-code (see below) to change the color of the text
### Color codes :
|code|color|
| --:| ---:|
|`%\last_color%`|Stop using last color|
|`%r%`|Red|
|`%rl%`|Light red|
|`%m%`|Magenta|
|`%t%`|Turquoise|
|`%pk%`|Pink|
|`%pp%`|Purple|
|`%b%`|Blue|
|`%bl%`|Light blue|
|`%br%`|Brown|
|`%o%`|Orange|
|`%g%`|Green|
|`%gl%`|Light green|
|`%c%`|Cyan|

View File

@@ -27,19 +27,21 @@ bool ReadBookController::handleEvent(Ion::Events::Event event) {
m_readerView.previousPage();
return true;
}
if(event == Ion::Events::Back || event == Ion::Events::Home) {
savePosition();
}
return false;
}
void ReadBookController::viewDidDisappear() {
savePosition();
}
void ReadBookController::savePosition() const {
int pageOffset = m_readerView.getPageOffset();
Ion::Storage::Record::ErrorStatus status = Ion::Storage::sharedStorage()->createRecordWithFullName(m_file->name, &pageOffset, sizeof(pageOffset));
BookSave save = m_readerView.getBookSave();
Ion::Storage::Record::ErrorStatus status = Ion::Storage::sharedStorage()->createRecordWithFullName(m_file->name, &save, sizeof(save));
if(Ion::Storage::Record::ErrorStatus::NameTaken == status) {
Ion::Storage::Record::Data data;
data.buffer = &pageOffset;
data.size = sizeof(pageOffset);
data.buffer = &save;
data.size = sizeof(save);
status = Ion::Storage::sharedStorage()->recordNamed(m_file->name).setValue(data);
}
}
@@ -47,11 +49,14 @@ void ReadBookController::savePosition() const {
void ReadBookController::loadPosition() {
Ion::Storage::Record r = Ion::Storage::sharedStorage()->recordNamed(m_file->name);
if(Ion::Storage::sharedStorage()->hasRecord(r)) {
int pageOffset = *(static_cast<const int*>(r.value().buffer));
m_readerView.setPageOffset(pageOffset);
BookSave save = *(static_cast<const BookSave*>(r.value().buffer));
m_readerView.setBookSave(save);
}
else {
m_readerView.setPageOffset(0);
m_readerView.setBookSave({
0,
*Palette::PrimaryText
});
}
}

View File

@@ -11,10 +11,9 @@ class ReadBookController : public ViewController {
public:
ReadBookController(Responder * parentResponder);
View * view() override;
void setBook(const External::Archive::File& file);
bool handleEvent(Ion::Events::Event event) override;
void viewDidDisappear() override;
void savePosition() const;
void loadPosition();
private:

View File

@@ -110,4 +110,21 @@ int filesWithExtension(const char* extension, External::Archive::File* files, in
}
#endif
const char * EndOfPrintableWord(const char * word, const char * end) {
if (word == end) {
return word;
}
UTF8Decoder decoder(word);
CodePoint codePoint = decoder.nextCodePoint();
const char * result = word;
while (codePoint != '\n' && codePoint != ' ' && codePoint != '%') {
result = decoder.stringPosition();
if (result >= end) {
break;
}
codePoint = decoder.nextCodePoint();
}
return result;
}
}

View File

@@ -2,6 +2,8 @@
#define __UTILITY_H__
#include <apps/external/archive.h>
#include <ion/unicode/code_point.h>
#include <ion/unicode/utf8_decoder.h>
namespace Reader
{
@@ -9,6 +11,7 @@ namespace Reader
bool stringEndsWith(const char* str, const char* end);
int filesWithExtension(const char* extension, External::Archive::File* files, int filesSize);
void stringNCopy(char* dest, int max, const char* src, int len);
const char * EndOfPrintableWord(const char * word, const char * end);
}
#endif

View File

@@ -1,10 +1,22 @@
#include "word_wrap_view.h"
#include "utility.h"
#include <poincare/expression.h>
#include "../shared/poincare_helpers.h"
#include <poincare/undefined.h>
namespace Reader
{
WordWrapTextView::WordWrapTextView() :
PointerTextView(GlobalPreferences::sharedGlobalPreferences()->font()),
m_pageOffset(0),
m_nextPageOffset(0),
m_length(0)
{
}
void WordWrapTextView::nextPage() {
if(m_nextPageOffset >= m_length) {
return;
@@ -29,12 +41,35 @@ void WordWrapTextView::previousPage() {
const char * endOfWord = text() + m_pageOffset - 1;
const char * startOfWord = UTF8Helper::BeginningOfWord(text(), endOfWord);
KDSize textSize = KDSizeZero;
KDPoint textEndPosition(m_frame.width() - k_margin, m_frame.height() - k_margin);
while(startOfWord>=text()) {
startOfWord = UTF8Helper::BeginningOfWord(text(), endOfWord);
endOfWord = UTF8Helper::EndOfWord(startOfWord);
KDSize textSize = m_font->stringSizeUntil(startOfWord, endOfWord);
endOfWord = UTF8Helper::EndOfWord(startOfWord);
if (*startOfWord == '%') {
if (updateTextColorBackward(startOfWord)) {
endOfWord = startOfWord - 1;
continue;
}
}
if (*startOfWord == '$' && *(endOfWord-1) == '$') {
const int wordMaxLength = 128;
char word[wordMaxLength];
stringNCopy(word, wordMaxLength, startOfWord + 1, endOfWord-startOfWord-2);
Poincare::Expression expr = Poincare::Expression::Parse(word, nullptr);
if (expr.isUninitialized()) {
expr = Poincare::Undefined::Builder();
}
Poincare::Layout layout = Shared::PoincareHelpers::CreateLayout(expr);
textSize = layout.layoutSize();
}
else {
textSize = m_font->stringSizeUntil(startOfWord, endOfWord);
}
KDPoint textStartPosition = KDPoint(textEndPosition.x()-textSize.width(), textEndPosition.y());
if(textStartPosition.x() < k_margin) {
@@ -84,37 +119,85 @@ void WordWrapTextView::drawRect(KDContext * ctx, KDRect rect) const {
const char * endOfFile = text() + m_length;
const char * startOfWord = text() + m_pageOffset;
const char * endOfWord = UTF8Helper::EndOfWord(startOfWord);
const char * endOfWord = EndOfPrintableWord(startOfWord, endOfFile);
KDPoint textPosition(k_margin, k_margin);
const int wordMaxLength = 128;
char word[wordMaxLength];
Poincare::Layout layout;
enum class ToDraw {
Text,
Expression,
Nothing
};
ToDraw toDraw = ToDraw::Text;
const int charWidth = m_font->glyphSize().width();
const int charHeight = m_font->glyphSize().height();
int nextLineOffset = charHeight;
KDSize textSize = KDSizeZero;
while(startOfWord < endOfFile) {
KDSize textSize = m_font->stringSizeUntil(startOfWord, endOfWord);
if (*startOfWord == '%') { // Look for color keyword (ex '%bl%')
if (updateTextColorForward(startOfWord)) {
startOfWord = endOfWord + 1;
endOfWord = EndOfPrintableWord(startOfWord, endOfFile);
continue;
}
}
if (*startOfWord == '$' && *(endOfWord-1) == '$') { // Look for expression
stringNCopy(word, wordMaxLength, startOfWord + 1, endOfWord-startOfWord-2);
Poincare::Expression expr = Poincare::Expression::Parse(word, nullptr);
if (expr.isUninitialized()) {
expr = Poincare::Undefined::Builder();
}
layout = Shared::PoincareHelpers::CreateLayout(expr);
textSize = layout.layoutSize();
toDraw = ToDraw::Expression;
}
else {
textSize = m_font->stringSizeUntil(startOfWord, endOfWord);
stringNCopy(word, wordMaxLength, startOfWord, endOfWord-startOfWord);
toDraw = ToDraw::Text;
}
KDPoint nextTextPosition = KDPoint(textPosition.x()+textSize.width(), textPosition.y());
if(nextTextPosition.x() > m_frame.width() - k_margin) { // Right overflow
textPosition = KDPoint(k_margin, textPosition.y() + textSize.height());
textPosition = KDPoint(k_margin, textPosition.y() + nextLineOffset);
nextTextPosition = KDPoint(k_margin + textSize.width(), textPosition.y());
nextLineOffset = charHeight;
}
if (nextLineOffset < textSize.height()) {
nextLineOffset = textSize.height();
}
if(textPosition.y() + textSize.height() > m_frame.height() - k_margin) { // Bottom overflow
break;
}
stringNCopy(word, wordMaxLength, startOfWord, endOfWord-startOfWord);
ctx->drawString(word, textPosition, m_font, m_textColor, m_backgroundColor);
if (toDraw == ToDraw::Expression) {
layout.draw(ctx, textPosition, m_textColor);
}
else if (toDraw == ToDraw::Text) {
ctx->drawString(word, textPosition, m_font, m_textColor, m_backgroundColor);
}
while(*endOfWord == ' ' || *endOfWord == '\n') {
if(*endOfWord == ' ') {
nextTextPosition = KDPoint(nextTextPosition.x() + charWidth, nextTextPosition.y());
}
else {
nextTextPosition = KDPoint(k_margin, nextTextPosition.y() + charHeight);
nextTextPosition = KDPoint(k_margin, nextTextPosition.y() + nextLineOffset);
nextLineOffset = charHeight;
}
++endOfWord;
}
@@ -123,6 +206,10 @@ void WordWrapTextView::drawRect(KDContext * ctx, KDRect rect) const {
//two times the same word if the break below is used
startOfWord = endOfWord;
if (endOfWord >= endOfFile) {
break;
}
if(nextTextPosition.y() + textSize.height() > m_frame.height() - k_margin) { // If out of page, quit
break;
}
@@ -130,22 +217,181 @@ void WordWrapTextView::drawRect(KDContext * ctx, KDRect rect) const {
nextTextPosition = KDPoint(k_margin, nextTextPosition.y());
}
if(nextTextPosition.x() > m_frame.width() - k_margin) { // Go to line if right overflow
nextTextPosition = KDPoint(k_margin, nextTextPosition.y() + textSize.height());
nextTextPosition = KDPoint(k_margin, nextTextPosition.y() + nextLineOffset);
nextLineOffset = charHeight;
}
textPosition = nextTextPosition;
endOfWord = UTF8Helper::EndOfWord(startOfWord);
endOfWord = EndOfPrintableWord(startOfWord+1, endOfFile);
}
m_nextPageOffset = startOfWord - text();
};
int WordWrapTextView::getPageOffset() const {
return m_pageOffset;
BookSave WordWrapTextView::getBookSave() const {
return {
m_pageOffset,
m_textColor
};
}
void WordWrapTextView::setPageOffset(int o) {
m_pageOffset = o;
void WordWrapTextView::setBookSave(BookSave save) {
m_pageOffset = save.offset;
m_textColor = save.color;
}
}
bool WordWrapTextView::updateTextColorForward(const char * colorStart) const {
if (*(colorStart + 1) == '\\') {
m_textColor = *Palette::PrimaryText;
return (*(colorStart + 3) == '%' || *(colorStart + 4) == '%');
}
int keySize = 1;
KDColor lastColor = m_textColor;
switch (*(colorStart+1))
{
case 'r':
if (*(colorStart+2) == 'l') {
m_textColor = *Palette::RedLight;
keySize = 2;
}
else {
m_textColor = *Palette::Red;
}
break;
case 'm':
m_textColor = *Palette::Magenta;
break;
case 't':
m_textColor = *Palette::Turquoise;
break;
case 'p':
if (*(colorStart+2) == 'k') {
m_textColor = *Palette::Pink;
keySize = 2;
}
else if (*(colorStart+2) == 'p') {
m_textColor = *Palette::Purple;
keySize = 2;
}
break;
case 'b':
if (*(colorStart+2) == 'r') {
m_textColor = *Palette::Brown;
keySize = 2;
}
if (*(colorStart+2) == 'l') {
m_textColor = *Palette::BlueLight;
keySize = 2;
}
else {
m_textColor = *Palette::Blue;
}
break;
case 'o':
m_textColor = *Palette::Orange;
break;
case 'g':
if (*(colorStart+2) == 'l') {
m_textColor = *Palette::GreenLight;
keySize = 2;
}
else {
m_textColor = *Palette::Green;
}
break;
case 'c':
m_textColor = *Palette::Cyan;
break;
default:
return false;
}
if (*(colorStart + keySize + 1) != '%') {
m_textColor = lastColor;
return false;
}
return true;
}
bool WordWrapTextView::updateTextColorBackward(const char * colorStart) const {
if (*(colorStart++) != '\\') {
return false;
}
int keySize = 1;
KDColor lastColor = m_textColor;
switch (*(colorStart+1))
{
case 'r':
if (*(colorStart+2) == 'l') {
m_textColor = *Palette::RedLight;
keySize = 2;
}
else {
m_textColor = *Palette::Red;
}
break;
case 'm':
m_textColor = *Palette::Magenta;
break;
case 't':
m_textColor = *Palette::Turquoise;
break;
case 'p':
if (*(colorStart+2) == 'k') {
m_textColor = *Palette::Pink;
keySize = 2;
}
else if (*(colorStart+2) == 'p') {
m_textColor = *Palette::Purple;
keySize = 2;
}
break;
case 'b':
if (*(colorStart+2) == 'r') {
m_textColor = *Palette::Brown;
keySize = 2;
}
if (*(colorStart+2) == 'l') {
m_textColor = *Palette::BlueLight;
keySize = 2;
}
else {
m_textColor = *Palette::Blue;
}
break;
case 'o':
m_textColor = *Palette::Orange;
break;
case 'g':
if (*(colorStart+2) == 'l') {
m_textColor = *Palette::GreenLight;
keySize = 2;
}
else {
m_textColor = *Palette::Green;
}
break;
case 'c':
m_textColor = *Palette::Cyan;
break;
default:
return false;
}
if (*(colorStart + keySize + 1) != '%') {
m_textColor = lastColor;
return false;
}
return true;
}
}

View File

@@ -7,20 +7,28 @@
namespace Reader
{
struct BookSave {
int offset;
KDColor color;
};
class WordWrapTextView : public PointerTextView {
public:
WordWrapTextView() : PointerTextView(GlobalPreferences::sharedGlobalPreferences()->font()) {};
WordWrapTextView();
void drawRect(KDContext * ctx, KDRect rect) const override;
void setText(const char*, int length);
void nextPage();
void previousPage();
int getPageOffset() const;
void setPageOffset(int o);
protected:
int m_pageOffset = 0;
mutable int m_nextPageOffset = 0;
int m_length = 0;
BookSave getBookSave() const;
void setBookSave(BookSave save);
private:
bool updateTextColorForward(const char * colorStart) const;
bool updateTextColorBackward(const char * colorStart) const;
static const int k_margin = 10;
int m_pageOffset;
mutable int m_nextPageOffset;
int m_length;
mutable KDColor m_textColor;
};
}

View File

@@ -26,18 +26,18 @@ CalculationController::CalculationController(Responder * parentResponder, Button
{
m_r2Layout = HorizontalLayout::Builder(CodePointLayout::Builder('r', KDFont::SmallFont), VerticalOffsetLayout::Builder(CodePointLayout::Builder('2', KDFont::SmallFont), VerticalOffsetLayoutNode::Position::Superscript));
m_selectableTableView.setVerticalCellOverlap(0);
m_selectableTableView.setBackgroundColor(Palette::BackgroundAppsSecondary);
m_selectableTableView.setBackgroundColor(*Palette::BackgroundAppsSecondary);
m_selectableTableView.setMargins(k_margin, k_scrollBarMargin, k_scrollBarMargin, k_margin);
m_r2TitleCell.setAlignment(1.0f, 0.5f);
for (int i = 0; i < Store::k_numberOfSeries; i++) {
m_columnTitleCells[i].setParentResponder(&m_selectableTableView);
}
for (int i = 0; i < k_numberOfDoubleCalculationCells; i++) {
m_doubleCalculationCells[i].setTextColor(Palette::SecondaryText);
m_doubleCalculationCells[i].setTextColor(*Palette::SecondaryText);
m_doubleCalculationCells[i].setParentResponder(&m_selectableTableView);
}
for (int i = 0; i < k_numberOfCalculationCells;i++) {
m_calculationCells[i].setTextColor(Palette::SecondaryText);
m_calculationCells[i].setTextColor(*Palette::SecondaryText);
}
for (int i = 0; i < k_maxNumberOfDisplayableRows; i++) {
m_titleCells[i].setMessageFont(KDFont::SmallFont);
@@ -167,7 +167,7 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int
buffer[0] = 'Y';
myCell->setSecondText(buffer);
assert(seriesNumber < Palette::numberOfDataColors());
myCell->setColor(Palette::DataColor[seriesNumber]);
myCell->setColor(*Palette::DataColor[seriesNumber]);
return;
}

View File

@@ -9,7 +9,7 @@ class ColumnTitleCell : public EvenOddDoubleBufferTextCellWithSeparator {
public:
ColumnTitleCell(Responder * parentResponder = nullptr) :
EvenOddDoubleBufferTextCellWithSeparator(parentResponder, 0.5f, 0.5f),
m_functionColor(Palette::Red)
m_functionColor(*Palette::Red)
{
}
virtual void setColor(KDColor color);

View File

@@ -391,7 +391,7 @@ void GraphController::setRoundCrossCursorView() {
if (round) {
// Set the color although the cursor view stays round
assert(*m_selectedSeriesIndex < Palette::numberOfDataColors());
m_roundCursorView.setColor(Palette::DataColor[*m_selectedSeriesIndex]);
m_roundCursorView.setColor(*Palette::DataColor[*m_selectedSeriesIndex]);
}
CursorView * nextCursorView = round ? static_cast<Shared::CursorView *>(&m_roundCursorView) : static_cast<Shared::CursorView *>(&m_crossCursorView);
// Escape if the cursor view stays the same

View File

@@ -15,7 +15,7 @@ GraphView::GraphView(Store * store, CurveViewCursor * cursor, BannerView * banne
}
void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(rect, Palette::BackgroundHard);
ctx->fillRect(rect, *Palette::BackgroundHard);
drawGrid(ctx, rect);
drawAxes(ctx, rect);
simpleDrawBothAxesLabels(ctx, rect);
@@ -23,7 +23,7 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
for (int series = 0; series < Store::k_numberOfSeries; series++) {
if (!m_store->seriesIsEmpty(series)) {
assert(series < Palette::numberOfDataColors());
KDColor color = Palette::DataColor[series];
KDColor color = *Palette::DataColor[series];
Model * seriesModel = m_store->modelForSeries(series);
drawCartesianCurve(ctx, rect, -INFINITY, INFINITY, [](float abscissa, void * model, void * context) {
Model * regressionModel = static_cast<Model *>(model);
@@ -35,7 +35,7 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
drawDot(ctx, rect, m_store->get(series, 0, index), m_store->get(series, 1, index), color);
}
drawDot(ctx, rect, m_store->meanOfColumn(series, 0), m_store->meanOfColumn(series, 1), color, Size::Small);
drawDot(ctx, rect, m_store->meanOfColumn(series, 0), m_store->meanOfColumn(series, 1), Palette::BackgroundHard);
drawDot(ctx, rect, m_store->meanOfColumn(series, 0), m_store->meanOfColumn(series, 1), *Palette::BackgroundHard);
}
}
}

View File

@@ -38,7 +38,7 @@ void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int
bool isValuesColumn = i%Store::k_numberOfColumnsPerSeries == 0;
mytitleCell->setSeparatorLeft(isValuesColumn && i > 0);
int seriesIndex = i/Store::k_numberOfColumnsPerSeries;
mytitleCell->setColor(m_store->numberOfPairsOfSeries(seriesIndex) == 0 ? Palette::SecondaryText : Store::colorOfSeriesAtIndex(seriesIndex)); // TODO Share GreyDark with graph/list_controller and statistics/store_controller
mytitleCell->setColor(m_store->numberOfPairsOfSeries(seriesIndex) == 0 ? *Palette::SecondaryText : Store::colorOfSeriesAtIndex(seriesIndex)); // TODO Share GreyDark with graph/list_controller and statistics/store_controller
char name[] = {isValuesColumn ? 'X' : 'Y', static_cast<char>('1' + seriesIndex), 0};
mytitleCell->setText(name);
}

View File

@@ -30,7 +30,7 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
}
drawDot(ctx, rect, x, y, s->color());
if (x >= m_highlightedStart && x <= m_highlightedEnd && record == m_selectedRecord) {
KDColor color = m_shouldColorHighlighted ? s->color() : Palette::PrimaryText;
KDColor color = m_shouldColorHighlighted ? s->color() : *Palette::PrimaryText;
if (y >= 0.0f) {
drawHorizontalOrVerticalSegment(ctx, rect, Axis::Vertical, x, 0.0f, y, color, 1);
} else {

View File

@@ -15,7 +15,7 @@ ListController::ListController(Responder * parentResponder, ::InputEventHandlerD
m_expressionCells{},
m_parameterController(inputEventHandlerDelegate, this),
m_typeParameterController(this, this, TableCell::Layout::Vertical),
m_typeStackController(nullptr, &m_typeParameterController, Palette::ToolboxHeaderText, Palette::ToolboxHeaderBackground, Palette::ToolboxHeaderBorder),
m_typeStackController(nullptr, &m_typeParameterController, *Palette::ToolboxHeaderText, *Palette::ToolboxHeaderBackground, *Palette::ToolboxHeaderBorder),
m_sequenceToolbox()
{
for (int i = 0; i < k_maxNumberOfRows; i++) {
@@ -191,7 +191,7 @@ void ListController::willDisplayTitleCellAtIndex(HighlightCell * cell, int j) {
myCell->setLayout(sequence->secondInitialConditionName());
}
// Set the color
KDColor nameColor = sequence->isActive() ? sequence->color() : Palette::SecondaryText;
KDColor nameColor = sequence->isActive() ? sequence->color() : *Palette::SecondaryText;
myCell->setColor(nameColor);
}
@@ -209,7 +209,7 @@ void ListController::willDisplayExpressionCellAtIndex(HighlightCell * cell, int
myCell->setLayout(sequence->secondInitialConditionLayout());
}
bool active = sequence->isActive();
KDColor textColor = active ? Palette::PrimaryText : Palette::SecondaryText;
KDColor textColor = active ? *Palette::PrimaryText : *Palette::SecondaryText;
myCell->setTextColor(textColor);
}

View File

@@ -11,6 +11,7 @@ app_settings_src = $(addprefix apps/settings/,\
main_controller_prompt_update.cpp:+update \
sub_menu/about_controller.cpp \
sub_menu/accessibility_controller.cpp \
sub_menu/code_options_controller.cpp \
sub_menu/about_controller_official.cpp:+official \
sub_menu/about_controller_non_official.cpp:-official \
sub_menu/exam_mode_controller_official.cpp:+official \

View File

@@ -8,7 +8,7 @@ void CellWithSeparator::setHighlighted(bool highlight) {
}
void CellWithSeparator::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(KDRect(0, Metric::CellSeparatorThickness, bounds().width(), k_margin), Palette::BackgroundApps);
ctx->fillRect(KDRect(0, Metric::CellSeparatorThickness, bounds().width(), k_margin), *Palette::BackgroundApps);
}
int CellWithSeparator::numberOfSubviews() const {

View File

@@ -17,9 +17,16 @@ constexpr SettingsMessageTree s_modelDateTimeChildren[3] = {SettingsMessageTree(
constexpr SettingsMessageTree s_symbolChildren[4] = {SettingsMessageTree(I18n::Message::SymbolMultiplicationCross),SettingsMessageTree(I18n::Message::SymbolMultiplicationMiddleDot),SettingsMessageTree(I18n::Message::SymbolMultiplicationStar),SettingsMessageTree(I18n::Message::SymbolMultiplicationAutoSymbol)};
constexpr SettingsMessageTree s_symbolFunctionChildren[3] = {SettingsMessageTree(I18n::Message::SymbolDefaultFunction), SettingsMessageTree(I18n::Message::SymbolArgDefaultFunction), SettingsMessageTree(I18n::Message::SymbolArgFunction)};
constexpr SettingsMessageTree s_modelMathOptionsChildren[6] = {SettingsMessageTree(I18n::Message::AngleUnit, s_modelAngleChildren), SettingsMessageTree(I18n::Message::DisplayMode, s_modelFloatDisplayModeChildren), SettingsMessageTree(I18n::Message::EditionMode, s_modelEditionModeChildren), SettingsMessageTree(I18n::Message::SymbolFunction, s_symbolFunctionChildren), SettingsMessageTree(I18n::Message::ComplexFormat, s_modelComplexFormatChildren), SettingsMessageTree(I18n::Message::SymbolMultiplication, s_symbolChildren)};
constexpr SettingsMessageTree s_modelFontChildren[2] = {SettingsMessageTree(I18n::Message::LargeFont), SettingsMessageTree(I18n::Message::SmallFont)};
constexpr SettingsMessageTree s_accessibilityChildren[6] = {SettingsMessageTree(I18n::Message::AccessibilityInvertColors), SettingsMessageTree(I18n::Message::AccessibilityMagnify),SettingsMessageTree(I18n::Message::AccessibilityGamma),SettingsMessageTree(I18n::Message::AccessibilityGammaRed),SettingsMessageTree(I18n::Message::AccessibilityGammaGreen),SettingsMessageTree(I18n::Message::AccessibilityGammaBlue)};
constexpr SettingsMessageTree s_contributorsChildren[23] = {SettingsMessageTree(I18n::Message::Developers), SettingsMessageTree(I18n::Message::QuentinGuidee), SettingsMessageTree(I18n::Message::JoachimLeFournis), SettingsMessageTree(I18n::Message::MaximeFriess), SettingsMessageTree(I18n::Message::JeanBaptisteBoric), SettingsMessageTree(I18n::Message::SandraSimmons), SettingsMessageTree(I18n::Message::David), SettingsMessageTree(I18n::Message::DamienNicolet), SettingsMessageTree(I18n::Message::EvannDreumont), SettingsMessageTree(I18n::Message::SzaboLevente), SettingsMessageTree(I18n::Message::VenceslasDuet), SettingsMessageTree(I18n::Message::CharlotteThomas), SettingsMessageTree(I18n::Message::AntoninLoubiere), SettingsMessageTree(I18n::Message::CyprienMejat), SettingsMessageTree(I18n::Message::BetaTesters), SettingsMessageTree(I18n::Message::TimeoArnouts), SettingsMessageTree(I18n::Message::JulieC), SettingsMessageTree(I18n::Message::LelahelHideux), SettingsMessageTree(I18n::Message::Madil), SettingsMessageTree(I18n::Message::HilaireLeRoux), SettingsMessageTree(I18n::Message::HectorNussbaumer), SettingsMessageTree(I18n::Message::RaphaelDyda), SettingsMessageTree(I18n::Message::ThibautC)};
// Code Settings
#ifdef HAS_CODE
constexpr SettingsMessageTree s_codeChildren[2] = {SettingsMessageTree(I18n::Message::FontSizes, s_modelFontChildren), SettingsMessageTree(I18n::Message::Autocomplete)};
#endif
constexpr SettingsMessageTree s_modelFontChildren[2] = {SettingsMessageTree(I18n::Message::LargeFont), SettingsMessageTree(I18n::Message::SmallFont)};
constexpr SettingsMessageTree s_modelAboutChildren[9] = {SettingsMessageTree(I18n::Message::Username), SettingsMessageTree(I18n::Message::SoftwareVersion), SettingsMessageTree(I18n::Message::UpsilonVersion), SettingsMessageTree(I18n::Message::MicroPythonVersion), SettingsMessageTree(I18n::Message::Battery), SettingsMessageTree(I18n::Message::MemUse), SettingsMessageTree(I18n::Message::SerialNumber), SettingsMessageTree(I18n::Message::FccId), SettingsMessageTree(I18n::Message::Contributors, s_contributorsChildren)};
MainController::MainController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate) :
@@ -31,6 +38,7 @@ MainController::MainController(Responder * parentResponder, InputEventHandlerDel
m_localizationController(this, Metric::CommonTopMargin, LocalizationController::Mode::Language),
m_accessibilityController(this),
m_dateTimeController(this),
m_codeOptionsController(this),
m_examModeController(this),
m_aboutController(this),
m_preferencesController(this)
@@ -62,7 +70,7 @@ bool MainController::handleEvent(Ion::Events::Event event) {
}
if (model()->childAtIndex(selectedRow())->numberOfChildren() == 0) {
if (model()->childAtIndex(selectedRow())->label() == promptMessage()) {
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
if (event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Right) {
globalPreferences->setShowPopUp(!globalPreferences->showPopUp());
m_selectableTableView.reloadCellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow());
return true;
@@ -103,6 +111,8 @@ bool MainController::handleEvent(Ion::Events::Event event) {
subController = &m_dateTimeController;
} else if (title == I18n::Message::MathOptions) {
subController = &m_mathOptionsController;
} else if (title == I18n::Message::CodeApp) {
subController = &m_codeOptionsController;
} else {
subController = &m_preferencesController;
}
@@ -202,9 +212,6 @@ void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) {
MessageTableCellWithChevronAndMessage * myTextCell = (MessageTableCellWithChevronAndMessage *)cell;
int childIndex = -1;
switch (model()->childAtIndex(index)->label()) {
case I18n::Message::FontSizes:
childIndex = GlobalPreferences::sharedGlobalPreferences()->font() == KDFont::LargeFont ? 0 : 1;
break;
default:
break;
}

View File

@@ -8,6 +8,7 @@
#include "sub_menu/accessibility_controller.h"
#include "sub_menu/datetime_controller.h"
#include "sub_menu/exam_mode_controller.h"
#include "sub_menu/code_options_controller.h"
#include "sub_menu/localization_controller.h"
#include "sub_menu/math_options_controller.h"
#include "sub_menu/preferences_controller.h"
@@ -22,6 +23,7 @@ extern const Shared::SettingsMessageTree s_symbolChildren[4];
extern const Shared::SettingsMessageTree s_symbolFunctionChildren[3];
extern const Shared::SettingsMessageTree s_modelMathOptionsChildren[6];
extern const Shared::SettingsMessageTree s_modelFontChildren[2];
extern const Shared::SettingsMessageTree s_codeChildren[2];
extern const Shared::SettingsMessageTree s_modelDateTimeChildren[3];
extern const Shared::SettingsMessageTree s_accessibilityChildren[6];
extern const Shared::SettingsMessageTree s_contributorsChildren[23];
@@ -70,6 +72,7 @@ private:
LocalizationController m_localizationController;
AccessibilityController m_accessibilityController;
DateTimeController m_dateTimeController;
CodeOptionsController m_codeOptionsController;
ExamModeController m_examModeController;
AboutController m_aboutController;
PreferencesController m_preferencesController;

View File

@@ -10,10 +10,12 @@ constexpr SettingsMessageTree s_modelMenu[] =
{SettingsMessageTree(I18n::Message::MathOptions, s_modelMathOptionsChildren),
SettingsMessageTree(I18n::Message::Brightness),
SettingsMessageTree(I18n::Message::DateTime, s_modelDateTimeChildren),
SettingsMessageTree(I18n::Message::FontSizes, s_modelFontChildren),
SettingsMessageTree(I18n::Message::Language),
SettingsMessageTree(I18n::Message::Country),
SettingsMessageTree(I18n::Message::ExamMode, ExamModeConfiguration::s_modelExamChildren),
#ifdef HAS_CODE
SettingsMessageTree(I18n::Message::CodeApp, s_codeChildren),
#endif
SettingsMessageTree(I18n::Message::BetaPopUp),
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren),
SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren)};

Some files were not shown because too many files have changed in this diff Show More