2013-08-09 00:01:20 +00:00
|
|
|
// Aseprite UI Library
|
2015-05-05 22:14:33 +00:00
|
|
|
// Copyright (C) 2001-2013, 2015 David Capello
|
2010-09-27 22:18:17 +00:00
|
|
|
//
|
2014-03-29 23:08:05 +00:00
|
|
|
// 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
|
|
|
|
2013-08-06 00:20:19 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2009-07-12 20:29:16 +00:00
|
|
|
#include "config.h"
|
2013-08-06 00:20:19 +00:00
|
|
|
#endif
|
2009-07-12 20:29:16 +00:00
|
|
|
|
2012-06-18 01:49:58 +00:00
|
|
|
#include "ui/manager.h"
|
|
|
|
#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
|
|
|
|
2012-06-16 02:37:59 +00:00
|
|
|
#include <list>
|
|
|
|
|
2012-06-18 01:02:54 +00:00
|
|
|
namespace ui {
|
|
|
|
|
2012-06-16 02:37:59 +00:00
|
|
|
static std::list<Widget*>* widgets;
|
2009-08-05 01:53:02 +00:00
|
|
|
|
2015-06-23 17:14:06 +00:00
|
|
|
int init_widgets()
|
2009-08-05 01:53:02 +00:00
|
|
|
{
|
2012-06-16 02:37:59 +00:00
|
|
|
widgets = new std::list<Widget*>;
|
2009-08-05 01:53:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-23 17:14:06 +00:00
|
|
|
void exit_widgets()
|
2009-08-05 01:53:02 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2012-06-16 02:37:59 +00:00
|
|
|
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
|
|
|
{
|
2015-05-05 22:14:33 +00:00
|
|
|
auto it = std::find(widgets->begin(), widgets->end(), widget);
|
2012-06-16 02:37:59 +00:00
|
|
|
if (it != widgets->end())
|
|
|
|
widgets->erase(it);
|
2007-09-18 23:57:02 +00:00
|
|
|
}
|
|
|
|
|
2015-05-05 22:14:33 +00:00
|
|
|
void resetFontAllWidgets()
|
2007-09-18 23:57:02 +00:00
|
|
|
{
|
2015-05-05 22:14:33 +00:00
|
|
|
for (auto widget : *widgets)
|
|
|
|
widget->resetFont();
|
2010-03-09 02:43:28 +00:00
|
|
|
}
|
|
|
|
|
2013-03-30 16:38:24 +00:00
|
|
|
void reinitThemeForAllWidgets()
|
2010-03-09 02:43:28 +00:00
|
|
|
{
|
2012-06-16 02:37:59 +00:00
|
|
|
// Reinitialize the theme of each widget
|
2015-05-05 22:14:33 +00:00
|
|
|
for (auto widget : *widgets) {
|
|
|
|
widget->setTheme(CurrentTheme::get());
|
|
|
|
widget->initTheme();
|
|
|
|
}
|
2007-09-18 23:57:02 +00:00
|
|
|
|
2010-03-09 02:43:28 +00:00
|
|
|
// Remap the windows
|
2015-05-05 22:14:33 +00:00
|
|
|
for (auto widget : *widgets) {
|
|
|
|
if (widget->type == kWindowWidget)
|
|
|
|
static_cast<Window*>(widget)->remapWindow();
|
2012-06-16 02:37:59 +00:00
|
|
|
}
|
2007-09-18 23:57:02 +00:00
|
|
|
|
2012-04-15 18:21:24 +00:00
|
|
|
// Redraw the whole screen
|
2012-06-18 01:02:54 +00:00
|
|
|
Manager::getDefault()->invalidate();
|
2007-09-18 23:57:02 +00:00
|
|
|
}
|
2012-06-18 01:02:54 +00:00
|
|
|
|
|
|
|
} // namespace ui
|