The Trunk: Morphic-mt.843.mcz

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

The Trunk: Morphic-mt.843.mcz

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

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

Name: Morphic-mt.843
Author: mt
Time: 8 April 2015, 8:31:38.574 pm
UUID: 1526b04c-0b9c-5546-ad8f-90e7925b10a5
Ancestors: Morphic-mt.842

Scroll pane refactored to avoid using floats for controlling the transform morph's offset but use integer values. This allows for a pixel-precise scrolling behavior.

Note: The postscript should correctly update all existing scroll panes and their scroll bars.

=============== Diff against Morphic-mt.842 ===============

Item was changed:
  ----- Method: IndentingListItemMorph>>charactersOccluded (in category 'private') -----
  charactersOccluded
  "Answer the number of characters occluded in my #visibleList by my right edge."
  | listIndex leftEdgeOfRightmostColumn eachString indexOfLastVisible iconWidth totalWidth |
  listIndex := 0.
  leftEdgeOfRightmostColumn := container columns
  ifNil: [ 0 ]
  ifNotNil:
  [ : cols | (1 to: cols size - 1)
  inject: 0
  into:
  [ : sum : each | sum + (self widthOfColumn: each) ] ].
  eachString := container columns
  ifNil: [ self complexContents asString ]
  ifNotNil:
  [ : cols | self contentsAtColumn: container columns size ].
  iconWidth := self icon
  ifNil: [ 0 ]
  ifNotNil:
  [ : icon | icon width + 2 ].
  totalWidth := self toggleBounds right.
  indexOfLastVisible := ((1 to: eachString size)
  detect:
  [ : stringIndex | (totalWidth:=totalWidth+(self fontToUse widthOf: (eachString at: stringIndex))) >
  (container width -
  (container vIsScrollbarShowing
+ ifTrue: [ container vScrollBar width ]
- ifTrue: [ container scrollBar width ]
  ifFalse: [ 0 ]) - iconWidth - leftEdgeOfRightmostColumn) ]
  ifNone: [ eachString size + 1 ]) - 1.
  ^ eachString size - indexOfLastVisible!

Item was removed:
- ----- Method: PluggableTextMorph>>hExtraScrollRange (in category 'scrolling') -----
- hExtraScrollRange
-
- ^ 0!

Item was removed:
- ----- Method: PluggableTextMorph>>vExtraScrollRange (in category 'scrolling') -----
- vExtraScrollRange
-
- ^ 10!

Item was removed:
- ----- Method: ScrollPane>>extraScrollRange (in category 'geometry') -----
- extraScrollRange
- "Return the amount of extra blank space to include below the bottom of the scroll content."
- "The classic behavior would be ^bounds height - (bounds height * 3 // 4)"
- ^ self scrollDeltaHeight!

Item was changed:
  ----- Method: ScrollPane>>hExtraScrollRange (in category 'geometry') -----
  hExtraScrollRange
  "Return the amount of extra blank space to include below the bottom of the scroll content."
+ ^ 0
- ^ self scrollDeltaWidth
  !

Item was changed:
  ----- Method: ScrollPane>>hIsScrollable (in category 'geometry testing') -----
  hIsScrollable
-
  "If the contents of the pane are too small to scroll, return false."
- ^ self hLeftoverScrollRange > 0
 
+ ^ self hLeftoverScrollRange > 0
  !

Item was changed:
  ----- Method: ScrollPane>>hLeftoverScrollRange (in category 'geometry') -----
  hLeftoverScrollRange
  "Return the entire scrolling range minus the currently viewed area."
+
+ ^ scroller hasSubmorphs
+ ifFalse: [0]
+ ifTrue: [self hTotalScrollRange - scroller width max: 0]
- | w |
- scroller hasSubmorphs ifFalse:[^0].
- w :=  bounds width.
- self vIsScrollbarShowing ifTrue:[ w := w - self scrollBarThickness ].
- ^ (self hTotalScrollRange - w roundTo: self scrollDeltaWidth) max: 0
  !

Item was added:
+ ----- Method: ScrollPane>>hScrollBar (in category 'access') -----
+ hScrollBar
+ ^ hScrollBar!

Item was changed:
  ----- Method: ScrollPane>>hScrollBarValue: (in category 'scrolling') -----
  hScrollBarValue: scrollValue
 
+ scroller hasSubmorphs ifFalse: [^ self].
+ lockOffset == true ifFalse: [
+ scroller offset: scrollValue @scroller offset y].
- | x |
- lockOffset == true ifTrue: [^ self].
-
- self hIsScrollbarShowing ifFalse:
- [^scroller offset: (0 - self hMargin)@scroller offset y].
- ((x := self hLeftoverScrollRange * scrollValue) <= 0)
- ifTrue:[x := 0 - self hMargin].
- scroller offset: (x@scroller offset y)
  !

Item was changed:
  ----- Method: ScrollPane>>hSetScrollDelta (in category 'geometry') -----
  hSetScrollDelta
  "Set the ScrollBar deltas, value and interval, based on the current scroll pane size, offset and range."
- | range delta |
 
+ | delta |
- scroller hasSubmorphs ifFalse:[scrollBar interval: 1.0. ^self].
-
  delta := self scrollDeltaWidth.
- range := self hLeftoverScrollRange.
- range = 0 ifTrue: [ hScrollBar scrollDelta: 0.02 pageDelta: 0.2; interval: 1.0; setValue: 0. ^self].
 
+ hScrollBar
+ truncate: true;
+ scrollDelta: delta
+ pageDelta: 10*delta;
+ maximumValue: self hLeftoverScrollRange;
+ interval: (self hTotalScrollRange = 0
+ ifTrue: [1.0]
+ ifFalse: [scroller width / self hTotalScrollRange]);
+ setValue: scroller offset x.!
- "Set up for one line (for arrow scrolling), or a full pane less one line (for paging)."
-
- hScrollBar
- scrollDelta: (delta / range) asFloat
- pageDelta: ((self innerBounds width - delta) / range) asFloat.
- hScrollBar interval: ((self innerBounds width) / self hTotalScrollRange) asFloat.
- hScrollBar setValue: ((scroller offset x / range) min: 1.0) asFloat.
- !

Item was changed:
  ----- Method: ScrollPane>>initializeScrollBars (in category 'initialization') -----
  initializeScrollBars
  "initialize the receiver's scrollBar"
 
+ (scrollBar := ScrollBar on: self getValue: nil setValue: #vScrollBarValue:)
- (scrollBar := ScrollBar new model: self slotName: 'vScrollBar')
  borderWidth: 1;
  borderColor: Color black.
+ (hScrollBar := ScrollBar on: self getValue: nil setValue: #hScrollBarValue:)
- (hScrollBar := ScrollBar new model: self slotName: 'hScrollBar')
  borderWidth: 1;
  borderColor: Color black.
 
  ""
  scroller := TransformMorph new color: Color transparent.
  scroller offset: 0 @ 0.
  self addMorph: scroller.
  ""
  scrollBar initializeEmbedded: retractableScrollBar not.
  hScrollBar initializeEmbedded: retractableScrollBar not.
  retractableScrollBar ifFalse:
  [self
  addMorph: scrollBar;
  addMorph: hScrollBar].
 
  Preferences alwaysShowVScrollbar ifTrue:
  [ self alwaysShowVScrollBar: true ].
 
  Preferences alwaysHideHScrollbar
  ifTrue:[self hideHScrollBarIndefinitely: true ]
  ifFalse:
  [Preferences alwaysShowHScrollbar ifTrue:
  [ self alwaysShowHScrollBar: true ]].
  !

Item was removed:
- ----- Method: ScrollPane>>scrollBar (in category 'testing') -----
- scrollBar
- ^ scrollBar!

Item was changed:
  ----- Method: ScrollPane>>scrollBy: (in category 'scrolling') -----
  scrollBy: delta
  "Move the contents in the direction delta."
 
+ self flag: #negated. "mt: Who uses this and why is does the expected behavor negate the delta?"
+ self vScrollBar scrollBy: delta y negated.
+ self hScrollBar scrollBy: delta x negated.!
- | newYoffset r newXoffset |
-
- "Set the offset on the scroller"
- newYoffset := scroller offset y - delta y max: 0.
- newXoffset := scroller offset x - delta x max: -3.
-
- scroller offset: newXoffset@ newYoffset.
-
- "Update the scrollBars"
- (r := self vLeftoverScrollRange) = 0
- ifTrue: [scrollBar value: 0.0]
- ifFalse: [scrollBar value: newYoffset asFloat / r].
- (r := self hLeftoverScrollRange) = 0
- ifTrue: [hScrollBar value: -3.0]
- ifFalse: [hScrollBar value: newXoffset asFloat / r]
- !

Item was changed:
  ----- Method: ScrollPane>>scrollByKeyboard: (in category 'event handling') -----
  scrollByKeyboard: event
  "If event is ctrl+up/down then scroll and answer true"
  (event controlKeyPressed or:[event commandKeyPressed]) ifFalse: [^ false].
+ event keyCharacter = Character arrowUp
- event keyValue = 30
  ifTrue:
  [scrollBar scrollUp: 3.
  ^ true].
+ event keyCharacter = Character arrowDown
- event keyValue = 31
  ifTrue:
  [scrollBar scrollDown: 3.
  ^ true].
+ "event keyCharacter = Character arrowRight
+ ifTrue:
+ [hScrollBar scrollDown: 3.
+ ^ true].
+ event keyCharacter = Character arrowLeft
+ ifTrue:
+ [hScrollBar scrollUp: 3.
+ ^ true]."
  ^ false!

Item was changed:
  ----- Method: ScrollPane>>setScrollDeltas (in category 'geometry') -----
  setScrollDeltas
  "Set the ScrollBar deltas, value and interval, based on the current scroll pane size, offset and range."
 
+ scroller hasSubmorphs ifFalse: [^ self].
- scroller hasSubmorphs ifFalse:
- [scrollBar interval: 1.0.
- hScrollBar interval: 1.0.
- ^ self].
 
  "NOTE: fullbounds commented out now -- trying to find a case where this expensive step is necessary -- perhaps there is a less expensive way to handle that case."
  "scroller fullBounds." "force recompute so that leftoverScrollRange will be up-to-date"
  self hideOrShowScrollBars.
+ self vSetScrollDelta.
+ self hSetScrollDelta..
-
- (retractableScrollBar or: [ self vIsScrollbarShowing ]) ifTrue:[ self vSetScrollDelta ].
- (retractableScrollBar or: [ self hIsScrollbarShowing ]) ifTrue:[ self hSetScrollDelta ].
  !

Item was changed:
  ----- Method: ScrollPane>>vExtraScrollRange (in category 'geometry') -----
  vExtraScrollRange
  "Return the amount of extra blank space to include below the bottom of the scroll content."
+ ^ 0
- "The classic behavior would be ^bounds height - (bounds height * 3 // 4)"
- ^ self scrollDeltaHeight
  !

Item was changed:
  ----- Method: ScrollPane>>vIsScrollable (in category 'geometry testing') -----
  vIsScrollable
+ "Return whether the verticle scrollbar is scrollable. If the contents of the pane are too small to scroll, return false."
+
+ ^ self vLeftoverScrollRange > 0!
- "Return whether the verticle scrollbar is scrollable"
-
- "If the contents of the pane are too small to scroll, return false."
- ^ self vLeftoverScrollRange > 0
- "treat a single line as non-scrollable"
- and: [self vTotalScrollRange > (self scrollDeltaHeight * 3/2)]
- !

Item was changed:
  ----- Method: ScrollPane>>vLeftoverScrollRange (in category 'geometry') -----
  vLeftoverScrollRange
  "Return the entire scrolling range minus the currently viewed area."
- | h |
 
+ ^ scroller hasSubmorphs
+ ifFalse: [0]
+ ifTrue: [self vTotalScrollRange - scroller height max: 0]
- scroller hasSubmorphs ifFalse:[^0].
- h := self vScrollBarHeight.
- ^ (self vTotalScrollRange - h roundTo: self scrollDeltaHeight) max: 0
  !

Item was added:
+ ----- Method: ScrollPane>>vScrollBar (in category 'access') -----
+ vScrollBar
+ ^ scrollBar!

Item was changed:
  ----- Method: ScrollPane>>vScrollBarValue: (in category 'scrolling') -----
  vScrollBarValue: scrollValue
+
  scroller hasSubmorphs ifFalse: [^ self].
  lockOffset == true ifFalse: [
+ scroller offset: scroller offset x @ scrollValue].
- scroller offset: (scroller offset x @ (self vLeftoverScrollRange * scrollValue) rounded)].
  !

Item was changed:
  ----- Method: ScrollPane>>vSetScrollDelta (in category 'geometry') -----
  vSetScrollDelta
  "Set the ScrollBar deltas, value and interval, based on the current scroll pane size, offset and range."
- | range delta |
 
+ | delta |
- scroller hasSubmorphs ifFalse:[scrollBar interval: 1.0. ^self].
-
  delta := self scrollDeltaHeight.
- range := self vLeftoverScrollRange.
- range = 0 ifTrue: [^ scrollBar scrollDelta: 0.02 pageDelta: 0.2; interval: 1.0; setValue: 0].
 
+ scrollBar
+ truncate: true;
+ scrollDelta: delta
+ pageDelta: 10*delta;
+ maximumValue: self vLeftoverScrollRange;
+ interval: (self vTotalScrollRange = 0
+ ifTrue: [1.0]
+ ifFalse: [scroller height / self vTotalScrollRange]);
+ setValue: scroller offset y.!
- "Set up for one line (for arrow scrolling), or a full pane less one line (for paging)."
- scrollBar scrollDelta: (delta / range) asFloat
- pageDelta: ((self innerBounds height - delta) / range) asFloat.
- scrollBar interval: ((self innerBounds height) / self vTotalScrollRange) asFloat.
- scrollBar setValue: (scroller offset y / range min: 1.0) asFloat.
- !

Item was changed:
  (PackageInfo named: 'Morphic') postscript: '(Preferences dictionaryOfPreferences at: #alternativeWindowBoxesLook) defaultValue: false.
  "Force SystemProgressMorph to be reset"
  SystemProgressMorph initialize; reset.
 
  "Initialize the key bindings and menus"
  Editor initialize.
 
  "Retain scrollBar look now that the pref actually does something"
  Preferences enable: #gradientScrollBars.
 
  "apply the new icons"
  MenuIcons initializeIcons.
  TheWorldMainDockingBar updateInstances.
 
-
  "Cleanup old-style preferences here. Remove before new release."
  Preferences removePreference: #gradientMenu. "Now in MenuMorph."
  Preferences removePreference: #roundedMenuCorners. "Now in MenuMorph."
 
  "Fix clipping bug of open windows. New ones are not affected."
+ TransformMorph allInstances do: [:ea | ea clipSubmorphs: true].
+
+ "Update existing scrollbars."
+ ScrollPane allSubInstances do: [:sc |
+ sc vScrollBar setValueSelector: #vScrollBarValue:.
+ sc hScrollBar setValueSelector: #hScrollBarValue:.
+ sc vSetScrollDelta; hSetScrollDelta].'!
- TransformMorph allInstances do: [:ea | ea clipSubmorphs: true].'!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Morphic-mt.843.mcz

marcel.taeumel (old)
Don't worry, I think this is the last *bigger* fix for the Squeak 4.6 release from my side. :)

Let's hope that the update code in the postscript works...

Best,
Marcel