[Cuis-dev] VectorGrahicsPlugin Troubles (WAS: Re: A few tweaks to preferences)

Gerald Klix cuis.01 at klix.ch
Fri Aug 20 12:58:41 PDT 2021



On 8/20/21 8:38 PM, Juan Vuletich via Cuis-dev wrote:
> On 8/20/2021 1:25 PM, Gerald Klix via Cuis-dev wrote:
>>
>>
>> On 8/20/21 5:53 PM, Juan Vuletich via Cuis-dev wrote:
>>> Hi Folks,
>>>
>>> After some off-list discussion, and the risk of newcomers, especially 
>>> students, get scared after accidentally doing World / Quit and 
>>> quitting without any warning, I did a few tweaks. Now the menu option 
>>> reads 'Quit without saving' and by default asks for confirmation. The 
>>> confirmation can be disabled by doing `Preferences disable: 
>>> #checkLostChangesOnStartUp`, although it will still be given if there 
>>> are unsaved ChangeSets.
>> After I adopted my SystemDictionary>>#saveAsNewHaverVersion:
>> to the changed behavior, sigh ...
>>>
>>> I also made the "Save new Release" option also quit.
>> Which I also did from the very beginning with my
>> "Save New Haver Release" option.
>> After all you don't want to taint your new automatically generated 
>> release image with incidental last second changes that are not 
>> reproducible.
> 
> Of course!
> 
>>
>> I also use this (ballon|hover) help text:
>>
>> -- snip --
>> 'Save as a new release of Haver.
>> Use an updated version-stamped name
>> and save it under that name on disk.
>>
>> ', 'Clear' bold, ' all user preferences and user state (class vars).
>> Then ', 'quit' bold, ' running the image.
>>
>> ','This action is for the maintainer of Haver!' red bold, '
>> Use at your own risk.' red
>> -- snap --
>>
>> I suggest to use something similar for Cuis.
>> Furthermore I would like to see this option,
>> together with my "Save New Haver Release",
>> in a Menu of its own withe something like
>> "Release Management". I am aware that this
>> single option menu will look a bit ridiculous
>> for Cuis, but it should make clear, that its
>> options are not intended for the casual Cuis/Haver
>> user.
> 
> It makes sense. But still, it is harmless, so I don't see a need to be 
> too strong about it.
It is intentionally too strong, I wanted to avoid lengthy explanations
like this one:
https://lists.cuis.st/mailman/archives/cuis-dev/2020-September/002264.html

If it's titled something like "Release Management" it should
give the causal user the right clue, Balloon Help can be overlooked
a menu title normally needs active ignorance to be overlooked.

> 
>>>
>>> I also flipped preference #checkLostChangesOnStartUp to false, as I 
>>> expect most people (like me) will prefer manually going over the 
>>> .user.???.changes files to recover stuff.
>> Thanks a lot!
>> This menu was most annoying, because it was displayed
>> before the display loop was started.
>> If you resized your VM window, which I did automatically,
>> you ended up with a white screen and you had to click smoewhere
>> on your VM window to get rid of that menu.
> 
> Oh, that must have been annoying!
> 
>>>
>>> And as usual, tweaks to VectorGraphics.
>> New VMs needed?
> 
> Not for the moment. Thank you. But all changes since last builds have 
> been pure Smalltalk, no impact in VectorEnginePlugin.
IC.
BTW: I found some (not easy reproducible) way to drive
the VectorgrahicsPlugin into a SegFault.

I attached a small package that enables the user to use
Control-ScrollUp/ScrollDown to zoom SystemWindows.
Currently it does not (always) work if your mouse
is over a scroll pane for obvious reasons
left as an exercise to the gentle reader.
You can also Press Control-0 to set the scale back to 1.

I used this package to test the scroll event stuff
with new event-handlers not previously in the image and
discovered that if you rapidly zoom in out, event handling
makes long (5 seconds) pauses, the hour-glass cursor is shown,
sometimes this ends up in a segmentation fault.
I tried 'Debug -> Message Tally ...' once, this ended
in a segfault in less than 2 seconds.

It gets worse if you zoom some a Browser-Window with
lots of text-heavy panes.

This might become a problem for Dr. Geo.


HTH,

Gerald
-------------- next part --------------
'From Haver 5.0 [latest update: #4758] on 17 August 2021 at 2:30:01 pm'!
'Description I provide modifications that support zooming Toplevel windows.'!
!provides: 'MorphZooming' 1 3!
!requires: 'VectorGraphics' 1 266 nil!






!Preferences class methodsFor: '*MorphZooming-queries' stamp: 'KLG 8/14/2021 21:45:24'!
controlVerticalScrollScalesSystemWindow
	"Answer true if the vertical wheel scrolling with the Control key pressed scales the system window."

	Smalltalk
		at: #VectorEngineWithPlugin 
		ifPresent: [ :plugin |
			plugin isPluginAvailable ifTrue: [
				^ self 
					valueOfFlag: #controlVerticalScrollScalesSystemWindow
					ifAbsent: [ true ] ] ]
		ifAbsent: [ ^ false ].
	! !

!SystemWindow methodsFor: '*MorphZooming-events' stamp: 'KLG 8/16/2021 22:08:10'!
handlesMouseScroll: aMouseScrollEvent
	"Answer true if we want mouse scroll events."
	
	aMouseScrollEvent controlKeyPressed ifFalse: [ 
		"D: Transcript cr; show: 'SW scroll no control key'.
		Transcript cr; show: aMouseScrollEvent buttons."
		^ super handlesMouseScroll: aMouseScrollEvent ].
	^ Preferences controlVerticalScrollScalesSystemWindow! !

!SystemWindow methodsFor: '*MorphZooming-events' stamp: 'KLG 8/16/2021 22:09:56'!
mouseScroll: aMouseScrollEvent localPosition: localEventPosition
	"Handle a mouse scroll event."

	| scaleFactor newScale |
	aMouseScrollEvent controlKeyPressed ifFalse: [ ^ self ].
	scaleFactor _ aMouseScrollEvent direction
		caseOf: {
			[ #up ] -> [ 1.05 ].
			[ #down ] -> [ `1 / 1.05` ].
			[ #left ] -> [ ^ self ].
			[ #right ] -> [ ^ self ] }.
	newScale _ self scale * scaleFactor min: 5 max: 0.5.
	(newScale - 1) abs < 0.01
		ifTrue: [ newScale _ 1 ].
	self scale: (newScale)! !

!KeyboardEvent methodsFor: '*MorphZooming-testing' stamp: 'KLG 8/16/2021 22:02:35'!
isScaleOneWindowShortcut

	^ (self commandAltKeyPressed or: [ self controlKeyPressed ])
		and: [self keyCharacter = $0]! !

!KeyboardEvent methodsFor: '*MorphZooming-actions' stamp: 'KLG 8/16/2021 21:58:32'!
scaleOneCurrentWindowOf: aMorph

	aMorph owningWindow ifNotNil: [ :w |
		(w containsGlobalPoint: position)
			ifTrue: [ w scale: 1 ] ].! !

!KeyboardEvent methodsFor: '*MorphZooming-dispatching' stamp: 'KLG 8/16/2021 22:03:01'!
sendEventTo: aMorph
	"Dispatch the receiver into anObject"
	type == #keystroke ifTrue: [
		self isFindClassShortcut
			ifTrue: [ ^ Preferences classFinder value ].
		self isCloseWindowShortcut
			ifTrue: [ ^ self closeCurrentWindowOf: aMorph ].
		self isScaleOneWindowShortcut ifTrue: [
			^ self scaleOneCurrentWindowOf: aMorph ].
		^ aMorph processKeystroke: self ].
	type == #keyDown ifTrue: [
		^ aMorph processKeyDown: self ].
	type == #keyUp ifTrue: [ 
		^ aMorph processKeyUp: self ].
	^ super sendEventTo: aMorph.! !


More information about the Cuis-dev mailing list