aboutsummaryrefslogtreecommitdiff
path: root/scene/resources/theme.cpp
diff options
context:
space:
mode:
authorMarianoGNU2015-12-20 18:21:53 -0300
committerMarianoGNU2016-01-15 17:23:19 -0300
commit1f3d6824c8db30cd5636aaa3978a953bedff4ed8 (patch)
tree970e602191846d847029fbda46d54e08a02f4da5 /scene/resources/theme.cpp
parentdc7755ffcd1e275b065d3acfcc7696697097567b (diff)
downloadgodot-1f3d6824c8db30cd5636aaa3978a953bedff4ed8.tar.gz
godot-1f3d6824c8db30cd5636aaa3978a953bedff4ed8.tar.zst
godot-1f3d6824c8db30cd5636aaa3978a953bedff4ed8.zip
Move shaders to default theme and add shader_override related methods to Control class
Diffstat (limited to 'scene/resources/theme.cpp')
-rw-r--r--scene/resources/theme.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index e2413f7d8..685b2e07e 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -266,7 +266,52 @@ void Theme::get_icon_list(StringName p_type, List<StringName> *p_list) const {
p_list->push_back(*key);
}
+
+}
+
+void Theme::set_shader(const StringName &p_name,const StringName &p_type,const Ref<Shader>& p_shader) {
+ bool new_value=!shader_map.has(p_type) || !shader_map[p_type].has(p_name);
+
+ shader_map[p_type][p_name]=p_shader;
+ if (new_value) {
+ _change_notify();
+ emit_changed();;
+ }
+}
+
+Ref<Shader> Theme::get_shader(const StringName &p_name, const StringName &p_type) const {
+ if (shader_map.has(p_type) && shader_map[p_type].has(p_name) && shader_map[p_type][p_name].is_valid()) {
+ return shader_map[p_type][p_name];
+ } else {
+ return NULL;
+ }
+}
+
+bool Theme::has_shader(const StringName &p_name, const StringName &p_type) const {
+ return (shader_map.has(p_type) && shader_map[p_type].has(p_name) && shader_map[p_type][p_name].is_valid());
+}
+
+void Theme::clear_shader(const StringName &p_name, const StringName &p_type) {
+ ERR_FAIL_COND(!shader_map.has(p_type));
+ ERR_FAIL_COND(!shader_map[p_type].has(p_name));
+
+ shader_map[p_type].erase(p_name);
+ _change_notify();
+ emit_changed();;
+}
+
+void Theme::get_shader_list(const StringName &p_type, List<StringName> *p_list) const {
+ if (!shader_map.has(p_type))
+ return;
+
+ const StringName *key=NULL;
+
+ while((key=shader_map[p_type].next(key))) {
+
+ p_list->push_back(*key);
+ }
+
}