def draw(self, context): if _skip_drawing_panel(context): return layout = self.layout layout.prop(g.light(), 'name')
def draw(self, context): if _skip_drawing_panel(context): return layout = self.layout layout.prop(g.light(), 'x', slider=True) layout.prop(g.light(), 'y', slider=True) content_type = g.light().content_type layout.prop(g.light(), 'width', slider=True) layout.prop(g.light(), 'height', slider=True) layout.prop(g.light(), 'angle', slider=True) layout.prop(g.light(), 'is_ellipse') if not (g.light().is_ellipse): layout.prop(g.light(), 'sides', slider=True) layout.prop(g.light(), 'corner_radius', slider=True)
def _skip_drawing_panel(context): if g.wrong(context): return True if g.no_lights(): return True if g.light().locked: return True return False
def _draw_callback_px(op, context): if g.wrong(context): return if g.no_lights(): return if not (cpp().lightIsVisible(g.light_index())): return if op.pressed: (x, y) = (op.img_x, op.img_y) else: (x, y) = (g.light().x, g.light().y) size = g.image().size uv_x, uv_y = x / size[0], y / size[1] reg_x, reg_y = context.region.view2d.view_to_region(uv_x, uv_y) gpu_extras.presets.draw_circle_2d((reg_x, reg_y), (0, 0, 0, 1), 9) gpu_extras.presets.draw_circle_2d((reg_x, reg_y), (1, 1, 1, 1), 10)
def _check_curve_update(scene): if g.light_index() == -1: return if cpp().curveFlatChanged(g.light_index()): cpp().updateLightLuminosity(g.light_index()) image.create_final() if g.light().content_type == 'IMAGE': if cpp().curveImageChanged(g.light_index()): cpp().changeLightImageBrightness(g.light_index()) image.create_final()
def draw(self, context): if _skip_drawing_panel(context): return layout = self.layout content_type = g.light().content_type data = g.light_data[g.light_index()] layout.template_curve_mapping(data.light_flat(), 'falloff_curve') layout.prop(g.light(), 'brightness_color', text='intensity', slider=True) layout.prop(g.light(), 'brightness_opacity', slider=True) layout.prop(g.light(), 'curve_x', slider=True) layout.prop(g.light(), 'curve_y', slider=True) if g.light().content_type == 'IMAGE': layout.template_curve_mapping(data.light_image(), 'falloff_curve')
def draw(self, context): if _skip_drawing_panel(context): return layout = self.layout s1 = layout.split() s1.label(text='blend mode:') s1.prop(g.light(), 'blend_mode', text='') s2 = layout.split() s2.label(text='content type:') s2.prop(g.light(), 'content_type', text='') content_type = g.light().content_type if content_type == 'FLAT': layout.prop(g.light(), 'color') if content_type == 'GRADIENT': layout.template_color_ramp(g.light_data[g.light_index()].texture(), 'color_ramp') layout.prop(g.light(), 'falloff_type', text='falloff') if g.light().falloff_type != 'RADIAL': layout.prop(g.light(), 'gradient_angle', text='angle', slider=True) else: layout.prop(g.light(), 'radial_x', slider=True) layout.prop(g.light(), 'radial_y', slider=True) layout.prop(g.light(), 'radial_width', slider=True) layout.prop(g.light(), 'radial_height', slider=True) if content_type == 'IMAGE': layout.prop_search(g.light(), 'image', bpy.data, 'images')
def modal(self, context, event): if not (editor.started): if _handler: remove_handler() self.delay = True return {'PASS_THROUGH'} if self.delay: self.delay = False return {'PASS_THROUGH'} return {'FINISHED'} if g.wrong_workspace(context): return {'PASS_THROUGH'} if g.no_lights(): return {'PASS_THROUGH'} if g.light().locked: return {'PASS_THROUGH'} if event.type == 'LEFTMOUSE' and event.value == 'PRESS': def inside(event, x, y, width, height): if event.mouse_x < x: return False if event.mouse_x > x + width: return False if event.mouse_y < y: return False if event.mouse_y > y + height: return False return True self.image_editor = None self.region = None if not (bpy.context.screen == g.workspace().screens[0]): return {'PASS_THROUGH'} for area in g.areas(): if area.type != 'IMAGE_EDITOR': continue if not (inside(event, area.x, area.y, area.width, area.height)): continue self.image_editor = area for region in area.regions: if region.type == 'WINDOW': self.region = region break if not (self.image_editor): return {'PASS_THROUGH'} if g.wrong_image(self.image_editor): return {'PASS_THROUGH'} for region in self.image_editor.regions: if region.type == 'HEADER': header = region if region.type == 'UI': ui = region if region.type == 'TOOLS': tools = region x = tools.x + tools.width if not (inside(event, x + 10, self.image_editor.y, ui.x - x - 20, self.image_editor.height - header.height)): return {'PASS_THROUGH'} if not (self.mouse_event_common(event)): return {'PASS_THROUGH'} self.pressed = True return {'RUNNING_MODAL'} if event.type == 'MOUSEMOVE': if not (self.pressed): return {'PASS_THROUGH'} self.mouse_event_common(event) return {'RUNNING_MODAL'} if event.type == 'LEFTMOUSE' and event.value == 'RELEASE': if not (self.pressed): return {'PASS_THROUGH'} self.pressed = False light.change_both_coordinates = True cpp().changeBothCoordinates(g.light_index()) g.light().x, g.light().y = self.img_x, self.img_y return {'PASS_THROUGH'} if event.type == 'RIGHTMOUSE' and event.value == 'PRESS': if self.pressed: self.pressed = False self.image_editor.tag_redraw() return {'PASS_THROUGH'} return {'PASS_THROUGH'}