mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-24 14:50:43 -04:00
Notepad text zoom support 5x8 to 8x16 font (#1211)
* Zoom button 5/8 to 8/16 font * Zoom button 5/8 to 8/16 font * Clang & revert unintended change * Suggested improvements * Suggested code changes * Added char_width function * Added char_width function * Oops copy-paste error * Delete added blank line
This commit is contained in:
parent
e15a8ed2d8
commit
b28b96fb4a
4 changed files with 42 additions and 21 deletions
|
@ -42,10 +42,9 @@ namespace ui {
|
|||
/* TextViewer *******************************************************/
|
||||
|
||||
TextViewer::TextViewer(Rect parent_rect)
|
||||
: Widget(parent_rect),
|
||||
max_line{static_cast<uint8_t>(parent_rect.height() / char_height)},
|
||||
max_col{static_cast<uint8_t>(parent_rect.width() / char_width)} {
|
||||
: Widget(parent_rect) {
|
||||
set_focusable(true);
|
||||
set_font_zoom(false);
|
||||
}
|
||||
|
||||
void TextViewer::paint(Painter& painter) {
|
||||
|
@ -207,7 +206,7 @@ void TextViewer::paint_text(Painter& painter, uint32_t line, uint16_t col) {
|
|||
if (result && *result > 0)
|
||||
painter.draw_string(
|
||||
{0, r.top() + (int)i * char_height},
|
||||
Styles::white_small, {buffer, *result});
|
||||
style(), {buffer, *result});
|
||||
|
||||
// Clear empty line sections. This is less visually jarring than full clear.
|
||||
int32_t clear_width = max_col - (result ? *result : 0);
|
||||
|
@ -216,7 +215,7 @@ void TextViewer::paint_text(Painter& painter, uint32_t line, uint16_t col) {
|
|||
{(max_col - clear_width) * char_width,
|
||||
r.top() + (int)i * char_height,
|
||||
clear_width * char_width, char_height},
|
||||
Styles::white_small.background);
|
||||
style().background);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,8 +236,8 @@ void TextViewer::paint_cursor(Painter& painter) {
|
|||
};
|
||||
|
||||
// Clear old cursor. CONSIDER: XOR cursor?
|
||||
draw_cursor(paint_state_.line, paint_state_.col, Styles::white_small.background);
|
||||
draw_cursor(cursor_.line, cursor_.col, Styles::white_small.foreground);
|
||||
draw_cursor(paint_state_.line, paint_state_.col, style().background);
|
||||
draw_cursor(cursor_.line, cursor_.col, style().foreground);
|
||||
paint_state_.line = cursor_.line;
|
||||
paint_state_.col = cursor_.col;
|
||||
}
|
||||
|
@ -261,7 +260,7 @@ TextEditorMenu::TextEditorMenu()
|
|||
&rect_frame,
|
||||
&button_cut,
|
||||
&button_paste,
|
||||
&button_copy,
|
||||
&button_zoom,
|
||||
&button_delline,
|
||||
&button_edit,
|
||||
&button_addline,
|
||||
|
@ -316,8 +315,10 @@ TextEditorView::TextEditorView(NavigationView& nav)
|
|||
menu.on_paste() = [this]() {
|
||||
show_nyi();
|
||||
};
|
||||
menu.on_copy() = [this]() {
|
||||
show_nyi();
|
||||
menu.on_zoom() = [this]() {
|
||||
viewer.toggle_font_zoom();
|
||||
refresh_ui();
|
||||
hide_menu(true);
|
||||
};
|
||||
|
||||
menu.on_delete_line() = [this]() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue