MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / ShowDatePicker

Function ShowDatePicker

Source/3rdParty/implot/implot.cpp:5513–5722  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5511}
5512
5513bool ShowDatePicker(const char* id, int* level, ImPlotTime* t, const ImPlotTime* t1, const ImPlotTime* t2) {
5514
5515 ImGui::PushID(id);
5516 ImGui::BeginGroup();
5517
5518 ImGuiStyle& style = ImGui::GetStyle();
5519 ImVec4 col_txt = style.Colors[ImGuiCol_Text];
5520 ImVec4 col_dis = style.Colors[ImGuiCol_TextDisabled];
5521 ImVec4 col_btn = style.Colors[ImGuiCol_Button];
5522 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0,0,0,0));
5523 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
5524
5525 const float ht = ImGui::GetFrameHeight();
5526 ImVec2 cell_size(ht*1.25f,ht);
5527 char buff[32];
5528 bool clk = false;
5529 tm& Tm = GImPlot->Tm;
5530
5531 const int min_yr = 1970;
5532 const int max_yr = 2999;
5533
5534 // t1 parts
5535 int t1_mo = 0; int t1_md = 0; int t1_yr = 0;
5536 if (t1 != nullptr) {
5537 GetTime(*t1,&Tm);
5538 t1_mo = Tm.tm_mon;
5539 t1_md = Tm.tm_mday;
5540 t1_yr = Tm.tm_year + 1900;
5541 }
5542
5543 // t2 parts
5544 int t2_mo = 0; int t2_md = 0; int t2_yr = 0;
5545 if (t2 != nullptr) {
5546 GetTime(*t2,&Tm);
5547 t2_mo = Tm.tm_mon;
5548 t2_md = Tm.tm_mday;
5549 t2_yr = Tm.tm_year + 1900;
5550 }
5551
5552 // day widget
5553 if (*level == 0) {
5554 *t = FloorTime(*t, ImPlotTimeUnit_Day);
5555 GetTime(*t, &Tm);
5556 const int this_year = Tm.tm_year + 1900;
5557 const int last_year = this_year - 1;
5558 const int next_year = this_year + 1;
5559 const int this_mon = Tm.tm_mon;
5560 const int last_mon = this_mon == 0 ? 11 : this_mon - 1;
5561 const int next_mon = this_mon == 11 ? 0 : this_mon + 1;
5562 const int days_this_mo = GetDaysInMonth(this_year, this_mon);
5563 const int days_last_mo = GetDaysInMonth(this_mon == 0 ? last_year : this_year, last_mon);
5564 ImPlotTime t_first_mo = FloorTime(*t,ImPlotTimeUnit_Mo);
5565 GetTime(t_first_mo,&Tm);
5566 const int first_wd = Tm.tm_wday;
5567 // month year
5568 ImFormatString(buff, 32, "%s %d", MONTH_NAMES[this_mon], this_year);
5569 if (ImGui::Button(buff))
5570 *level = 1;

Callers 1

ShowAxisContextMenuFunction · 0.85

Calls 15

PushIDFunction · 0.85
ImVec4Class · 0.85
ImVec2Function · 0.85
FloorTimeFunction · 0.85
GetDaysInMonthFunction · 0.85
ImFormatStringFunction · 0.85
BeginDisabledControlsFunction · 0.85
AddTimeFunction · 0.85
EndDisabledControlsFunction · 0.85
PushItemFlagFunction · 0.85
MakeTimeFunction · 0.85
PopStyleColorFunction · 0.85

Tested by

no test coverage detected