mirror of
https://github.com/gwm17/implot.git
synced 2024-11-26 12:18:52 -05:00
add Configuration section to demo
This commit is contained in:
parent
2f139f8a99
commit
acb69ab410
12
implot.cpp
12
implot.cpp
|
@ -2034,6 +2034,9 @@ void SetColormap(ImPlotColormap colormap, int samples) {
|
|||
ResampleColormap(gp.Colormap, gp.ColormapSize, &resampled[0], samples);
|
||||
SetColormap(&resampled[0], samples);
|
||||
}
|
||||
else {
|
||||
BustItemCache();
|
||||
}
|
||||
}
|
||||
|
||||
void SetColormap(const ImVec4* colors, int size) {
|
||||
|
@ -2047,6 +2050,7 @@ void SetColormap(const ImVec4* colors, int size) {
|
|||
user_colormap.push_back(colors[i]);
|
||||
gp.Colormap = &user_colormap[0];
|
||||
gp.ColormapSize = size;
|
||||
BustItemCache();
|
||||
}
|
||||
|
||||
const ImVec4* GetColormap(ImPlotColormap colormap, int* size_out) {
|
||||
|
@ -2475,12 +2479,14 @@ void ShowStyleEditor(ImPlotStyle* ref) {
|
|||
int size;
|
||||
const ImVec4* cmap = GetColormap(i, &size);
|
||||
bool selected = cmap == gp.Colormap;
|
||||
if (selected) {
|
||||
custom_set = false;
|
||||
}
|
||||
|
||||
if (!selected)
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.25f);
|
||||
if (ImGui::Button(GetColormapName(i), ImVec2(75,0))) {
|
||||
SetColormap(i);
|
||||
BustItemCache();
|
||||
custom_set = false;
|
||||
}
|
||||
if (!selected)
|
||||
|
@ -2506,7 +2512,6 @@ void ShowStyleEditor(ImPlotStyle* ref) {
|
|||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.25f);
|
||||
if (ImGui::Button("Custom", ImVec2(75, 0))) {
|
||||
SetColormap(&custom[0], custom.Size);
|
||||
BustItemCache();
|
||||
custom_set = true;
|
||||
}
|
||||
if (!custom_set_now)
|
||||
|
@ -2515,7 +2520,6 @@ void ShowStyleEditor(ImPlotStyle* ref) {
|
|||
custom.push_back(ImVec4(0,0,0,1));
|
||||
if (custom_set) {
|
||||
SetColormap(&custom[0], custom.Size);
|
||||
BustItemCache();
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
@ -2523,7 +2527,6 @@ void ShowStyleEditor(ImPlotStyle* ref) {
|
|||
custom.pop_back();
|
||||
if (custom_set) {
|
||||
SetColormap(&custom[0], custom.Size);
|
||||
BustItemCache();
|
||||
}
|
||||
}
|
||||
ImGui::EndGroup();
|
||||
|
@ -2533,7 +2536,6 @@ void ShowStyleEditor(ImPlotStyle* ref) {
|
|||
ImGui::PushID(c);
|
||||
if (ImGui::ColorEdit4("##Col1", &custom[c].x, ImGuiColorEditFlags_NoInputs) && custom_set) {
|
||||
SetColormap(&custom[0], custom.Size);
|
||||
BustItemCache();
|
||||
}
|
||||
if ((c + 1) % 12 != 0)
|
||||
ImGui::SameLine();
|
||||
|
|
11
implot.h
11
implot.h
|
@ -171,7 +171,8 @@ struct ImPlotPoint {
|
|||
double operator[] (size_t idx) const { return (&x)[idx]; }
|
||||
double& operator[] (size_t idx) { return (&x)[idx]; }
|
||||
#ifdef IMPLOT_POINT_CLASS_EXTRA
|
||||
IMPLOT_POINT_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImPlotPoint.
|
||||
IMPLOT_POINT_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h
|
||||
// to convert back and forth between your math types and ImPlotPoint.
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -418,7 +419,7 @@ bool IsLegendEntryHovered(const char* label_id);
|
|||
// Provides access to plot style structure for permanant modifications to colors, sizes, etc.
|
||||
ImPlotStyle& GetStyle();
|
||||
|
||||
// Style colors from current ImGui style (default)
|
||||
// Style colors for current ImGui style (default).
|
||||
void StyleColorsAuto(ImPlotStyle* dst = NULL);
|
||||
// Style colors for ImGui "Classic".
|
||||
void StyleColorsClassic(ImPlotStyle* dst = NULL);
|
||||
|
@ -463,7 +464,7 @@ int GetColormapSize();
|
|||
ImVec4 GetColormapColor(int index);
|
||||
// Linearly interpolates a color from the current colormap given t between 0 and 1.
|
||||
ImVec4 LerpColormap(float t);
|
||||
// Returns the next unused colormap color and advances the colormap. Can be used to skip colors if desired. Call between BeginPlot/EndPlot.
|
||||
// Returns the next unused colormap color and advances the colormap. Can be used to skip colors if desired.
|
||||
ImVec4 NextColormapColor();
|
||||
|
||||
const char* GetStyleColorName(ImPlotCol color);
|
||||
|
@ -482,9 +483,9 @@ ImPlotInputMap& GetInputMap();
|
|||
|
||||
// Shows ImPlot style selector dropdown menu.
|
||||
bool ShowStyleSelector(const char* label);
|
||||
// Shows ImPlot style editor block (not a window)
|
||||
// Shows ImPlot style editor block (not a window).
|
||||
void ShowStyleEditor(ImPlotStyle* ref = NULL);
|
||||
// Add basic help/info block (not a window): how to manipulate ImPlot as a end-user
|
||||
// Add basic help/info block (not a window): how to manipulate ImPlot as an end-user.
|
||||
void ShowUserGuide();
|
||||
|
||||
// Push clip rect for rendering to current plot area.
|
||||
|
|
|
@ -139,6 +139,7 @@ struct BenchmarkItem {
|
|||
};
|
||||
|
||||
void ShowDemoWindow(bool* p_open) {
|
||||
t_float DEMO_TIME = (t_float)ImGui::GetTime();
|
||||
static bool show_imgui_metrics = false;
|
||||
static bool show_imgui_style_editor = false;
|
||||
static bool show_implot_style_editor = false;
|
||||
|
@ -195,7 +196,24 @@ void ShowDemoWindow(bool* p_open) {
|
|||
ImGui::Text("USER GUIDE:");
|
||||
ShowUserGuide();
|
||||
}
|
||||
t_float DEMO_TIME = (t_float)ImGui::GetTime();
|
||||
//-------------------------------------------------------------------------
|
||||
if (ImGui::CollapsingHeader("Configuration")) {
|
||||
ImGui::ShowFontSelector("Font");
|
||||
ImGui::ShowStyleSelector("ImGui Style");
|
||||
ImPlot::ShowStyleSelector("ImPlot Style");
|
||||
|
||||
static const char* map = ImPlot::GetColormapName(ImPlotColormap_Default);
|
||||
if (ImGui::BeginCombo("ImPlot Colormap", map)) {
|
||||
for (int i = 0; i < ImPlotColormap_COUNT; ++i) {
|
||||
const char* name = GetColormapName(i);
|
||||
if (ImGui::Selectable(name, map == name)) {
|
||||
map = name;
|
||||
ImPlot::SetColormap(i);
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
if (ImGui::CollapsingHeader("Line Plots")) {
|
||||
static t_float xs1[1001], ys1[1001];
|
||||
|
|
Loading…
Reference in New Issue
Block a user