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" |
#include "panel.hpp" |
||||||
|
|
||||||
void Panel::resize(int width, int height) { |
void Panel::resize(int width, int height) { |
||||||
|
$dirty = true; |
||||||
$screen = Screen(width, height); |
$screen = Screen(width, height); |
||||||
} |
} |
||||||
|
|
||||||
void Panel::set_renderer(std::function< Element()> render) { |
void Panel::set_renderer(std::function< Element()> render) { |
||||||
|
$dirty = true; |
||||||
$component = Renderer(render); |
$component = Renderer(render); |
||||||
} |
} |
||||||
|
|
||||||
Screen &Panel::render() { |
void Panel::render() { |
||||||
|
$dirty = true; |
||||||
if($must_clear) $screen.Clear(); |
if($must_clear) $screen.Clear(); |
||||||
Render($screen, $component->Render()); |
Render($screen, $component->Render()); |
||||||
return $screen; |
|
||||||
} |
} |
||||||
|
|
||||||
std::wstring Panel::to_string() { |
const std::wstring& Panel::to_string() { |
||||||
std::string screenout = $screen.ToString(); |
if($dirty) { |
||||||
return $converter.from_bytes(screenout); |
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; |
return $screen; |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue