Andreas Raab uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-ar.120.mcz ==================== Summary ==================== Name: Graphics-ar.120 Author: ar Time: 9 March 2010, 10:46:20.491 pm UUID: 4f4d332a-a71e-7943-a69e-7483f611a7d8 Ancestors: Graphics-nice.118 Graphics fixes: - Add CursorWithAlpha from OLPC. Try this: CursorWithAlpha biggerNormal showWhile:[Sensor waitButton]. - Fix Cursor>>showWhile: to not allow changing the cursor unless being invoked from the UI process. - Fix Form>>asFormOfDepth: to have alpha set when converting from 16 -> 32 bit. =============== Diff against Graphics-nice.118 =============== Item was added: + ----- Method: CursorWithAlpha classSide>>biggerNormal (in category 'constants') ----- + biggerNormal + "self biggerNormal showWhile:[Sensor waitButton]" + "(Base64MimeConverter mimeEncode: ((FileStream readOnlyFileNamed: 'EtoysCursor.png') binary)) upToEnd" + + ^self constants at: #biggerNormal ifAbsentPut: [ + | form cursor | + form := (PNGReadWriter on: (Base64MimeConverter mimeDecodeToBytes: + 'iVBORw0KGgoAAAANSUhEUgAAABsAAAArCAYAAACJrvP4AAAACXBIWXMAAAsTAAALEwEAmpwY + AAAEF0lEQVRYCb2XS0hcVxjHj2/G8ZWMQQbSGO2iRhERwRALBmJNoOOqwUXtYtxOTQJxI8SN + CyXJqggVEghusrAuBB8IddUWF64CvnCj+AJrsYKio6JJOPn/j+dc5s6MztyZMR/857v3PL7f + /c4595w7QmiTUvrN9ZV7wGhfB3jOunpgOoYtPQQm19fXn6DsulY2PJUSi4ARvLm5+SuiE5hS + mAsBXSYzv99vLuXExMRL1H2jlRKoDYbAMhS4uLj4PJUwN4K5TTqEhQPHxsZeayCzTCrDqLC0 + tLQryTAqjNmFA1OR4YWwaMBk5/BSWDRgMhnGhEUDJpphXDACqdDXIpEMHcHCF43TDB3Bks0w + IVj4kMabYcKwcGA8c+gIlp2drRaKGc5wYKwMHcFycnIiYOHACzLkhi9SAgsHRsnQOSzaMBJk + FPoejo6OvkJ5iZY67R1lZoJe5kOBKysrzxzBCgoKrCcnpKysTO7v75sjMKafmZl5gX6uNPww + M4EeQXrsEAJDJc7Ozngr8vPzRVVVldjZ2RGrq6uqrLi4WPT394u2tjZxeHj4P8C7qiLkJzMz + 8zNvc3NzT+jR/yl9xDBmZWWpTAoLC2V9fb3c29uTXV1dtuwaGxtVRgcHBzuI0QY91vLBUw+0 + voOnXPyyijBEUWWVlZViampKFBUVCcyDKC8vt9pitYnp6WlmfqO7u/uOVRHjIiKzjIwM2dDQ + oDIKnZCWlhZbdoFAQFUvLCz8Bcb3WrfgqWItFR/XKrEIWG1trQWam5v7Z3Bw8C2jjoyMyNLS + UgvIYeYQ05A5h5HA+GE1NTVWgPn5+b/RubWiosJ/enoaZNDq6moLhjrZ19fHYjk7O/sO9/eg + G1oZ8JTNbJmZJ9Wgn9GyleJQMWhPT48NhnllsTw+Pv4X7WLCuI1YX8TsuLy8/CfKmrXuwt9t + b2//iXX4LJder9cCut1uOT4+zio5PDz8G9pWaqm4uLaZDaZBXLY2GO4bdnd3PzAowDZYc3Mz + i+X29vY82l0K4ypR/2JOTk7e49qsIuMLUEbdXFpaes6gk5OT0uPxWECeBGtra6ySvb29v6Bt + ve7DfjZTsKOjo99RyvkzEOMtGOpuBoPBbQblQsK9Ejfnzs5OFsuNjY0JlF8IQ11clodWeVgo + bxh0YGDABmOmNGxzh2j3EPJqRV2VqLvUFKyjo+NHBuWqxb4nS0pKVFZmGFG+gihJw8wTerHx + /kEgXng6y7a2thYxnAHAHkHfavEcoxyZBcOh+AOHixS+7HwnfT4f/6nynSQoaZh5MjWcTU1N + 94aGhtrr6up8qLgPcVFQd7SuwVPmIdN5njk1wmi31a8QHu3VuYVrLhDaf+dOHGgvE4Gp3RsB + cnUQMx+f9P1H7c9PXyHUIcoy01HXX637AibwgHAnFRPGAAAAAElFTkSuQmCC' + readStream) readStream) nextImage. + cursor := CursorWithAlpha extent: form extent depth: 32. + form displayOn: cursor. + cursor offset: -2 @ -1. + cursor preMultiplyAlpha. + cursor]! Item was added: + Cursor subclass: #CursorWithAlpha + instanceVariableNames: 'fallback' + classVariableNames: 'Constants' + poolDictionaries: '' + category: 'Graphics-Display Objects'! + + !CursorWithAlpha commentStamp: '<historical>' prior: 0! + A 32-bit ARGB Cursor of arbitrary extent (some platforms may limit the size). Compositing assumes alpha is pre-multiplied.! Item was added: + ----- Method: CursorWithAlpha classSide>>resetConstants (in category 'constants') ----- + resetConstants + Constants := nil. + ! Item was added: + ----- Method: CursorWithAlpha>>fallback: (in category 'accessing') ----- + fallback: aCursor + fallback := aCursor! Item was changed: ----- Method: Cursor>>showWhile: (in category 'displaying') ----- showWhile: aBlock + "While evaluating the argument, aBlock, make the receiver be the cursor shape." + "ar 2/2/2006: Only allow this if active process is ui process" - "While evaluating the argument, aBlock, make the receiver be the cursor - shape." - | oldcursor | + Processor activeProcess == Project uiProcess ifFalse:[^aBlock value]. oldcursor := Sensor currentCursor. self show. ^aBlock ensure: [oldcursor show] ! Item was added: + ----- Method: Form>>fillAlpha: (in category 'other') ----- + fillAlpha: alphaValue + "Fill a 32bit form with a constant alpha value" + | bb | + self depth = 32 ifFalse:[^self error: 'Only valid for 32 bit forms']. + bb := BitBlt toForm: self. + bb combinationRule: 7. "bitOr:with:". + bb fillColor: (Bitmap with: alphaValue << 24). + bb copyBits. + ! Item was added: + ----- Method: CursorWithAlpha>>fallback (in category 'accessing') ----- + fallback + ^fallback ifNil: [NormalCursor]! Item was changed: ----- Method: Form>>asFormOfDepth: (in category 'converting') ----- asFormOfDepth: d | newForm | d = self depth ifTrue:[^self]. newForm := Form extent: self extent depth: d. (BitBlt current toForm: newForm) colorMap: (self colormapIfNeededFor: newForm); copy: (self boundingBox) from: 0@0 in: self fillColor: nil rule: Form over. + "Special case: For a 16 -> 32 bit conversion fill the alpha channel because it gets lost in translation." + (self depth = 16 and:[d= 32]) ifTrue:[newForm fillAlpha: 255]. ^newForm! Item was added: + ----- Method: CursorWithAlpha>>asCursorForm (in category 'converting') ----- + asCursorForm + + ^ self as: StaticForm! Item was added: + ----- Method: Form>>preMultiplyAlpha (in category 'other') ----- + preMultiplyAlpha + "Pre-multiply each pixel by its alpha, for proper alpha compositing (BitBlt rule 34). + E.g., half-transparent green 16r7F00FF00 becomes 16r7F007F00" + + depth = 32 ifFalse: [^self]. + 1 to: bits size do: [:i | + | v a r g b | + v := bits at: i. + a := v bitShift: -24. + r := ((v bitShift: -16) bitAnd: 255) * a // 255. + g := ((v bitShift: -8) bitAnd: 255) * a // 255. + b := (v bitAnd: 255) * a // 255. + bits at: i put: (a bitShift: 24) + (r bitShift: 16) + (g bitShift: 8) + b].! Item was added: + ----- Method: CursorWithAlpha classSide>>constants (in category 'constants') ----- + constants + ^Constants ifNil: [Constants := Dictionary new]! Item was added: + ----- Method: CursorWithAlpha>>primBeCursor (in category 'primitives') ----- + primBeCursor + <primitive: 101> + self fallback primBeCursor! |
sweet
|
On 10.03.2010, at 09:06, Alexander Lazarević wrote:
> > sweet Hehe, thanks. Try this: CursorWithAlpha fromUser offset: 0@0; show. Sensor waitClickButton - Bert - |
Free forum by Nabble | Edit this page |