@@ -434,9 +434,7 @@ bool FilterGraphEditor::DoRender()
434434
435435 // NodeEditor seems to handle DPI scaling on its own
436436 // so turn off global scaling to avoid double scaling
437- ImGui::GetStyle ().FontScaleDpi = 1 .0f ;
438- ImGui::UpdateCurrentFontSize (0 .0f );
439- m_parent->ResetStyle ();
437+ SetCanvasManagedDPI ();
440438
441439 // Handle dropping a stream or channel from the browser
442440 ax::NodeEditor::NodeId newNode;
@@ -619,10 +617,8 @@ bool FilterGraphEditor::DoRender()
619617 bool triggerChanged = HandleNodeProperties ();
620618 HandleBackgroundContextMenu ();
621619
622- ImGui::GetStyle ().FontScaleDpi = ImGui::GetWindowViewport ()->DpiScale ;
623- ImGui::UpdateCurrentFontSize (0 .0f );
624- m_parent->ResetStyle ();
625-
620+ // Done with canvas stuff
621+ SetImGuiManagedDPI ();
626622 ax::NodeEditor::End ();
627623
628624 // Refresh all of our groups to have up-to-date child contents
@@ -954,7 +950,9 @@ void FilterGraphEditor::DoNodeForGroupOutputs(shared_ptr<FilterGraphGroup> group
954950 {
955951 // Output port
956952 ax::NodeEditor::Suspend ();
953+ SetImGuiManagedDPI ();
957954 OutputPortTooltip (hoveredStream);
955+ SetCanvasManagedDPI ();
958956 ax::NodeEditor::Resume ();
959957 }
960958
@@ -1553,6 +1551,7 @@ void FilterGraphEditor::HandleLinkCreationRequests(Filter*& fReconfigure)
15531551 ax::NodeEditor::EndCreate ();
15541552
15551553 ax::NodeEditor::Suspend ();
1554+ SetImGuiManagedDPI ();
15561555
15571556 // Create-filter menu
15581557 if (ImGui::BeginPopup (" Create Filter" ))
@@ -1568,9 +1567,30 @@ void FilterGraphEditor::HandleLinkCreationRequests(Filter*& fReconfigure)
15681567 ImGui::EndPopup ();
15691568 }
15701569
1570+ SetCanvasManagedDPI ();
15711571 ax::NodeEditor::Resume ();
15721572}
15731573
1574+ /* *
1575+ @brief Use 1.0 as the DPI since the canvas scales independently
1576+ */
1577+ void FilterGraphEditor::SetCanvasManagedDPI ()
1578+ {
1579+ ImGui::GetStyle ().FontScaleDpi = 1 .0f ;
1580+ ImGui::UpdateCurrentFontSize (0 .0f );
1581+ m_parent->ResetStyle ();
1582+ }
1583+
1584+ /* *
1585+ @brief Use the ImGui viewport scale as the DPI scale
1586+ */
1587+ void FilterGraphEditor::SetImGuiManagedDPI ()
1588+ {
1589+ ImGui::GetStyle ().FontScaleDpi = ImGui::GetWindowViewport ()->DpiScale ;
1590+ ImGui::UpdateCurrentFontSize (0 .0f );
1591+ m_parent->ResetStyle ();
1592+ }
1593+
15741594/* *
15751595 @brief Determine if a proposed edge in the filter graph is a back edge (one whose creation would lead to a cycle)
15761596
@@ -1742,11 +1762,8 @@ void FilterGraphEditor::FilterMenu(StreamDescriptor stream)
17421762void FilterGraphEditor::FilterSubmenu (StreamDescriptor stream, const string& name, Filter::Category cat)
17431763{
17441764 auto & refs = m_parent->GetSession ().GetReferenceFilters ();
1745-
17461765 if (ImGui::BeginMenu (name.c_str ()))
17471766 {
1748- ImGui::PushFont (nullptr , 0 );
1749-
17501767 // Find all filters in this category and sort them alphabetically
17511768 vector<string> sortedNames;
17521769 for (auto it : refs)
@@ -1786,8 +1803,6 @@ void FilterGraphEditor::FilterSubmenu(StreamDescriptor stream, const string& nam
17861803 ax::NodeEditor::SetNodePosition (GetID (f), mousePos);
17871804 }
17881805 }
1789-
1790- ImGui::PopFont ();
17911806 ImGui::EndMenu ();
17921807 }
17931808}
0 commit comments