Added option to change the line color for plots and bar color for histograms in the histogram container (#4859)

Signed-off-by: Benjamin Jillich <jillich@amazon.com>
This commit is contained in:
Benjamin Jillich
2021-10-22 09:22:28 +02:00
committed by GitHub
parent d394f6da3c
commit 618da447a6
2 changed files with 9 additions and 0 deletions
@@ -85,6 +85,10 @@ namespace ImGui
//! Calculate the min and maximum values for the present samples.
void CalcMinMaxValues(float& outMin, float& outMax);
//! Set/get color used by either the lines in case ViewType is Lines or bars in case or Histogram.
void SetBarLineColor(const ImColor& color) { m_barLineColor = color; }
ImColor GetBarLineColor() const { return m_barLineColor; }
private:
// Set the Max Size and clear the container
void SetMaxSize(int size);
@@ -99,6 +103,7 @@ namespace ImGui
bool m_dispalyOverlays;
ScaleMode m_scaleMode; //! Determines if the vertical range of the histogram will be manually specified, auto-expanded or automatically scaled based on the samples.
float m_autoScaleSpeed = 0.05f; //! Indicates how fast the min max values and the visible vertical range are adapting to new samples.
ImColor m_barLineColor = ImColor(66, 166, 178); //! Color used by either the lines in case ViewType is Lines or bars in case or Histogram.
bool m_collapsed;
bool m_drawMostRecentValueText;
};
@@ -147,6 +147,8 @@ namespace ImGui
float imGuiHistoWidgetHeight = m_collapsed ? histogramHeight : (histogramHeight - 15);
if (GetSize() > 0)
{
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, m_barLineColor.Value);
switch (m_viewType)
{
default:
@@ -160,6 +162,8 @@ namespace ImGui
ImGui::PlotLines(AZStd::string::format("##%s_lines", m_histogramName.c_str()).c_str(), ImGui::LYImGuiUtils::s_histogramContainerGetter, this, GetSize(), 0, m_histogramName.c_str(), m_minScale, m_maxScale, ImVec2(histogramWidth - 10, imGuiHistoWidgetHeight));
break;
}
ImGui::PopStyleColor();
}