mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-27 11:37:39 +00:00
Replace ui::CurrentTheme with ui::set/get_theme()
This commit is contained in:
parent
d9817b888c
commit
6c9c0066a0
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -40,8 +40,7 @@ RefreshCommand::RefreshCommand()
|
||||
|
||||
void RefreshCommand::onExecute(Context* context)
|
||||
{
|
||||
ui::CurrentTheme::get()->regenerate();
|
||||
|
||||
ui::get_theme()->regenerate();
|
||||
app_refresh_screen();
|
||||
|
||||
// Print memory information
|
||||
|
@ -185,7 +185,7 @@ int init_module_gui()
|
||||
// Setup the GUI theme for all widgets
|
||||
gui_theme = new SkinTheme();
|
||||
gui_theme->setScale(Preferences::instance().general.uiScale());
|
||||
CurrentTheme::set(gui_theme);
|
||||
ui::set_theme(gui_theme);
|
||||
|
||||
if (maximized)
|
||||
main_display->maximize();
|
||||
@ -204,7 +204,7 @@ void exit_module_gui()
|
||||
delete manager;
|
||||
|
||||
// Now we can destroy theme
|
||||
CurrentTheme::set(NULL);
|
||||
ui::set_theme(nullptr);
|
||||
delete gui_theme;
|
||||
|
||||
main_display->dispose();
|
||||
|
@ -746,7 +746,7 @@ void StandbyState::Decorator::postRenderDecorator(EditorPostRender* render)
|
||||
// Draw transformation handles (if the mask is visible and isn't frozen).
|
||||
gfx::Rect box1, box2;
|
||||
if (StandbyState::Decorator::getSymmetryHandles(editor, box1, box2)) {
|
||||
skin::SkinTheme* theme = static_cast<skin::SkinTheme*>(CurrentTheme::get());
|
||||
skin::SkinTheme* theme = static_cast<skin::SkinTheme*>(ui::get_theme());
|
||||
she::Surface* part = theme->parts.transformationHandle()->bitmap(0);
|
||||
ScreenGraphics g;
|
||||
g.drawRgbaSurface(part, box1.x, box1.y);
|
||||
@ -777,7 +777,7 @@ bool StandbyState::Decorator::getSymmetryHandles(Editor* editor, gfx::Rect& box1
|
||||
symmetry.yAxis());
|
||||
gfx::RectF spriteBounds = gfx::RectF(editor->sprite()->bounds());
|
||||
gfx::RectF editorViewport = gfx::RectF(View::getView(editor)->viewportBounds());
|
||||
skin::SkinTheme* theme = static_cast<skin::SkinTheme*>(CurrentTheme::get());
|
||||
skin::SkinTheme* theme = static_cast<skin::SkinTheme*>(ui::get_theme());
|
||||
she::Surface* part = theme->parts.transformationHandle()->bitmap(0);
|
||||
gfx::PointF pt1, pt2;
|
||||
|
||||
|
@ -53,7 +53,7 @@ static struct HandlesInfo {
|
||||
|
||||
HandleType TransformHandles::getHandleAtPoint(Editor* editor, const gfx::Point& pt, const Transformation& transform)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(CurrentTheme::get());
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
she::Surface* gfx = theme->parts.transformationHandle()->bitmap(0);
|
||||
fixmath::fixed angle = fixmath::ftofix(128.0 * transform.angle() / PI);
|
||||
|
||||
@ -128,7 +128,7 @@ void TransformHandles::drawHandles(Editor* editor, const Transformation& transfo
|
||||
// Draw the pivot
|
||||
if (visiblePivot(angle)) {
|
||||
gfx::Rect pivotBounds = getPivotHandleBounds(editor, transform, corners);
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(CurrentTheme::get());
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
she::Surface* part = theme->parts.pivotHandle()->bitmap(0);
|
||||
|
||||
g.drawRgbaSurface(part, pivotBounds.x, pivotBounds.y);
|
||||
@ -137,7 +137,7 @@ void TransformHandles::drawHandles(Editor* editor, const Transformation& transfo
|
||||
|
||||
void TransformHandles::invalidateHandles(Editor* editor, const Transformation& transform)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(CurrentTheme::get());
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
fixmath::fixed angle = fixmath::ftofix(128.0 * transform.angle() / PI);
|
||||
|
||||
Transformation::Corners corners;
|
||||
@ -174,7 +174,7 @@ gfx::Rect TransformHandles::getPivotHandleBounds(Editor* editor,
|
||||
const Transformation& transform,
|
||||
const Transformation::Corners& corners)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(CurrentTheme::get());
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
gfx::Size partSize = theme->parts.pivotHandle()->size();
|
||||
gfx::Point screenPivotPos = editor->editorToScreen(gfx::Point(transform.pivot()));
|
||||
|
||||
@ -198,7 +198,7 @@ bool TransformHandles::inHandle(const gfx::Point& pt, int x, int y, int gfx_w, i
|
||||
|
||||
void TransformHandles::drawHandle(Graphics* g, int x, int y, fixmath::fixed angle)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(CurrentTheme::get());
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
she::Surface* part = theme->parts.transformationHandle()->bitmap(0);
|
||||
|
||||
adjustHandle(x, y, part->width(), part->height(), angle);
|
||||
|
@ -205,7 +205,7 @@ void SkinTheme::onRegenerate()
|
||||
catch (const std::exception& e) {
|
||||
LOG("SKIN: Error loading user-theme: %s\n", e.what());
|
||||
|
||||
if (CurrentTheme::get())
|
||||
if (ui::get_theme())
|
||||
Console::showException(e);
|
||||
|
||||
// We can continue, as we've already loaded the default theme
|
||||
|
@ -37,7 +37,7 @@ void Rule::paint(ui::Graphics* g,
|
||||
|
||||
void BackgroundRule::onPaint(ui::Graphics* g, const gfx::Rect& bounds, const char* text)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(ui::CurrentTheme::get());
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
|
||||
if (m_part && m_part->countBitmaps() > 0) {
|
||||
if (m_part->countBitmaps() == 1) {
|
||||
@ -76,7 +76,7 @@ void BackgroundRule::onPaint(ui::Graphics* g, const gfx::Rect& bounds, const cha
|
||||
|
||||
void TextRule::onPaint(ui::Graphics* g, const gfx::Rect& bounds, const char* text)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(ui::CurrentTheme::get());
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
|
||||
if (text) {
|
||||
g->drawAlignedUIText(text,
|
||||
|
@ -445,7 +445,7 @@ gfx::Size Graphics::doUIStringAlgorithm(const std::string& str, gfx::Color fg, g
|
||||
ScreenGraphics::ScreenGraphics()
|
||||
: Graphics(she::instance()->defaultDisplay()->getSurface(), 0, 0)
|
||||
{
|
||||
setFont(CurrentTheme::get()->getDefaultFont());
|
||||
setFont(get_theme()->getDefaultFont());
|
||||
}
|
||||
|
||||
ScreenGraphics::~ScreenGraphics()
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2001-2013, 2015 David Capello
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -52,7 +52,7 @@ void reinitThemeForAllWidgets()
|
||||
{
|
||||
// Reinitialize the theme of each widget
|
||||
for (auto widget : *widgets) {
|
||||
widget->setTheme(CurrentTheme::get());
|
||||
widget->setTheme(get_theme());
|
||||
widget->initTheme();
|
||||
}
|
||||
|
||||
|
@ -151,8 +151,8 @@ static void update_mouse_cursor()
|
||||
// Use a custom cursor
|
||||
if (nativeCursor == she::kNoCursor &&
|
||||
mouse_cursor_type != ui::kOutsideDisplay &&
|
||||
CurrentTheme::get()) {
|
||||
cursor = CurrentTheme::get()->getCursor(mouse_cursor_type);
|
||||
get_theme()) {
|
||||
cursor = get_theme()->getCursor(mouse_cursor_type);
|
||||
}
|
||||
|
||||
// Try to use a custom native cursor if it's possible
|
||||
@ -179,7 +179,7 @@ UISystem::~UISystem()
|
||||
OverlayManager::destroyInstance();
|
||||
|
||||
// finish theme
|
||||
CurrentTheme::set(NULL);
|
||||
set_theme(nullptr);
|
||||
|
||||
details::exitWidgets();
|
||||
|
||||
|
@ -33,7 +33,7 @@ Theme::Theme()
|
||||
Theme::~Theme()
|
||||
{
|
||||
if (current_theme == this)
|
||||
CurrentTheme::set(NULL);
|
||||
set_theme(nullptr);
|
||||
}
|
||||
|
||||
void Theme::regenerate()
|
||||
@ -56,7 +56,7 @@ void Theme::regenerate()
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CurrentTheme::set(Theme* theme)
|
||||
void set_theme(Theme* theme)
|
||||
{
|
||||
if (theme) {
|
||||
// As the regeneration may fail, first we regenerate the theme and
|
||||
@ -74,7 +74,7 @@ void CurrentTheme::set(Theme* theme)
|
||||
}
|
||||
}
|
||||
|
||||
Theme* CurrentTheme::get()
|
||||
Theme* get_theme()
|
||||
{
|
||||
return current_theme;
|
||||
}
|
||||
|
@ -79,17 +79,13 @@ namespace ui {
|
||||
int m_guiscale;
|
||||
};
|
||||
|
||||
namespace CurrentTheme
|
||||
{
|
||||
void set(Theme* theme);
|
||||
Theme* get();
|
||||
}
|
||||
void set_theme(Theme* theme);
|
||||
Theme* get_theme();
|
||||
|
||||
// This value is a factor to multiply every screen size/coordinate.
|
||||
// Every icon/graphics/font should be scaled to this factor.
|
||||
inline int guiscale()
|
||||
{
|
||||
return CurrentTheme::get() ? CurrentTheme::get()->guiscale(): 1;
|
||||
inline int guiscale() {
|
||||
return (get_theme() ? get_theme()->guiscale(): 1);
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
@ -63,7 +63,7 @@ WidgetType register_widget_type()
|
||||
Widget::Widget(WidgetType type)
|
||||
: m_type(type)
|
||||
, m_flags(0)
|
||||
, m_theme(CurrentTheme::get())
|
||||
, m_theme(get_theme())
|
||||
, m_font(nullptr)
|
||||
, m_bgColor(gfx::ColorNone)
|
||||
, m_bounds(0, 0, 0, 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user