Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1202.mcz ==================== Summary ==================== Name: Morphic-mt.1202 Author: mt Time: 28 July 2016, 11:57:51.049147 am UUID: e61b0d9d-ba29-b74a-a3ac-aaf3d1be624a Ancestors: Morphic-mt.1201 Add and use pragma-style preference for gradient scroll bars. =============== Diff against Morphic-mt.1201 =============== Item was changed: Slider subclass: #ScrollBar instanceVariableNames: 'menuButton upButton downButton pagingArea scrollDelta pageDelta interval menuSelector timeOfMouseDown timeOfLastScroll nextPageDirection currentScrollDelay' + classVariableNames: 'ArrowImagesCache BoxesImagesCache GradientScrollBar RoundedScrollBarLook ScrollBarsWithoutArrowButtons ScrollBarsWithoutMenuButton UpArrow UpArrow8Bit' - classVariableNames: 'ArrowImagesCache BoxesImagesCache RoundedScrollBarLook ScrollBarsWithoutArrowButtons ScrollBarsWithoutMenuButton UpArrow UpArrow8Bit' poolDictionaries: '' category: 'Morphic-Windows'! !ScrollBar commentStamp: '<historical>' prior: 0! Inspired by an oiginal design of Hans-Martin Mosner, this ScrollBar is intended to exercise the handling of input events in Morphic. With sufficient flexibility in this area, all particular behavior can be concentrated in this single class with no need to specialize any other morphs to achieve button, slider and menu-button behavior. Once we have this working, put in logic for horizontal operation as well. CachedImages was added to reduce the number of forms created and thrown away. This will be helpful for Nebraska and others as well.! Item was changed: ----- Method: ScrollBar class>>createArrowOfDirection:size:color: (in category 'images') ----- createArrowOfDirection: aSymbolDirection size: finalSizeInteger color: aColor "PRIVATE - create an arrow with aSymbolDirectionDirection, finalSizeInteger and aColor aSymbolDirectionDirection = #top, #bottom. #left or #right Try with: (ScrollBar createArrowOfDirection: #top size: 32 color: Color lightGreen) asMorph openInHand. " | resizeFactor outerBox arrow resizedForm gradient | resizeFactor := 4. outerBox := RectangleMorph new extent: finalSizeInteger asPoint * resizeFactor; borderWidth: 0; color: aColor. + self gradientScrollBar ifTrue: [ - Preferences gradientScrollBars ifTrue: [ gradient := GradientFillStyle ramp: { 0 -> (Color gray: 0.95). 0.49 -> (Color gray: 0.9). 0.5 -> (Color gray: 0.87). 1 -> (Color gray: 0.93). }. gradient origin: outerBox topLeft. (aSymbolDirection == #left or:[aSymbolDirection == #right]) ifTrue:[gradient direction: 0@ outerBox height] ifFalse:[gradient direction: outerBox width @ 0]. outerBox fillStyle: gradient]. outerBox borderStyle: (BorderStyle width: 4 color: Color lightGray). "" arrow := self createArrowOfDirection: aSymbolDirection in: (outerBox bounds expandBy: -4). self updateScrollBarButtonAspect: arrow color: aColor muchDarker. outerBox addMorphCentered: arrow. "" resizedForm := outerBox imageForm magnify: outerBox imageForm boundingBox by: 1 / resizeFactor smoothing: 4. "" ^ (resizedForm replaceColor: aColor withColor: Color transparent) trimBordersOfColor: Color transparent! Item was changed: ----- Method: ScrollBar class>>createBoxOfSize:color: (in category 'images') ----- createBoxOfSize: finalSizeInteger color: aColor "PRIVATE - create a box with finalSizeInteger and aColor Try with: (ScrollBar createBoxOfSize: 32 color: Color lightGreen) asMorph openInHand. " | resizeFactor outerBox innerBox resizedForm gradient | resizeFactor := 4. outerBox := RectangleMorph new extent: finalSizeInteger asPoint * resizeFactor; borderWidth: 0; color: aColor. + self gradientScrollBar ifTrue: [ - Preferences gradientScrollBars ifTrue: [ gradient := GradientFillStyle ramp: { 0 -> (Color gray: 0.95). 0.49 -> (Color gray: 0.9). 0.5 -> (Color gray: 0.87). 1 -> (Color gray: 0.93). }. gradient origin: outerBox topLeft. gradient direction: outerBox width @ 0. outerBox fillStyle: gradient]. outerBox borderStyle: (BorderStyle width: 4 color: Color lightGray). "" innerBox := self createBoxIn: (outerBox bounds expandBy: -4). self updateScrollBarButtonAspect: innerBox color: aColor muchDarker. outerBox addMorphCentered: innerBox. "" resizedForm := outerBox imageForm magnify: outerBox imageForm boundingBox by: 1 / resizeFactor smoothing: 4. "" ^ (resizedForm replaceColor: aColor withColor: Color transparent) trimBordersOfColor: Color transparent! Item was added: + ----- Method: ScrollBar class>>gradientScrollBar (in category 'preferences') ----- + gradientScrollBar + + <preference: 'gradientScrollBar' + categoryList: #(windows scrolling) + description: 'If true, scroll bars will have a gradient look.' + type: #Boolean> + ^ GradientScrollBar ifNil: [false]! Item was added: + ----- Method: ScrollBar class>>gradientScrollBar: (in category 'preferences') ----- + gradientScrollBar: aBoolean + + GradientScrollBar = aBoolean ifTrue: [^ self]. + GradientScrollBar := aBoolean. + + ScrollBar allSubInstancesDo: [:ea | ea updateSliderColor].! Item was changed: ----- Method: ScrollBar class>>updateScrollBarButtonAspect:color: (in category 'coloring morphs') ----- updateScrollBarButtonAspect: aMorph color: aColor "update aMorph with aColor" | fill direction | aMorph isNil ifTrue: [^ self]. "" aMorph color: aColor. + self gradientScrollBar - Preferences gradientScrollBars ifFalse: [^ self]. "" fill := GradientFillStyle ramp: { 0.0 -> aColor twiceLighter twiceLighter. 1.0 -> aColor twiceDarker}. "" direction := ((aMorph width min: aMorph height) + ((aMorph width - aMorph height) abs * 0.3)) rounded. "" fill origin: aMorph topLeft + (direction // 8). fill direction: direction @ direction. fill radial: true. "" aMorph fillStyle: fill! Item was changed: ----- Method: ScrollBar>>initializePagingArea (in category 'initialize') ----- initializePagingArea "Appearance" pagingArea := RectangleMorph newBounds: self totalSliderArea color: (self class roundedScrollBarLook ifTrue: [Color gray: 0.9] ifFalse: [Color r: 0.6 g: 0.6 b: 0.8]). + self class gradientScrollBar - Preferences gradientScrollBars ifTrue: [pagingArea setBorderWidth: 1 borderColor: (Color lightGray alpha: 0.5)] ifFalse: [pagingArea borderWidth: 0]. self addMorphBack: pagingArea. "Interactions" pagingArea on: #mouseDown send: #scrollPageInit: to: self. pagingArea on: #mouseUp send: #finishedScrolling to: self. ! Item was added: + ----- Method: ScrollBar>>updateSliderColor (in category 'access') ----- + updateSliderColor + + self updateSliderColor: self sliderColor.! Item was changed: ----- Method: ScrollBar>>updateSliderColor: (in category 'access') ----- updateSliderColor: aColor | gradient | + self class gradientScrollBar ifFalse: [ - Preferences gradientScrollBars ifFalse: [ slider borderColor: (aColor adjustBrightness: -0.3); color: aColor. pagingArea borderColor: (aColor muchDarker alpha: pagingArea borderStyle color alpha); color: (aColor darker alpha: 0.35). ^ self]. slider borderStyle: (BorderStyle width: 1 color: Color lightGray). "Fill the slider." gradient := GradientFillStyle ramp: { 0 -> (Color gray: 0.95). 0.49 -> (Color gray: 0.9). 0.5 -> (Color gray: 0.87). 1 -> (Color gray: 0.93). }. gradient origin: slider topLeft. gradient direction: (self orientation == #horizontal ifTrue:[0@slider height] ifFalse:[slider width@0]). slider fillStyle: gradient. "Fill the paging area." gradient := GradientFillStyle ramp: { 0 -> (Color gray: 0.65). 0.6 -> (Color gray: 0.82). 1 -> (Color gray: 0.88). }. gradient origin: self topLeft. gradient direction: (self orientation == #horizontal ifTrue:[0@self height] ifFalse:[self width@0]). pagingArea fillStyle: gradient.! |
Free forum by Nabble | Edit this page |