def __init__(self, editor: SoulstructMapEditor, row_index: int, main_bindings: dict = None): super().__init__(editor=editor, row_index=row_index, main_bindings=main_bindings) bg_color = self._get_color() self.value_vector_frame = editor.Frame( self.value_box, bg=bg_color, width=editor.FIELD_VALUE_WIDTH, height=editor.FIELD_ROW_HEIGHT, no_grid=True) bind_events(self.value_vector_frame, main_bindings) self.value_vector_x = editor.Label( self.value_vector_frame, text='', bg=bg_color, width=editor.FIELD_VALUE_WIDTH // 6, column=0, anchor='w') self.value_vector_y = editor.Label( self.value_vector_frame, text='', bg=bg_color, width=editor.FIELD_VALUE_WIDTH // 6, column=1, anchor='w') self.value_vector_z = editor.Label( self.value_vector_frame, text='', bg=bg_color, width=editor.FIELD_VALUE_WIDTH // 6, column=2, anchor='w') for coord, label in zip('xyz', (self.value_vector_x, self.value_vector_y, self.value_vector_z)): vector_bindings = main_bindings.copy() vector_bindings.update({ '<Button-1>': lambda _, c=coord: editor.select_displayed_field_row( row_index, coord=c) }) bind_events(label, vector_bindings) self.unhide()
def refresh_categories(self): """There are few enough categories changing rarely enough that the widgets can just be regenerated.""" self.select_category(None) for box, label in self.category_boxes.values(): box.destroy() label.destroy() self.category_boxes = {} with self.set_master(self.category_i_frame): categories = self._get_display_categories() for row, category in enumerate(categories): box = self.Frame( row=row, width=self.CATEGORY_BOX_WIDTH, height=self.CATEGORY_ROW_HEIGHT, highlightthickness=self.CATEGORY_ROW_HIGHLIGHT, bg=self.CATEGORY_UNSELECTED_BG, sticky="nsew", ) label_text = camel_case_to_spaces(category).replace("_", ": ") label = self.Label( text=label_text, sticky="w", row=row, fg=self._get_category_text_fg(category), bg=self.CATEGORY_UNSELECTED_BG, padx=1, font_size=10, ) for widget in {label, box}: bind_events( widget, { "<Button-1>": lambda e, c=category: self.select_category(c, view_change=True), "<Up>": self._category_press_up, "<Down>": self._category_press_down, "<Prior>": self._category_press_up, "<Next>": self._category_press_down, }, ) if category == self.active_category: label["bg"] = self.CATEGORY_SELECTED_BG box["bg"] = self.CATEGORY_SELECTED_BG self.link_to_scrollable(self.category_canvas, box, label) self.category_boxes[category] = (box, label) self.category_canvas.yview_moveto(0) self.category_i_frame.columnconfigure(0, weight=1)
def __init__(self, editor: SoulstructTalkEditor, row_index: int, main_bindings: dict = None): self.master = editor self.STYLE_DEFAULTS = editor.STYLE_DEFAULTS self.row_index = row_index self._entry_id = None self._entry_text = None # never changes self._active = False bg_color = self._get_color() self.row_box = editor.Frame( width=self.ENTRY_ID_WIDTH, height=self.ENTRY_ROW_HEIGHT, bg=bg_color, row=row_index, columnspan=3, sticky="nsew", ) bind_events(self.row_box, main_bindings) self.id_box = editor.Frame(row=row_index, column=1, bg=bg_color, sticky="ew") self.id_label = editor.Label( self.id_box, text="", width=self.ENTRY_ID_WIDTH, bg=bg_color, fg=self.ENTRY_ID_FG, font_size=11, sticky="e", ) id_bindings = main_bindings.copy() id_bindings[ "<Button-1>"] = lambda _, i=row_index: self.master.select_entry_row_index( i, id_clicked=True) id_bindings[ "<Shift-Button-1>"] = lambda _, i=row_index: self.master.popout_entry_id_edit( i) bind_events(self.id_box, id_bindings) bind_events(self.id_label, id_bindings) self.context_menu = editor.Menu(self.row_box) self.tool_tip = None
def __init__(self, editor: SoulstructBaseFieldEditor, row_index: int, main_bindings: dict = None): self.master = editor self.STYLE_DEFAULTS = editor.STYLE_DEFAULTS self.row_index = row_index self._active = False self._link_missing = False self._default_value = False self.field_name = "" self.field_type = type # type: tp.Union[tp.Type[GameObject], tp.Type[GameObjectSequence], type, tp.Iterable] self.field_nickname = "" self.field_docstring = "" self.field_links = [] self.link_missing = False bg_color = self._get_color() self.row_box = editor.Frame( width=editor.FIELD_BOX_WIDTH, height=editor.FIELD_ROW_HEIGHT, bg=bg_color, row=row_index, columnspan=2, sticky="nsew", ) bind_events(self.row_box, main_bindings) self.field_name_box = editor.Frame(row=row_index, column=0, bg=bg_color, sticky="w") bind_events(self.field_name_box, main_bindings) self.field_name_label = editor.Label( self.field_name_box, text="", fg=editor.FIELD_NAME_FG, width=editor.FIELD_NAME_WIDTH, bg=bg_color, anchor="w", font_size=10, ) bind_events(self.field_name_label, main_bindings) self.value_box = editor.Frame( width=editor.FIELD_VALUE_BOX_WIDTH, row=row_index, column=1, bg=bg_color, sticky="ew" ) bind_events(self.value_box, main_bindings) # VALUE WIDGETS self.value_label = editor.Label( self.value_box, text="", bg=bg_color, width=editor.FIELD_VALUE_WIDTH, anchor="w" ) bind_events(self.value_label, main_bindings) self.value_checkbutton = editor.Checkbutton( self.value_box, label=None, bg=bg_color, no_grid=True, selectcolor="#000", command=self._checkbutton_toggle, ) # Main focus bindings are not bound to Checkbutton. self.value_combobox = editor.Combobox( self.value_box, values=None, width=editor.FIELD_VALUE_WIDTH, no_grid=True, font=("Segoe UI", 10), on_select_function=self._combobox_choice, ) self.value_combobox.bind("<MouseWheel>", lambda _: "break") # prevent scrolling on collapsed Combobox # Main focus bindings are not bound to Combobox. # TODO: BEHAVIOR_REF_TYPE combobox should also force a refresh, as it may change field names. # (Class will need access to ParamEntry for this, which is fine.) self.context_menu = editor.Menu(self.row_box) self.tool_tip = ToolTip(self.row_box, self.field_name_box, self.field_name_label, text=None) self.active_value_widget = self.value_label self.hide()
def __init__(self, editor: SoulstructEntityEditor, row_index: int, main_bindings: dict = None): self.master = editor self.STYLE_DEFAULTS = editor.STYLE_DEFAULTS self.row_index = row_index self._entry_id = None self._entry_text = None self._entry_description = None self._active = False self.maps_link = None bg_color = self._get_color() self.row_box = editor.Frame( width=self.ENTRY_ID_WIDTH + self.ENTRY_TEXT_WIDTH + self.ENTRY_DESCRIPTION_WIDTH, height=self.ENTRY_ROW_HEIGHT, bg=bg_color, row=row_index, columnspan=2, sticky="nsew", ) bind_events(self.row_box, main_bindings) self.id_box = editor.Frame(row=row_index, column=0, bg=bg_color, sticky="ew") self.id_label = editor.Label( self.id_box, text="", width=self.ENTRY_ID_WIDTH, bg=bg_color, fg=self.ENTRY_ID_FG, font_size=11, sticky="e", ) if self.EDIT_ENTRY_ID: id_bindings = main_bindings.copy() id_bindings[ "<Button-1>"] = lambda _, i=row_index: self.master.select_entry_row_index( i, id_clicked=True) id_bindings[ "<Shift-Button-1>"] = lambda _, i=row_index: self.master.popout_entry_id_edit( i) else: id_bindings = main_bindings bind_events(self.id_box, id_bindings) bind_events(self.id_label, id_bindings) self.text_box = editor.Frame(row=row_index, column=1, bg=bg_color, sticky="ew") self.text_label = editor.Label( self.text_box, text="", bg=bg_color, fg=self.ENTRY_TEXT_FG, anchor="w", font_size=11, justify="left", width=self.ENTRY_TEXT_WIDTH, ) bind_events(self.text_box, main_bindings) bind_events(self.text_label, main_bindings) self.description_box = editor.Frame(row=row_index, column=2, bg=bg_color, sticky="nsew") self.description_label = editor.Label( self.description_box, text="", bg=bg_color, fg=self.ENTRY_TEXT_FG, anchor="w", font_size=11, justify="left", width=self.ENTRY_DESCRIPTION_WIDTH, ) desc_bindings = main_bindings.copy() desc_bindings.pop("<Shift-Button-1", None) desc_bindings[ "<Button-1>"] = lambda _, i=row_index: self.master.select_entry_row_index( i, description_clicked=True) bind_events(self.description_box, desc_bindings) bind_events(self.description_label, desc_bindings) self.context_menu = editor.Menu(self.row_box) self.tool_tip = None
def __init__(self, editor: SoulstructBaseEditor, row_index: int, main_bindings: dict = None): self.master = editor self.STYLE_DEFAULTS = editor.STYLE_DEFAULTS self.row_index = row_index self._entry_id = None self._entry_text = None self._active = False bg_color = self._get_color() self.row_box = editor.Frame( width=self.ENTRY_ID_WIDTH + self.ENTRY_TEXT_WIDTH, height=self.ENTRY_ROW_HEIGHT, bg=bg_color, row=row_index, columnspan=2 if self.SHOW_ENTRY_ID else 1, sticky="nsew", ) bind_events(self.row_box, main_bindings) if self.SHOW_ENTRY_ID: self.id_box = editor.Frame(row=row_index, column=0, bg=bg_color, sticky="ew") self.id_label = editor.Label( self.id_box, text="", width=self.ENTRY_ID_WIDTH, bg=bg_color, fg=self.ENTRY_ID_FG, font_size=11, sticky="e", ) if self.EDIT_ENTRY_ID: id_bindings = main_bindings.copy() id_bindings["<Button-1>"] = lambda _, i=row_index: self.master.select_entry_row_index( i, id_clicked=True ) else: id_bindings = main_bindings bind_events(self.id_box, id_bindings) bind_events(self.id_label, id_bindings) else: self.id_label = None self.text_box = editor.Frame(row=row_index, column=1 if self.SHOW_ENTRY_ID else 0, bg=bg_color, sticky="ew") bind_events(self.text_box, main_bindings) self.text_label = editor.Label( self.text_box, text="", bg=bg_color, fg=self.ENTRY_TEXT_FG, anchor="w", font_size=11, justify="left", width=self.ENTRY_TEXT_WIDTH, ) bind_events(self.text_label, main_bindings) self.context_menu = editor.Menu(self.row_box) self.tool_tip = ToolTip( self.row_box, self.id_box, self.id_label, self.text_box, self.text_label, text=None, wraplength=350 )