mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Clear the screen only on window resize and layer removal
Should actually also be done if a layer shrinks. Luckily, clear can be called anytime, as draw() is the last action performed in the event loop - so it's safe to clear the screen in any event callback, or even during layout.
This commit is contained in:
parent
9b2dec2a7f
commit
08ab18608b
@ -289,10 +289,9 @@ impl Cursive {
|
||||
while self.running {
|
||||
// Do we need to redraw everytime?
|
||||
// Probably, actually.
|
||||
// TODO: Do we actually need to clear everytime?
|
||||
B::clear();
|
||||
// TODO: Do we need to re-layout everytime?
|
||||
self.layout();
|
||||
|
||||
// TODO: Do we need to redraw every view every time?
|
||||
// (Is this getting repetitive? :p)
|
||||
self.draw();
|
||||
@ -300,6 +299,10 @@ impl Cursive {
|
||||
// Wait for next event.
|
||||
// (If set_fps was called, this returns -1 now and then)
|
||||
let event = B::poll_event();
|
||||
if event == Event::Key(event::Key::Resize) {
|
||||
B::clear();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Event dispatch order:
|
||||
// * Focused element:
|
||||
|
@ -1,5 +1,6 @@
|
||||
use std::any::Any;
|
||||
|
||||
use backend::Backend;
|
||||
use vec::Vec2;
|
||||
use view::{Offset, Position, Selector, ShadowView, View};
|
||||
use event::{Event, EventResult};
|
||||
@ -54,6 +55,7 @@ impl StackView {
|
||||
/// Remove the top-most layer.
|
||||
pub fn pop_layer(&mut self) {
|
||||
self.layers.pop();
|
||||
::B::clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user