#pragma once // MassBuilderSaveTool // Copyright (C) 2021-2022 Guillaume Jacquemin // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . #include #include #include #include #include using namespace Corrade; using namespace Magnum; class Toast { public: enum class Type : UnsignedByte { Default, Success, Info, Warning, Error }; enum class Phase : UnsignedByte { FadeIn, Wait, FadeOut, TimedOut }; explicit Toast(Type type, Containers::StringView message, std::chrono::milliseconds timeout = std::chrono::milliseconds{3000}); Toast(const Toast& other) = delete; Toast& operator=(const Toast& other) = delete; Toast(Toast&& other) = default; Toast& operator=(Toast&& other) = default; auto type() -> Type; auto message() -> Containers::StringView; auto timeout() -> std::chrono::milliseconds; auto creationTime() -> std::chrono::steady_clock::time_point; auto elapsedTime() -> std::chrono::milliseconds; auto phase() -> Phase; auto opacity() -> Float; private: Type _type{Type::Default}; Containers::String _message; std::chrono::milliseconds _timeout; std::chrono::steady_clock::time_point _creationTime; Animation::Track _phaseTrack; }; class ToastQueue { public: void addToast(Toast&& toast); void addToast(Toast::Type type, Containers::StringView message, std::chrono::milliseconds timeout = std::chrono::milliseconds{3000}); void draw(Vector2i viewport_size); private: void removeToast(Long index); std::vector _toasts; };