Skip to content

Commit 0253ef9

Browse files
committed
Made filters with errors more visually obvious
1 parent e2ca260 commit 0253ef9

3 files changed

Lines changed: 34 additions & 16 deletions

File tree

src/ngscopeclient/FilterGraphEditor.cpp

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,9 @@ bool FilterGraphEditor::DoRender()
503503

504504
nodeAdded = true;
505505
newNode = GetID(f);
506+
507+
//Do an initial refresh so we can get error messages, an initial output if it's a waveform generation filter, etc
508+
m_parent->OnFilterReconfigured(f);
506509
}
507510
}
508511
}
@@ -1397,8 +1400,8 @@ void FilterGraphEditor::HandleLinkCreationRequests(Filter*& fReconfigure)
13971400
{
13981401
//for some reason node editor wants colors as vec4 not ImU32
13991402
auto& prefs = m_session.GetPreferences();
1400-
auto validcolor = ImGui::ColorConvertU32ToFloat4(prefs.GetColor("Appearance.Filter Graph.valid_link_color"));
1401-
auto invalidcolor = ImGui::ColorConvertU32ToFloat4(prefs.GetColor("Appearance.Filter Graph.invalid_link_color"));
1403+
auto validcolor = prefs.GetColorFloat4("Appearance.Filter Graph.valid_link_color");
1404+
auto invalidcolor = prefs.GetColorFloat4("Appearance.Filter Graph.invalid_link_color");
14021405

14031406
if(ax::NodeEditor::BeginCreate())
14041407
{
@@ -2009,6 +2012,7 @@ void FilterGraphEditor::DoNodeForChannel(
20092012
displaycolor = "#808080";
20102013

20112014
auto& prefs = m_session.GetPreferences();
2015+
auto errorColor = prefs.GetColor("Appearance.Filter Graph.error_outline_color");
20122016

20132017
//Get some configuration / style settings
20142018
auto color = ColorFromString(displaycolor);
@@ -2194,18 +2198,18 @@ void FilterGraphEditor::DoNodeForChannel(
21942198
headercolor,
21952199
headerText.c_str());
21962200

2197-
//TODO: add an option for toggling this
2198-
//TODO: add preference for colors
2201+
auto bubbleColor = prefs.GetColor("Appearance.Filter Graph.infobubble_color");
2202+
21992203
//Draw a bubble above the text with the runtime stats
2204+
//TODO: add an option for toggling this
22002205
float messageSpacing = 0.1 * headerheight;
22012206
float nextIconBot = pos.y - messageSpacing;
22022207
if(runtime > 0)
22032208
{
22042209
auto runtimeText = fs.PrettyPrint(runtime, 3);
22052210
auto runtimeSize = ImGui::CalcTextSize(runtimeText.c_str());
22062211

2207-
auto timebgColor = ColorFromString("#404040");
2208-
auto timeTextColor = ColorFromString("#ffffff");
2212+
auto timeTextColor = ImGui::GetColorU32(ImGui::GetStyleColorVec4(ImGuiCol_Text));
22092213
float bubbleHeight = runtimeSize.y + 2*ImGui::GetStyle().FramePadding.y;
22102214

22112215
ImVec2 clockiconpos(
@@ -2220,7 +2224,7 @@ void FilterGraphEditor::DoNodeForChannel(
22202224
bgList->AddRectFilled(
22212225
ImVec2(pos.x + 1, nextIconBot - bubbleHeight),
22222226
ImVec2(textpos.x + runtimeSize.x + ImGui::GetStyle().FramePadding.y, nextIconBot),
2223-
timebgColor,
2227+
bubbleColor,
22242228
rounding,
22252229
ImDrawFlags_RoundCornersAll);
22262230

@@ -2234,7 +2238,7 @@ void FilterGraphEditor::DoNodeForChannel(
22342238
timeTextColor,
22352239
runtimeText.c_str());
22362240

2237-
nextIconBot -= runtimeSize.y + 3*messageSpacing;
2241+
nextIconBot -= bubbleHeight + 2*messageSpacing;
22382242
}
22392243

22402244
//Display errors
@@ -2243,10 +2247,8 @@ void FilterGraphEditor::DoNodeForChannel(
22432247
auto errorText = channel->GetErrorTitle();
22442248
auto errorSize = ImGui::CalcTextSize(errorText.c_str());
22452249

2246-
//TODO: preferences?
2247-
auto bgColor = ColorFromString("#404040");
2248-
auto textColor = ColorFromString("#ffffff");
2249-
float bubbleHeight = errorSize.y + 2*ImGui::GetStyle().FramePadding.y;
2250+
auto textColor = ImGui::GetColorU32(ImGui::GetStyleColorVec4(ImGuiCol_Text));
2251+
float bubbleHeight = errorSize.y + 3*ImGui::GetStyle().FramePadding.y;
22502252

22512253
ImVec2 erriconpos(
22522254
pos.x + ImGui::GetStyle().FramePadding.x,
@@ -2257,7 +2259,7 @@ void FilterGraphEditor::DoNodeForChannel(
22572259
ImVec2 rectStart(pos.x + 1, nextIconBot - bubbleHeight);
22582260
ImVec2 rectEnd(textpos.x + errorSize.x + ImGui::GetStyle().FramePadding.y, nextIconBot);
22592261

2260-
bgList->AddRectFilled(rectStart, rectEnd, bgColor, rounding, ImDrawFlags_RoundCornersAll);
2262+
bgList->AddRectFilled(rectStart, rectEnd, bubbleColor, rounding, ImDrawFlags_RoundCornersAll);
22612263
bgList->AddImage(m_parent->GetTextureManager()->GetTexture("error"), erriconpos, erriconpos + erriconsize );
22622264
bgList->AddText(textpos, textColor, errorText.c_str());
22632265

@@ -2277,7 +2279,11 @@ void FilterGraphEditor::DoNodeForChannel(
22772279
ax::NodeEditor::Resume();
22782280
}
22792281

2280-
nextIconBot -= errorSize.y + 3*messageSpacing;
2282+
nextIconBot -= bubbleHeight + 2*messageSpacing;
2283+
2284+
//Draw outline rectangle around the entire filter
2285+
auto errorOutlineThickness = 0.4 * ImGui::GetFontSize();
2286+
bgList->AddRect(pos, pos+size, errorColor, rounding, ImDrawFlags_RoundCornersAll, errorOutlineThickness);
22812287
}
22822288

22832289
ImGui::PopFont(); // headerfont

src/ngscopeclient/PreferenceManager.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/***********************************************************************************************************************
22
* *
3-
* glscopeclient *
3+
* ngscopeclient *
44
* *
5-
* Copyright (c) 2012-2022 Andrew D. Zonenberg *
5+
* Copyright (c) 2012-2026 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -79,6 +79,10 @@ class PreferenceManager
7979
double GetReal(const std::string& path) const;
8080
bool GetBool(const std::string& path) const;
8181
ImU32 GetColor(const std::string& path) const;
82+
83+
ImVec4 GetColorFloat4(const std::string& path) const
84+
{ return ImGui::ColorConvertU32ToFloat4(GetColor(path)); }
85+
8286
FontDescription GetFont(const std::string& path) const;
8387

8488
template< typename E >

src/ngscopeclient/PreferenceSchema.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ void PreferenceManager::InitializeDefaults()
155155
Preference::Color("invalid_link_color", ColorFromString("#ff0000"))
156156
.Label("Invalid link color")
157157
.Description("Color indicating a potential connection path is invalid"));
158+
graph.AddPreference(
159+
Preference::Color("infobubble_color", ColorFromString("#404040"))
160+
.Label("Info bubble color")
161+
.Description("Color for information bubbles displayed above graph nodes"));
162+
graph.AddPreference(
163+
Preference::Color("error_outline_color", ColorFromString("#ff0000"))
164+
.Label("Error outline color")
165+
.Description("Color for outlining graph nodes with errors"));
158166
graph.AddPreference(
159167
Preference::Font("icon_caption_font", FontDescription(FindDataFile("fonts/DejaVuSans.ttf"), 13))
160168
.Label("Icon font")

0 commit comments

Comments
 (0)