Checklist highlights
This commit is contained in:
@@ -50,11 +50,20 @@ public:
|
||||
std::unordered_map<std::string, std::vector<time_t>> tasks = {};
|
||||
};
|
||||
|
||||
enum class HoverTargetType
|
||||
{
|
||||
HOVER_TARGET_NONE = 0,
|
||||
HOVER_TARGET_CHECKLIST_DAY = 1,
|
||||
};
|
||||
|
||||
class ApplicationData {
|
||||
public:
|
||||
ApplicationSettings settings = {};
|
||||
size_t checklistLength = 0;
|
||||
int checklistHighlightDurationDays = 3;
|
||||
std::shared_ptr<AudioData> audioData = std::make_shared<AudioData>();
|
||||
HoverTargetType hoverTargetType = HoverTargetType::HOVER_TARGET_NONE;
|
||||
time_t hoverTargetDay = 0;
|
||||
|
||||
//ApplicationData(const ApplicationData&) = delete;
|
||||
//ApplicationData& operator=(const ApplicationData&) = delete;
|
||||
|
||||
@@ -83,7 +83,7 @@ void init(DrawData& drawData, ApplicationData& appData)
|
||||
ImFontConfig icons_config;
|
||||
icons_config.MergeMode = true;
|
||||
icons_config.PixelSnapH = true;
|
||||
icons_config.GlyphOffset = { 0., 2. };
|
||||
icons_config.GlyphOffset = { 0., 1. };
|
||||
std::string iconFontPath = std::string(appPathStr);
|
||||
iconFontPath.append("\\remixicon.ttf");
|
||||
io.Fonts->AddFontFromFileTTF(iconFontPath.c_str(), 14.0f, &icons_config, icons_ranges);
|
||||
@@ -99,6 +99,7 @@ void init(DrawData& drawData, ApplicationData& appData)
|
||||
void draw(DrawData& drawData, ApplicationData& appData)
|
||||
{
|
||||
justDocked = false;
|
||||
appData.hoverTargetType = HoverTargetType::HOVER_TARGET_NONE;
|
||||
|
||||
if (isHidden)
|
||||
{
|
||||
@@ -140,6 +141,18 @@ void draw(DrawData& drawData, ApplicationData& appData)
|
||||
glfwGetMonitorWorkarea(glfwGetPrimaryMonitor(), &monitorX, &monitorY, &monitorW, &monitorH);
|
||||
glfwSetWindowPos(drawData.window, monitorX + monitorW - drawData.window_size.x, monitorY + monitorH - drawData.window_size.y);
|
||||
}
|
||||
|
||||
if (appData.hoverTargetType == HoverTargetType::HOVER_TARGET_CHECKLIST_DAY)
|
||||
{
|
||||
tm time_tm;
|
||||
localtime_s(&time_tm, &appData.hoverTargetDay);
|
||||
|
||||
ImGui::BeginTooltip();
|
||||
char timeStr[32];
|
||||
strftime(timeStr, 32, "%d.%m", &time_tm);
|
||||
ImGui::Text(timeStr);
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
void cleanup(DrawData& drawData, ApplicationData& appData)
|
||||
@@ -266,6 +279,12 @@ void drawDayLineButton(ApplicationData& appData, ImDrawList* drawList, float lin
|
||||
selectedDay = day;
|
||||
}
|
||||
ImGui::SetCursorScreenPos(pos);
|
||||
|
||||
if (ImGui::IsMouseHoveringRect(startPos, endPos, false))
|
||||
{
|
||||
appData.hoverTargetType = HoverTargetType::HOVER_TARGET_CHECKLIST_DAY;
|
||||
appData.hoverTargetDay = day;
|
||||
}
|
||||
}
|
||||
|
||||
ImVec2 checklistWindow(ApplicationData& appData, const char* title)
|
||||
@@ -308,6 +327,16 @@ ImVec2 checklistWindow(ApplicationData& appData, const char* title)
|
||||
std::vector<time_t>& taskDates = appData.settings.tasks[taskName];
|
||||
bool taskDone = std::any_of(taskDates.begin(), taskDates.end(), selectedDayMatcher);
|
||||
|
||||
bool highlightButton = std::all_of(taskDates.begin(), taskDates.end(), [&](time_t t) {
|
||||
double timeDiffSeconds = difftime(today, getDayStartOf(t));
|
||||
return timeDiffSeconds >= appData.checklistHighlightDurationDays * 24 * 60 * 60 + 1;
|
||||
});
|
||||
if (highlightButton)
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg, { .5f, .2f, .15f, 0.54f });
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgActive, { .6f, .3f, .2f, 0.40f });
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, { .6f, .3f, .2f, 0.67f });
|
||||
}
|
||||
if (ImGui::Checkbox(taskName.c_str(), &taskDone))
|
||||
{
|
||||
if (taskDone)
|
||||
@@ -319,8 +348,22 @@ ImVec2 checklistWindow(ApplicationData& appData, const char* title)
|
||||
std::erase_if(taskDates, selectedDayMatcher);
|
||||
}
|
||||
}
|
||||
if (highlightButton)
|
||||
{
|
||||
ImGui::PopStyleColor(3);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
}
|
||||
|
||||
if (ImGui::SmallButton(ICON_SETTINGS_FILL))
|
||||
{
|
||||
ImGui::OpenPopup("checklist settings");
|
||||
}
|
||||
if (ImGui::BeginPopup("checklist settings"))
|
||||
{
|
||||
ImGui::DragInt("Task highlight duration", &appData.checklistHighlightDurationDays, .05f, 1, 7, "%d days");
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
ImVec2 size = ImGui::GetWindowSize();
|
||||
|
||||
Reference in New Issue
Block a user