parent
f5ade64669
commit
c1df746813
@ -51,6 +51,15 @@ void init(){
|
|||||||
|
|
||||||
static const char* month_names[] = {"Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"};
|
static const char* month_names[] = {"Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
bool editing = false;
|
||||||
|
float color[3];
|
||||||
|
char name[64] = "New Category";
|
||||||
|
} Category;
|
||||||
|
|
||||||
|
size_t num_categories = 0;
|
||||||
|
Category categories[128];
|
||||||
|
|
||||||
void per_frame(){
|
void per_frame(){
|
||||||
ImGuiID main_viewport_dock = ImGui::GetID("main_viewport_dock");
|
ImGuiID main_viewport_dock = ImGui::GetID("main_viewport_dock");
|
||||||
if (!ImGui::DockBuilderGetNode(main_viewport_dock)) {
|
if (!ImGui::DockBuilderGetNode(main_viewport_dock)) {
|
||||||
@ -195,40 +204,50 @@ void per_frame(){
|
|||||||
|
|
||||||
// Legende
|
// Legende
|
||||||
if (ImGui::Begin("Legende", 0)) {
|
if (ImGui::Begin("Legende", 0)) {
|
||||||
static float col[3] = {};
|
|
||||||
static bool editing = false;
|
|
||||||
static char name[64] = "color";
|
|
||||||
|
|
||||||
if(ImGui::BeginTable("Legend", 4, ImGuiTableFlags_SizingStretchProp)) {
|
if(ImGui::BeginTable("Legend", 4, ImGuiTableFlags_SizingStretchProp)) {
|
||||||
ImGui::TableSetupColumn("Color", ImGuiTableColumnFlags_WidthFixed);
|
ImGui::TableSetupColumn("Color", ImGuiTableColumnFlags_WidthFixed);
|
||||||
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthStretch);
|
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthStretch);
|
||||||
ImGui::TableSetupColumn("Edit", ImGuiTableColumnFlags_WidthFixed);
|
ImGui::TableSetupColumn("Edit", ImGuiTableColumnFlags_WidthFixed);
|
||||||
ImGui::TableSetupColumn("Delete", ImGuiTableColumnFlags_WidthFixed );
|
ImGui::TableSetupColumn("Delete", ImGuiTableColumnFlags_WidthFixed );
|
||||||
|
|
||||||
|
for (size_t i = 0; i < num_categories; i++) {
|
||||||
|
auto &category = categories[i];
|
||||||
|
ImGui::PushID(i);
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
|
||||||
|
ImGui::TableSetColumnIndex(0);
|
||||||
|
ImGuiColorEditFlags color_edit_flags = ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoOptions;
|
||||||
|
ImGui::ColorEdit3(category.name, category.color, ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoInputs | (category.editing ? 0 : color_edit_flags));
|
||||||
|
|
||||||
|
ImGui::TableSetColumnIndex(1);
|
||||||
|
if (category.editing) {
|
||||||
|
ImGui::SetNextItemWidth(-1);
|
||||||
|
if(ImGui::InputText("##name", category.name, IM_ARRAYSIZE(category.name), ImGuiInputTextFlags_EnterReturnsTrue)) {
|
||||||
|
category.editing = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ImGui::Text("%s", category.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::TableSetColumnIndex(2);
|
||||||
|
if (ImGui::Button("e"))
|
||||||
|
category.editing = !category.editing;
|
||||||
|
|
||||||
|
ImGui::TableSetColumnIndex(3);
|
||||||
|
if (ImGui::Button("d")) {
|
||||||
|
num_categories--;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableSetColumnIndex(0);
|
ImGui::TableSetColumnIndex(0);
|
||||||
|
if (ImGui::Button("+")) {
|
||||||
//ImGui::ColorPicker3("colortest", col);
|
categories[num_categories] = {};
|
||||||
ImGui::ColorEdit3(name, col, ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoInputs);
|
num_categories++;
|
||||||
ImGui::TableSetColumnIndex(1);
|
|
||||||
if (editing) {
|
|
||||||
ImGui::SetNextItemWidth(-1);
|
|
||||||
if(ImGui::InputText("##name", name, IM_ARRAYSIZE(name), ImGuiInputTextFlags_EnterReturnsTrue)) {
|
|
||||||
editing = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ImGui::Text("%s", name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableSetColumnIndex(2);
|
|
||||||
if(ImGui::Button("e")) {
|
|
||||||
editing = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
ImGui::TableSetColumnIndex(3);
|
|
||||||
ImGui::Button("d");
|
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user