Advertisement
Jules_de_Cube

Rainbow theme_001

Aug 29th, 2017
565
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.04 KB | None | 0 0
  1. '''
  2. Copyright (C) 2017 Jules de Cube
  3. juleslefebvre.pro@outlook.fr
  4.  
  5. Created by Jules de Cube
  6.  
  7.    This program is free software: you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License as published by
  9.    the Free Software Foundation, either version 3 of the License, or
  10.    (at your option) any later version.
  11.  
  12.    This program is distributed in the hope that it will be useful,
  13.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.    GNU General Public License for more details.
  16.  
  17.    You should have received a copy of the GNU General Public License
  18.    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19. '''
  20.  
  21. bl_info = {
  22.     "name": "Rainbow theme",
  23.     "description": "change color",
  24.     "author": "Jules de Cube",
  25.     "version": (1, 0, 0),
  26.     "blender": (2, 78, 0),
  27.     "location": "Info > File",
  28.     "warning": "This addon is still in development.",
  29.     "wiki_url": "",
  30.     "category": "System" }
  31.  
  32. import colorsys
  33.  
  34. import bpy
  35. from bpy.types import Operator, AddonPreferences
  36. from bpy.props import StringProperty, IntProperty, BoolProperty , FloatProperty
  37.  
  38.  
  39. class AddonPreferences(AddonPreferences):
  40.     bl_idname = __name__
  41.  
  42.     RT_loop_time = FloatProperty(
  43.             name="Hue incremental",
  44.             default=2,
  45.             min = 0.00
  46.             )
  47.  
  48.  
  49.     def draw(self, context):
  50.         layout = self.layout
  51.         layout.label(text="is a preferences view for our addon")
  52.         layout.prop(self, "RT_loop_time")
  53.  
  54.  
  55.        
  56.  
  57.  
  58.  
  59. # load and reload submodules
  60. ##################################
  61.  
  62.  
  63. class ModalTimerOperator(bpy.types.Operator):
  64.     """Operator which runs its self from a timer"""
  65.     bl_idname = "wm.modal_timer_operator"
  66.     bl_label = "Modal Timer Operator"
  67.  
  68.     _timer = None
  69.  
  70.  
  71.     def modal(self, context, event):
  72.      
  73.         addon_prefs = context.user_preferences.addons[__name__].preferences
  74.  
  75.         if event.type == 'TIMER':
  76.             ui = bpy.context.user_preferences.themes[0].user_interface
  77.            
  78.  
  79.             bpy.context.window_manager.RT_hue  = bpy.context.window_manager.RT_hue + (0.05 / addon_prefs.RT_loop_time)
  80.  
  81.             color_rgb = colorsys.hsv_to_rgb(bpy.context.window_manager.RT_hue,1,1)
  82.  
  83.             color_rgba = (color_rgb[0], color_rgb[1], color_rgb[2], 1)
  84.  
  85.             ui.wcol_regular.inner_sel = color_rgba
  86.  
  87.             ui.wcol_tool.inner_sel = color_rgba
  88.  
  89.             ui.wcol_radio.inner_sel = color_rgba
  90.  
  91.             ui.wcol_text.item = color_rgba
  92.  
  93.             ui.wcol_option.item = color_rgba
  94.  
  95.             ui.wcol_toggle.inner_sel = color_rgba
  96.  
  97.             ui.wcol_num.item = color_rgba
  98.  
  99.             ui.wcol_numslider.item = color_rgba
  100.  
  101.             ui.wcol_box.inner_sel = color_rgba
  102.  
  103.             ui.wcol_menu.item = color_rgba
  104.  
  105.             ui.wcol_pie_menu.inner_sel = color_rgba
  106.  
  107.             ui.wcol_pulldown.inner_sel = color_rgba
  108.  
  109.             ui.wcol_menu_back.item = color_rgba
  110.  
  111.             ui.wcol_tooltip.inner_sel = color_rgba
  112.  
  113.             ui.wcol_menu_item.inner_sel = color_rgba
  114.  
  115.             ui.wcol_scroll.inner_sel = color_rgba
  116.  
  117.             ui.wcol_progress.item = color_rgba
  118.  
  119.             ui.wcol_list_item.inner_sel = color_rgba
  120.  
  121.         return {'PASS_THROUGH'}
  122.  
  123.     def execute(self, context):
  124.  
  125.        
  126.         wm = context.window_manager
  127.         self._timer = wm.event_timer_add(0.05 , context.window)
  128.         wm.modal_handler_add(self)
  129.         return {'RUNNING_MODAL'}
  130.  
  131.     def cancel(self, context):
  132.         wm = context.window_manager
  133.         wm.event_timer_remove(self._timer)
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141. # register
  142. ##################################
  143.  
  144. import traceback
  145.  
  146. def register():
  147.     bpy.utils.register_class(ModalTimerOperator)
  148.     bpy.utils.register_class(AddonPreferences)
  149.     bpy.types.WindowManager.RT_hue = bpy.props.FloatProperty(default = 0.0)
  150.  
  151.  
  152. def unregister():
  153.     bpy.utils.unregister_class(ModalTimerOperator)
  154.     bpy.utils.unregister_class(AddonPreferences)
  155.     del bpy.types.WindowManager.RT_hue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement