| 5435 | } |
| 5436 | |
| 5437 | bool ShowDatePicker(const char* id, int* level, ImPlotTime* t, const ImPlotTime* t1, const ImPlotTime* t2) { |
| 5438 | |
| 5439 | ImGui::PushID(id); |
| 5440 | ImGui::BeginGroup(); |
| 5441 | |
| 5442 | ImGuiStyle& style = ImGui::GetStyle(); |
| 5443 | ImVec4 col_txt = style.Colors[ImGuiCol_Text]; |
| 5444 | ImVec4 col_dis = style.Colors[ImGuiCol_TextDisabled]; |
| 5445 | ImVec4 col_btn = style.Colors[ImGuiCol_Button]; |
| 5446 | ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0,0,0,0)); |
| 5447 | ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0)); |
| 5448 | |
| 5449 | const float ht = ImGui::GetFrameHeight(); |
| 5450 | ImVec2 cell_size(ht*1.25f,ht); |
| 5451 | char buff[32]; |
| 5452 | bool clk = false; |
| 5453 | tm& Tm = GImPlot->Tm; |
| 5454 | |
| 5455 | const int min_yr = 1970; |
| 5456 | const int max_yr = 2999; |
| 5457 | |
| 5458 | // t1 parts |
| 5459 | int t1_mo = 0; int t1_md = 0; int t1_yr = 0; |
| 5460 | if (t1 != nullptr) { |
| 5461 | GetTime(*t1,&Tm); |
| 5462 | t1_mo = Tm.tm_mon; |
| 5463 | t1_md = Tm.tm_mday; |
| 5464 | t1_yr = Tm.tm_year + 1900; |
| 5465 | } |
| 5466 | |
| 5467 | // t2 parts |
| 5468 | int t2_mo = 0; int t2_md = 0; int t2_yr = 0; |
| 5469 | if (t2 != nullptr) { |
| 5470 | GetTime(*t2,&Tm); |
| 5471 | t2_mo = Tm.tm_mon; |
| 5472 | t2_md = Tm.tm_mday; |
| 5473 | t2_yr = Tm.tm_year + 1900; |
| 5474 | } |
| 5475 | |
| 5476 | // day widget |
| 5477 | if (*level == 0) { |
| 5478 | *t = FloorTime(*t, ImPlotTimeUnit_Day); |
| 5479 | GetTime(*t, &Tm); |
| 5480 | const int this_year = Tm.tm_year + 1900; |
| 5481 | const int last_year = this_year - 1; |
| 5482 | const int next_year = this_year + 1; |
| 5483 | const int this_mon = Tm.tm_mon; |
| 5484 | const int last_mon = this_mon == 0 ? 11 : this_mon - 1; |
| 5485 | const int next_mon = this_mon == 11 ? 0 : this_mon + 1; |
| 5486 | const int days_this_mo = GetDaysInMonth(this_year, this_mon); |
| 5487 | const int days_last_mo = GetDaysInMonth(this_mon == 0 ? last_year : this_year, last_mon); |
| 5488 | ImPlotTime t_first_mo = FloorTime(*t,ImPlotTimeUnit_Mo); |
| 5489 | GetTime(t_first_mo,&Tm); |
| 5490 | const int first_wd = Tm.tm_wday; |
| 5491 | // month year |
| 5492 | ImFormatString(buff, 32, "%s %d", MONTH_NAMES[this_mon], this_year); |
| 5493 | if (ImGui::Button(buff)) |
| 5494 | *level = 1; |
no test coverage detected