ui stuff + clear notifications

This commit is contained in:
2023-04-02 16:29:35 +02:00
parent 537cd2cbdf
commit 708371a3d1
4 changed files with 63 additions and 22 deletions

View File

@@ -378,6 +378,7 @@ ImVec2 timerWindow(DrawData& drawData, ApplicationData& appData)
// Draw window
if (ImGui::Begin(title.c_str(), 0, ImGuiWindowFlags_NoResize))
{
dropShadowWindowTitle();
if (windowHeaderButton(ICON_SETTINGS_FILL))
{
ImGui::OpenPopup(SETTINGS_POPUP_NAME);
@@ -426,6 +427,7 @@ ImVec2 timerWindow(DrawData& drawData, ApplicationData& appData)
else
{
timerData.isTimerActive = false;
WinToast::instance()->clear();
}
}
@@ -541,6 +543,7 @@ ImVec2 checklistWindow(ApplicationData& appData, const char* title)
{
if (ImGui::Begin(title, 0, ImGuiWindowFlags_NoResize))
{
dropShadowWindowTitle();
if (windowHeaderButton(ICON_SETTINGS_FILL))
{
ImGui::OpenPopup(SETTINGS_POPUP_NAME);
@@ -731,6 +734,7 @@ ImVec2 baseStationWindow(ApplicationData& appData)
{
if (ImGui::Begin(std::format("{} Base Stations", ICON_ALARM_WARNING_FILL).c_str(), 0, ImGuiWindowFlags_NoResize))
{
dropShadowWindowTitle();
if (windowHeaderButton(ICON_SETTINGS_FILL))
{
ImGui::OpenPopup(SETTINGS_POPUP_NAME);
@@ -780,6 +784,7 @@ ImVec2 audioDeviceWindow(ApplicationData& appData, std::vector<AudioDevice>& dev
{
if (ImGui::Begin(title, 0, ImGuiWindowFlags_NoResize))
{
dropShadowWindowTitle();
if (windowHeaderButton(ICON_SETTINGS_FILL))
{
ImGui::OpenPopup(SETTINGS_POPUP_NAME);
@@ -791,7 +796,8 @@ ImVec2 audioDeviceWindow(ApplicationData& appData, std::vector<AudioDevice>& dev
ImGui::TableSetupColumn("Volume", ImGuiTableColumnFlags_WidthStretch, 1.);
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, getButtonWidth(ICON_MUSIC_2_FILL));
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, getButtonWidth(ICON_PHONE_FILL));
ImGui::TableHeadersRow();
dropShadowTableHeadersRow();
for (auto& dev : deviceList)
{

View File

@@ -179,7 +179,7 @@ void setAutostart(bool newValue)
void loadUiStyle()
{
ImGuiStyle& style = ImGui::GetStyle();
style.WindowPadding = { 6.f, 12.f };
style.WindowPadding = { 10.f, 14.f };
style.WindowBorderSize = 0.f;
style.FramePadding = { 8.f, 4.f };

View File

@@ -575,31 +575,62 @@ ImVec2 getWindowSize(GLFWwindow* window)
void dropShadow()
{
dropShadow(DEFAULT_DROP_SHADOW_SIZE, ImGui::GetStyle().Colors[DEFAULT_DROP_SHADOW_COLOR_ID]);
dropShadow(DEFAULT_DROP_SHADOW_SIZE, DEFAULT_DROP_SHADOW_SIZE, ImGui::GetStyle().Colors[DEFAULT_DROP_SHADOW_COLOR_ID]);
}
void dropShadow(const float shadowSize, const ImColor& color)
void dropShadow(const float shadowSizeX, const float shadowSizeY, const ImColor& color)
{
ImVec2 lastMin = ImGui::GetItemRectMin();
ImVec2 lastMax = ImGui::GetItemRectMax();
renderDropShadow(shadowSize, lastMin, lastMax, color);
renderDropShadow(shadowSizeX, shadowSizeY, lastMin, lastMax, color);
}
void renderDropShadow(const float shadowSize, const ImVec2& min, const ImVec2& max, const ImColor& color)
void renderDropShadow(const float shadowSizeX, const float shadowSizeY, const ImVec2& min, const ImVec2& max, const ImColor& color)
{
ImDrawList* windowDrawList = ImGui::GetWindowDrawList();
if (shadowSizeY > 0.f)
{
windowDrawList->AddQuadFilled(
{ min.x, max.y },
{ max.x, max.y },
{ max.x + shadowSize, max.y + shadowSize },
{ min.x + shadowSize, max.y + shadowSize },
{ max.x + shadowSizeX, max.y + shadowSizeY },
{ min.x + shadowSizeX, max.y + shadowSizeY },
color);
}
if (shadowSizeX > 0.f)
{
windowDrawList->AddQuadFilled(
{ max.x, min.y },
{ max.x + shadowSize, min.y + shadowSize },
{ max.x + shadowSize, max.y + shadowSize },
{ max.x + shadowSizeX, min.y + shadowSizeY },
{ max.x + shadowSizeX, max.y + shadowSizeY },
{ max.x, max.y },
color);
}
}
void dropShadowTableHeadersRow()
{
ImGui::TableNextRow();
ImVec2 startPos = {};
for (int i = 0; i < ImGui::TableGetColumnCount(); i++)
{
ImGui::TableSetColumnIndex(i);
ImGui::TableHeader(ImGui::TableGetColumnName());
if (i == 0) startPos = ImGui::GetItemRectMin();
}
renderDropShadow(DEFAULT_DROP_SHADOW_SIZE, DEFAULT_DROP_SHADOW_SIZE, startPos, ImGui::GetItemRectMax(), ImGui::GetStyle().Colors[DEFAULT_DROP_SHADOW_COLOR_ID]);
}
void dropShadowWindowTitle()
{
ImRect tempRect = ImGui::GetCurrentWindow()->ClipRect;
ImGui::PopClipRect();
dropShadow(0., 4., { .2f, .2f, .2f, .5f });
ImGui::PushClipRect(tempRect.Min, tempRect.Max, false);
}
bool dropButton(const char* label, const ImVec2& size, float shadowSize, bool smallButton)
@@ -630,7 +661,9 @@ bool dropButton(const char* label, const ImVec2& size, float shadowSize, bool sm
ImGui::RenderFrame(rectMin, rectMax, col, true, style.FrameRounding);
ImGui::RenderTextClipped(rectMin, rectMax, label, NULL, &labelSize, style.ButtonTextAlign);
renderDropShadow(held ? 1.f : shadowSize, rectMin, rectMax, ImGui::GetStyle().Colors[DEFAULT_DROP_SHADOW_COLOR_ID]);
float realShadowSize = held ? 1.f : shadowSize;
renderDropShadow(realShadowSize, realShadowSize, rectMin, rectMax, ImGui::GetStyle().Colors[DEFAULT_DROP_SHADOW_COLOR_ID]);
style.FramePadding = backupPadding;
return result;
@@ -645,7 +678,7 @@ bool checkboxWithDropShadow(const char* label, bool* v, const float shadowSize)
style.ItemInnerSpacing.x = oldSpacingX;
ImVec2 lastMin = ImGui::GetItemRectMin();
renderDropShadow(shadowSize, lastMin, lastMin + ImVec2{ ImGui::GetFrameHeight(), ImGui::GetFrameHeight() }, ImGui::GetStyle().Colors[DEFAULT_DROP_SHADOW_COLOR_ID]);
renderDropShadow(shadowSize, shadowSize, lastMin, lastMin + ImVec2{ ImGui::GetFrameHeight(), ImGui::GetFrameHeight() }, ImGui::GetStyle().Colors[DEFAULT_DROP_SHADOW_COLOR_ID]);
return result;
}

View File

@@ -62,9 +62,11 @@ constexpr float DEFAULT_DROP_SHADOW_SIZE = 3.f;
constexpr ImGuiCol DEFAULT_DROP_SHADOW_COLOR_ID = ImGuiCol_TabUnfocused;
void dropShadow();
void dropShadow(const float shadowSize, const ImColor& color);
void renderDropShadow(const float shadowSize, const ImVec2& min, const ImVec2& max, const ImColor& color);
void dropShadow(const float shadowSizeX, const float shadowSizeY, const ImColor& color);
void renderDropShadow(const float shadowSizeX, const float shadowSizeY, const ImVec2& min, const ImVec2& max, const ImColor& color);
void dropShadowTableHeadersRow();
void dropShadowWindowTitle();
bool dropButton(const char* label, const ImVec2& size = ImVec2(0, 0), float shadowSize = DEFAULT_DROP_SHADOW_SIZE, bool smallButton = false);
bool checkboxWithDropShadow(const char* label, bool* v, const float shadowSize = DEFAULT_DROP_SHADOW_SIZE);