1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-11-13 22:48:50 -05:00

tidy up selection/query code, add new methods

This commit is contained in:
epezent 2021-03-23 23:50:02 -06:00
parent ef6c55cd00
commit e5c457b326

View File

@ -1281,6 +1281,17 @@ void UpdateAxisColors(int axis_flag, ImPlotAxis* axis) {
axis->ColorTxt = ImGui::GetColorU32(col_label); axis->ColorTxt = ImGui::GetColorU32(col_label);
} }
//-----------------------------------------------------------------------------
// RENDERING
//-----------------------------------------------------------------------------
static inline void RenderSelectionRect(ImDrawList& DrawList, const ImVec2& p_min, const ImVec2& p_max, const ImVec4& col) {
const ImU32 col_bg = ImGui::GetColorU32(col * ImVec4(1,1,1,0.25f));
const ImU32 col_bd = ImGui::GetColorU32(col);
DrawList.AddRectFilled(p_min, p_max, col_bg);
DrawList.AddRect(p_min, p_max, col_bd);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// BeginPlot() // BeginPlot()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -2342,13 +2353,9 @@ void EndPlot() {
DrawList.AddText(pos + gp.Style.AnnotationPadding, an.ColorFg, txt); DrawList.AddText(pos + gp.Style.AnnotationPadding, an.ColorFg, txt);
} }
// render selection // render selection
if (plot.Selected) { if (plot.Selected)
const ImVec4 col = GetStyleColorVec4(ImPlotCol_Selection); RenderSelectionRect(DrawList, plot.SelectRect.Min + plot.PlotRect.Min, plot.SelectRect.Max + plot.PlotRect.Min, GetStyleColorVec4(ImPlotCol_Selection));
const ImU32 col_bg = ImGui::GetColorU32(col * ImVec4(1,1,1,0.25f));
const ImU32 col_bd = ImGui::GetColorU32(col);
DrawList.AddRectFilled(plot.SelectRect.Min + plot.PlotRect.Min, plot.SelectRect.Max + plot.PlotRect.Min, col_bg);
DrawList.AddRect( plot.SelectRect.Min + plot.PlotRect.Min, plot.SelectRect.Max + plot.PlotRect.Min, col_bd);
}
// render query // render query
if (plot.Queried) { if (plot.Queried) {
const ImVec4 col = GetStyleColorVec4(ImPlotCol_Query); const ImVec4 col = GetStyleColorVec4(ImPlotCol_Query);