3#include <initializer_list>
7#include "core/screen/screen_pages.h"
8#include "core/screen/screen_controller.h"
13 ScreenBook(vex::brain::lcd screen, std::initializer_list<ScreenPage *> pages);
14 ScreenBook(vex::brain::lcd screen, std::vector<ScreenPage *> pages);
15 ScreenBook() =
default;
17 inline std::function<void()> handle() {
19 if(this->pages.empty()) {
20 this->screen.clearScreen(vex::color::red);
24 ScreenPage *front_page = this->pages[this->index];
25 std::optional<Point2d> pressing;
27 if((pressing = ScreenController::get_press_pos()).has_value()) {
28 this->x_press = pressing->x();
29 this->y_press = pressing->y();
31 bool just_pressed = pressing.has_value() && !this->was_pressed;
33 if (just_pressed && this->x_press < 40) {
35 if (this->index < 0) {
36 this->index += this->pages.size();
39 if (just_pressed && this->x_press > 440) {
41 this->index %= this->pages.size();
45 for (
auto page : this->pages) {
46 if (page == front_page) {
47 page->update(this->was_pressed, this->x_press, this->y_press);
49 page->update(
false, 0, 0);
54 int frame = ScreenController::get_frame_count();
56 this->screen.clearScreen(vex::color::black);
57 this->screen.setPenColor(
"#FFFFFF");
58 this->screen.setFillColor(
"#000000");
59 front_page->
draw(this->screen,
false, frame / 5);
62 this->screen.setPenColor(
"#202020");
63 this->screen.setFillColor(
"#202020");
64 this->screen.drawRectangle(0, 0, 40, 240);
65 this->screen.drawRectangle(440, 0, 40, 240);
66 this->screen.setPenColor(
"#FFFFFF");
68 this->screen.drawLine(30, 100, 15, 120);
69 this->screen.drawLine(30, 140, 15, 120);
71 this->screen.drawLine(450, 100, 465, 120);
72 this->screen.drawLine(450, 140, 465, 120);
75 this->was_pressed = pressing.has_value();
86 static inline std::function<void()> pre_initialize(vex::brain& brain, Initializer& initializer, ScreenBook* page, std::function<
void()> o =
nullptr) {
87 return [&, o, page]() {
90 std::vector<ScreenPage*> pages;
size_t initializations = 0;
96 *page = ScreenBook(brain.Screen, pages);
97 ScreenController::set(page->handle());
108 std::vector<ScreenPage *> pages;
109 vex::brain::lcd screen;
InitializerPage(const Initializer &initializer, size_t starting_index=0)
Creates an InitializerPage.
Definition screen_pages.cpp:313
const std::size_t initialization_count() const
Definition initializer.cpp:48
virtual void draw(vex::brain::lcd &screen, bool first_draw, unsigned int frame_number)
draw stored data to the screen (runs at 10 hz and only runs if this page is in front)