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"};
|
||||
|
||||
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(){
|
||||
ImGuiID main_viewport_dock = ImGui::GetID("main_viewport_dock");
|
||||
if (!ImGui::DockBuilderGetNode(main_viewport_dock)) {
|
||||
@ -195,39 +204,49 @@ void per_frame(){
|
||||
|
||||
// Legende
|
||||
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)) {
|
||||
ImGui::TableSetupColumn("Color", ImGuiTableColumnFlags_WidthFixed);
|
||||
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::TableSetupColumn("Edit", 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);
|
||||
|
||||
//ImGui::ColorPicker3("colortest", col);
|
||||
ImGui::ColorEdit3(name, col, ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoInputs);
|
||||
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 (editing) {
|
||||
if (category.editing) {
|
||||
ImGui::SetNextItemWidth(-1);
|
||||
if(ImGui::InputText("##name", name, IM_ARRAYSIZE(name), ImGuiInputTextFlags_EnterReturnsTrue)) {
|
||||
editing = false;
|
||||
if(ImGui::InputText("##name", category.name, IM_ARRAYSIZE(category.name), ImGuiInputTextFlags_EnterReturnsTrue)) {
|
||||
category.editing = false;
|
||||
}
|
||||
} else {
|
||||
ImGui::Text("%s", name);
|
||||
ImGui::Text("%s", category.name);
|
||||
}
|
||||
|
||||
ImGui::TableSetColumnIndex(2);
|
||||
if(ImGui::Button("e")) {
|
||||
editing = true;
|
||||
if (ImGui::Button("e"))
|
||||
category.editing = !category.editing;
|
||||
|
||||
ImGui::TableSetColumnIndex(3);
|
||||
if (ImGui::Button("d")) {
|
||||
num_categories--;
|
||||
}
|
||||
|
||||
//TODO
|
||||
ImGui::TableSetColumnIndex(3);
|
||||
ImGui::Button("d");
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
if (ImGui::Button("+")) {
|
||||
categories[num_categories] = {};
|
||||
num_categories++;
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user