diff --git a/include/custom_widgets.h b/include/custom_widgets.h new file mode 100644 index 0000000..ec4e8a3 --- /dev/null +++ b/include/custom_widgets.h @@ -0,0 +1,5 @@ + +#include +#include + +void batteryIcon(ImVec2 pos,bool absolute,uint32_t batlevel); \ No newline at end of file diff --git a/source/UI/custom_widgets.cpp b/source/UI/custom_widgets.cpp new file mode 100644 index 0000000..1356262 --- /dev/null +++ b/source/UI/custom_widgets.cpp @@ -0,0 +1,27 @@ +#include "custom_widgets.h" + +void batteryIcon(ImVec2 pos,bool absolute,uint32_t batlevel){ + + ImVec2 iconsize = ImVec2(50.0f, 20.0f); + + ImVec2 canvas_p0 = ImGui::GetCursorScreenPos(); + if(absolute){ + canvas_p0 = pos; + } + ImVec2 canvas_pnew = ImVec2(canvas_p0.x+3.0,canvas_p0.y+3.0f); + ImVec2 canvas_p1 = ImVec2(canvas_p0.x+iconsize.x, canvas_p0.y + iconsize.y); + ImVec2 batteryfill = ImVec2(canvas_p0.x+(float)batlevel*(iconsize.x-3.0f)/100.0f, canvas_p0.y-3.0 + iconsize.y); + ImVec2 batteryicon_p0 = ImVec2(canvas_p1.x,canvas_p0.y+5.0f); + ImVec2 batteryicon_p1 = ImVec2(canvas_p1.x+5.0,canvas_p0.y+15.0f); + + + + //ImDrawList* draw_list = ImGui::GetWindowDrawList(); + ImGui::GetForegroundDrawList()->AddRectFilled(canvas_p0, canvas_p1, IM_COL32(0, 0, 0, 255)); + ImGui::GetForegroundDrawList()->AddRectFilled(canvas_pnew, batteryfill, IM_COL32(50, 255, 50, 255)); + ImGui::GetForegroundDrawList()->AddRect(canvas_p0, canvas_p1, IM_COL32(255, 255, 255, 255)); + + ImGui::GetForegroundDrawList()->AddRectFilled(batteryicon_p0, batteryicon_p1, IM_COL32(255, 255, 255, 255)); + + +} \ No newline at end of file diff --git a/source/UI/mainMenu.cpp b/source/UI/mainMenu.cpp index faf812f..433e1ca 100644 --- a/source/UI/mainMenu.cpp +++ b/source/UI/mainMenu.cpp @@ -7,10 +7,13 @@ #include "Enigma2.h" #include "curldownloader.h" +#include "custom_widgets.h" + namespace Windows { void MainMenuWindow(bool *focus, bool *first_item) { Windows::SetupMainWindow(); std::vector topmenu = configini->topmenu; + batteryIcon(ImVec2(1200.0f,5.0f),true,35); if (ImGui::Begin(nxmpTitle.c_str(), nullptr, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse)) { static int selected = -1; for (unsigned int n = 0; n < topmenu.size(); n++){ @@ -170,8 +173,11 @@ namespace Windows { g.NavDisableMouseHover = true; *first_item = false; } + } + Windows::ExitMainWindow(); + } } \ No newline at end of file