Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Copyright (C) 2017 Jules de Cube
- juleslefebvre.pro@outlook.fr
- Created by Jules de Cube
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- '''
- bl_info = {
- "name": "Rainbow theme",
- "description": "change color",
- "author": "Jules de Cube",
- "version": (1, 0, 0),
- "blender": (2, 78, 0),
- "location": "Info > File",
- "warning": "This addon is still in development.",
- "wiki_url": "",
- "category": "System" }
- import colorsys
- import bpy
- from bpy.types import Operator, AddonPreferences
- from bpy.props import StringProperty, IntProperty, BoolProperty , FloatProperty
- class AddonPreferences(AddonPreferences):
- bl_idname = __name__
- RT_loop_time = FloatProperty(
- name="Hue incremental",
- default=2,
- min = 0.00
- )
- def draw(self, context):
- layout = self.layout
- layout.label(text="is a preferences view for our addon")
- layout.prop(self, "RT_loop_time")
- # load and reload submodules
- ##################################
- class ModalTimerOperator(bpy.types.Operator):
- """Operator which runs its self from a timer"""
- bl_idname = "wm.modal_timer_operator"
- bl_label = "Modal Timer Operator"
- _timer = None
- def modal(self, context, event):
- addon_prefs = context.user_preferences.addons[__name__].preferences
- if event.type == 'TIMER':
- ui = bpy.context.user_preferences.themes[0].user_interface
- bpy.context.window_manager.RT_hue = bpy.context.window_manager.RT_hue + (0.05 / addon_prefs.RT_loop_time)
- color_rgb = colorsys.hsv_to_rgb(bpy.context.window_manager.RT_hue,1,1)
- color_rgba = (color_rgb[0], color_rgb[1], color_rgb[2], 1)
- ui.wcol_regular.inner_sel = color_rgba
- ui.wcol_tool.inner_sel = color_rgba
- ui.wcol_radio.inner_sel = color_rgba
- ui.wcol_text.item = color_rgba
- ui.wcol_option.item = color_rgba
- ui.wcol_toggle.inner_sel = color_rgba
- ui.wcol_num.item = color_rgba
- ui.wcol_numslider.item = color_rgba
- ui.wcol_box.inner_sel = color_rgba
- ui.wcol_menu.item = color_rgba
- ui.wcol_pie_menu.inner_sel = color_rgba
- ui.wcol_pulldown.inner_sel = color_rgba
- ui.wcol_menu_back.item = color_rgba
- ui.wcol_tooltip.inner_sel = color_rgba
- ui.wcol_menu_item.inner_sel = color_rgba
- ui.wcol_scroll.inner_sel = color_rgba
- ui.wcol_progress.item = color_rgba
- ui.wcol_list_item.inner_sel = color_rgba
- return {'PASS_THROUGH'}
- def execute(self, context):
- wm = context.window_manager
- self._timer = wm.event_timer_add(0.05 , context.window)
- wm.modal_handler_add(self)
- return {'RUNNING_MODAL'}
- def cancel(self, context):
- wm = context.window_manager
- wm.event_timer_remove(self._timer)
- # register
- ##################################
- import traceback
- def register():
- bpy.utils.register_class(ModalTimerOperator)
- bpy.utils.register_class(AddonPreferences)
- bpy.types.WindowManager.RT_hue = bpy.props.FloatProperty(default = 0.0)
- def unregister():
- bpy.utils.unregister_class(ModalTimerOperator)
- bpy.utils.unregister_class(AddonPreferences)
- del bpy.types.WindowManager.RT_hue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement