From e5610b29165041987fc709bc36bb00ae01a510ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Thu, 13 Apr 2017 11:57:45 +0200 Subject: [PATCH] [apps] Add an icon when mode exam is on Change-Id: I5b12f7857fe27d7b2db97062c17cafe7b571e303 --- apps/Makefile | 2 ++ apps/exam_icon.png | Bin 0 -> 550 bytes apps/exam_pop_up_controller.cpp | 1 + apps/title_bar_view.cpp | 14 +++++++++++++- apps/title_bar_view.h | 4 ++++ 5 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 apps/exam_icon.png diff --git a/apps/Makefile b/apps/Makefile index f66a8a5de..c6aeb8504 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -30,6 +30,8 @@ app_objs += $(addprefix apps/,\ variable_box_leaf_cell.o\ ) +app_images += apps/exam_icon.png + # Tracking which source file uses which image is painful. But we need to ensure # that a .png file has been inlined before building any source file that uses # said image (because it will expect the ".h" file to be there). diff --git a/apps/exam_icon.png b/apps/exam_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..e168f55bd35ebce29550148e5330d048e865ae78 GIT binary patch literal 550 zcmeAS@N?(olHy`uVBq!ia0vp^LO{&P!3HGl@7M4HDVB6cUq=Rpjs4tz5?O(Kg=CK) zUj~LMRR)HJW(J0z|AF)i28JLG21d~c1_rC?3=HD=*Q4Yo0M)W3dAqwX{0G4WdzViJ zif|TqL>4nJh<1Q5_`(0heTRmgQeK{)pHQH=>?*z{1(9wmjY}d~TQ50I*z(0PCMqXbv3%#A z)7J9O@2viEbIG&)U6Bdrn{3%NH0C%xlxZq@v6`!K3TJ1ggok%{+G?lk3rbik{dcX~ z+F0d&(6hUFhU*fpQ;#luH()SGN;tB((|W3r;Qe<@JbKP~(sJdCT|fIju)W-qwuq>#Etj_Lng3mJw`SnnEe1o1c=IR*6M}5k$kB)w3o6H86O(`njxgN@xNA Dmx{@8 literal 0 HcmV?d00001 diff --git a/apps/exam_pop_up_controller.cpp b/apps/exam_pop_up_controller.cpp index b66c280f6..6889faed1 100644 --- a/apps/exam_pop_up_controller.cpp +++ b/apps/exam_pop_up_controller.cpp @@ -58,6 +58,7 @@ ExamPopUpController::ContentView::ContentView(Responder * parentResponder) : } else { Ion::LED::setColor(KDColorBlack); } + container->refreshPreferences(); container->activeApp()->dismissModalViewController(); }, parentResponder), KDText::FontSize::Small)), m_warningTextView(MessageTextView(KDText::FontSize::Small, I18n::Message::Warning, 0.5, 0.5, KDColorWhite, KDColorBlack)), diff --git a/apps/title_bar_view.cpp b/apps/title_bar_view.cpp index 7aec661d5..e2010b3a7 100644 --- a/apps/title_bar_view.cpp +++ b/apps/title_bar_view.cpp @@ -1,4 +1,6 @@ #include "title_bar_view.h" +#include "exam_icon.h" +#include "global_preferences.h" extern "C" { #include } @@ -11,6 +13,7 @@ TitleBarView::TitleBarView() : m_titleView(KDText::FontSize::Small, I18n::Message::Default, 0.5f, 0.5f, KDColorWhite, Palette::YellowDark), m_preferenceView(KDText::FontSize::Small, 1.0f, 0.5, KDColorWhite, Palette::YellowDark) { + m_examModeIconView.setImage(ImageStore::ExamIcon); } void TitleBarView::setTitle(I18n::Message title) { @@ -26,7 +29,7 @@ bool TitleBarView::setIsCharging(bool isCharging) { } int TitleBarView::numberOfSubviews() const { - return 3; + return 4; } View * TitleBarView::subviewAtIndex(int index) { @@ -36,6 +39,9 @@ View * TitleBarView::subviewAtIndex(int index) { if (index == 1) { return &m_preferenceView; } + if (index == 2) { + return &m_examModeIconView; + } return &m_batteryView; } @@ -44,6 +50,11 @@ void TitleBarView::layoutSubviews() { m_preferenceView.setFrame(KDRect(0, 0, m_preferenceView.minimalSizeForOptimalDisplay())); KDSize batterySize = m_batteryView.minimalSizeForOptimalDisplay(); m_batteryView.setFrame(KDRect(bounds().width() - batterySize.width() - k_batteryLeftMargin, (bounds().height()- batterySize.height())/2, batterySize)); + if (GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Activate) { + m_examModeIconView.setFrame(KDRect(k_examIconMargin, (bounds().height() - k_examIconHeight)/2, k_examIconWidth, k_examIconHeight)); + } else { + m_examModeIconView.setFrame(KDRectZero); + } } void TitleBarView::refreshPreferences() { @@ -62,5 +73,6 @@ void TitleBarView::refreshPreferences() { } buffer[numberOfChar] = 0; m_preferenceView.setText(buffer); + // Layout the exam mode icon if needed layoutSubviews(); } diff --git a/apps/title_bar_view.h b/apps/title_bar_view.h index b56cca6f3..21ea060f8 100644 --- a/apps/title_bar_view.h +++ b/apps/title_bar_view.h @@ -14,12 +14,16 @@ public: void refreshPreferences(); private: constexpr static KDCoordinate k_batteryLeftMargin = 5; + constexpr static KDCoordinate k_examIconWidth = 18; + constexpr static KDCoordinate k_examIconHeight = 9; + constexpr static KDCoordinate k_examIconMargin = 93; int numberOfSubviews() const override; void layoutSubviews() override; View * subviewAtIndex(int index) override; MessageTextView m_titleView; BatteryView m_batteryView; BufferTextView m_preferenceView; + ImageView m_examModeIconView; }; #endif