The Trunk: Morphic-mt.1218.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Morphic-mt.1218.mcz

commits-2
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1218.mcz

==================== Summary ====================

Name: Morphic-mt.1218
Author: mt
Time: 1 August 2016, 2:42:37.666063 pm
UUID: c5757b59-e3d1-5841-a689-f52f1a38c28e
Ancestors: Morphic-mt.1217

Add the possibility to filter button-only dialogs via keyboard expressions as known from menus.

=============== Diff against Morphic-mt.1217 ===============

Item was changed:
  Morph subclass: #DialogWindow
+ instanceVariableNames: 'titleMorph messageMorph paneMorph buttonRow result selectedButton cancelButton timeout preferredPosition keyMap exclusive filter filterEnabled filterMorph'
- instanceVariableNames: 'titleMorph messageMorph paneMorph buttonRow result selectedButton cancelButton timeout preferredPosition keyMap exclusive'
  classVariableNames: 'GradientDialog RoundedDialogCorners UseWiggleAnimation'
  poolDictionaries: ''
  category: 'Morphic-Windows'!
 
  !DialogWindow commentStamp: '<historical>' prior: 0!
  A DialogBoxMorph is Morph used in simple yes/no/confirm dialogs. Strongly modal.!

Item was changed:
  ----- Method: DialogWindow>>createBody (in category 'initialization') -----
  createBody
 
  | body |
  body := Morph new
  changeTableLayout;
  hResizing: #shrinkWrap;
  vResizing: #shrinkWrap;
  listDirection: #topToBottom;
  cellPositioning: #leftCenter;
  layoutInset: (10@5 corner: 10@10);
  cellInset: 5;
  color: Color transparent;
  yourself.
+ body addAllMorphs: {self createMessage: ''. self createPane. self createButtonRow. self createFilter}.
- body addAllMorphs: {self createMessage: ''. self createPane. self createButtonRow}.
  self addMorphBack: body.!

Item was added:
+ ----- Method: DialogWindow>>createFilter (in category 'initialization') -----
+ createFilter
+
+ filterMorph := '' asText asMorph lock.
+ filterMorph
+ visible: false;
+ disableTableLayout: true.
+ ^ filterMorph!

Item was changed:
  ----- Method: DialogWindow>>drawOverlayOn: (in category 'drawing') -----
  drawOverlayOn: aCanvas
 
  | title inset |
  super drawOverlayOn: aCanvas.
 
  title := self submorphs first.
 
  self wantsRoundedCorners ifTrue: [
  inset := (self class roundedDialogCorners and: [self class gradientDialog])
  "This check compensates a bug in balloon."
  ifTrue: [0@0 corner: 0@ -1] ifFalse: [self borderWidth @ 0].
 
  "Overdraw lower part of title bar to hide bottom corners."
  aCanvas
  fillRectangle:( (title bottomLeft - (0 @ self submorphs first cornerRadius) corner: title bottomRight) insetBy: inset)
  color: self color].
 
  "Draw a line between the title and the contents."
  self borderWidth > 0 ifTrue: [
  "Redraw the border all around. Needed because rounded borders do not align very well."
  self wantsRoundedCorners
  ifTrue: [ aCanvas frameRoundRect: self bounds radius: self cornerRadius width: self borderStyle width color: self borderStyle color]
  ifFalse: [aCanvas frameRectangle: self bounds width: self borderStyle width color: self borderStyle color]].!

Item was changed:
  ----- Method: DialogWindow>>ensureSelectedButton (in category 'selection') -----
  ensureSelectedButton
 
+ self buttons ifEmpty: [^ self].
+ self selectedButton ifNil: [self selectButton: self buttons first].
+ self selectedButton enabled ifFalse: [self selectNextButton].!
- self selectedButton ifNil: [self selectButton: self buttons first].!

Item was added:
+ ----- Method: DialogWindow>>filter (in category 'accessing') -----
+ filter
+ ^ filter ifNil: ['']!

Item was added:
+ ----- Method: DialogWindow>>filter: (in category 'accessing') -----
+ filter: aString
+ filter := aString.
+ self updateFilter.!

Item was added:
+ ----- Method: DialogWindow>>filterEnabled (in category 'accessing') -----
+ filterEnabled
+ ^ filterEnabled ifNil: [false]!

Item was added:
+ ----- Method: DialogWindow>>filterEnabled: (in category 'accessing') -----
+ filterEnabled: aBoolean
+
+ filterEnabled := aBoolean.
+ self updateFilter.!

Item was changed:
  ----- Method: DialogWindow>>keyStroke: (in category 'events') -----
  keyStroke: evt
  | char |
  self stopAutoTrigger.
  char := evt keyCharacter.
 
  char = Character escape ifTrue: [ ^ self cancelDialog ].
  (char = Character cr or: [char = Character enter]) ifTrue: [ ^ self closeDialog ].
 
  ((char = Character arrowLeft or: [char = Character arrowUp])
  or: [ evt shiftPressed and: [ char = Character tab ] ])
  ifTrue: [ ^ self selectPreviousButton ].
  ((char = Character arrowRight or: [char = Character arrowDown])
  or: [ char = Character tab ])
  ifTrue: [ ^ self selectNextButton ].
+
+ self filterEnabled ifTrue: [
+ char = Character backspace ifTrue: [self filter: (self filter ifEmpty: [''] ifNotEmpty: [:f | f allButLast])].
+ (char isAlphaNumeric or: [char = Character space])
+ ifTrue: [self filter: self filter, char asString]].
+
-
  keyMap
  at: char asLowercase
  ifPresent: [ : foundButton | foundButton performAction ]
  ifAbsent: [ "do nothing" ].!

Item was changed:
  ----- Method: DialogWindow>>selectNextButton (in category 'selection') -----
  selectNextButton
 
  self selectedButton ifNil: [^ self].
+ (self buttons anySatisfy: [:ea | ea enabled]) ifFalse: [^ self].
+
+ self selectedButtonIndex: self selectedButtonIndex \\ self buttons size + 1.
+ self selectedButton enabled ifFalse: [self selectNextButton].!
- self selectedButtonIndex: self selectedButtonIndex \\ self buttons size + 1.!

Item was changed:
  ----- Method: DialogWindow>>selectPreviousButton (in category 'selection') -----
  selectPreviousButton
 
  self selectedButton ifNil: [^ self].
+ (self buttons anySatisfy: [:ea | ea enabled]) ifFalse: [^ self].
+
+ self selectedButtonIndex: self selectedButtonIndex - 2 \\ self buttons size + 1.
+ self selectedButton enabled ifFalse: [self selectPreviousButton].!
- self selectedButtonIndex: self selectedButtonIndex - 2 \\ self buttons size + 1.!

Item was changed:
  ----- Method: DialogWindow>>setMessageParameters (in category 'initialization') -----
  setMessageParameters
 
  messageMorph ifNotNil: [
  | fontToUse colorToUse |
  fontToUse := self userInterfaceTheme font ifNil: [TextStyle defaultFont].
  colorToUse := self userInterfaceTheme textColor ifNil: [Color black].
 
  messageMorph contents
  addAttribute: (TextFontReference toFont: fontToUse);
  addAttribute: (TextColor color: colorToUse).
+ messageMorph textColor: colorToUse.
  messageMorph releaseParagraph; changed].!

Item was added:
+ ----- Method: DialogWindow>>updateFilter (in category 'updating') -----
+ updateFilter
+
+ self buttons do: [:ea |
+ ea enabled: (self filter isEmpty or: [ea label asString includesSubstring: self filter caseSensitive: false])].
+
+ filterMorph
+ visible: self filter notEmpty;
+ disableTableLayout: self filter isEmpty;
+ contents: '<', self filter, '>';
+ textColor: self messageMorph textColor.
+
+ self ensureSelectedButton.!