Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fullscreen feature and pixel formatting fix #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions src/layout/confirmfullscreen.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
use super::{ButtonAction, Element, Layout, LayoutId};
use libremarkable::framebuffer::common;

pub fn create() -> Layout {
let buttons = vec![
Element::Text {
rect: common::mxcfb_rect {
left: 0,
top: 1400 - 300 - 10 - 10,
width: common::DISPLAYWIDTH as u32,
height: 100,
},
text: "Go Fullscreen?",
size: 100.0,
},
Element::Text {
rect: common::mxcfb_rect {
left: 0,
top: 1400 - 300 - 10 - 10 + 100,
width: common::DISPLAYWIDTH as u32,
height: 100,
},
text: "You'll need to attach a physical keyboard to play!",
size: 50.0,
},
Element::Text {
rect: common::mxcfb_rect {
left: 0,
top: 1400 - 300 - 10 - 10 + 100 + 75,
width: common::DISPLAYWIDTH as u32,
height: 100,
},
text: "To exit fullscreen, just touch anywhere.",
size: 50.0,
},
Element::Button {
rect: common::mxcfb_rect {
left: (common::DISPLAYWIDTH as u32 - (300 + 50 + 300)) / 2,
top: 1400 - 300 - 10 - 10 + 100 + 75 + 75 + 50,
width: 300,
height: 150,
},
label: "OK",
label_size: 75.0,
action: ButtonAction::EnterFullscreen,
},
Element::Button {
rect: common::mxcfb_rect {
left: (common::DISPLAYWIDTH as u32 - (300 + 50 + 300)) / 2 + 300 + 50,
top: 1400 - 300 - 10 - 10 + 100 + 75 + 75 + 50,
width: 300,
height: 150,
},
label: "Back",
label_size: 75.0,
action: ButtonAction::SwitchLayout(LayoutId::Settings),
},
];

Layout::new(buttons)
}
9 changes: 9 additions & 0 deletions src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ use libremarkable::framebuffer::{FramebufferDraw, FramebufferIO, FramebufferRefr
use libremarkable::input::{Finger, InputEvent, MultitouchEvent};

mod confirmexit;
mod confirmfullscreen;
mod controls;
mod keyboard;
mod settings;

pub enum InputOutcome {
KeyData(KeyData),
SwitchLayout(LayoutId),
EnterFullscreen,
}

pub struct LayoutManager {
Expand Down Expand Up @@ -57,6 +59,7 @@ impl LayoutManager {
layouts.insert(LayoutId::Settings, settings::create());
layouts.insert(LayoutId::ConfirmExit, confirmexit::create());
layouts.insert(LayoutId::Keyboard, keyboard::create());
layouts.insert(LayoutId::ConfirmFullscreen, confirmfullscreen::create());

let instance = Self {
layouts,
Expand Down Expand Up @@ -108,6 +111,7 @@ pub enum LayoutId {
Settings,
ConfirmExit,
Keyboard,
ConfirmFullscreen,
}

impl Default for LayoutId {
Expand Down Expand Up @@ -282,6 +286,9 @@ impl Layout {
ButtonAction::SwitchLayout(layout_id) => {
outcomes.push(InputOutcome::SwitchLayout(*layout_id));
}
ButtonAction::EnterFullscreen => {
outcomes.push(InputOutcome::EnterFullscreen);
}
}
}
}
Expand All @@ -298,6 +305,7 @@ impl Layout {

ButtonAction::Function(_) => {}
ButtonAction::SwitchLayout(_) => {}
ButtonAction::EnterFullscreen => {}
}
}
}
Expand Down Expand Up @@ -333,4 +341,5 @@ enum ButtonAction {
DoomKey(u8),
Function(Box<dyn Fn()>),
SwitchLayout(LayoutId),
EnterFullscreen,
}
11 changes: 11 additions & 0 deletions src/layout/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ pub fn create() -> Layout {
width: 400,
height: 100,
},
label: "Fullscreen",
label_size: 50.0,
action: ButtonAction::SwitchLayout(LayoutId::ConfirmFullscreen),
},
Element::Button {
rect: common::mxcfb_rect {
left: 62,
top: 1400 - 300 - 10 + 100 + 10 + (100 + 10) * 2,
width: 400,
height: 100,
},
label: "Exit",
label_size: 50.0,
action: ButtonAction::SwitchLayout(LayoutId::ConfirmExit),
Expand Down
Loading