Etoys: Morphic-kfr.82.mcz

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

Etoys: Morphic-kfr.82.mcz

commits-2
Karl Ramberg uploaded a new version of Morphic to project Etoys:
http://source.squeak.org/etoys/Morphic-kfr.82.mcz

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

Name: Morphic-kfr.82
Author: kfr
Time: 5 March 2012, 9:03:03 pm
UUID: f9891cac-5355-ee47-86fb-f69e5deeba55
Ancestors: Morphic-kfr.81

Change Set:             graphingFixes-sw
Date:                   4 March 2012
Author:                 Scott Wallace

Addresses various bug-reports and recommendations relating to recent number-line and graph-paper updates:
- Enforce reasonable ranges for the sliders governing the grid parameters, taking the grid-size, coarse-grid-size , and playfield dimensions into account.
- Provide a button to request 'graph paper' from the 'generic property sheet' when appropriate.
- Retain position of number line when its pixelsPerUnit changes.
- Disable the 'offset' when coarse-grid in effect.
- Protect sliders against zero-divide that can happen if minVal = maxVal.
- Protect InfiniteForms against incidental calls to #darker and #twiceDarker that can be sent to any object's fillStyle by some of the custom border code.
- Removes about a dozen superfluous methods that had mistakenly lingered in the earlier updates, and removes three inst vars of NumberLineMorph that were remnants from earlier code

=============== Diff against Morphic-kfr.81 ===============

Item was changed:
  ----- Method: GraphPaperPanel>>adjustOffset: (in category 'adjusting parameters') -----
  adjustOffset: aFractionalPoint
  "Adjust the offset to reflect the value embodied in the argument supplied."
 
+ | constrained |
+ constrained := aFractionalPoint min: (1 @ 1) max: (-1 @ -1).
+ offset := (constrained * self gridEvery asPoint) rounded.
- offset := (aFractionalPoint * self extent) rounded.
  self showSliderFeedback: offset.
  self makeToolReflectCurrentSettings!

Item was changed:
  ----- Method: GraphPaperPanel>>darkerGridEvery: (in category 'accessing') -----
  darkerGridEvery: aNumber
  "Set the value of darkerGridEvery."
 
  darkerGridEvery := aNumber rounded.
+ self harmonizeGridEvery.
  self makeToolReflectCurrentSettings!

Item was changed:
  ----- Method: GraphPaperPanel>>doEnables (in category 'private') -----
  doEnables
  "Carry out appropriate enablings within the receiver's interior."
 
+ | itsName existing |
+ existing := darkerGridEvery.
+ self harmonizeCoarseGrid.
+ existing = darkerGridEvery ifFalse:
+ [self makeToolReflectCurrentSettings].
+
- | itsName |
  self allMorphsDo: [ :each |
  itsName := each knownName.
  (#(pickerForDarkerGrid darkerGridEvery) includes: itsName) ifTrue:
+ [self enable: each when: self showDarkerGridAlso].
+ (#(offset) includes: itsName) ifTrue:
+ [self enable: each when: true]]!
- [self enable: each when: self showDarkerGridAlso]]!

Item was changed:
  ----- Method: GraphPaperPanel>>gridEvery: (in category 'accessing') -----
  gridEvery: aNumber
  "Set the value of gridEvery"
 
  gridEvery := aNumber rounded.
+ self harmonizeCoarseGrid.
  self makeToolReflectCurrentSettings!

Item was added:
+ ----- Method: GraphPaperPanel>>harmonizeCoarseGrid (in category 'adjusting parameters') -----
+ harmonizeCoarseGrid
+ "The pixelsPerUnit having changed, reconsider  'darkerGridEvery'  and the slider that governs it."
+
+ | aSlider maxGridEvery |
+ maxGridEvery := self maxValueForCoarseGrid.
+ darkerGridEvery := darkerGridEvery min:  maxGridEvery max: 2.
+ aSlider := self deepSubpartNamed: #darkerGridEverySlider.
+ aSlider ifNotNil:
+ [aSlider setMaxVal: maxGridEvery.
+ aSlider adjustToValue: darkerGridEvery]
+
+ !

Item was added:
+ ----- Method: GraphPaperPanel>>harmonizeGridEvery (in category 'adjusting parameters') -----
+ harmonizeGridEvery
+ "Other metrics having possibly changed, make sure the gridEvery variable is within range and that its slider offers a reasonable range of values."
+
+ | aSlider maxGridEvery |
+ maxGridEvery := self maxValueForGridEvery.
+ gridEvery := gridEvery min:  maxGridEvery max: 10.
+ aSlider := self deepSubpartNamed: #gridEverySlider.
+ aSlider ifNotNil:
+ [aSlider setMaxVal: maxGridEvery.
+ aSlider adjustToValue: gridEvery]
+
+ !

Item was changed:
  ----- Method: GraphPaperPanel>>initialize (in category 'initialization') -----
  initialize
  "Initialize the receiver.  Notice that, because of GenericPropertiesMorph's custom, 'myTarget' is already set before this is called."
 
  | existing toUse |
  super initialize.
  existing := myTarget renderedMorph valueOfProperty: #graphPaperParameters.
  toUse := existing
  ifNotNil:
  [existing deepCopy]
  ifNil:
  [GraphPaperParameters new].
  backgroundColor := existing
  ifNotNil:
  [toUse backgroundColor]
  ifNil:
  [myTarget color asColor].
  gridColor := toUse gridColor.
  gridEvery := toUse gridEvery.
  showDarkerGridAlso := toUse showDarkerGridAlso.
  darkerGridColor := toUse darkerGridColor.
  darkerGridEvery := toUse darkerGridEvery.
+ offset := toUse showDarkerGridAlso ifTrue: [toUse offset] ifFalse: [0 @ 0].
- offset := toUse offset.
 
  thingsToRevert at: #fillStyle: put: myTarget fillStyle.
  self rebuild.
 
  self makeToolReflectCurrentSettings
 
  !

Item was added:
+ ----- Method: GraphPaperPanel>>maxValueForCoarseGrid (in category 'adjusting parameters') -----
+ maxValueForCoarseGrid
+ "Given the pixelsPerUnit and the dimensions of my target, determine and answer a plausible maximum value for the coarse-grid multiplier."
+
+ | maxDimension |
+ maxDimension := myTarget width max: myTarget height.
+ ^ ((maxDimension // gridEvery) - 1) max: 2!

Item was added:
+ ----- Method: GraphPaperPanel>>maxValueForGridEvery (in category 'adjusting parameters') -----
+ maxValueForGridEvery
+ "Answer the largest plausible value for gridEvery"
+
+ | maxDimension |
+ maxDimension := myTarget width max: myTarget height.
+ ^ self showDarkerGridAlso
+ ifTrue:
+ [maxDimension // darkerGridEvery]
+ ifFalse:
+ [(maxDimension - 1) max: 10]!

Item was changed:
  ----- Method: GraphPaperPanel>>paneForDarkerGridEvery (in category 'panes') -----
  paneForDarkerGridEvery
  "Answer a pane for the darkerGridEvery datum."
 
  | aSlider |
  aSlider :=  SimpleSliderMorph new
  color: color darker;
  extent: 100@28;
  target: self;
  minVal: 2;
  maxVal: 40;
  actionSelector: #darkerGridEvery:;
+ setNameTo: #darkerGridEverySlider;
  adjustToValue: self darkerGridEvery.
 
  ^ (self inARow: {
  (UpdatingStringMorph new)
  getSelector: #darkerGridEvery;
  putSelector: #darkerGridEvery:;
  target: self;
  growable: false;
  decimalPlaces: 0;
  minimumWidth: 40;
  maximumWidth: 40;
  yourself.
  aSlider}) setNameTo: #darkerGridEvery; yourself!

Item was changed:
  ----- Method: GraphPaperPanel>>paneForGridEvery (in category 'panes') -----
  paneForGridEvery
  "Answer a pane to govern the gridEvery datum."
 
  | aSlider |
  aSlider :=  SimpleSliderMorph new
  color: color darker;
  extent: 100@28;
  target: self;
  minVal: 4;
  maxVal: 360;
  actionSelector: #gridEvery:;
+ setNameTo: #gridEverySlider;
  adjustToValue: self gridEvery.
 
  ^ self inARow: {
  self lockedString: ('grid size' translated, '  ').
  (UpdatingStringMorph new)
  getSelector: #gridEvery;
  putSelector: #gridEvery:;
  target: self;
  growable: false;
  decimalPlaces: 0;
  minimumWidth: 40;
  maximumWidth: 40;
  yourself.
  aSlider}!

Item was changed:
  ----- Method: GraphPaperPanel>>paneForOffset (in category 'panes') -----
  paneForOffset
  "Answer a pane for the Offset button."
 
+ | aPane |
+ aPane := (self inARow: {
- ^ (self inARow: {
  self
  buildFakeSlider: 'Offset' translated
  selector: #adjustOffset:
  help: 'Drag in here to change the offset' translated
+ }) hResizing: #shrinkWrap.
+ aPane setNameTo: #offset.
+ ^ aPane
- }) hResizing: #shrinkWrap
 
  !

Item was changed:
  ----- Method: GraphPaperPanel>>toggleShowDarkerGridAlso (in category 'adjusting parameters') -----
  toggleShowDarkerGridAlso
  "Toggle whether a secondary grid should be shown."
 
  showDarkerGridAlso := self showDarkerGridAlso not.
+ showDarkerGridAlso ifTrue: [offset := 0].
  self rebuild.
  self doEnables.
  self makeToolReflectCurrentSettings!

Item was added:
+ ----- Method: Morph>>deepSubpartNamed: (in category 'accessing') -----
+ deepSubpartNamed: aName
+ "Answer, from anywhere in the morph tree beneath the receiver, a subpart of the given name -- nil if none."
+
+ ^ self allMorphs detect: [:m | m externalName = aName] ifNone: [nil]!

Item was added:
+ ----- Method: Morph>>wantsGraphPaperAlternative (in category 'testing') -----
+ wantsGraphPaperAlternative
+ "Answer whether the receiver woud be willing to adopt graph paper as a fill style."
+
+ ^ false!

Item was added:
+ ----- Method: PasteUpMorph>>wantsGraphPaperAlternative (in category 'testing') -----
+ wantsGraphPaperAlternative
+ "Answer whether the receiver woud be willing to adopt graph paper as a fill style."
+
+ ^ true!

_______________________________________________
etoys-dev mailing list
[hidden email]
http://lists.squeakland.org/mailman/listinfo/etoys-dev