diff --git a/res/open-sans/LICENSE b/res/open-sans/LICENSE new file mode 100644 index 0000000..c91bd22 --- /dev/null +++ b/res/open-sans/LICENSE @@ -0,0 +1,88 @@ +Copyright 2020 The Open Sans Project Authors (https://github.com/googlefonts/opensans) + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font +creation efforts of academic and linguistic communities, and to +provide a free and open framework in which fonts may be shared and +improved in partnership with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply to +any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software +components as distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, +deleting, or substituting -- in part or in whole -- any of the +components of the Original Version, by changing formats or by porting +the Font Software to a new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, +modify, redistribute, and sell modified and unmodified copies of the +Font Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, in +Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the +corresponding Copyright Holder. This restriction only applies to the +primary font name as presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created using +the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/res/open-sans/OpenSans-Regular.ttf b/res/open-sans/OpenSans-Regular.ttf new file mode 100644 index 0000000..db43334 Binary files /dev/null and b/res/open-sans/OpenSans-Regular.ttf differ diff --git a/src/fde.rs b/src/fde.rs index 72f691d..bb7b708 100644 --- a/src/fde.rs +++ b/src/fde.rs @@ -378,6 +378,9 @@ fn form_display_inner(form: &Form, user_input: &mut UserInput) -> Result<()> { &mut *DISPLAY }; + // If you want to test the security screen, uncomment this line: + // crate::security::confirm(display); + let (display_w, display_h) = (display.width(), display.height()); let scale = if display_h > 1440 { @@ -389,12 +392,12 @@ fn form_display_inner(form: &Form, user_input: &mut UserInput) -> Result<()> { }; // Style { - let margin_lr = 8 * scale; + let margin_lr = 12 * scale; let margin_tb = 4 * scale; - let title_font_size = (20 * scale) as f32; - let font_size = (16 * scale) as f32; // (display_h as f32) / 26.0 - let help_font_size = (12 * scale) as f32; + let title_font_size = (12 * scale) as f32; + let font_size = (10 * scale) as f32; // (display_h as f32) / 26.0 + let help_font_size = (10 * scale) as f32; // } Style let ui = Ui::new()?; @@ -674,7 +677,7 @@ fn form_display_inner(form: &Form, user_input: &mut UserInput) -> Result<()> { if selected == !0 { render_hotkey_help(""); } else if !editing || !editing_value { - render_hotkey_help("↑↓=Move Highlight"); + render_hotkey_help("Up/Down=Move Highlight"); } if editing { diff --git a/src/security.rs b/src/security.rs index 013e727..a4a94c9 100644 --- a/src/security.rs +++ b/src/security.rs @@ -40,7 +40,7 @@ impl Timeout for UefiTimeout { } } -fn confirm(display: &mut Display) -> Result<()> { +pub(crate) fn confirm(display: &mut Display) -> Result<()> { let (display_w, display_h) = (display.width(), display.height()); let scale: i32 = if display_h > 1440 { @@ -52,14 +52,14 @@ fn confirm(display: &mut Display) -> Result<()> { }; // Style { - let margin_lr = 16 * scale; - let margin_tb = 8 * scale; + let margin_lr = 12 * scale; + let margin_tb = 4 * scale; let form_width = cmp::min(640 * scale as u32, display_w - margin_lr as u32 * 2); let form_x = (display_w as i32 - form_width as i32) / 2; - let title_font_size = (20 * scale) as f32; - let font_size = (16 * scale) as f32; + let title_font_size = (12 * scale) as f32; + let font_size = (10 * scale) as f32; // } Style let ui = Ui::new()?; diff --git a/src/ui.rs b/src/ui.rs index 80374c3..769c498 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -8,7 +8,7 @@ use std::prelude::*; use crate::display::Display; use crate::image::{self, Image}; -static FONT_TTF: &[u8] = include_bytes!("../res/FiraSans-Regular.ttf"); +static FONT_TTF: &[u8] = include_bytes!("../res/open-sans/OpenSans-Regular.ttf"); static CHECKBOX_CHECKED_BMP: &[u8] = include_bytes!("../res/checkbox_checked.bmp"); static CHECKBOX_UNCHECKED_BMP: &[u8] = include_bytes!("../res/checkbox_unchecked.bmp"); @@ -29,11 +29,11 @@ pub struct Ui { impl Ui { pub fn new() -> Result { - let background_color = Color::rgb(0x36, 0x32, 0x2F); - let highlight_color = Color::rgb(0xFB, 0xB8, 0x6C); + let background_color = Color::rgb(0x1B, 0x1B, 0x1B); + let highlight_color = Color::rgb(0x63, 0xD0, 0xDF); let outline_color = Color::rgba(0xfe, 0xff, 0xff, 0xc4); - let text_color = Color::rgb(0xCC, 0xCC, 0xCC); - let highlight_text_color = Color::rgb(0x27, 0x27, 0x27); + let text_color = Color::rgb(0xC4, 0xC4, 0xC4); + let highlight_text_color = Color::rgb(0x00, 0x00, 0x00); let font = unsafe { if FONT.is_null() { @@ -151,126 +151,21 @@ impl Ui { // Style { let padding_lr = 4 * scale; let padding_tb = 2 * scale; - - //TODO: does not scale due to hardcoded checkbox image! - let rect_radius = 4; // } Style - let checkbox = if highlighted { - // Center - display.rect( - x - padding_lr, - y - padding_tb + rect_radius, - w + padding_lr as u32 * 2, - h + (padding_tb - rect_radius) as u32 * 2, - self.highlight_color, - ); - - // Top middle - display.rect( - x - padding_lr + rect_radius, - y - padding_tb, - w + (padding_lr - rect_radius) as u32 * 2, - rect_radius as u32, - self.highlight_color, - ); - - // Bottom middle - display.rect( - x - padding_lr + rect_radius, - y + h as i32 + padding_tb - rect_radius, - w + (padding_lr - rect_radius) as u32 * 2, - rect_radius as u32, - self.highlight_color, - ); - - self.checkbox_checked - } else { - // Top middle - display.rect( - x - padding_lr + rect_radius, - y - padding_tb, - w + (padding_lr - rect_radius) as u32 * 2, - 2, - self.outline_color, - ); - - // Bottom middle - display.rect( - x - padding_lr + rect_radius, - y + h as i32 + padding_tb - 2, - w + (padding_lr - rect_radius) as u32 * 2, - 2, - self.outline_color, - ); - - // Left middle - display.rect( - x - padding_lr, - y - padding_tb + rect_radius, - 2, - h + (padding_tb - rect_radius) as u32 * 2, - self.outline_color, - ); - - // Right middle - display.rect( - x + w as i32 + padding_lr - 2, - y - padding_tb + rect_radius, - 2, - h + (padding_tb - rect_radius) as u32 * 2, - self.outline_color, - ); - - self.checkbox_unchecked - }; - - // Top left - checkbox - .roi(0, 0, rect_radius as u32, rect_radius as u32) - .draw(display, x - padding_lr, y - padding_tb); - - // Top right - checkbox - .roi( - checkbox.width() - rect_radius as u32, - 0, - rect_radius as u32, - rect_radius as u32, - ) - .draw( - display, - x + w as i32 + padding_lr - rect_radius, - y - padding_tb, - ); - - // Bottom left - checkbox - .roi( - 0, - checkbox.height() - rect_radius as u32, - rect_radius as u32, - rect_radius as u32, - ) - .draw( - display, - x - padding_lr, - y + h as i32 + padding_tb - rect_radius, - ); - - // Bottom right - checkbox - .roi( - checkbox.width() - rect_radius as u32, - checkbox.height() - rect_radius as u32, - rect_radius as u32, - rect_radius as u32, - ) - .draw( - display, - x + w as i32 + padding_lr - rect_radius, - y + h as i32 + padding_tb - rect_radius, - ); + display.rounded_rect( + x - padding_lr, + y - padding_tb, + w + (padding_lr * 2) as u32, + h + (padding_tb * 2) as u32, + 0, + highlighted, + if highlighted { + self.highlight_color + } else { + self.outline_color + } + ); } pub fn draw_text_box(