def __init__(self): GObject.GObject.__init__(self) self.set_title(_("Titler")) self.connect("delete-event", lambda w, e: close_titler()) if editorstate.screen_size_small_height() == True: global TEXT_LAYER_LIST_HEIGHT, TEXT_VIEW_HEIGHT, VIEW_EDITOR_HEIGHT TEXT_LAYER_LIST_HEIGHT = 150 TEXT_VIEW_HEIGHT = 180 VIEW_EDITOR_HEIGHT = 450 if editorstate.screen_size_small_height() == True: global VIEW_EDITOR_WIDTH VIEW_EDITOR_WIDTH = 680 self.block_updates = False self.view_editor = vieweditor.ViewEditor(PLAYER().profile, VIEW_EDITOR_WIDTH, VIEW_EDITOR_HEIGHT) self.view_editor.active_layer_changed_listener = self.active_layer_changed self.guides_toggle = vieweditor.GuidesViewToggle(self.view_editor) add_b = Gtk.Button(_("Add")) del_b = Gtk.Button(_("Delete")) add_b.connect("clicked", lambda w: self._add_layer_pressed()) del_b.connect("clicked", lambda w: self._del_layer_pressed()) add_del_box = Gtk.HBox() add_del_box = Gtk.HBox(True, 1) add_del_box.pack_start(add_b, True, True, 0) add_del_box.pack_start(del_b, True, True, 0) center_h_icon = Gtk.Image.new_from_file(respaths.IMAGE_PATH + "center_horizontal.png") center_v_icon = Gtk.Image.new_from_file(respaths.IMAGE_PATH + "center_vertical.png") center_h = Gtk.Button() center_h.set_image(center_h_icon) center_h.connect("clicked", lambda w: self._center_h_pressed()) center_v = Gtk.Button() center_v.set_image(center_v_icon) center_v.connect("clicked", lambda w: self._center_v_pressed()) self.layer_list = TextLayerListView(self._layer_selection_changed, self._layer_visibility_toggled) self.layer_list.set_size_request(TEXT_LAYER_LIST_WIDTH, TEXT_LAYER_LIST_HEIGHT) self.text_view = Gtk.TextView() self.text_view.set_pixels_above_lines(2) self.text_view.set_left_margin(2) self.text_view.get_buffer().connect("changed", self._text_changed) self.sw = Gtk.ScrolledWindow() self.sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.ALWAYS) self.sw.add(self.text_view) self.sw.set_size_request(TEXT_VIEW_WIDTH, TEXT_VIEW_HEIGHT) scroll_frame = Gtk.Frame() scroll_frame.add(self.sw) self.tc_display = guicomponents.MonitorTCDisplay() self.tc_display.use_internal_frame = True self.tc_display.widget.set_valign(Gtk.Align.CENTER) self.pos_bar = positionbar.PositionBar() self.pos_bar.set_listener(self.position_listener) self.pos_bar.update_display_from_producer(PLAYER().producer) self.pos_bar.mouse_release_listener = self.pos_bar_mouse_released pos_bar_frame = Gtk.Frame() pos_bar_frame.add(self.pos_bar.widget) pos_bar_frame.set_shadow_type(Gtk.ShadowType.ETCHED_IN) pos_bar_frame.set_valign(Gtk.Align.CENTER) font_map = PangoCairo.font_map_get_default() unsorted_families = font_map.list_families() if len(unsorted_families) == 0: print "No font families found in system! Titler will not work." self.font_families = sorted(unsorted_families, key=lambda family: family.get_name()) self.font_family_indexes_for_name = {} combo = Gtk.ComboBoxText() indx = 0 for family in self.font_families: combo.append_text(family.get_name()) self.font_family_indexes_for_name[family.get_name()] = indx indx += 1 combo.set_active(0) self.font_select = combo self.font_select.connect("changed", self._edit_value_changed) adj = Gtk.Adjustment(float(DEFAULT_FONT_SIZE), float(1), float(300), float(1)) self.size_spin = Gtk.SpinButton() self.size_spin.set_adjustment(adj) self.size_spin.connect("changed", self._edit_value_changed) self.size_spin.connect("key-press-event", self._key_pressed_on_widget) font_main_row = Gtk.HBox() font_main_row.pack_start(self.font_select, True, True, 0) font_main_row.pack_start(guiutils.pad_label(5, 5), False, False, 0) font_main_row.pack_start(self.size_spin, False, False, 0) self.bold_font = Gtk.ToggleButton() self.italic_font = Gtk.ToggleButton() bold_icon = Gtk.Image.new_from_stock(Gtk.STOCK_BOLD, Gtk.IconSize.BUTTON) italic_icon = Gtk.Image.new_from_stock(Gtk.STOCK_ITALIC, Gtk.IconSize.BUTTON) self.bold_font.set_image(bold_icon) self.italic_font.set_image(italic_icon) self.bold_font.connect("clicked", self._edit_value_changed) self.italic_font.connect("clicked", self._edit_value_changed) self.left_align = Gtk.RadioButton(None) self.center_align = Gtk.RadioButton.new_from_widget(self.left_align) self.right_align = Gtk.RadioButton.new_from_widget(self.left_align) left_icon = Gtk.Image.new_from_stock(Gtk.STOCK_JUSTIFY_LEFT, Gtk.IconSize.BUTTON) center_icon = Gtk.Image.new_from_stock(Gtk.STOCK_JUSTIFY_CENTER, Gtk.IconSize.BUTTON) right_icon = Gtk.Image.new_from_stock(Gtk.STOCK_JUSTIFY_RIGHT, Gtk.IconSize.BUTTON) self.left_align.set_image(left_icon) self.center_align.set_image(center_icon) self.right_align.set_image(right_icon) self.left_align.set_mode(False) self.center_align.set_mode(False) self.right_align.set_mode(False) self.left_align.connect("clicked", self._edit_value_changed) self.center_align.connect("clicked", self._edit_value_changed) self.right_align.connect("clicked", self._edit_value_changed) self.color_button = Gtk.ColorButton.new_with_rgba( Gdk.RGBA(red=1.0, green=1.0, blue=1.0, alpha=1.0)) self.color_button.connect("color-set", self._edit_value_changed) buttons_box = Gtk.HBox() buttons_box.pack_start(Gtk.Label(), True, True, 0) buttons_box.pack_start(self.bold_font, False, False, 0) buttons_box.pack_start(self.italic_font, False, False, 0) buttons_box.pack_start(guiutils.pad_label(5, 5), False, False, 0) buttons_box.pack_start(self.left_align, False, False, 0) buttons_box.pack_start(self.center_align, False, False, 0) buttons_box.pack_start(self.right_align, False, False, 0) buttons_box.pack_start(guiutils.pad_label(5, 5), False, False, 0) buttons_box.pack_start(self.color_button, False, False, 0) buttons_box.pack_start(Gtk.Label(), True, True, 0) load_layers = Gtk.Button(_("Load Layers")) load_layers.connect("clicked", lambda w: self._load_layers_pressed()) save_layers = Gtk.Button(_("Save Layers")) save_layers.connect("clicked", lambda w: self._save_layers_pressed()) clear_layers = Gtk.Button(_("Clear All")) clear_layers.connect("clicked", lambda w: self._clear_layers_pressed()) layers_save_buttons_row = Gtk.HBox() layers_save_buttons_row.pack_start(save_layers, False, False, 0) layers_save_buttons_row.pack_start(load_layers, False, False, 0) layers_save_buttons_row.pack_start(Gtk.Label(), True, True, 0) adj = Gtk.Adjustment(float(0), float(0), float(3000), float(1)) self.x_pos_spin = Gtk.SpinButton() self.x_pos_spin.set_adjustment(adj) self.x_pos_spin.connect("changed", self._position_value_changed) self.x_pos_spin.connect("key-press-event", self._key_pressed_on_widget) adj = Gtk.Adjustment(float(0), float(0), float(3000), float(1)) self.y_pos_spin = Gtk.SpinButton() self.y_pos_spin.set_adjustment(adj) self.y_pos_spin.connect("changed", self._position_value_changed) self.y_pos_spin.connect("key-press-event", self._key_pressed_on_widget) adj = Gtk.Adjustment(float(0), float(0), float(3000), float(1)) self.rotation_spin = Gtk.SpinButton() self.rotation_spin.set_adjustment(adj) self.rotation_spin.connect("changed", self._position_value_changed) self.rotation_spin.connect("key-press-event", self._key_pressed_on_widget) undo_pos = Gtk.Button() undo_icon = Gtk.Image.new_from_stock(Gtk.STOCK_UNDO, Gtk.IconSize.BUTTON) undo_pos.set_image(undo_icon) next_icon = Gtk.Image.new_from_file(respaths.IMAGE_PATH + "next_frame_s.png") prev_icon = Gtk.Image.new_from_file(respaths.IMAGE_PATH + "prev_frame_s.png") prev_frame = Gtk.Button() prev_frame.set_image(prev_icon) prev_frame.connect("clicked", lambda w: self._prev_frame_pressed()) next_frame = Gtk.Button() next_frame.set_image(next_icon) next_frame.connect("clicked", lambda w: self._next_frame_pressed()) self.scale_selector = vieweditor.ScaleSelector(self) timeline_box = Gtk.HBox() timeline_box.pack_start(self.tc_display.widget, False, False, 0) timeline_box.pack_start(guiutils.pad_label(12, 12), False, False, 0) timeline_box.pack_start(pos_bar_frame, True, True, 0) timeline_box.pack_start(guiutils.pad_label(12, 12), False, False, 0) timeline_box.pack_start(prev_frame, False, False, 0) timeline_box.pack_start(next_frame, False, False, 0) timeline_box.pack_start(self.guides_toggle, False, False, 0) timeline_box.pack_start(self.scale_selector, False, False, 0) timeline_box.set_margin_top(6) timeline_box.set_margin_bottom(6) positions_box = Gtk.HBox() positions_box.pack_start(Gtk.Label(), True, True, 0) positions_box.pack_start(Gtk.Label(label="X:"), False, False, 0) positions_box.pack_start(self.x_pos_spin, False, False, 0) positions_box.pack_start(guiutils.pad_label(40, 5), False, False, 0) positions_box.pack_start(Gtk.Label(label="Y:"), False, False, 0) positions_box.pack_start(self.y_pos_spin, False, False, 0) #positions_box.pack_start(Gtk.Label(label=_("Angle")), False, False, 0) #positions_box.pack_start(self.rotation_spin, False, False, 0) positions_box.pack_start(guiutils.pad_label(40, 5), False, False, 0) positions_box.pack_start(center_h, False, False, 0) positions_box.pack_start(center_v, False, False, 0) positions_box.pack_start(Gtk.Label(), True, True, 0) controls_panel_1 = Gtk.VBox() controls_panel_1.pack_start(add_del_box, False, False, 0) controls_panel_1.pack_start(self.layer_list, False, False, 0) controls_panel_1.pack_start(layers_save_buttons_row, False, False, 0) controls_panel_2 = Gtk.VBox() controls_panel_2.pack_start(scroll_frame, True, True, 0) controls_panel_2.pack_start(font_main_row, False, False, 0) controls_panel_2.pack_start(buttons_box, False, False, 0) controls_panel = Gtk.VBox() controls_panel.pack_start( guiutils.get_named_frame(_("Active Layer"), controls_panel_2), True, True, 0) controls_panel.pack_start( guiutils.get_named_frame(_("Layers"), controls_panel_1), False, False, 0) view_editor_editor_buttons_row = Gtk.HBox() view_editor_editor_buttons_row.pack_start(positions_box, False, False, 0) view_editor_editor_buttons_row.pack_start(Gtk.Label(), True, True, 0) keep_label = Gtk.Label(label=_("Keep Layers When Closed")) self.keep_layers_check = Gtk.CheckButton() self.keep_layers_check.set_active(_keep_titler_data) self.keep_layers_check.connect("toggled", self._keep_layers_toggled) open_label = Gtk.Label(label=_("Open Saved Title In Bin")) self.open_in_current_check = Gtk.CheckButton() self.open_in_current_check.set_active(_open_saved_in_bin) self.open_in_current_check.connect("toggled", self._open_saved_in_bin) exit_b = guiutils.get_sized_button(_("Close"), 150, 32) exit_b.connect("clicked", lambda w: close_titler()) save_titles_b = guiutils.get_sized_button(_("Save Title Graphic"), 150, 32) save_titles_b.connect("clicked", lambda w: self._save_title_pressed()) editor_buttons_row = Gtk.HBox() editor_buttons_row.pack_start(Gtk.Label(), True, True, 0) editor_buttons_row.pack_start(keep_label, False, False, 0) editor_buttons_row.pack_start(self.keep_layers_check, False, False, 0) editor_buttons_row.pack_start(guiutils.pad_label(24, 2), False, False, 0) editor_buttons_row.pack_start(open_label, False, False, 0) editor_buttons_row.pack_start(self.open_in_current_check, False, False, 0) editor_buttons_row.pack_start(guiutils.pad_label(24, 2), False, False, 0) editor_buttons_row.pack_start(exit_b, False, False, 0) editor_buttons_row.pack_start(save_titles_b, False, False, 0) editor_panel = Gtk.VBox() editor_panel.pack_start(self.view_editor, True, True, 0) editor_panel.pack_start(timeline_box, False, False, 0) editor_panel.pack_start( guiutils.get_in_centering_alignment( view_editor_editor_buttons_row), False, False, 0) editor_panel.pack_start(guiutils.pad_label(2, 24), True, True, 0) editor_panel.pack_start(editor_buttons_row, False, False, 0) editor_row = Gtk.HBox() editor_row.pack_start(controls_panel, False, False, 0) editor_row.pack_start(editor_panel, True, True, 0) alignment = guiutils.set_margins(editor_row, 8, 8, 8, 8) self.add(alignment) self.layer_list.fill_data_model() self._update_gui_with_active_layer_data() self.show_all() self.connect("size-allocate", lambda w, e: self.window_resized()) self.connect("window-state-event", lambda w, e: self.window_resized())
def __init__(self): GObject.GObject.__init__(self) self.connect("delete-event", lambda w, e:_shutdown()) app_icon = GdkPixbuf.Pixbuf.new_from_file(respaths.IMAGE_PATH + "flowbladetoolicon.png") self.set_icon(app_icon) #---- LEFT PANEL hamburger_launcher_surface = cairo.ImageSurface.create_from_png(respaths.IMAGE_PATH + "hamburger.png") self.hamburger_launcher = guicomponents.PressLaunch(_hamburger_launch_pressed, hamburger_launcher_surface) guiutils.set_margins(self.hamburger_launcher.widget, 0, 8, 0, 8) # Animation selector menu launcher row self.animation_label = Gtk.Label(_animation_instance.info.name) self.present_event_box = Gtk.EventBox() self.present_event_box.add(self.animation_label) self.present_event_box.connect("button-press-event", animations_menu_launched) self.script_menu = toolguicomponents.PressLaunch(animations_menu_launched) selector_row = Gtk.HBox(False, 2) selector_row.pack_start(self.hamburger_launcher.widget, False, False, 0) selector_row.pack_start(self.present_event_box, False, False, 0) selector_row.pack_start(self.script_menu.widget, False, False, 0) selector_row.set_margin_top(2) # Edit area self.value_edit_frame = Gtk.Frame() self.value_edit_frame.set_shadow_type(Gtk.ShadowType.IN) self.value_edit_frame.set_size_request(EDIT_PANEL_WIDTH+ 10, EDIT_PANEL_HEIGHT + 10) self.value_edit_box = None #---- RIGHT PANEL self.preview_info = Gtk.Label() self.preview_info.set_markup("<small>" + _("no preview") + "</small>" ) preview_info_row = Gtk.HBox() preview_info_row.pack_start(self.preview_info, False, False, 0) preview_info_row.pack_start(Gtk.Label(), True, True, 0) preview_info_row.set_margin_top(6) preview_info_row.set_margin_bottom(8) preview_info_row.set_size_request(200, 10) # Monitor self.preview_monitor = cairoarea.CairoDrawableArea2(MONITOR_WIDTH, MONITOR_HEIGHT, self._draw_preview) # Position control panel self.pos_bar = positionbar.PositionBar(False) self.pos_bar.set_listener(self.position_listener) pos_bar_frame = Gtk.Frame() pos_bar_frame.add(self.pos_bar.widget) pos_bar_frame.set_shadow_type(Gtk.ShadowType.ETCHED_IN) pos_bar_frame.set_margin_top(5) pos_bar_frame.set_margin_bottom(4) pos_bar_frame.set_margin_left(6) pos_bar_frame.set_margin_right(2) self.preview_button = Gtk.Button(_("Preview Frame")) self.preview_button.connect("clicked", lambda w: render_preview_frame()) control_panel = Gtk.HBox(False, 2) control_panel.pack_start(pos_bar_frame, True, True, 0) control_panel.pack_start(guiutils.pad_label(2, 2), False, False, 0) control_panel.pack_start(self.preview_button, False, False, 0) # Range setting in_label = Gtk.Label(_("Start:")) self.range_in = Gtk.SpinButton.new_with_range(1, 249, 1) out_label = Gtk.Label(_("End:")) self.range_out = Gtk.SpinButton.new_with_range(2, 250, 1) self.range_in.set_value(1) self.range_out.set_value(250) self.range_in.connect("value-changed", self.range_changed) self.range_out.connect("value-changed", self.range_changed) pos_label = Gtk.Label(_("Frame:")) self.pos_info = Gtk.Label(_("1")) range_row = Gtk.HBox(False, 2) range_row.pack_start(in_label, False, False, 0) range_row.pack_start(self.range_in, False, False, 0) range_row.pack_start(Gtk.Label(), True, True, 0) range_row.pack_start(pos_label, False, False, 0) range_row.pack_start(self.pos_info, False, False, 0) range_row.pack_start(Gtk.Label(), True, True, 0) range_row.pack_start(out_label, False, False, 0) range_row.pack_start(self.range_out, False, False, 0) range_row.set_margin_bottom(24) range_row.set_margin_left(5) # Render panel self.out_folder = Gtk.FileChooserButton(_("Select Folder")) self.out_folder.set_action(Gtk.FileChooserAction.SELECT_FOLDER) self.out_folder.connect("selection-changed", self.folder_selection_changed) self.out_label = Gtk.Label(label=_("Frames Folder:")) self.frame_name = Gtk.Entry() self.frame_name.set_text("frame") self.extension_label = Gtk.Label() self.extension_label.set_markup("<small>XXXX.png</small>") out_folder_row = guiutils.get_left_justified_box([self.out_label, guiutils.pad_label(12, 2), \ self.out_folder, guiutils.pad_label(24, 2), self.frame_name, \ guiutils.pad_label(2, 2), self.extension_label]) self.encode_check_label = Gtk.Label(_("Encode Video")) self.encode_check = Gtk.CheckButton() self.encode_check.set_active(False) self.encode_check.connect("toggled", lambda w:self.update_encode_sensitive()) self.encode_settings_button = Gtk.Button(_("Encoding settings")) self.encode_settings_button.connect("clicked", lambda w:_encode_settings_clicked()) self.encode_desc = Gtk.Label() self.encode_desc.set_markup("<small>" + _("not set") + "</small>") self.encode_desc.set_ellipsize(Pango.EllipsizeMode.END) self.encode_desc.set_max_width_chars(32) encode_row = Gtk.HBox(False, 2) encode_row.pack_start(self.encode_check, False, False, 0) encode_row.pack_start(self.encode_check_label, False, False, 0) encode_row.pack_start(guiutils.pad_label(48, 12), False, False, 0) encode_row.pack_start(self.encode_settings_button, False, False, 0) encode_row.pack_start(guiutils.pad_label(6, 12), False, False, 0) encode_row.pack_start(self.encode_desc, False, False, 0) encode_row.pack_start(Gtk.Label(), True, True, 0) encode_row.set_margin_bottom(6) format_label = Gtk.Label(_("Natron Render Format:")) self.format_selector = Gtk.ComboBoxText() # filled later when current sequence known for format_desc in NATRON_RENDER_FORMATS: self.format_selector.append_text(format_desc) self.format_selector.set_active(NATRON_DEFAULT_RENDER_FORMAT) format_select_row = Gtk.HBox(False, 2) format_select_row.pack_start(format_label, False, False, 0) format_select_row.pack_start(guiutils.pad_label(12, 2), False, False, 0) format_select_row.pack_start(self.format_selector, False, False, 0) format_select_row.set_margin_top(24) self.render_percentage = Gtk.Label("") self.status_no_render = _("Set Frames Folder for valid render") self.render_status_info = Gtk.Label() self.render_status_info.set_markup("<small>" + self.status_no_render + "</small>") render_status_row = Gtk.HBox(False, 2) render_status_row.pack_start(self.render_percentage, False, False, 0) render_status_row.pack_start(Gtk.Label(), True, True, 0) render_status_row.pack_start(self.render_status_info, False, False, 0) render_status_row.set_margin_bottom(6) self.render_progress_bar = Gtk.ProgressBar() self.render_progress_bar.set_valign(Gtk.Align.CENTER) self.stop_button = guiutils.get_sized_button(_("Stop"), 100, 32) #self.stop_button.connect("clicked", lambda w:abort_render()) self.render_button = guiutils.get_sized_button(_("Render"), 100, 32) self.render_button.connect("clicked", lambda w:render_output()) render_row = Gtk.HBox(False, 2) render_row.pack_start(self.render_progress_bar, True, True, 0) render_row.pack_start(guiutils.pad_label(12, 2), False, False, 0) render_row.pack_start(self.stop_button, False, False, 0) render_row.pack_start(self.render_button, False, False, 0) render_vbox = Gtk.VBox(False, 2) render_vbox.pack_start(encode_row, False, False, 0) render_vbox.pack_start(Gtk.Label(), True, True, 0) render_vbox.pack_start(out_folder_row, False, False, 0) render_vbox.pack_start(format_select_row, False, False, 0) render_vbox.pack_start(Gtk.Label(), True, True, 0) render_vbox.pack_start(render_status_row, False, False, 0) render_vbox.pack_start(render_row, False, False, 0) render_vbox.pack_start(guiutils.pad_label(24, 24), False, False, 0) render_vbox.set_margin_left(8) # Bottomrow self.load_anim = Gtk.Button(_("Load Animation")) self.load_anim.connect("clicked", lambda w:load_script_dialog(_load_script_dialog_callback)) self.save_anim = Gtk.Button(_("Save Animation")) self.save_anim.connect("clicked", lambda w:save_script_dialog(_save_script_dialog_callback)) exit_b = guiutils.get_sized_button(_("Close"), 150, 32) exit_b.connect("clicked", lambda w:_shutdown()) editor_buttons_row = Gtk.HBox() editor_buttons_row.pack_start(self.load_anim, False, False, 0) editor_buttons_row.pack_start(self.save_anim, False, False, 0) editor_buttons_row.pack_start(Gtk.Label(), True, True, 0) editor_buttons_row.pack_start(exit_b, False, False, 0) # Build window left_panel = Gtk.VBox(False, 2) left_panel.pack_start(selector_row, False, False, 0) left_panel.pack_start(self.value_edit_frame, True, True, 0) right_panel = Gtk.VBox(False, 0) right_panel.pack_start(preview_info_row, False, False, 0) right_panel.pack_start(self.preview_monitor, False, False, 0) right_panel.pack_start(control_panel, False, False, 0) right_panel.pack_start(range_row, False, False, 0) right_panel.pack_start(render_vbox, True, True, 0) right_panel.set_margin_left(4) sides_pane = Gtk.HBox(False, 2) sides_pane.pack_start(left_panel, False, False, 0) sides_pane.pack_start(right_panel, False, False, 0) pane = Gtk.VBox(False, 2) pane.pack_start(sides_pane, False, False, 0) pane.pack_start(editor_buttons_row, False, False, 0) align = guiutils.set_margins(pane, 2, 12, 12, 12) # Connect global key listener #self.connect("key-press-event", _global_key_down_listener) # Set pane and show window self.add(align) self.set_title(_("Natron Animations")) self.set_position(Gtk.WindowPosition.CENTER) #self.set_widgets_sensitive(False) self.show_all() self.set_resizable(False) #self.set_active_state(False) self.update_render_status_info() self.change_animation()