@@ -757,8 +757,8 @@ def model(self, model: Model):
757757 model .region_only_changed .connect (self .update_generate_options ),
758758 model .style_changed .connect (self .update_generate_options ),
759759 model .edit_mode_changed .connect (self .update_generate_options ),
760- self .add_control_button .clicked .connect (model . regions .add_control ),
761- self .add_region_button .clicked .connect (model . regions . create_region_group ),
760+ self .add_control_button .clicked .connect (self .add_control ),
761+ self .add_region_button .clicked .connect (self . add_region ),
762762 self .region_prompt .activated .connect (model .generate ),
763763 self .generate_button .clicked .connect (model .generate ),
764764 self .generate_button .ctrl_clicked .connect (model .generate_replace ),
@@ -846,7 +846,7 @@ def _create_edit_menu(self):
846846 def show_inpaint_menu (self ):
847847 width = self .generate_button .width () + self .inpaint_mode_button .width ()
848848 pos = QPoint (0 , self .generate_button .height ())
849- if self .model .arch .is_edit :
849+ if not self . model . edit_mode and self .model .arch .is_edit :
850850 menu = self .edit_menu
851851 elif self .model .strength == 1.0 :
852852 if self .model .region_only :
@@ -873,12 +873,18 @@ def toggle_region_only(self, checked: bool):
873873 self .model .region_only = checked
874874
875875 def update_add_region_button (self ):
876- supported = self .model .arch .supports_regions and not self . model . edit_mode
876+ supported = self .model .arch .supports_regions
877877 self .add_region_button .setEnabled (supported )
878878 self .add_region_button .setToolTip (
879879 _ ("Add Region" ) if supported else _ ("Regions are not supported for the current model" )
880880 )
881881
882+ def add_region (self ):
883+ self .model .active_regions .create_region_group ()
884+
885+ def add_control (self ):
886+ self .model .active_regions .add_control ()
887+
882888 def update_generate_options (self ):
883889 if not self .model .has_document :
884890 return
@@ -890,8 +896,10 @@ def update_generate_options(self):
890896 has_regions = len (regions ) > 0
891897 has_active_region = regions .is_linked (self .model .layers .active )
892898 is_region_only = has_regions and has_active_region and self .model .region_only
893- is_edit = self .model .arch .is_edit or self .model .edit_mode
894- can_switch_edit = not self .model .arch .is_edit and self .model .edit_style is not None
899+ is_edit = self .model .arch .is_edit
900+ can_switch_edit = (
901+ self .model .style .linked_edit_style != "" and self .model .edit_style is not None
902+ )
895903 self .region_mask_button .setVisible (has_regions )
896904 self .region_mask_button .setEnabled (has_active_region )
897905 self .region_mask_button .setIcon (_region_mask_button_icons [is_region_only ])
0 commit comments