Making different Property windows not appear in the same ImGui window

This commit is contained in:
Alexander Bock
2016-06-28 15:10:45 +02:00
parent 9fb7814145
commit 3417f45805
6 changed files with 26 additions and 18 deletions
-2
View File
@@ -72,8 +72,6 @@ public:
GuiPropertyComponent _globalProperty;
GuiTimeComponent _time;
GuiIswaComponent _iswa;
bool _showHelp;
};
} // namespace gui
@@ -25,7 +25,6 @@
#ifndef __GUIISWACOMPONENT_H__
#define __GUIISWACOMPONENT_H__
#include <modules/onscreengui/include/guicomponent.h>
#include <modules/onscreengui/include/guipropertycomponent.h>
#include <map>
@@ -53,7 +52,6 @@ private:
std::map<std::string, int> _cdfOptionsMap;
};
} // namespace gui
} // namespace openspace
@@ -43,6 +43,8 @@ class GuiPropertyComponent : public GuiComponent {
public:
using SourceFunction = std::function<std::vector<properties::PropertyOwner*>()>;
GuiPropertyComponent(std::string name);
// This is the function that evaluates to the list of Propertyowners that this
// component should render
void setSource(SourceFunction func);
@@ -52,6 +54,7 @@ public:
protected:
void renderProperty(properties::Property* prop, properties::PropertyOwner* owner);
std::string _name;
SourceFunction _function;
};
+17 -12
View File
@@ -25,9 +25,7 @@
#include <modules/onscreengui/include/gui.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/properties/property.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/rendering/screenspacerenderable.h>
#include <openspace/util/keys.h>
#include <ghoul/filesystem/cachemanager.h>
@@ -45,6 +43,7 @@ namespace {
const std::string _loggerCat = "GUI";
const std::string configurationFile = "imgui.ini";
const std::string GuiFont = "${FONTS}/Roboto/Roboto-Regular.ttf";
const ImVec2 size = ImVec2(350, 500);
//GLuint fontTex = 0;
@@ -166,7 +165,9 @@ namespace gui {
GUI::GUI()
: GuiComponent()
, _showHelp(false)
, _property("Properties")
, _screenSpaceProperty("ScreenSpace Properties")
, _globalProperty("Global")
{}
GUI::~GUI() {
@@ -208,10 +209,8 @@ void GUI::initialize() {
io.KeyMap[ImGuiKey_Z] = static_cast<int>(Key::Z);
io.RenderDrawListsFn = RenderDrawLists;
//io.SetClipboardTextFn = SetClipboardTextFn_DefaultImpl; // @TODO implement? ---abock
//io.GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // @TODO implement? ---abock
io.Fonts->AddFontFromFileTTF(
absPath("${FONTS}/Roboto/Roboto-Regular.ttf").c_str(),
absPath(GuiFont).c_str(),
16.f
);
@@ -250,10 +249,16 @@ void GUI::initialize() {
_performance.initialize();
_help.initialize();
_iswa.initialize();
}
void GUI::deinitialize() {
_iswa.deinitialize();
_help.deinitialize();
_performance.deinitialize();
_globalProperty.deinitialize();
_screenSpaceProperty.deinitialize();
_property.deinitialize();
delete iniFileBuffer;
}
@@ -335,12 +340,12 @@ void GUI::deinitializeGL() {
glDeleteVertexArrays(1, &vao);
glDeleteBuffers(1, &vbo);
_property.deinitializeGL();
_screenSpaceProperty.deinitializeGL();
_globalProperty.deinitializeGL();
_performance.deinitializeGL();
_help.deinitializeGL();
_iswa.deinitializeGL();
_help.deinitializeGL();
_performance.deinitializeGL();
_globalProperty.deinitializeGL();
_screenSpaceProperty.deinitializeGL();
_property.deinitializeGL();
}
void GUI::startFrame(float deltaTime, const glm::vec2& windowSize,
+1 -1
View File
@@ -58,7 +58,7 @@ namespace {
namespace openspace {
namespace gui {
GuiIswaComponent::GuiIswaComponent()
: GuiPropertyComponent()
: GuiPropertyComponent("iSWA")
, _gmdata(false)
, _gmimage(false)
, _iondata(false)
@@ -48,6 +48,10 @@ namespace {
namespace openspace {
namespace gui {
GuiPropertyComponent::GuiPropertyComponent(std::string name)
: _name(std::move(name))
{}
void GuiPropertyComponent::setSource(SourceFunction function) {
_function = std::move(function);
}
@@ -61,7 +65,7 @@ void GuiPropertyComponent::setSource(SourceFunction function) {
//}
void GuiPropertyComponent::render() {
ImGui::Begin("Properties", &_isEnabled, size, 0.5f);
ImGui::Begin(_name.c_str(), &_isEnabled, size, 0.5f);
ImGui::Spacing();