Skip to content

Commit b5d356b

Browse files
committed
Updated to latest upstream imgui release. Fixes #850.
1 parent bde2022 commit b5d356b

17 files changed

Lines changed: 127 additions & 97 deletions

src/imgui

Submodule imgui updated 93 files

src/imgui_markdown

src/ngscopeclient/AboutDialog.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* ngscopeclient *
44
* *
5-
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
5+
* Copyright (c) 2012-2025 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 *
@@ -67,16 +67,23 @@ AboutDialog::~AboutDialog()
6767
*/
6868
bool AboutDialog::DoRender()
6969
{
70+
pair<ImFont*, float> headings[] =
71+
{
72+
m_parent->GetFontPref("Appearance.Markdown.heading_1_font"),
73+
m_parent->GetFontPref("Appearance.Markdown.heading_2_font"),
74+
m_parent->GetFontPref("Appearance.Markdown.heading_3_font")
75+
};
76+
7077
ImGui::MarkdownConfig mdConfig
7178
{
7279
nullptr, //linkCallback
7380
nullptr, //tooltipCallback
7481
nullptr, //imageCallback
7582
"", //linkIcon (not used)
7683
{
77-
{ m_parent->GetFontPref("Appearance.Markdown.heading_1_font"), true },
78-
{ m_parent->GetFontPref("Appearance.Markdown.heading_2_font"), true },
79-
{ m_parent->GetFontPref("Appearance.Markdown.heading_3_font"), false }
84+
{ headings[0].first, headings[0].second, true },
85+
{ headings[1].first, headings[1].second, true },
86+
{ headings[2].first, headings[2].second, false }
8087
},
8188
nullptr //userData
8289
};

src/ngscopeclient/FilterGraphEditor.cpp

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,9 @@ void FilterGraphEditor::DoNodeForGroupInputs(shared_ptr<FilterGraphGroup> group)
766766

767767
//Set size/position
768768
auto headerfont = m_parent->GetFontPref("Appearance.Filter Graph.header_font");
769-
auto headerfontsize = headerfont->FontSize * ImGui::GetIO().FontGlobalScale;
769+
ImGui::PushFont(headerfont.first, headerfont.second);
770+
auto headerfontsize = ImGui::GetFontSize();
771+
ImGui::PopFont();
770772
float headerheight = headerfontsize * 1.5;
771773
auto gborder = ax::NodeEditor::GetStyle().GroupBorderWidth;
772774
auto gpad = ax::NodeEditor::GetStyle().NodePadding.x;
@@ -862,7 +864,9 @@ void FilterGraphEditor::DoNodeForGroupOutputs(shared_ptr<FilterGraphGroup> group
862864

863865
//Set size/position
864866
auto headerfont = m_parent->GetFontPref("Appearance.Filter Graph.header_font");
865-
auto headerfontsize = headerfont->FontSize * ImGui::GetIO().FontGlobalScale;
867+
ImGui::PushFont(headerfont.first, headerfont.second);
868+
auto headerfontsize = ImGui::GetFontSize();
869+
ImGui::PopFont();
866870
float headerheight = headerfontsize * 1.5;
867871
auto gborder = ax::NodeEditor::GetStyle().GroupBorderWidth;
868872
auto gpad = ax::NodeEditor::GetStyle().NodePadding.x;
@@ -1865,7 +1869,9 @@ void FilterGraphEditor::DoNodeForTrigger(Trigger* trig)
18651869
auto id = GetID(trig);
18661870
auto headercolor = prefs.GetColor("Appearance.Filter Graph.header_text_color");
18671871
auto headerfont = m_parent->GetFontPref("Appearance.Filter Graph.header_font");
1868-
auto headerfontsize = headerfont->FontSize * ImGui::GetIO().FontGlobalScale;
1872+
ImGui::PushFont(headerfont.first, headerfont.second);
1873+
auto headerfontsize = ImGui::GetFontSize();
1874+
ImGui::PopFont();
18691875
float headerheight = headerfontsize * 1.5;
18701876
float rounding = ax::NodeEditor::GetStyle().NodeRounding;
18711877

@@ -1880,7 +1886,7 @@ void FilterGraphEditor::DoNodeForTrigger(Trigger* trig)
18801886
headerText = trig->GetScope()->m_nickname + ": " + headerText;
18811887

18821888
//Figure out how big the header text is and reserve space for it
1883-
auto headerSize = headerfont->CalcTextSizeA(headerfontsize, FLT_MAX, 0, headerText.c_str());
1889+
auto headerSize = headerfont.first->CalcTextSizeA(headerfontsize, FLT_MAX, 0, headerText.c_str());
18841890
float nodewidth = max(15*tsize, headerSize.x);
18851891
ImGui::Dummy(ImVec2(nodewidth, headerheight));
18861892

@@ -1933,8 +1939,8 @@ void FilterGraphEditor::DoNodeForTrigger(Trigger* trig)
19331939
rounding,
19341940
ImDrawFlags_RoundCornersTop);
19351941
bgList->AddText(
1936-
headerfont,
1937-
headerfontsize,
1942+
headerfont.first,
1943+
headerfont.second,
19381944
ImVec2(pos.x + headerfontsize*0.5, pos.y + headerfontsize*0.25),
19391945
headercolor,
19401946
headerText.c_str());
@@ -1965,9 +1971,13 @@ void FilterGraphEditor::DoNodeForChannel(
19651971
auto color = ColorFromString(displaycolor);
19661972
auto headercolor = prefs.GetColor("Appearance.Filter Graph.header_text_color");
19671973
auto headerfont = m_parent->GetFontPref("Appearance.Filter Graph.header_font");
1968-
auto headerfontsize = headerfont->FontSize * ImGui::GetIO().FontGlobalScale;
1974+
ImGui::PushFont(headerfont.first, headerfont.second);
1975+
auto headerfontsize = ImGui::GetFontSize();
1976+
ImGui::PopFont();
19691977
auto textfont = m_parent->GetFontPref("Appearance.Filter Graph.icon_caption_font");
1970-
auto textfontsize = textfont->FontSize * ImGui::GetIO().FontGlobalScale;
1978+
ImGui::PushFont(textfont.first, textfont.second);
1979+
auto textfontsize = ImGui::GetFontSize();
1980+
ImGui::PopFont();
19711981
float headerheight = headerfontsize * 1.5;
19721982
float rounding = ax::NodeEditor::GetStyle().NodeRounding;
19731983

@@ -1985,7 +1995,7 @@ void FilterGraphEditor::DoNodeForChannel(
19851995
headerText = inst->m_nickname + ": " + headerText;
19861996

19871997
//Figure out how big the header text is
1988-
auto headerSize = headerfont->CalcTextSizeA(headerfontsize, FLT_MAX, 0, headerText.c_str());
1998+
auto headerSize = headerfont.first->CalcTextSizeA(headerfontsize, FLT_MAX, 0, headerText.c_str());
19891999

19902000
//Format block type early, even though it's not drawn until later
19912001
//so that we know how much space to allocate
@@ -2011,7 +2021,7 @@ void FilterGraphEditor::DoNodeForChannel(
20112021
blocktype = "Hardware input";
20122022
}
20132023
ImVec2 iconsize(ImGui::GetFontSize() * 6, ImGui::GetFontSize() * 3);
2014-
auto captionsize = textfont->CalcTextSizeA(textfontsize, FLT_MAX, 0, blocktype.c_str());
2024+
auto captionsize = textfont.first->CalcTextSizeA(textfontsize, FLT_MAX, 0, blocktype.c_str());
20152025

20162026
//Reserve space for the center icon and node type caption
20172027
float iconwidth = max(iconsize.x, captionsize.x);
@@ -2025,13 +2035,13 @@ void FilterGraphEditor::DoNodeForChannel(
20252035
{
20262036
auto name = string("") + channel->GetInputName(i);
20272037
inames.push_back(name);
2028-
iportmax = max(iportmax, textfont->CalcTextSizeA(textfontsize, FLT_MAX, 0, name.c_str()).x);
2038+
iportmax = max(iportmax, textfont.first->CalcTextSizeA(textfontsize, FLT_MAX, 0, name.c_str()).x);
20292039
}
20302040
for(size_t i=0; i<channel->GetStreamCount(); i++)
20312041
{
20322042
auto name = channel->GetStreamName(i) + "";
20332043
onames.push_back(name);
2034-
oportmax = max(oportmax, textfont->CalcTextSizeA(textfontsize, FLT_MAX, 0, name.c_str()).x);
2044+
oportmax = max(oportmax, textfont.first->CalcTextSizeA(textfontsize, FLT_MAX, 0, name.c_str()).x);
20352045
}
20362046
float colswidth = iportmax + oportmax + iconwidth;
20372047
float nodewidth = max(colswidth, headerSize.x) + 3*ImGui::GetStyle().ItemSpacing.x;
@@ -2139,8 +2149,8 @@ void FilterGraphEditor::DoNodeForChannel(
21392149
rounding,
21402150
ImDrawFlags_RoundCornersTop);
21412151
bgList->AddText(
2142-
headerfont,
2143-
headerfontsize,
2152+
headerfont.first,
2153+
headerfont.second,
21442154
ImVec2(pos.x + headerfontsize*0.5, pos.y + headerfontsize*0.25),
21452155
headercolor,
21462156
headerText.c_str());
@@ -2151,7 +2161,7 @@ void FilterGraphEditor::DoNodeForChannel(
21512161
if(runtime > 0)
21522162
{
21532163
auto runtimeText = fs.PrettyPrint(runtime, 3);
2154-
auto runtimeSize = headerfont->CalcTextSizeA(headerfontsize, FLT_MAX, 0, runtimeText.c_str());
2164+
auto runtimeSize = headerfont.first->CalcTextSizeA(headerfontsize, FLT_MAX, 0, runtimeText.c_str());
21552165

21562166
auto timebgColor = ColorFromString("#404040");
21572167
auto timeTextColor = ColorFromString("#ffffff");
@@ -2181,8 +2191,8 @@ void FilterGraphEditor::DoNodeForChannel(
21812191
clockiconpos + clockiconsize );
21822192

21832193
bgList->AddText(
2184-
headerfont,
2185-
headerfontsize,
2194+
headerfont.first,
2195+
headerfont.second,
21862196
textpos,
21872197
timeTextColor,
21882198
runtimeText.c_str());
@@ -2203,8 +2213,8 @@ void FilterGraphEditor::DoNodeForChannel(
22032213
pos + icondelta +
22042214
ImVec2(0, iconsize.y + ImGui::GetStyle().ItemSpacing.y*3);
22052215
bgList->AddText(
2206-
textfont,
2207-
textfontsize,
2216+
textfont.first,
2217+
textfont.second,
22082218
textpos + ImVec2( (iconwidth - captionsize.x)/2, 0),
22092219
textColor,
22102220
blocktype.c_str());

src/ngscopeclient/FilterGraphEditor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* ngscopeclient *
44
* *
5-
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
5+
* Copyright (c) 2012-2025 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 *

src/ngscopeclient/FontManager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class PreferenceCategory;
4242
//pair of (font file, size)
4343
typedef std::pair<std::string, float> FontDescription;
4444

45+
//pair of (font object, size)
46+
typedef std::pair<ImFont*, float> FontWithSize;
47+
4548
class FontManager
4649
{
4750
public:

src/ngscopeclient/LogViewerDialog.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* ngscopeclient *
44
* *
5-
* Copyright (c) 2012-2024 Andrew D. Zonenberg *
5+
* Copyright (c) 2012-2025 Andrew D. Zonenberg *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -65,7 +65,8 @@ bool LogViewerDialog::DoRender()
6565

6666
ImGui::BeginChild("scrollview", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar);
6767

68-
ImGui::PushFont(m_parent->GetFontPref("Appearance.General.console_font"));
68+
auto font = m_parent->GetFontPref("Appearance.General.console_font");
69+
ImGui::PushFont(font.first, font.second);
6970
auto& lines = g_guiLog->GetLines();
7071

7172
float width = ImGui::GetFontSize();

src/ngscopeclient/MainWindow.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,16 +1720,23 @@ void MainWindow::RenderLoadWarningPopup()
17201720
"Please review your lab notes and confirm that the experimental setup matches your previous session."
17211721
);
17221722

1723+
pair<ImFont*, float> headings[] =
1724+
{
1725+
GetFontPref("Appearance.Markdown.heading_1_font"),
1726+
GetFontPref("Appearance.Markdown.heading_2_font"),
1727+
GetFontPref("Appearance.Markdown.heading_3_font")
1728+
};
1729+
17231730
ImGui::MarkdownConfig mdConfig
17241731
{
17251732
nullptr, //linkCallback
17261733
nullptr, //tooltipCallback
17271734
nullptr, //imageCallback
17281735
"", //linkIcon (not used)
17291736
{
1730-
{ GetFontPref("Appearance.Markdown.heading_1_font"), true },
1731-
{ GetFontPref("Appearance.Markdown.heading_2_font"), true },
1732-
{ GetFontPref("Appearance.Markdown.heading_3_font"), false }
1737+
{ headings[0].first, headings[0].second, true },
1738+
{ headings[1].first, headings[1].second, true },
1739+
{ headings[2].first, headings[2].second, false }
17331740
},
17341741
nullptr //userData
17351742
};
@@ -1875,8 +1882,7 @@ void MainWindow::UpdateFonts()
18751882
auto& prefs = GetSession().GetPreferences();
18761883
if(m_fontmgr.UpdateFonts(prefs.AllPreferences(), GetContentScale()))
18771884
{
1878-
//Download imgui fonts
1879-
ImGui_ImplVulkan_CreateFontsTexture();
1885+
//TODO: remove this if not needed
18801886
}
18811887

18821888
//Set the default font. Needs to be done regardless of atlas rebuild as it may already be loaded

src/ngscopeclient/MainWindow.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,11 @@ class MainWindow : public VulkanWindow
543543
/**
544544
@brief Returns a font, given the name of a preference setting
545545
*/
546-
ImFont* GetFontPref(const std::string& name)
547-
{ return m_fontmgr.GetFont(m_session.GetPreferences().GetFont(name.c_str())); }
546+
FontWithSize GetFontPref(const std::string& name)
547+
{
548+
auto desc = m_session.GetPreferences().GetFont(name.c_str());
549+
return std::pair<ImFont*, float>(m_fontmgr.GetFont(desc), desc.second);
550+
}
548551

549552
ImU32 GetColorPref(const std::string& name)
550553
{ return m_session.GetPreferences().GetColor(name); }

src/ngscopeclient/NotesDialog.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* ngscopeclient *
44
* *
5-
* Copyright (c) 2012-2023 Andrew D. Zonenberg *
5+
* Copyright (c) 2012-2025 Andrew D. Zonenberg *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -111,16 +111,23 @@ void NotesDialog::GeneralNotes()
111111
*/
112112
void NotesDialog::MarkdownEditor(string& str)
113113
{
114+
pair<ImFont*, float> headings[] =
115+
{
116+
m_parent->GetFontPref("Appearance.Markdown.heading_1_font"),
117+
m_parent->GetFontPref("Appearance.Markdown.heading_2_font"),
118+
m_parent->GetFontPref("Appearance.Markdown.heading_3_font")
119+
};
120+
114121
ImGui::MarkdownConfig mdConfig
115122
{
116123
nullptr, //linkCallback
117124
nullptr, //tooltipCallback
118125
nullptr, //imageCallback
119126
"", //linkIcon (not used)
120127
{
121-
{ m_parent->GetFontPref("Appearance.Markdown.heading_1_font"), true },
122-
{ m_parent->GetFontPref("Appearance.Markdown.heading_2_font"), true },
123-
{ m_parent->GetFontPref("Appearance.Markdown.heading_3_font"), false }
128+
{ headings[0].first, headings[0].second, true },
129+
{ headings[1].first, headings[1].second, true },
130+
{ headings[2].first, headings[2].second, false }
124131
},
125132
nullptr //userData
126133
};

0 commit comments

Comments
 (0)