Merge branch 'master' into feature/NewAtmosphere

This commit is contained in:
Alexander Bock
2017-12-11 11:22:52 -05:00
10 changed files with 85 additions and 47 deletions

View File

@@ -69,12 +69,18 @@ public:
/// Renders the individual subcomponents to the screen
virtual void render() = 0;
void setShowHelpTooltip(bool showHelpTooltip);
void setShowHelpTooltipDelay(double delay);
protected:
/// <code>true</code> if this component is enabled and visible on the screen
properties::BoolProperty _isEnabled;
/// if <code>true</code> this window is currently collapsed. This setting mirrors the
/// ImGui internal state of the window
properties::BoolProperty _isCollapsed;
bool _showHelpTooltip;
double _tooltipDelay;
};
} // namespace openspace::gui

View File

@@ -59,8 +59,6 @@ public:
void setVisibility(properties::Property::Visibility visibility);
void setHasRegularProperties(bool hasOnlyRegularProperties);
void setShowHelpTooltip(bool showHelpTooltip);
void setShowHelpTooltipDelay(double delay);
void render() override;
@@ -78,9 +76,6 @@ protected:
properties::BoolProperty _useTreeLayout;
properties::StringListProperty _treeOrdering;
bool _showHelpTooltip;
double _tooltipDelay;
};
} // namespace openspace::gui

View File

@@ -313,10 +313,23 @@ GUI::GUI()
{
auto showHelpTextFunc = [this](){
_help.setShowHelpTooltip(_showHelpText);
_filePath.setShowHelpTooltip(_showHelpText);
#ifdef GLOBEBROWSING_USE_GDAL
_globeBrowsing.setShowHelpTooltip(_showHelpText);
#endif // GLOBEBROWSING_USE_GDAL
_performance.setShowHelpTooltip(_showHelpText);
_globalProperty.setShowHelpTooltip(_showHelpText);
_property.setShowHelpTooltip(_showHelpText);
_screenSpaceProperty.setShowHelpTooltip(_showHelpText);
_virtualProperty.setShowHelpTooltip(_showHelpText);
_spaceTime.setShowHelpTooltip(_showHelpText);
_mission.setShowHelpTooltip(_showHelpText);
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
_iswa.setShowHelpTooltip(_showHelpText);
#endif // OPENSPACE_MODULE_ISWA_ENABLED
_parallel.setShowHelpTooltip(_showHelpText);
_featuredProperties.setShowHelpTooltip(_showHelpText);
};
showHelpTextFunc();
_showHelpText.onChange(std::move(showHelpTextFunc));
@@ -325,10 +338,23 @@ GUI::GUI()
{
auto helpTextDelayFunc = [this](){
_help.setShowHelpTooltipDelay(_helpTextDelay);
_filePath.setShowHelpTooltipDelay(_helpTextDelay);
#ifdef GLOBEBROWSING_USE_GDAL
_globeBrowsing.setShowHelpTooltipDelay(_helpTextDelay);
#endif // GLOBEBROWSING_USE_GDAL
_performance.setShowHelpTooltipDelay(_helpTextDelay);
_globalProperty.setShowHelpTooltipDelay(_helpTextDelay);
_property.setShowHelpTooltipDelay(_helpTextDelay);
_screenSpaceProperty.setShowHelpTooltipDelay(_helpTextDelay);
_virtualProperty.setShowHelpTooltipDelay(_helpTextDelay);
_spaceTime.setShowHelpTooltipDelay(_helpTextDelay);
_mission.setShowHelpTooltipDelay(_helpTextDelay);
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
_iswa.setShowHelpTooltipDelay(_helpTextDelay);
#endif // OPENSPACE_MODULE_ISWA_ENABLED
_parallel.setShowHelpTooltipDelay(_helpTextDelay);
_featuredProperties.setShowHelpTooltipDelay(_helpTextDelay);
};
helpTextDelayFunc();
_helpTextDelay.onChange(std::move(helpTextDelayFunc));

View File

@@ -57,6 +57,14 @@ void GuiComponent::setEnabled(bool enabled) {
_isEnabled = enabled;
}
void GuiComponent::setShowHelpTooltip(bool showHelpTooltip) {
_showHelpTooltip = showHelpTooltip;
}
void GuiComponent::setShowHelpTooltipDelay(double delay) {
_tooltipDelay = delay;
}
void GuiComponent::initialize() {}
void GuiComponent::initializeGL() {}

View File

@@ -183,14 +183,6 @@ void GuiPropertyComponent::setHasRegularProperties(bool hasOnlyRegularProperties
_hasOnlyRegularProperties = hasOnlyRegularProperties;
}
void GuiPropertyComponent::setShowHelpTooltip(bool showHelpTooltip) {
_showHelpTooltip = showHelpTooltip;
}
void GuiPropertyComponent::setShowHelpTooltipDelay(double delay) {
_tooltipDelay = delay;
}
void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner) {
if (owner->propertiesRecursive().empty()) {
return;

View File

@@ -35,6 +35,8 @@
#include <openspace/scene/scenegraphnode.h>
#include <openspace/scene/scene.h>
#include <imgui_internal.h>
namespace {
static const ImVec2 Size = ImVec2(350, 500);
@@ -44,6 +46,27 @@ namespace {
"This value determines the minimum and maximum value for the delta time slider."
};
void showTooltip(const std::string& message, double delay) {
// Hackish way to enfore a window size for TextWrapped (SetNextWindowSize did not
// do the trick)
constexpr std::string::size_type FirstLineLength = 64;
if (ImGui::IsItemHovered() && GImGui->HoveredIdTimer > delay) {
ImGui::BeginTooltip();
ImGui::Text(
"%s",
message.substr(0, std::min(message.size() - 1, FirstLineLength)).c_str()
);
if (message.size() > FirstLineLength) {
ImGui::TextWrapped(
"%s",
message.substr(std::min(message.size() - 1, FirstLineLength)).c_str()
);
}
ImGui::EndTooltip();
}
}
} // namespace
namespace openspace::gui {
@@ -152,15 +175,14 @@ void GuiSpaceTimeComponent::render() {
scripting::ScriptEngine::RemoteScripting::Yes
);
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
"%s",
"Entering a date here and confirming with ENTER sets the current simulation "
"time to the entered date. The format of the date has to be either ISO 8601 "
"YYYY-MM-DDThh:mm:ss (2017-08-27T04:00:00) or YYYY MMM DD hh:mm:ss "
"(2017 MAY 01 12:00:00). The hours are in 24h and specified as UTC."
);
}
showTooltip(
"Entering a date here and confirming with ENTER sets the current simulation time "
"to the entered date. The format of the date has to be either ISO 8601 "
"YYYY-MM-DDThh:mm:ss (2017-08-27T04:00:00) or YYYY MMM DD hh:mm:ss "
"(2017 MAY 01 12:00:00). The hours are in 24h and specified as UTC.",
_tooltipDelay
);
auto incrementTime = [](int days) {
using namespace std::chrono;
@@ -186,12 +208,7 @@ void GuiSpaceTimeComponent::render() {
};
bool minusMonth = ImGui::Button("-Month");
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
"%s",
"OBS: A month here equals 30 days."
);
}
showTooltip("OBS: A month here equals 30 days.", _tooltipDelay);
if (minusMonth) {
incrementTime(-30);
}
@@ -241,12 +258,7 @@ void GuiSpaceTimeComponent::render() {
if (plusMonth) {
incrementTime(30);
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
"%s",
"OBS: A month here equals 30 days."
);
}
showTooltip("OBS: A month here equals 30 days.", _tooltipDelay);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 20.f);
@@ -273,14 +285,12 @@ void GuiSpaceTimeComponent::render() {
scripting::ScriptEngine::RemoteScripting::Yes
);
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
"%s",
"This determines the simulation time increment, that is the passage "
"of time in OpenSpace relative to a wall clock. Times are expressed as "
"simulation time / real world time."
);
}
showTooltip(
"This determines the simulation time increment, that is the passage of time in "
"OpenSpace relative to a wall clock. Times are expressed as simulation time / "
"real world time.",
_tooltipDelay
);
bool isPaused = OsEng.timeManager().time().paused();