def post_item_rename_event(self, data_obj, old_name=''): doc = AnimationEditor.get_active_document() if not doc: return if isinstance(data_obj, ctg.ae2.core.data.Set_Item): doc.event_manager.post_set_renamed_event([data_obj], old_name) elif isinstance(data_obj, ctg.ae2.core.data.Group_Item): doc.event_manager.post_group_renamed_event([data_obj], old_name) elif isinstance(data_obj, ctg.ae2.core.data.State_Tag_Item): doc.event_manager.post_state_tag_renamed_event([data_obj]) elif isinstance(data_obj, ctg.ae2.core.data.Action_Tag_Item): doc.event_manager.post_action_tag_renamed_event([data_obj]) elif isinstance(data_obj, ctg.ae2.core.data.Control_Filter_Item): doc.event_manager.post_control_filter_renamed_event([data_obj], old_name) elif isinstance(data_obj, ctg.ae2.core.data.Control_Parameter_Item): doc.event_manager.post_control_parameter_renamed_event([data_obj], old_name) elif isinstance(data_obj, ctg.ae2.core.data.State_Machine_Item): doc.event_manager.post_state_machine_renamed_event([data_obj], old_name) elif isinstance(data_obj, ctg.ae2.core.data.Blend_Tree_Item): doc.event_manager.post_blend_tree_renamed_event([data_obj], old_name)
def text_changed( self, event ): doc = AnimationEditor.get_active_document( ) if not doc: return sel_objs = doc.selection_manager.get_selected_objects() value = self.selected_name_text_ctrl.GetValue( ) bg_color = wx.SystemSettings.GetColour( wx.SYS_COLOUR_LISTBOX ) if sel_objs: if len( sel_objs ) == 1: if hasattr( sel_objs[0], 'validate_name' ): valid = sel_objs[0].validate_name( value ) if not valid: bg_color = wx.Colour( 255, 0, 0 ) try: self.selected_name_text_ctrl.SetBackgroundColour( bg_color ) except: print('This fails when adding a state or action tag association') self.selected_name_text_ctrl.Refresh( ) if event: event.Skip()
def text_changed(self, event): doc = AnimationEditor.get_active_document() if not doc: return sel_objs = doc.selection_manager.get_selected_objects() value = self.selected_name_text_ctrl.GetValue() bg_color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_LISTBOX) if sel_objs: if len(sel_objs) == 1: if hasattr(sel_objs[0], 'validate_name'): valid = sel_objs[0].validate_name(value) if not valid: bg_color = wx.Colour(255, 0, 0) try: self.selected_name_text_ctrl.SetBackgroundColour(bg_color) except: print('This fails when adding a state or action tag association') self.selected_name_text_ctrl.Refresh() if event: event.Skip()
def get_text_style(self, grid, node, column_object, is_selected): style = wx.Font(pointSize=9, family=wx.FONTFAMILY_DEFAULT, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL, underline=False, face=u'Segoe UI', encoding=wx.FONTENCODING_SYSTEM) if is_selected: if hasattr(node, 'get_render_colors'): node_color_set = node.get_render_colors(column_object) valid_column_ids = ['tag_assoc_tag', 'tag_assoc_clip'] column_string_dict = { 'NODE_TYPE_TAG_STATE': 'tag_assoc_tag', 'NODE_TYPE_TAG_ACTION': 'tag_assoc_tag', 'NODE_TYPE_ANIM_CLIP': 'tag_assoc_clip' } if column_object.id_string in valid_column_ids: doc = AnimationEditor.get_active_document() if doc and (doc.selection_manager. recent_sel_tag_associations_col == column_object.id_string): style = node_color_set.get_text_style(is_selected) return style
def update_frame_count( self ): doc = AnimationEditor.get_active_document( ) if not doc: return self.frame_count = doc.get_preview_clip_frame_count( ) self.prg_render_progress.SetRange( ( self.frame_count - 1 ) )
def post_item_rename_event( self, data_obj, old_name = '' ): doc = AnimationEditor.get_active_document( ) if not doc: return if isinstance( data_obj, ctg.ae2.core.data.Set_Item ): doc.event_manager.post_set_renamed_event( [ data_obj ], old_name ) elif isinstance( data_obj, ctg.ae2.core.data.Group_Item ): doc.event_manager.post_group_renamed_event( [ data_obj ], old_name ) elif isinstance( data_obj, ctg.ae2.core.data.State_Tag_Item ): doc.event_manager.post_state_tag_renamed_event( [ data_obj ] ) elif isinstance( data_obj, ctg.ae2.core.data.Action_Tag_Item ): doc.event_manager.post_action_tag_renamed_event( [ data_obj ] ) elif isinstance( data_obj, ctg.ae2.core.data.Control_Filter_Item ): doc.event_manager.post_control_filter_renamed_event( [ data_obj ], old_name ) elif isinstance( data_obj, ctg.ae2.core.data.Control_Parameter_Item ): doc.event_manager.post_control_parameter_renamed_event( [ data_obj ], old_name ) elif isinstance( data_obj, ctg.ae2.core.data.State_Machine_Item ): doc.event_manager.post_state_machine_renamed_event( [ data_obj ], old_name ) elif isinstance( data_obj, ctg.ae2.core.data.Blend_Tree_Item ): doc.event_manager.post_blend_tree_renamed_event( [ data_obj ], old_name )
def on_sync_file_pressed(self, event): doc = AnimationEditor.get_active_document() if not doc: return sel_objs = doc.selection_manager.get_recent_sel_clips() if sel_objs: if len(sel_objs) == 1: if hasattr(sel_objs[0], 'sync_file'): synced = sel_objs[0].sync_file() self.update_sync_button_bg_color(synced)
def on_sync_file_pressed( self, event ): doc = AnimationEditor.get_active_document( ) if not doc: return sel_objs = doc.selection_manager.get_recent_sel_clips() if sel_objs: if len( sel_objs ) == 1: if hasattr( sel_objs[0], 'sync_file'): synced = sel_objs[0].sync_file( ) self.update_sync_button_bg_color( synced )
def get_prop_pane_type_to_display( self ): doc = AnimationEditor.get_active_document( ) prop_pane_type_to_display = None if not doc: return prop_pane_type_to_display sel_objs = doc.selection_manager.get_selected_objects() if sel_objs: prop_pane_type_to_display = list( inspect.getmro( sel_objs[0].__class__ ) )[ -2 ].__name__ return prop_pane_type_to_display
def setup_dialog( self ): doc = AnimationEditor.get_active_document( ) if self.IsShown( ) or not doc: return if hasattr( doc, 'preview_pane' ): self.set_position( ) self.Show( True ) self.Layout( ) else: return
def get_prop_pane_type_to_display(self): doc = AnimationEditor.get_active_document() prop_pane_type_to_display = None if not doc: return prop_pane_type_to_display sel_objs = doc.selection_manager.get_selected_objects() if sel_objs: prop_pane_type_to_display = list( inspect.getmro(sel_objs[0].__class__))[-2].__name__ return prop_pane_type_to_display
def get_property_panels(self): """ This method gets and returns a list of property panes based on type of item selected. *Arguments:* * ``none`` *Keyword Arguments:* * ``none`` *Returns:* * ``none`` """ #get active document doc = AnimationEditor.get_active_document() #get property panes subclasses subclasses = ctg.ui.panel.CTG_Animation_Properties_Panel.__subclasses__( ) panes_to_show = [] if not doc: return panes_to_show #update name and type controls and return a list of type names of selected objects type_names = self.update_name_type_controls() #get selected objects sel_objs = doc.selection_manager.get_selected_objects() if not sel_objs or len(type_names) > 1: return panes_to_show #get the panes and the display weight value prop_pane_type_name = self.get_prop_pane_type_to_display() for sub_class in subclasses: prop_class = None if hasattr(sub_class, 'PROPERTY_PANE_TYPE'): if sub_class.PROPERTY_PANE_TYPE == prop_pane_type_name: if hasattr(sel_objs[0], 'get_prop_nodes'): #get child prop nodes if sel_objs[0].get_prop_nodes()[0]: prop_class = sub_class else: prop_class = sub_class if prop_class: panes_to_show.append(prop_class) return panes_to_show
def get_preview_window_screen_rect( self ): """ Returns the screen rect of the AE's preview window. """ doc = AnimationEditor.get_active_document( ) if not doc: return None rect = wx.Rect( 0, 0, 0, 0 ) screen_rect = doc.get_preview_rect( ) rect.SetPosition( ( screen_rect[ 0 ], screen_rect[ 1 ] ) ) rect.SetSize( ( screen_rect[ 2 ] - screen_rect[ 0 ], screen_rect[ 3 ] - screen_rect[ 1 ] ) ) return rect
def on_render_movie( self, event ): doc = AnimationEditor.get_active_document( ) if not doc: return self.enable_controls( False ) self.update_frame_count( ) self.reset_values( ) #callbacks ctg.CALLBACK_SYSTEM.register_callback( self.callback_string, 'ae preview updated', self.update_current_frame ) if event: event.Skip( )
def get_property_panels( self ): """ This method gets and returns a list of property panes based on type of item selected. *Arguments:* * ``none`` *Keyword Arguments:* * ``none`` *Returns:* * ``none`` """ #get active document doc = AnimationEditor.get_active_document( ) #get property panes subclasses subclasses = ctg.ui.panel.CTG_Animation_Properties_Panel.__subclasses__() panes_to_show = [ ] if not doc: return panes_to_show #update name and type controls and return a list of type names of selected objects type_names = self.update_name_type_controls( ) #get selected objects sel_objs = doc.selection_manager.get_selected_objects() if not sel_objs or len( type_names ) > 1: return panes_to_show #get the panes and the display weight value prop_pane_type_name = self.get_prop_pane_type_to_display( ) for sub_class in subclasses: prop_class = None if hasattr( sub_class, 'PROPERTY_PANE_TYPE' ): if sub_class.PROPERTY_PANE_TYPE == prop_pane_type_name: if hasattr( sel_objs[0], 'get_prop_nodes'): #get child prop nodes if sel_objs[0].get_prop_nodes()[0]: prop_class = sub_class else: prop_class = sub_class if prop_class: panes_to_show.append( prop_class ) return panes_to_show
def on_name_changed(self, event): doc = AnimationEditor.get_active_document() if not doc: return sel_objs = doc.selection_manager.get_selected_objects() value = self.selected_name_text_ctrl.GetValue() if sel_objs: if len(sel_objs) == 1: if hasattr(sel_objs[0], 'validate_name'): valid = sel_objs[0].validate_name(value) if valid: if hasattr(sel_objs[0], 'rename'): did_rename = sel_objs[0].rename(value) if did_rename: #obj = doc.selection_manager.get_item_from_collection( sel_objs[0], value ) #self.post_item_rename_event( obj, self.sel_obj_name ) self.sel_obj_name = sel_objs[0].get_name() self.selected_name_text_ctrl.SetValue( self.sel_obj_name) else: dlg = wx.MessageDialog( self, 'Renaming failed.', 'Renaming Failed', wx.OK | wx.ICON_INFORMATION) if dlg.ShowModal() == wx.ID_OK: self.selected_name_text_ctrl.SetValue( self.sel_obj_name) dlg.Destroy() else: dlg = wx.MessageDialog( self, 'The name is invalid either the name exist\n or has invalid characters.', 'Invalid Name', wx.OK | wx.ICON_INFORMATION) if dlg.ShowModal() == wx.ID_OK: self.selected_name_text_ctrl.SetValue( self.sel_obj_name) dlg.Destroy()
def cancel_pressed( self, event ): doc = AnimationEditor.get_active_document( ) if not doc: return self.enable_controls( False ) if not self.movie_file_created: self.txt_prog_message.SetLabel( 'Rendering canceled... Closing...' ) ctg.CALLBACK_SYSTEM.unregister_callbacks( self.callback_string ) self.reset_values( ) ctg.ui.util.set_editor_modal( False ) self.Show( False ) self.Destroy( )
def get_sel_clips_names( self ): doc = AnimationEditor.get_active_document( ) sel_clips_names = [ ] if not doc: return sel_clips_names sel_clip_objs = doc.selection_manager.get_recent_sel_clips() if not sel_clip_objs: sel_clips_names = [ NO_CLIP_SELECTED ] return sel_clips_names for clip_obj in sel_clip_objs: sel_clips_names.append( clip_obj.get_name( ) ) return sel_clips_names
def on_name_changed( self, event ): doc = AnimationEditor.get_active_document( ) if not doc: return sel_objs = doc.selection_manager.get_selected_objects() value = self.selected_name_text_ctrl.GetValue( ) if sel_objs: if len( sel_objs ) == 1: if hasattr( sel_objs[0], 'validate_name' ): valid = sel_objs[0].validate_name( value ) if valid: if hasattr( sel_objs[0], 'rename'): did_rename = sel_objs[0].rename( value ) if did_rename: #obj = doc.selection_manager.get_item_from_collection( sel_objs[0], value ) #self.post_item_rename_event( obj, self.sel_obj_name ) self.sel_obj_name = sel_objs[0].get_name( ) self.selected_name_text_ctrl.SetValue( self.sel_obj_name ) else: dlg = wx.MessageDialog(self, 'Renaming failed.','Renaming Failed', wx.OK | wx.ICON_INFORMATION ) if dlg.ShowModal() == wx.ID_OK: self.selected_name_text_ctrl.SetValue( self.sel_obj_name ) dlg.Destroy() else: dlg = wx.MessageDialog(self, 'The name is invalid either the name exist\n or has invalid characters.','Invalid Name', wx.OK | wx.ICON_INFORMATION ) if dlg.ShowModal() == wx.ID_OK: self.selected_name_text_ctrl.SetValue( self.sel_obj_name ) dlg.Destroy()
def get_text_style( self, grid, node, column_object, is_selected ): style = wx.Font( pointSize = 9, family = wx.FONTFAMILY_DEFAULT, style = wx.FONTSTYLE_NORMAL, weight = wx.FONTWEIGHT_NORMAL, underline = False, face = u'Segoe UI', encoding = wx.FONTENCODING_SYSTEM ) if is_selected: if hasattr( node, 'get_render_colors' ): node_color_set = node.get_render_colors( column_object ) valid_column_ids = [ 'tag_assoc_tag', 'tag_assoc_clip' ] column_string_dict = { 'NODE_TYPE_TAG_STATE' : 'tag_assoc_tag', 'NODE_TYPE_TAG_ACTION': 'tag_assoc_tag', 'NODE_TYPE_ANIM_CLIP' : 'tag_assoc_clip' } if column_object.id_string in valid_column_ids: doc = AnimationEditor.get_active_document( ) if doc and ( doc.selection_manager.recent_sel_tag_associations_col == column_object.id_string ): style = node_color_set.get_text_style( is_selected ) return style
def Draw(self, grid, attr, dc, rect, row, col, isSelected): # Get the column_collection column_collection = grid.get_column_collection() # Draw Background renderer = grid.get_renderer() renderer.draw_background(grid, dc, rect, row, col, isSelected) # Draw Column Highlight column_object = column_collection.column_order[col] # Get the node node = grid.get_row_as_node(row) if node.repair(): # This node was in need of repair and was successfully repaired pass obj = node.get_data_obj() obj_val = column_object.get_value(node) obj_locked = grid.is_node_read_only(node) isSortColumn = (column_object == column_collection.sort_column) # set the proper bitmap bitmap = None # if the object is a state machine or blendtree set the appropriate icon doc = AnimationEditor.get_active_document() if doc: if node.is_clip_valid: clip_name = obj.get_tag().get_clip_name() if clip_name: if doc.is_blend_tree(clip_name): bitmap = self.bmp_blendtree elif doc.is_state_machine(clip_name): bitmap = self.bmp_statemachine #clip_name = obj.get_tag( ).get_clip_name( ) #if clip_name: ## get the name lists #if clip_name.endswith( ' sm' ): #bitmap = self.bmp_statemachine #elif clip_name.endswith( ' bt' ): #bitmap = self.bmp_blendtree # see if the object has an error if it does override the icon with the error if not node.is_clip_valid or not node.is_tag_valid: bitmap = self.bmp_error if bitmap: image = wx.MemoryDC() image.SelectObject(bitmap) # set the bullet color if obj_val == True: color = wx.GREEN else: color = wx.LIGHT_GREY # set the colors dc.SetBrush(wx.Brush(wx.GREEN)) dc.SetPen(wx.BLACK_PEN) #dc.DrawRectangleRect( rect ) # copy the image but only to the size of the grid cell if bitmap: width, height = bitmap.GetWidth(), bitmap.GetHeight() if width > rect.width - 2: width = rect.width - 2 if height > rect.height - 2: height = rect.height - 2 dc.Blit(rect.x + 6, rect.y + 3, width, height, image, 0, 0, wx.COPY, True)
def __init__(self, parent, size=(-1, -1)): wx.Panel.__init__(self, parent, size=size) #self.SetDoubleBuffered( True ) self.folding_panes_dict = {} self.prop_panes_dict = {} self.child_prop_panes_dict = {} self.fold_pane_to_show = [] self.fold_pane_to_hide = [] self.last_shown_panes = [] self.prop_panes_to_show = [] self.sel_obj_name = '' self.fold_pane_names_dict = {} #main pane sizer main_sizer = wx.BoxSizer(wx.VERTICAL) self.name_inner_sizer = wx.BoxSizer(wx.HORIZONTAL) #folding panels images self.fp_images = wx.ImageList(16, 16) expanded = vlib.image.cache.load( ctg.ui.bitmaps.STR_BMP_EXPANDED_ICON_16) self.fp_images.Add(expanded.get_wx_bitmap()) collapsed = vlib.image.cache.load( ctg.ui.bitmaps.STR_BMP_COLLAPSED_ICON_16) self.fp_images.Add(collapsed.get_wx_bitmap()) #folding panels style setup self.fp_style = wx.lib.agw.foldpanelbar.CaptionBarStyle() self.fp_style.SetCaptionStyle( wx.lib.agw.foldpanelbar.CAPTIONBAR_FILLED_RECTANGLE) self.fp_style.SetFirstColour(wx.Colour(160, 160, 160, 255)) self.fp_style.SetSecondColour(wx.Colour(0, 0, 0, 255)) self.fp_style.SetCaptionColour(wx.Colour(0, 0, 0, 255)) #label to display selected name self.name_label = wx.StaticText(self, -1, 'Name:') self.name_label.SetFont( wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.BOLD)) self.selected_name_text_ctrl = wx.TextCtrl(self, -1, '', size=(240, 20), style=wx.TE_PROCESS_ENTER) self.sync_bt_ctrl = wx.Button(self, -1, '', size=(20, 20)) self.sync_bt_ctrl.SetBackgroundColour(wx.Colour(255, 0, 0)) #label to display selected type self.type_label = wx.StaticText(self, -1, 'Type:') self.type_label.SetFont( wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.BOLD)) self.selected_type_label = wx.StaticText(self, -1, '') #setup name and type sizer self.name_inner_sizer.Add(self.selected_name_text_ctrl) self.name_inner_sizer.AddSpacer(3) self.name_inner_sizer.Add(self.sync_bt_ctrl, wx.ALIGN_TOP) self.name_type_sizer = wx.FlexGridSizer(cols=2, hgap=9, vgap=4) self.name_type_sizer.Add(self.name_label) self.name_type_sizer.Add(self.name_inner_sizer) self.name_type_sizer.Add(self.type_label) self.name_type_sizer.Add(self.selected_type_label) # scroll panel for properties folding panels self.scroll_panel = wx.ScrolledWindow(self, -1, pos=wx.DefaultPosition, size=self.GetSize(), style=wx.SUNKEN_BORDER) self.pnl_page = wx.Panel(self.scroll_panel, wx.ID_ANY) self.pnl_sizer = wx.BoxSizer(wx.VERTICAL) self.pnl_page.SetSizer(self.pnl_sizer) # create folding panel self.folding_panels = wx.lib.agw.foldpanelbar.FoldPanelBar( self.pnl_page, -1, wx.DefaultPosition, wx.DefaultSize, wx.lib.agw.foldpanelbar.FPB_VERTICAL) self.pnl_sizer.Add(self.folding_panels, 1, wx.EXPAND | wx.ALL, 2) self.scroll_panel.SetScrollRate(20, 20) #setup main panel sizer self.main_sizer = wx.BoxSizer(wx.VERTICAL) self.main_sizer.AddSpacer(5) self.main_sizer.Add(self.name_type_sizer, 0, wx.ALL, 2) self.main_sizer.Add(self.scroll_panel, 1, wx.EXPAND | wx.ALL, 2) self.SetSizer(self.main_sizer) #bind event to update scroll bars self.folding_panels.Bind(wx.lib.agw.foldpanelbar.EVT_CAPTIONBAR, self.update_scrolling_bars) self.Bind(wx.EVT_SIZE, self.on_panel_resize) self.selected_name_text_ctrl.Bind(wx.EVT_TEXT_ENTER, self.on_name_changed) self.selected_name_text_ctrl.Bind(wx.EVT_TEXT, self.text_changed) self.sync_bt_ctrl.Bind(wx.EVT_BUTTON, self.on_sync_file_pressed) self.scroll_panel.Bind(wx.EVT_CHILD_FOCUS, self.on_folding_panel_gain_focus) self.Bind(wx.EVT_KEY_DOWN, self.on_key_down) #refresh pane self.refresh_ui() doc = AnimationEditor.get_active_document() setattr(doc, 'animation_properties_pane', self)
def update_name_type_controls( self ): """ This method updates name and type controls. *Arguments:* * ``none`` *Keyword Arguments:* * ``none`` *Returns:* * ``type_names`` Names of all types """ doc = AnimationEditor.get_active_document( ) if not doc: return type_names = [ ] obj_names = [ ] enable = False sel_objs = doc.selection_manager.get_selected_objects() if sel_objs: for obj in sel_objs: #object type if hasattr( obj, "object_type_name") and obj.object_type_name != None: type_name = "{0}_{1}".format( str( obj.object_type_name ).replace(" ", "_"), "Node" ) else: type_name = obj.__class__.__name__ #object name if hasattr( obj, 'get_name'): obj_name = obj.get_name( ) elif hasattr( obj, 'get_bone_name'): obj_name = obj.get_bone_name( ) elif hasattr( obj, 'name'): obj_name = obj.name #add object type to list of object type if type_name not in type_names: type_names.append( type_name ) #add object name to list of object names if obj_name not in obj_names: obj_names.append( obj_name ) if len( sel_objs ) == 1: if type_names[0] in [ 'Clip_Item', 'Tag_Association_Item', 'Control_Parameter_Node', 'Rig_Bone_Item' ] or obj_names[0].lower() == 'Default'.lower(): enable = False else: enable = True else: enable = False if not obj_names or len( obj_names ) > 1: self.selected_name_text_ctrl.SetValue( '' ) self.sel_obj_name = '' else: self.selected_name_text_ctrl.SetValue( obj_names[0] ) self.sel_obj_name = obj_names[0] if not type_names: self.selected_type_label.SetLabel( '' ) else: if len( type_names ) == 1: self.selected_type_label.SetLabel( type_names[0] ) else: self.selected_type_label.SetLabel( 'Multiple Types Selected' ) #enable self.selected_name_text_ctrl.Enable( enable ) self.name_inner_sizer.Hide( self.sync_bt_ctrl ) self.name_inner_sizer.Layout( ) self.name_type_sizer.Layout( ) return type_names
def update_name_type_controls(self): """ This method updates name and type controls. *Arguments:* * ``none`` *Keyword Arguments:* * ``none`` *Returns:* * ``type_names`` Names of all types """ doc = AnimationEditor.get_active_document() if not doc: return type_names = [] obj_names = [] enable = False sel_objs = doc.selection_manager.get_selected_objects() if sel_objs: for obj in sel_objs: #object type if hasattr( obj, "object_type_name") and obj.object_type_name != None: type_name = "{0}_{1}".format( str(obj.object_type_name).replace(" ", "_"), "Node") else: type_name = obj.__class__.__name__ #object name if hasattr(obj, 'get_name'): obj_name = obj.get_name() elif hasattr(obj, 'get_bone_name'): obj_name = obj.get_bone_name() elif hasattr(obj, 'name'): obj_name = obj.name #add object type to list of object type if type_name not in type_names: type_names.append(type_name) #add object name to list of object names if obj_name not in obj_names: obj_names.append(obj_name) if len(sel_objs) == 1: if type_names[0] in [ 'Clip_Item', 'Tag_Association_Item', 'Control_Parameter_Node', 'Rig_Bone_Item' ] or obj_names[0].lower() == 'Default'.lower(): enable = False else: enable = True else: enable = False if not obj_names or len(obj_names) > 1: self.selected_name_text_ctrl.SetValue('') self.sel_obj_name = '' else: self.selected_name_text_ctrl.SetValue(obj_names[0]) self.sel_obj_name = obj_names[0] if not type_names: self.selected_type_label.SetLabel('') else: if len(type_names) == 1: self.selected_type_label.SetLabel(type_names[0]) else: self.selected_type_label.SetLabel('Multiple Types Selected') #enable self.selected_name_text_ctrl.Enable(enable) self.name_inner_sizer.Hide(self.sync_bt_ctrl) self.name_inner_sizer.Layout() self.name_type_sizer.Layout() return type_names
def __init__( self, parent, size = (-1, -1 ) ): wx.Panel.__init__( self, parent, size=size ) #self.SetDoubleBuffered( True ) self.folding_panes_dict = { } self.prop_panes_dict = { } self.child_prop_panes_dict = { } self.fold_pane_to_show = [ ] self.fold_pane_to_hide = [ ] self.last_shown_panes = [ ] self.prop_panes_to_show = [ ] self.sel_obj_name = '' self.fold_pane_names_dict = { } #main pane sizer main_sizer = wx.BoxSizer( wx.VERTICAL ) self.name_inner_sizer = wx.BoxSizer( wx.HORIZONTAL ) #folding panels images self.fp_images = wx.ImageList( 16, 16 ) expanded = vlib.image.cache.load( ctg.ui.bitmaps.STR_BMP_EXPANDED_ICON_16 ) self.fp_images.Add( expanded.get_wx_bitmap( ) ) collapsed = vlib.image.cache.load( ctg.ui.bitmaps.STR_BMP_COLLAPSED_ICON_16 ) self.fp_images.Add( collapsed.get_wx_bitmap( ) ) #folding panels style setup self.fp_style = wx.lib.agw.foldpanelbar.CaptionBarStyle( ) self.fp_style.SetCaptionStyle( wx.lib.agw.foldpanelbar.CAPTIONBAR_FILLED_RECTANGLE ) self.fp_style.SetFirstColour( wx.Colour( 160, 160, 160, 255 ) ) self.fp_style.SetSecondColour( wx.Colour( 0, 0, 0, 255 ) ) self.fp_style.SetCaptionColour( wx.Colour( 0, 0, 0, 255 ) ) #label to display selected name self.name_label = wx.StaticText( self, -1, 'Name:' ) self.name_label.SetFont( wx.Font( 8, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.BOLD )) self.selected_name_text_ctrl = wx.TextCtrl( self, -1, '', size = (240, 20), style = wx.TE_PROCESS_ENTER ) self.sync_bt_ctrl = wx.Button( self, -1, '', size=(20, 20)) self.sync_bt_ctrl.SetBackgroundColour( wx.Colour( 255, 0, 0 ) ) #label to display selected type self.type_label = wx.StaticText( self, -1, 'Type:' ) self.type_label.SetFont( wx.Font( 8, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.BOLD )) self.selected_type_label = wx.StaticText( self, -1, '' ) #setup name and type sizer self.name_inner_sizer.Add( self.selected_name_text_ctrl ) self.name_inner_sizer.AddSpacer( 3 ) self.name_inner_sizer.Add( self.sync_bt_ctrl, wx.ALIGN_TOP ) self.name_type_sizer = wx.FlexGridSizer(cols=2, hgap=9, vgap=4) self.name_type_sizer.Add( self.name_label ) self.name_type_sizer.Add( self.name_inner_sizer ) self.name_type_sizer.Add( self.type_label ) self.name_type_sizer.Add( self.selected_type_label ) # scroll panel for properties folding panels self.scroll_panel = wx.ScrolledWindow( self, -1, pos=wx.DefaultPosition, size=self.GetSize( ), style=wx.SUNKEN_BORDER ) self.pnl_page = wx.Panel( self.scroll_panel, wx.ID_ANY ) self.pnl_sizer = wx.BoxSizer( wx.VERTICAL ) self.pnl_page.SetSizer( self.pnl_sizer ) # create folding panel self.folding_panels = wx.lib.agw.foldpanelbar.FoldPanelBar( self.pnl_page, -1, wx.DefaultPosition, wx.DefaultSize, wx.lib.agw.foldpanelbar.FPB_VERTICAL ) self.pnl_sizer.Add( self.folding_panels, 1, wx.EXPAND|wx.ALL, 2 ) self.scroll_panel.SetScrollRate( 20, 20 ) #setup main panel sizer self.main_sizer = wx.BoxSizer( wx.VERTICAL ) self.main_sizer.AddSpacer( 5 ) self.main_sizer.Add( self.name_type_sizer, 0, wx.ALL, 2 ) self.main_sizer.Add( self.scroll_panel, 1, wx.EXPAND|wx.ALL, 2 ) self.SetSizer( self.main_sizer ) #bind event to update scroll bars self.folding_panels.Bind( wx.lib.agw.foldpanelbar.EVT_CAPTIONBAR, self.update_scrolling_bars ) self.Bind( wx.EVT_SIZE, self.on_panel_resize ) self.selected_name_text_ctrl.Bind( wx.EVT_TEXT_ENTER, self.on_name_changed ) self.selected_name_text_ctrl.Bind( wx.EVT_TEXT, self.text_changed ) self.sync_bt_ctrl.Bind( wx.EVT_BUTTON, self.on_sync_file_pressed ) self.scroll_panel.Bind( wx.EVT_CHILD_FOCUS, self.on_folding_panel_gain_focus ) self.Bind( wx.EVT_KEY_DOWN, self.on_key_down ) #refresh pane self.refresh_ui( ) doc = AnimationEditor.get_active_document( ) setattr( doc, 'animation_properties_pane', self )
def __init__( self, parent ): ctg.ui.dialogs.CTG_Dialog.__init__( self, parent, title = 'Render Preview Movies', size = ( 374, 350 ), lock_min_size=False, style = wx.DEFAULT_DIALOG_STYLE ) #wx.FRAME_TOOL_WINDOW ) doc = AnimationEditor.get_active_document( ) self.current_frame = 0 self.finished = False self.movie_file_created = False self.sel_rendered_movie_name = None self.animx_name = self.get_sel_clips_names( )[0] self.frame_count = doc.get_preview_clip_frame_count( ) self.image_files = [ ] self.path_movie_name_dict = { } self.ToggleWindowStyle( wx.RESIZE_BORDER ) # BUILD THE UI #========================================== self.main_sizer = wx.BoxSizer( wx.VERTICAL ) self.btn_sizer = wx.BoxSizer( wx.HORIZONTAL ) self.output_folder_sizer = wx.BoxSizer( wx.HORIZONTAL ) self.movie_ext_sizer = wx.BoxSizer( wx.HORIZONTAL ) self.rendered_movies_box = wx.StaticBox( self, -1, 'Recent rendered movies:' ) self.rendered_movies_sizer = wx.StaticBoxSizer( self.rendered_movies_box, wx.VERTICAL ) self.txt_prog_message = wx.StaticText( self, -1, 'Rendering movie: {0}{1}'.format( self.animx_name, '.animx' ) ) self.txt_output_folder = wx.StaticText( self, -1, 'Output Folder: ') self.txt_movie_ext = wx.StaticText( self, -1, 'Movie Ext: ') self.prg_render_progress = wx.Gauge( self, -1, self.frame_count, style = wx.GA_SMOOTH ) self.output_folder_control = ctg.ui.widgets.misc.Directory_Control( self, -1, message='Choose Path:', show_full_path=True, default_path = OUTPUT_FOLDER, size=( 224, 25 ) ) self.btn_cancel = wx.Button( self, -1, "Cancel Rendering" ) self.btn_render = wx.Button( self, -1, "Render Movie" ) self.btn_close = wx.Button( self, -1, size=( 60,-1), label = "Close" ) self.btn_play = wx.Button( self, -1, size=( 85, -1), label = "Play Movie" ) self.btn_play.Enable( False ) self.movie_type_control = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, ( 60, -1 ), ['mov', 'avi', 'mpeg'] , 0 ) self.render_movies = wx.ListBox(self, -1, (-1,-1 ), (320, 80), [ ], wx.LB_SINGLE ) warning_str = wx.StaticText( self, -1, "WARNING: While these movie is rendering,you cannot move any\nother window on top of the AE's preview window. Rendering data\nwill be lost if this happens." ) self.movie_ext_sizer.AddSpacer( 22 ) self.movie_ext_sizer.Add( self.txt_movie_ext, 0, wx.ALIGN_CENTER, 5 ) self.movie_ext_sizer.Add( self.movie_type_control, 1, wx.EXPAND | wx.ALIGN_CENTER, 5 ) self.output_folder_sizer.Add( self.txt_output_folder, 0, wx.ALIGN_CENTER, 5 ) self.output_folder_sizer.Add( self.output_folder_control, 1, wx.EXPAND | wx.ALIGN_CENTER, 5 ) self.btn_sizer.Add( self.btn_render, 0, wx.ALIGN_CENTER, 5 ) self.btn_sizer.Add( self.btn_cancel, 0, wx.ALIGN_CENTER, 5 ) self.btn_sizer.Add( self.btn_play, 0, wx.ALIGN_CENTER, 5 ) self.btn_sizer.Add( self.btn_close, 0, wx.ALIGN_CENTER, 5 ) self.rendered_movies_sizer.Add( self.render_movies, 1, wx.EXPAND | wx.ALIGN_CENTER, 5 ) self.main_sizer.Add( self.txt_prog_message, 0, wx.EXPAND | wx.ALL, 8 ) self.main_sizer.Add( warning_str, 0, wx.EXPAND | wx.ALL, 8 ) self.main_sizer.AddSpacer( 6 ) self.main_sizer.Add( self.output_folder_sizer, 1, wx.EXPAND | wx.LEFT | wx.RIGHT, 1 ) self.main_sizer.AddSpacer( 4 ) self.main_sizer.Add( self.movie_ext_sizer, 1, wx.EXPAND | wx.LEFT | wx.RIGHT, 1 ) self.main_sizer.AddSpacer( 4 ) self.main_sizer.Add( self.rendered_movies_sizer, 1, wx.EXPAND ) self.main_sizer.Add( self.prg_render_progress, 1, wx.EXPAND| wx.ALIGN_CENTER, 10 ) self.main_sizer.Add( self.btn_sizer, 0, wx.ALIGN_CENTER | wx.TOP, 5 ) self.main_sizer.AddSpacer( 7 ) #========================================== #bind events self.btn_cancel.Bind( wx.EVT_BUTTON, self.cancel_pressed ) self.Bind( wx.EVT_CLOSE, self.cancel_pressed ) self.btn_render.Bind( wx.EVT_BUTTON, self.on_render_movie ) self.btn_close.Bind( wx.EVT_BUTTON, self.close ) self.btn_play.Bind( wx.EVT_BUTTON, self.on_play_movie ) self.render_movies.Bind( wx.EVT_LISTBOX, self.on_movie_name_selected ) self.output_folder_control.Bind( ctg.ui.widgets.misc.EVT_DIRECTORY_SELECTED, self.on_output_folder_changed ) self.movie_type_control.Bind( wx.EVT_CHOICE, self.on_movie_ext_changed ) #callbacks self.callback_string = 'animation_preview_render_dialog_callbacks_%s' % id( doc ) #set default rendering values and enable controls self.set_default_values( ) self.enable_controls( True ) #setup main sizer self.SetSizer( self.main_sizer )
def Draw( self, grid, attr, dc, rect, row, col, isSelected ): # Get the column_collection column_collection = grid.get_column_collection( ) # Draw Background renderer = grid.get_renderer( ) renderer.draw_background( grid, dc, rect, row, col, isSelected ) # Draw Column Highlight column_object = column_collection.column_order[ col ] # Get the node node = grid.get_row_as_node( row ) if node.repair( ): # This node was in need of repair and was successfully repaired pass obj = node.get_data_obj( ) obj_val = column_object.get_value( node ) obj_locked = grid.is_node_read_only( node ) isSortColumn = ( column_object == column_collection.sort_column ) # set the proper bitmap bitmap = None # if the object is a state machine or blendtree set the appropriate icon doc = AnimationEditor.get_active_document( ) if doc: if node.is_clip_valid: clip_name = obj.get_tag( ).get_clip_name( ) if clip_name: if doc.is_blend_tree( clip_name ): bitmap = self.bmp_blendtree elif doc.is_state_machine( clip_name ): bitmap = self.bmp_statemachine #clip_name = obj.get_tag( ).get_clip_name( ) #if clip_name: ## get the name lists #if clip_name.endswith( ' sm' ): #bitmap = self.bmp_statemachine #elif clip_name.endswith( ' bt' ): #bitmap = self.bmp_blendtree # see if the object has an error if it does override the icon with the error if not node.is_clip_valid or not node.is_tag_valid: bitmap = self.bmp_error if bitmap: image = wx.MemoryDC( ) image.SelectObject( bitmap ) # set the bullet color if obj_val == True: color = wx.GREEN else: color = wx.LIGHT_GREY # set the colors dc.SetBrush( wx.Brush( wx.GREEN ) ) dc.SetPen( wx.BLACK_PEN ) #dc.DrawRectangleRect( rect ) # copy the image but only to the size of the grid cell if bitmap: width, height = bitmap.GetWidth(), bitmap.GetHeight() if width > rect.width-2: width = rect.width-2 if height > rect.height-2: height = rect.height-2 dc.Blit(rect.x+6, rect.y+3, width, height, image, 0, 0, wx.COPY, True)