-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Daily forecast can be used as power off logo
Refs: #28
- Loading branch information
Showing
19 changed files
with
162 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,6 @@ class AlertViewer : public ModalWidget { | |
|
||
void hide(); | ||
|
||
protected: | ||
void do_paint() override; | ||
|
||
private: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include "logo.h" | ||
|
||
#include <boost/log/trivial.hpp> | ||
|
||
#include "config.h" | ||
#include "dailyforecastbox.h" | ||
#include "inkview.h" | ||
#include "statusbar.h" | ||
|
||
namespace taranis { | ||
|
||
Logo::Logo(std::shared_ptr<Model> model, std::shared_ptr<Icons> icons, | ||
std::shared_ptr<Fonts> fonts) | ||
: Widget{0, 0, ScreenWidth(), ScreenHeight()}, | ||
location_box{0, 0, model, fonts}, status_bar{model, fonts}, | ||
forecast_box{0, | ||
this->location_box.get_height() + Logo::vertical_padding, | ||
ScreenWidth(), | ||
ScreenHeight() - 2 * Logo::vertical_padding - | ||
this->location_box.get_height() - | ||
this->status_bar.get_height(), | ||
model, | ||
icons, | ||
fonts} {} | ||
|
||
void Logo::do_paint() { | ||
this->location_box.do_paint(); | ||
this->status_bar.do_paint(); | ||
this->forecast_box.do_paint(); | ||
} | ||
|
||
void LogoGenerator::generate_maybe() const { | ||
Config config; | ||
const auto must_generate = config.read_bool("generate_shutdown_logo", false); | ||
if (must_generate) { | ||
this->generate(); | ||
} else { | ||
BOOST_LOG_TRIVIAL(debug) << "Skipping logo generation"; | ||
} | ||
} | ||
|
||
void LogoGenerator::generate() const { | ||
BOOST_LOG_TRIVIAL(debug) << "Generating new logo"; | ||
|
||
auto *const original_canvas = GetCanvas(); | ||
if (not original_canvas) { | ||
return; | ||
} | ||
std::vector<unsigned char> data; | ||
data.resize(ScreenHeight() * ScreenWidth()); | ||
|
||
icanvas canvas{ScreenWidth(), | ||
ScreenHeight(), | ||
ScreenWidth(), | ||
original_canvas->depth, | ||
0, | ||
ScreenWidth(), | ||
0, | ||
ScreenHeight(), | ||
data.data()}; | ||
SetCanvas(&canvas); | ||
|
||
Logo logo{this->model, this->icons, this->fonts}; | ||
logo.paint(); | ||
|
||
const auto bitmap = | ||
BitmapFromCanvas(0, 0, ScreenWidth(), ScreenHeight(), 0, &canvas); | ||
const auto filename = | ||
std::string{USEROFFLOGOPATH} + "/taranis_weather_forecast.bmp"; | ||
SaveBitmap(filename.data(), bitmap); | ||
|
||
SetCanvas(original_canvas); | ||
} | ||
} // namespace taranis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#pragma once | ||
|
||
#include <inkview.h> | ||
#include <memory> | ||
|
||
#include "dailyforecastbox.h" | ||
#include "fonts.h" | ||
#include "icons.h" | ||
#include "locationbox.h" | ||
#include "model.h" | ||
#include "statusbar.h" | ||
#include "widget.h" | ||
|
||
namespace taranis { | ||
|
||
class Logo : public Widget { | ||
public: | ||
Logo(std::shared_ptr<Model> model, std::shared_ptr<Icons> icons, | ||
std::shared_ptr<Fonts> fonts); | ||
|
||
void do_paint() override; | ||
|
||
private: | ||
static constexpr int horizontal_padding{25}; | ||
static constexpr int vertical_padding{25}; | ||
|
||
LocationBox location_box; | ||
StatusBar status_bar; | ||
DailyForecastBox forecast_box; | ||
}; | ||
|
||
struct LogoGenerator { | ||
LogoGenerator(std::shared_ptr<Model> model, std::shared_ptr<Icons> icons, | ||
std::shared_ptr<Fonts> fonts) | ||
: model{model}, icons{icons}, fonts{fonts} {} | ||
|
||
void generate_maybe() const; | ||
|
||
private: | ||
std::shared_ptr<Model> model; | ||
std::shared_ptr<Icons> icons; | ||
std::shared_ptr<Fonts> fonts; | ||
|
||
void generate() const; | ||
}; | ||
} // namespace taranis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters