Browse Source

Delete instead of hide TipWindow (and its overlay) when closing.

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
b3d8f4f997
4 changed files with 14 additions and 48 deletions
  1. +0
    -1
      include/app/Scene.hpp
  2. +2
    -1
      src/app/MenuBar.cpp
  3. +9
    -9
      src/app/Scene.cpp
  4. +3
    -37
      src/app/TipWindow.cpp

+ 0
- 1
include/app/Scene.hpp View File

@@ -18,7 +18,6 @@ struct Scene : widget::OpaqueWidget {
RackWidget* rack;
widget::Widget* menuBar;
widget::Widget* moduleBrowser;
widget::Widget* tipWindow;
widget::Widget* frameRateWidget;

double lastAutosaveTime = 0.0;


+ 2
- 1
src/app/MenuBar.cpp View File

@@ -4,6 +4,7 @@
#include <osdialog.h>

#include <app/MenuBar.hpp>
#include <app/TipWindow.hpp>
#include <widget/OpaqueWidget.hpp>
#include <ui/Button.hpp>
#include <ui/MenuItem.hpp>
@@ -889,7 +890,7 @@ struct CheckAppUpdateItem : ui::MenuItem {

struct TipItem : ui::MenuItem {
void onAction(const event::Action& e) override {
APP->scene->tipWindow->show();
APP->scene->addChild(tipWindowCreate());
}
};



+ 9
- 9
src/app/Scene.cpp View File

@@ -46,14 +46,14 @@ Scene::Scene() {
moduleBrowser->hide();
addChild(moduleBrowser);

tipWindow = tipWindowCreate();
tipWindow->setVisible(settings::showTipsOnLaunch);
addChild(tipWindow);
frameRateWidget = new FrameRateWidget;
frameRateWidget->box.size = math::Vec(80.0, 30.0);
frameRateWidget->hide();
addChild(frameRateWidget);
if (settings::showTipsOnLaunch) {
addChild(tipWindowCreate());
}
// frameRateWidget = new FrameRateWidget;
// frameRateWidget->box.size = math::Vec(80.0, 30.0);
// frameRateWidget->hide();
// addChild(frameRateWidget);
}

Scene::~Scene() {
@@ -71,7 +71,7 @@ void Scene::step() {
rackScroll->box.pos.y = menuBar->box.size.y;
}

frameRateWidget->box.pos.x = box.size.x - frameRateWidget->box.size.x;
// frameRateWidget->box.pos.x = box.size.x - frameRateWidget->box.size.x;

// Resize owned descendants
menuBar->box.size.x = box.size.x;


+ 3
- 37
src/app/TipWindow.cpp View File

@@ -2,6 +2,7 @@

#include <app/TipWindow.hpp>
#include <widget/OpaqueWidget.hpp>
#include <ui/MenuOverlay.hpp>
#include <ui/Label.hpp>
#include <ui/Button.hpp>
#include <ui/OptionButton.hpp>
@@ -15,36 +16,6 @@ namespace rack {
namespace app {


struct TipOverlay : widget::OpaqueWidget {
void step() override {
box = parent->box.zeroPos();
OpaqueWidget::step();
}

void onButton(const event::Button& e) override {
OpaqueWidget::onButton(e);
if (e.getTarget() != this)
return;

if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT) {
hide();
e.consume(this);
}
}

void onHoverKey(const event::HoverKey& e) override {
OpaqueWidget::onHoverKey(e);
if (e.isConsumed())
return;

if (e.action == GLFW_PRESS && e.key == GLFW_KEY_ESCAPE) {
hide();
e.consume(this);
}
}
};


struct UrlButton : ui::Button {
std::string url;
void onAction(const event::Action& e) override {
@@ -162,7 +133,7 @@ struct TipWindow : widget::OpaqueWidget {
struct CloseButton : ui::Button {
TipWindow* tipWindow;
void onAction(const event::Action& e) override {
tipWindow->getParent()->hide();
tipWindow->getParent()->requestDelete();
}
};
CloseButton* closeButton = new CloseButton;
@@ -198,16 +169,11 @@ struct TipWindow : widget::OpaqueWidget {
bndMenuBackground(args.vg, 0.0, 0.0, box.size.x, box.size.y, 0);
Widget::draw(args);
}

void onShow(const event::Show& e) override {
advanceTip();
OpaqueWidget::onShow(e);
}
};


widget::Widget* tipWindowCreate() {
TipOverlay* overlay = new TipOverlay;
ui::MenuOverlay* overlay = new ui::MenuOverlay;

TipWindow* tipWindow = new TipWindow;
overlay->addChild(tipWindow);


Loading…
Cancel
Save