A bit of cleanup and testing of the panel, then some optimization to avoid re-rendering and multiple wchar converts.
parent
6e848004c4
commit
7d3605f58b
@ -1,24 +1,31 @@ |
||||
#include "panel.hpp" |
||||
|
||||
void Panel::resize(int width, int height) { |
||||
$dirty = true; |
||||
$screen = Screen(width, height); |
||||
} |
||||
|
||||
void Panel::set_renderer(std::function< Element()> render) { |
||||
$dirty = true; |
||||
$component = Renderer(render); |
||||
} |
||||
|
||||
Screen &Panel::render() { |
||||
void Panel::render() { |
||||
$dirty = true; |
||||
if($must_clear) $screen.Clear(); |
||||
Render($screen, $component->Render()); |
||||
return $screen; |
||||
} |
||||
|
||||
std::wstring Panel::to_string() { |
||||
std::string screenout = $screen.ToString(); |
||||
return $converter.from_bytes(screenout); |
||||
const std::wstring& Panel::to_string() { |
||||
if($dirty) { |
||||
std::string as_text = $screen.ToString(); |
||||
$screenout = $converter.from_bytes(as_text); |
||||
$dirty = false; |
||||
} |
||||
|
||||
return $screenout; |
||||
} |
||||
|
||||
Screen &Panel::screen() { |
||||
const Screen &Panel::screen() { |
||||
return $screen; |
||||
} |
||||
|
Loading…
Reference in new issue