add dockspace for calendar and legend view
add width behaviour to legend elements #6
This commit is contained in:
parent
32ad42b162
commit
f5ade64669
@ -49,30 +49,28 @@ void init(){
|
||||
year = get_current_year();
|
||||
}
|
||||
|
||||
static const char* month_names[] = {"Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"};
|
||||
|
||||
void per_frame(){
|
||||
static bool use_work_area = true;
|
||||
static ImGuiWindowFlags flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings;
|
||||
// We demonstrate using the full viewport area or the work area (without menu-bars, task-bars etc.)
|
||||
const ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||
ImGui::SetNextWindowPos(use_work_area ? viewport->WorkPos : viewport->Pos);
|
||||
ImGui::SetNextWindowSize(use_work_area ? viewport->WorkSize : viewport->Size);
|
||||
ImGuiID main_viewport_dock = ImGui::GetID("main_viewport_dock");
|
||||
if (!ImGui::DockBuilderGetNode(main_viewport_dock)) {
|
||||
ImGui::DockBuilderAddNode (main_viewport_dock, ImGuiDockNodeFlags_DockSpace | ImGuiDockNodeFlags_NoTabBar);
|
||||
ImGui::DockBuilderSetNodePos (main_viewport_dock, ImGui::GetMainViewport()->WorkPos);
|
||||
ImGui::DockBuilderSetNodeSize(main_viewport_dock, ImGui::GetMainViewport()->WorkSize);
|
||||
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
auto default_item_spacing = style.ItemSpacing;
|
||||
|
||||
const char* month_names[] = {"Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"};
|
||||
|
||||
//
|
||||
ImGui::Begin("Work Calendar", 0, flags);
|
||||
ImGuiID left_dock = 0;
|
||||
ImGuiID right_dock = ImGui::DockBuilderSplitNode(main_viewport_dock, ImGuiDir_Right, 0.15f, NULL, &left_dock);
|
||||
ImGui::DockBuilderDockWindow("Work Calendar", left_dock);
|
||||
ImGui::DockBuilderDockWindow("Legende", right_dock);
|
||||
ImGui::DockBuilderFinish(main_viewport_dock);
|
||||
}
|
||||
ImGui::DockSpaceOverViewport(main_viewport_dock, ImGui::GetMainViewport(), ImGuiDockNodeFlags_NoTabBar);
|
||||
|
||||
if (ImGui::Begin("Work Calendar", 0)) {
|
||||
ImGui::PushStyleColor(ImGuiCol_TableHeaderBg, {0,0,0,0});
|
||||
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, {0,0,0,0});
|
||||
ImGui::PushStyleColor(ImGuiCol_HeaderActive, {0,0,0,0});
|
||||
|
||||
if(ImGui::BeginTable("Calendar", 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_NoHostExtendX)) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
|
||||
ImGui::BeginGroup();
|
||||
if (ImGui::ArrowButton("##left", ImGuiDir_Left))
|
||||
year--;
|
||||
@ -85,13 +83,6 @@ void per_frame(){
|
||||
ImGui::TextAligned(0.5, -FLT_MIN, "%d", year);
|
||||
ImGui::EndGroup();
|
||||
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::TextAligned(0.5, -FLT_MIN, "Legende");
|
||||
|
||||
//
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
|
||||
for (int month = 1; month <= 12; month++) {
|
||||
ImGui::PushID(month);
|
||||
ImGui::PushStyleColor(ImGuiCol_TableBorderStrong, {0,0,0,0});
|
||||
@ -198,21 +189,49 @@ void per_frame(){
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
//Legende
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImVec4 col = {};
|
||||
ImGui::ColorButton("colortest", col);
|
||||
ImGui::SameLine(0, 0);
|
||||
char buf[64] = {};
|
||||
ImGui::InputText("", buf, IM_ARRAYSIZE(buf));
|
||||
//TODO
|
||||
ImGui::PopStyleColor(3);
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
//calendar table
|
||||
ImGui::EndTable();
|
||||
// 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 );
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
|
||||
//ImGui::ColorPicker3("colortest", col);
|
||||
ImGui::ColorEdit3(name, col, ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoInputs);
|
||||
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::PopStyleColor(3);
|
||||
ImGui::TableSetColumnIndex(2);
|
||||
if(ImGui::Button("e")) {
|
||||
editing = true;
|
||||
}
|
||||
|
||||
//TODO
|
||||
ImGui::TableSetColumnIndex(3);
|
||||
ImGui::Button("d");
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user