Merge pull request #25308 from supagu/theme-fix
Added copy_theme and fixed bugs in copy theme introduced by #2e0a94e
This commit is contained in:
commit
00ec3e9d2a
2 changed files with 18 additions and 12 deletions
|
@ -622,43 +622,47 @@ void Theme::clear() {
|
||||||
void Theme::copy_default_theme() {
|
void Theme::copy_default_theme() {
|
||||||
|
|
||||||
Ref<Theme> default_theme = get_default();
|
Ref<Theme> default_theme = get_default();
|
||||||
|
copy_theme(default_theme);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Theme::copy_theme(const Ref<Theme> &p_other) {
|
||||||
|
|
||||||
//these need reconnecting, so add normally
|
//these need reconnecting, so add normally
|
||||||
{
|
{
|
||||||
const StringName *K = NULL;
|
const StringName *K = NULL;
|
||||||
while ((K = default_theme->icon_map.next(K))) {
|
while ((K = p_other->icon_map.next(K))) {
|
||||||
const StringName *L = NULL;
|
const StringName *L = NULL;
|
||||||
while ((L = default_theme->icon_map[*K].next(L))) {
|
while ((L = p_other->icon_map[*K].next(L))) {
|
||||||
set_icon(*K, *L, default_theme->icon_map[*K][*L]);
|
set_icon(*L, *K, p_other->icon_map[*K][*L]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const StringName *K = NULL;
|
const StringName *K = NULL;
|
||||||
while ((K = default_theme->style_map.next(K))) {
|
while ((K = p_other->style_map.next(K))) {
|
||||||
const StringName *L = NULL;
|
const StringName *L = NULL;
|
||||||
while ((L = default_theme->style_map[*K].next(L))) {
|
while ((L = p_other->style_map[*K].next(L))) {
|
||||||
set_stylebox(*K, *L, default_theme->style_map[*K][*L]);
|
set_stylebox(*L, *K, p_other->style_map[*K][*L]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const StringName *K = NULL;
|
const StringName *K = NULL;
|
||||||
while ((K = default_theme->font_map.next(K))) {
|
while ((K = p_other->font_map.next(K))) {
|
||||||
const StringName *L = NULL;
|
const StringName *L = NULL;
|
||||||
while ((L = default_theme->font_map[*K].next(L))) {
|
while ((L = p_other->font_map[*K].next(L))) {
|
||||||
set_font(*K, *L, default_theme->font_map[*K][*L]);
|
set_font(*L, *K, p_other->font_map[*K][*L]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//these are ok to just copy
|
//these are ok to just copy
|
||||||
|
|
||||||
color_map = default_theme->color_map;
|
color_map = p_other->color_map;
|
||||||
constant_map = default_theme->constant_map;
|
constant_map = p_other->constant_map;
|
||||||
shader_map = default_theme->shader_map;
|
shader_map = p_other->shader_map;
|
||||||
|
|
||||||
_change_notify();
|
_change_notify();
|
||||||
emit_changed();
|
emit_changed();
|
||||||
|
@ -752,6 +756,7 @@ void Theme::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("_emit_theme_changed"), &Theme::_emit_theme_changed);
|
ClassDB::bind_method(D_METHOD("_emit_theme_changed"), &Theme::_emit_theme_changed);
|
||||||
|
|
||||||
ClassDB::bind_method("copy_default_theme", &Theme::copy_default_theme);
|
ClassDB::bind_method("copy_default_theme", &Theme::copy_default_theme);
|
||||||
|
ClassDB::bind_method("copy_theme", &Theme::copy_theme);
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "default_font", PROPERTY_HINT_RESOURCE_TYPE, "Font"), "set_default_font", "get_default_font");
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "default_font", PROPERTY_HINT_RESOURCE_TYPE, "Font"), "set_default_font", "get_default_font");
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,6 +184,7 @@ public:
|
||||||
void get_type_list(List<StringName> *p_list) const;
|
void get_type_list(List<StringName> *p_list) const;
|
||||||
|
|
||||||
void copy_default_theme();
|
void copy_default_theme();
|
||||||
|
void copy_theme(const Ref<Theme> &p_other);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
Theme();
|
Theme();
|
||||||
|
|
Loading…
Add table
Reference in a new issue