#include "Toast.h" Toast::Toast() { InitializeCriticalSection(&m_cs); } Toast::~Toast() { EnterCriticalSection(&m_cs); while (!m_ToastList.empty()) { ToastBean* temp=m_ToastList.front(); delete temp; m_ToastList.pop_front(); } LeaveCriticalSection(&m_cs); DeleteCriticalSection(&m_cs); } void Toast::AddToast(ToastBean* tbean) { EnterCriticalSection(&m_cs); if (m_ToastList.size() < 100) { bool isfind = false; for (list::iterator it = m_ToastList.begin(); it != m_ToastList.end(); it++) { ToastBean* temp = (*it); if (temp->content==tbean->content) { isfind = true; break; } } if (!isfind)m_ToastList.push_back(tbean); } LeaveCriticalSection(&m_cs); } ToastBean* Toast::GetToast() { ToastBean* bean = NULL; EnterCriticalSection(&m_cs); while (!m_ToastList.empty()) { ToastBean* temp=m_ToastList.front(); if ((temp->liveEnd-temp->liveBegin) > temp->duration) { m_ToastList.pop_front(); delete temp; temp = NULL; } else { bean = temp; break; } } LeaveCriticalSection(&m_cs); return bean; } const ImVec4 Toast::COLOR_ORANGE(1.0f, 0.4f, 0.0f, 1.0f); const ImVec4 Toast::COLOR_RED(1.0f, 0.0f, 0.0f, 1.0f); const ImVec4 Toast::COLOR_GREEN(0.0f, 1.0f, 0.0f, 1.0f);