aseprite/src/ui/intern.cpp

69 lines
1.1 KiB
C++
Raw Normal View History

// Aseprite UI Library
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
2007-09-18 23:57:02 +00:00
#ifdef HAVE_CONFIG_H
2009-07-12 20:29:16 +00:00
#include "config.h"
#endif
2009-07-12 20:29:16 +00:00
2012-06-18 01:49:58 +00:00
#include "ui/manager.h"
#include "ui/system.h"
2012-06-18 01:49:58 +00:00
#include "ui/theme.h"
#include "ui/widget.h"
2012-07-09 02:24:42 +00:00
#include "ui/window.h"
2007-09-18 23:57:02 +00:00
#include <list>
namespace ui {
namespace details {
static std::list<Widget*>* widgets;
void initWidgets()
{
assert_ui_thread();
widgets = new std::list<Widget*>;
}
void exitWidgets()
{
assert_ui_thread();
delete widgets;
}
2007-09-18 23:57:02 +00:00
2013-03-30 16:38:24 +00:00
void addWidget(Widget* widget)
2007-09-18 23:57:02 +00:00
{
assert_ui_thread();
widgets->push_back(widget);
2007-09-18 23:57:02 +00:00
}
2013-03-30 16:38:24 +00:00
void removeWidget(Widget* widget)
2007-09-18 23:57:02 +00:00
{
assert_ui_thread();
ASSERT(!Manager::widgetAssociatedToManager(widget));
auto it = std::find(widgets->begin(), widgets->end(), widget);
if (it != widgets->end())
widgets->erase(it);
2007-09-18 23:57:02 +00:00
}
2013-03-30 16:38:24 +00:00
void reinitThemeForAllWidgets()
{
assert_ui_thread();
// Reinitialize the theme of each widget
auto theme = get_theme();
for (auto widget : *widgets)
widget->setTheme(theme);
2007-09-18 23:57:02 +00:00
}
} // namespace details
} // namespace ui