Start not in full screen mode.

master
Zed A. Shaw 4 weeks ago
parent 1beb5709dc
commit 0f2780478c
  1. 2
      sample/about-bezos.md
  2. 44
      src/control_ui.cpp
  3. 1
      src/control_ui.hpp
  4. 1
      src/main.cpp

@ -69,7 +69,7 @@ Bare content like this
* You don't even need text * You don't even need text
--- ---
{ {
"shader": "lightning", "shader": "flame",
"bg_color": [100, 30, 40, 255] "bg_color": [100, 30, 40, 255]
} }
# Shaders # Shaders

@ -19,8 +19,14 @@ ControlUI::ControlUI(sf::RenderWindow& presenter, sf::RenderWindow& controller)
{ {
$gui.position(0, 0, CONTROL_WIDTH, CONTROL_HEIGHT); $gui.position(0, 0, CONTROL_WIDTH, CONTROL_HEIGHT);
$gui.layout( $gui.layout(
"[status|*%(200,100)current|_]" "[status|*%(200,400)current|_]"
"[docs|*%(200,100)preview|_]" "[title0|_|_]"
"[title1|_|_]"
"[title2|_|_]"
"[title3|*%(200,400)preview|_]"
"[title4|_|_]"
"[title5|_|_]"
"[help|_|_]"
); );
} }
@ -28,8 +34,10 @@ void ControlUI::init() {
auto status_id = $gui.entity("status"); auto status_id = $gui.entity("status");
$gui.set<guecs::Text>(status_id, {L""}); $gui.set<guecs::Text>(status_id, {L""});
auto docs_id = $gui.entity("docs"); auto docs_id = $gui.entity("help");
$gui.set<guecs::Text>(docs_id, {L"F: fullscreen\nA: win left\nD: win right\nQ: quit"}); $gui.set<guecs::Text>(docs_id, {
.content=L"F: fullscreen\nA: win left\nD: win right\nQ: quit",
.size=20});
auto current = $gui.entity("current"); auto current = $gui.entity("current");
$gui.set<guecs::Rectangle>(current, {}); $gui.set<guecs::Rectangle>(current, {});
@ -43,6 +51,11 @@ void ControlUI::init() {
.color={180, 180, 180, 255} .color={180, 180, 180, 255}
}); });
for(int i = 0; i < 6; i++) {
auto id = $gui.entity("title", i);
$gui.set<guecs::Rectangle>(id, {.color=guecs::THEME.TRANSPARENT});
}
$gui.init(); $gui.init();
// warning! must come after init so the thing is there // warning! must come after init so the thing is there
@ -72,6 +85,19 @@ void ControlUI::render(sf::RenderWindow& window, SlideDeck& deck) {
render_slide("preview", deck.slide_at(preview)); render_slide("preview", deck.slide_at(preview));
} }
void ControlUI::full_screen(bool do_it) {
if(do_it) {
$presenter.setSize($window_size);
$presenter.setMouseCursorVisible(false);
} else {
$presenter.setSize({$window_size.x/2, $window_size.y/2});
$presenter.setMouseCursorVisible(true);
}
$full_screen = do_it;
}
void ControlUI::handle_events(std::shared_ptr<SlidesUI> slides, const sf::Event& event) { void ControlUI::handle_events(std::shared_ptr<SlidesUI> slides, const sf::Event& event) {
dbc::check($status != nullptr, "handle_events called before init?!"); dbc::check($status != nullptr, "handle_events called before init?!");
@ -97,15 +123,7 @@ void ControlUI::handle_events(std::shared_ptr<SlidesUI> slides, const sf::Event&
$controller.close(); $controller.close();
break; break;
case KEY::F: case KEY::F:
if($full_screen) { full_screen(!$full_screen);
$presenter.setSize({$window_size.x/2, $window_size.y/2});
$presenter.setMouseCursorVisible(true);
} else {
$presenter.setSize($window_size);
$presenter.setMouseCursorVisible(false);
}
$full_screen = !$full_screen;
break; break;
default: default:
slides->handle_events($controller, event); slides->handle_events($controller, event);

@ -17,4 +17,5 @@ struct ControlUI {
void render(sf::RenderWindow& window, SlideDeck& deck); void render(sf::RenderWindow& window, SlideDeck& deck);
void handle_events(std::shared_ptr<SlidesUI> slides, const sf::Event& event); void handle_events(std::shared_ptr<SlidesUI> slides, const sf::Event& event);
void render_slide(const std::string& name, Slide& slide); void render_slide(const std::string& name, Slide& slide);
void full_screen(bool do_it);
}; };

@ -87,6 +87,7 @@ int main(int argc, char *argv[]) {
ControlUI control_ui(presenter, controller); ControlUI control_ui(presenter, controller);
control_ui.init(); control_ui.init();
control_ui.full_screen(false);
dbc::check(control_ui.$status != nullptr, "bad ptr"); dbc::check(control_ui.$status != nullptr, "bad ptr");

Loading…
Cancel
Save