opuntiaOS - an operating system targeting x86 and ARMv7
at master 47 lines 1.6 kB view raw
1/* 2 * Copyright (C) 2020-2022 The opuntiaOS Project Authors. 3 * + Contributed by Nikita Melekhin <nimelehin@gmail.com> 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9#include "LoadingScreen.h" 10#include <libg/Context.h> 11#include <libg/ImageLoaders/PNGLoader.h> 12 13namespace WinServer { 14 15LoadingScreen* s_WinServer_LoadingScreen_the = nullptr; 16 17LoadingScreen::LoadingScreen() 18 : m_screen(Screen::the()) 19{ 20 s_WinServer_LoadingScreen_the = this; 21 22 LG::PNG::PNGLoader loader; 23 m_logo = loader.load_from_file("/res/system/logo_dark_128.png"); 24 25 int content_min_x = m_screen.bounds().mid_x() - (m_logo.bounds().width() / 2); 26 int content_min_y = m_screen.bounds().mid_y() - ((m_logo.bounds().height() + progress_line_height()) / 2); 27 28 m_progress_line_min_x = m_screen.bounds().mid_x() - (progress_line_width() / 2); 29 m_progress_line_min_y = content_min_y + m_logo.bounds().height(); 30 31 LG::Context ctx(m_screen.display_bitmap()); 32 ctx.draw({ content_min_x, content_min_y }, m_logo); 33} 34 35void LoadingScreen::display_status_bar(int progress, int out_of) 36{ 37 LG::Context ctx(m_screen.display_bitmap()); 38 int widthp = (progress * progress_line_width()) / out_of; 39 40 ctx.set_fill_color(LG::Color(20, 20, 20)); 41 ctx.fill_rounded(LG::Rect(m_progress_line_min_x, m_progress_line_min_y, progress_line_width(), progress_line_height()), LG::CornerMask(4)); 42 43 ctx.set_fill_color(LG::Color::White); 44 ctx.fill_rounded(LG::Rect(m_progress_line_min_x, m_progress_line_min_y, widthp, progress_line_height()), LG::CornerMask(4)); 45} 46 47} // namespace WinServer