ImageEditor.st
changeset 3489 ed003c06c33b
parent 3488 e9655ba452c7
child 3492 f212578d1276
equal deleted inserted replaced
3488:e9655ba452c7 3489:ed003c06c33b
  3877      by the MenuEditor of ST/X."
  3877      by the MenuEditor of ST/X."
  3878 
  3878 
  3879     "Do not manually edit this!! If it is corrupted,
  3879     "Do not manually edit this!! If it is corrupted,
  3880      the MenuEditor may not be able to read the specification."
  3880      the MenuEditor may not be able to read the specification."
  3881 
  3881 
       
  3882 
  3882     "
  3883     "
  3883      MenuEditor new openOnClass:ImageEditor andSelector:#previewMenu
  3884      MenuEditor new openOnClass:ImageEditor andSelector:#previewMenu
  3884      (Menu new fromLiteralArrayEncoding:(ImageEditor previewMenu)) startUp
  3885      (Menu new fromLiteralArrayEncoding:(ImageEditor previewMenu)) startUp
  3885     "
  3886     "
  3886 
  3887 
  3889     ^ 
  3890     ^ 
  3890      #(Menu
  3891      #(Menu
  3891         (
  3892         (
  3892          (MenuItem
  3893          (MenuItem
  3893             label: 'TileMode'
  3894             label: 'TileMode'
  3894             translateLabel: true
       
  3895             indication: tileModeHolder
  3895             indication: tileModeHolder
  3896           )
  3896           )
  3897          (MenuItem
  3897          (MenuItem
  3898             label: '-'
  3898             label: '-'
  3899           )
  3899           )
  3900          (MenuItem
  3900          (MenuItem
  3901             label: 'Background Color'
  3901             label: 'Background Color'
  3902             translateLabel: true
       
  3903             submenu: 
  3902             submenu: 
  3904            (Menu
  3903            (Menu
  3905               (
  3904               (
  3906                (MenuItem
  3905                (MenuItem
  3907                   label: 'Gray'
  3906                   label: 'Gray'
  3908                   translateLabel: true
       
  3909                   choice: previewBackgroundColorHolder
  3907                   choice: previewBackgroundColorHolder
  3910                   choiceValue: nil
       
  3911                 )
  3908                 )
  3912                (MenuItem
  3909                (MenuItem
  3913                   label: 'Black'
  3910                   label: 'Black'
  3914                   translateLabel: true
       
  3915                   choice: previewBackgroundColorHolder
  3911                   choice: previewBackgroundColorHolder
  3916                   choiceValue: black
  3912                   choiceValue: black
  3917                 )
  3913                 )
  3918                (MenuItem
  3914                (MenuItem
  3919                   label: 'White'
  3915                   label: 'White'
  3920                   translateLabel: true
       
  3921                   choice: previewBackgroundColorHolder
  3916                   choice: previewBackgroundColorHolder
  3922                   choiceValue: white
  3917                   choiceValue: white
  3923                 )
  3918                 )
  3924                (MenuItem
  3919                (MenuItem
  3925                   label: '-'
  3920                   label: '-'
  3926                 )
  3921                 )
  3927                (MenuItem
  3922                (MenuItem
  3928                   label: 'Red'
  3923                   label: 'Red'
  3929                   translateLabel: true
       
  3930                   choice: previewBackgroundColorHolder
  3924                   choice: previewBackgroundColorHolder
  3931                   choiceValue: red
  3925                   choiceValue: red
  3932                 )
  3926                 )
  3933                (MenuItem
  3927                (MenuItem
  3934                   label: 'Green'
  3928                   label: 'Green'
  3935                   translateLabel: true
       
  3936                   choice: previewBackgroundColorHolder
  3929                   choice: previewBackgroundColorHolder
  3937                   choiceValue: green
  3930                   choiceValue: green
  3938                 )
  3931                 )
  3939                (MenuItem
  3932                (MenuItem
  3940                   label: 'Blue'
  3933                   label: 'Blue'
  3941                   translateLabel: true
       
  3942                   choice: previewBackgroundColorHolder
  3934                   choice: previewBackgroundColorHolder
  3943                   choiceValue: blue
  3935                   choiceValue: blue
  3944                 )
  3936                 )
  3945                )
  3937                )
  3946               nil
  3938               nil
  3947               nil
  3939               nil
  3948             )
  3940             )
  3949           )
  3941           )
       
  3942          (MenuItem
       
  3943             label: '-'
       
  3944           )
       
  3945          (MenuItem
       
  3946             label: 'Magnification'
       
  3947             submenu: 
       
  3948            (Menu
       
  3949               (
       
  3950                (MenuItem
       
  3951                   label: '0.1'
       
  3952                   choice: previewMagnificationHolder
       
  3953                   choiceValue: 0.1
       
  3954                 )
       
  3955                (MenuItem
       
  3956                   label: '0.25'
       
  3957                   choice: previewMagnificationHolder
       
  3958                   choiceValue: 0.25
       
  3959                 )
       
  3960                (MenuItem
       
  3961                   label: '0.5'
       
  3962                   choice: previewMagnificationHolder
       
  3963                   choiceValue: 0.5
       
  3964                 )
       
  3965                (MenuItem
       
  3966                   label: '1'
       
  3967                   choice: previewMagnificationHolder
       
  3968                   choiceValue: 1
       
  3969                 )
       
  3970                (MenuItem
       
  3971                   label: '2'
       
  3972                   choice: previewMagnificationHolder
       
  3973                   choiceValue: 2
       
  3974                 )
       
  3975                (MenuItem
       
  3976                   label: '4'
       
  3977                   choice: previewMagnificationHolder
       
  3978                   choiceValue: 4
       
  3979                 )
       
  3980                (MenuItem
       
  3981                   label: '-'
       
  3982                 )
       
  3983                (MenuItem
       
  3984                   label: 'Choose...'
       
  3985                   itemValue: changePreviewImageMagnification
       
  3986                 )
       
  3987                )
       
  3988               nil
       
  3989               nil
       
  3990             )
       
  3991           )
  3950          )
  3992          )
  3951         nil
  3993         nil
  3952         nil
  3994         nil
  3953       )
  3995       )
  3954 
  3996 
  3955     "Modified: / 04-07-2010 / 10:20:09 / cg"
  3997     "Modified: / 10-09-2017 / 14:54:41 / cg"
  3956 !
  3998 !
  3957 
  3999 
  3958 toolsMenuToolbar
  4000 toolsMenuToolbar
  3959     "This resource specification was automatically generated
  4001     "This resource specification was automatically generated
  3960      by the MenuEditor of ST/X."
  4002      by the MenuEditor of ST/X."
  4778     ^ holder
  4820     ^ holder
  4779 
  4821 
  4780     "Created: / 04-07-2010 / 10:19:34 / cg"
  4822     "Created: / 04-07-2010 / 10:19:34 / cg"
  4781 !
  4823 !
  4782 
  4824 
       
  4825 previewMagnificationHolder
       
  4826     |holder|
       
  4827 
       
  4828     (holder := builder bindingAt:#previewMagnificationHolder) isNil ifTrue:[
       
  4829         builder aspectAt:#previewMagnificationHolder put:(holder := 1 asValue).
       
  4830         holder addDependent:self.
       
  4831     ].
       
  4832     ^ holder
       
  4833 
       
  4834     "Created: / 10-09-2017 / 14:10:07 / cg"
       
  4835 !
       
  4836 
  4783 readOnly
  4837 readOnly
  4784     ^ false
  4838     ^ false
  4785 !
  4839 !
  4786 
  4840 
  4787 saveButtonInToolbarVisibleHolder
  4841 saveButtonInToolbarVisibleHolder
  4846     self obsoleteMethodWarning:'stupid method name - use #magnificationHolder'.
  4900     self obsoleteMethodWarning:'stupid method name - use #magnificationHolder'.
  4847     ^ self magnificationHolder
  4901     ^ self magnificationHolder
  4848 ! !
  4902 ! !
  4849 
  4903 
  4850 !ImageEditor methodsFor:'change & update'!
  4904 !ImageEditor methodsFor:'change & update'!
       
  4905 
       
  4906 changePreviewImageMagnification
       
  4907     |mag|
       
  4908 
       
  4909     mag := Dialog request:'Magnification?' initialAnswer:self imagePreView magnificationFactor.
       
  4910     mag isEmptyOrNil ifTrue:[^ self].
       
  4911     mag := Number readFrom:mag onError:nil.
       
  4912     mag isNil ifTrue:[^ self].
       
  4913 
       
  4914     self previewMagnificationHolder value:mag
       
  4915 
       
  4916     "Created: / 10-09-2017 / 14:52:52 / cg"
       
  4917 !
  4851 
  4918 
  4852 colorCropTabSelectionIndexChanged
  4919 colorCropTabSelectionIndexChanged
  4853     |selIndex sym|
  4920     |selIndex sym|
  4854 
  4921 
  4855     selIndex := self colorCropTabSelectionIndexHolder value.
  4922     selIndex := self colorCropTabSelectionIndexHolder value.
  4972             tileMode:(changedObject value) tileOffset:(image extent);
  5039             tileMode:(changedObject value) tileOffset:(image extent);
  4973             clear; 
  5040             clear; 
  4974             invalidate.
  5041             invalidate.
  4975         ^ self
  5042         ^ self
  4976     ].
  5043     ].
       
  5044     
  4977     changedObject == self previewBackgroundColorHolder ifTrue:[
  5045     changedObject == self previewBackgroundColorHolder ifTrue:[
  4978         clr := changedObject value isNil 
  5046         clr := changedObject value isNil 
  4979                     ifTrue:[imageEditView viewBackground]
  5047                     ifTrue:[imageEditView viewBackground]
  4980                     ifFalse:[Color perform:changedObject value].
  5048                     ifFalse:[Color perform:changedObject value].
  4981         imagePreView 
  5049         imagePreView 
  4982             viewBackground:clr;
  5050             viewBackground:clr;
  4983             clear; 
  5051             clear; 
  4984             invalidate.
  5052             invalidate.
  4985         ^ self
  5053         ^ self
  4986     ].
  5054     ].
  4987 
  5055     changedObject == self previewMagnificationHolder ifTrue:[
       
  5056         imagePreView 
       
  5057             magnificationFactor:(self previewMagnificationHolder value);
       
  5058             clear; 
       
  5059             invalidate;
       
  5060             yourself.
       
  5061         ^ self.    
       
  5062     ].
       
  5063     
  4988     changedObject == self listOfColors ifTrue:[
  5064     changedObject == self listOfColors ifTrue:[
  4989         something == #at: ifTrue:[
  5065         something == #at: ifTrue:[
  4990             "/ colormap entry changed at aParameter
  5066             "/ colormap entry changed at aParameter
  4991 
  5067 
  4992             clrIndex := aParameter.
  5068             clrIndex := aParameter.
  5071         ^ self.
  5147         ^ self.
  5072     ].
  5148     ].
  5073 
  5149 
  5074     super update:something with:aParameter from:changedObject
  5150     super update:something with:aParameter from:changedObject
  5075 
  5151 
  5076     "Modified: / 05-09-2017 / 09:04:21 / cg"
  5152     "Modified: / 10-09-2017 / 14:56:00 / cg"
  5077 !
  5153 !
  5078 
  5154 
  5079 updateAfterImageChange
  5155 updateAfterImageChange
  5080     |img|
  5156     |img|
  5081 
  5157 
  5381     view notNil ifTrue:[
  5457     view notNil ifTrue:[
  5382         
  5458         
  5383         view == self imagePreView ifTrue:[
  5459         view == self imagePreView ifTrue:[
  5384             ((anEvent isButtonPressEvent and:[ anEvent button == 1 ])
  5460             ((anEvent isButtonPressEvent and:[ anEvent button == 1 ])
  5385             or:[ anEvent isButtonMotionEvent and:[ anEvent hasButton1 ]])  ifTrue:[
  5461             or:[ anEvent isButtonMotionEvent and:[ anEvent hasButton1 ]])  ifTrue:[
  5386                 p := anEvent x @ anEvent y.
  5462                 p := anEvent x @ anEvent y.                
  5387                 (transformation := view transformation) notNil ifTrue:[
  5463                 (transformation := view transformation) notNil ifTrue:[
  5388                     p := transformation applyInverseTo:p.
  5464                     p := transformation applyInverseTo:p.
  5389                 ].
  5465                 ].
       
  5466                 p := p / self previewMagnificationHolder value.
  5390                 self imageEditView scrollToMakeVisible:p.    
  5467                 self imageEditView scrollToMakeVisible:p.    
  5391                 ^ true.
  5468                 ^ true.
  5392             ].
  5469             ].
  5393         ].
  5470         ].
  5394 
  5471 
  5406             ].
  5483             ].
  5407         ].
  5484         ].
  5408     ].
  5485     ].
  5409     ^ false.
  5486     ^ false.
  5410 
  5487 
  5411     "Modified: / 04-04-2011 / 13:50:09 / cg"
  5488     "Modified: / 10-09-2017 / 16:40:13 / cg"
  5412     "Modified (format): / 16-02-2017 / 09:54:01 / cg"
       
  5413 ! !
  5489 ! !
  5414 
  5490 
  5415 !ImageEditor methodsFor:'help'!
  5491 !ImageEditor methodsFor:'help'!
  5416 
  5492 
  5417 defaultInfoLabel
  5493 defaultInfoLabel