1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-11-26 20:28:50 -05:00

[#174] DatePicker separate disabled color

Separate disabled color from the selected date to the truly disabled dates in another month. Move setting col/styles after we are done getting them.
This commit is contained in:
Preston Cothren 2021-01-31 14:51:16 -06:00 committed by GitHub
parent e64df657b2
commit 413fb083ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3878,12 +3878,14 @@ bool ShowDatePicker(const char* id, int* level, ImPlotTime* t, const ImPlotTime*
ImGui::PushID(id); ImGui::PushID(id);
ImGui::BeginGroup(); ImGui::BeginGroup();
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0,0,0,0));
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
ImGuiStyle& style = ImGui::GetStyle(); ImGuiStyle& style = ImGui::GetStyle();
ImVec4 col_txt = style.Colors[ImGuiCol_Text]; ImVec4 col_txt = style.Colors[ImGuiCol_Text];
ImVec4 col_dis = style.Colors[ImGuiCol_TextDisabled]; ImVec4 col_dis = style.Colors[ImGuiCol_TextDisabled];
ImVec4 col_btn = style.Colors[ImGuiCol_Button];
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0,0,0,0));
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
const float ht = ImGui::GetFrameHeight(); const float ht = ImGui::GetFrameHeight();
ImVec2 cell_size(ht*1.25f,ht); ImVec2 cell_size(ht*1.25f,ht);
char buff[32]; char buff[32];
@ -3969,7 +3971,7 @@ bool ShowDatePicker(const char* id, int* level, ImPlotTime* t, const ImPlotTime*
if (off_mo) if (off_mo)
ImGui::PushStyleColor(ImGuiCol_Text, col_dis); ImGui::PushStyleColor(ImGuiCol_Text, col_dis);
if (t1_or_t2) { if (t1_or_t2) {
ImGui::PushStyleColor(ImGuiCol_Button, col_dis); ImGui::PushStyleColor(ImGuiCol_Button, col_btn);
ImGui::PushStyleColor(ImGuiCol_Text, col_txt); ImGui::PushStyleColor(ImGuiCol_Text, col_txt);
} }
ImGui::PushID(i*7+j); ImGui::PushID(i*7+j);
@ -4019,7 +4021,7 @@ bool ShowDatePicker(const char* id, int* level, ImPlotTime* t, const ImPlotTime*
const bool t1_or_t2 = (t1 != NULL && t1_yr == this_yr && t1_mo == mo) || const bool t1_or_t2 = (t1 != NULL && t1_yr == this_yr && t1_mo == mo) ||
(t2 != NULL && t2_yr == this_yr && t2_mo == mo); (t2 != NULL && t2_yr == this_yr && t2_mo == mo);
if (t1_or_t2) if (t1_or_t2)
ImGui::PushStyleColor(ImGuiCol_Button, col_dis); ImGui::PushStyleColor(ImGuiCol_Button, col_btn);
if (ImGui::Button(MONTH_ABRVS[mo],cell_size) && !clk) { if (ImGui::Button(MONTH_ABRVS[mo],cell_size) && !clk) {
*t = MakeTime(this_yr, mo); *t = MakeTime(this_yr, mo);
*level = 0; *level = 0;
@ -4057,7 +4059,7 @@ bool ShowDatePicker(const char* id, int* level, ImPlotTime* t, const ImPlotTime*
for (int j = 0; j < 4; ++j) { for (int j = 0; j < 4; ++j) {
const bool t1_or_t2 = (t1 != NULL && t1_yr == yr) || (t2 != NULL && t2_yr == yr); const bool t1_or_t2 = (t1 != NULL && t1_yr == yr) || (t2 != NULL && t2_yr == yr);
if (t1_or_t2) if (t1_or_t2)
ImGui::PushStyleColor(ImGuiCol_Button, col_dis); ImGui::PushStyleColor(ImGuiCol_Button, col_btn);
snprintf(buff,32,"%d",yr); snprintf(buff,32,"%d",yr);
if (yr<1970||yr>3000) { if (yr<1970||yr>3000) {
ImGui::Dummy(cell_size); ImGui::Dummy(cell_size);