-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
223 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Class { | ||
#name : #OPRTCanvasExporter, | ||
#superclass : #RTCanvasExporter, | ||
#category : #'OpenPonk-Roassal2' | ||
} | ||
|
||
{ #category : #accessing } | ||
OPRTCanvasExporter class >> maxWidthAndHeight [ | ||
|
||
^ 10000 | ||
] | ||
|
||
{ #category : #private } | ||
OPRTCanvasExporter >> scaleToMorphLimits [ | ||
|
||
"scale down to estimated morph (maxWidthAndHeight) and exporter (maxArea) size limits" | ||
|
||
| scaledDown | | ||
scaledDown := false. | ||
self extent x > self class maxWidthAndHeight ifTrue: [ | ||
scaledDown := true. | ||
self scale: | ||
self class maxWidthAndHeight / self extent x * self cameraScale ]. | ||
self extent y > self class maxWidthAndHeight ifTrue: [ | ||
scaledDown := true. | ||
self scale: | ||
self class maxWidthAndHeight / self extent y * self cameraScale ]. | ||
scaledDown ifTrue: [ | ||
GrowlMorph | ||
openWithLabel: 'Warning' | ||
contents: 'Image was forced to scale down to ' | ||
, (self cameraScale * 100 printShowingDecimalPlaces: 0) | ||
, ' % zoom due to technical restrictions (max resolution).' | ||
backgroundColor: GrowlMorph theme warningBackgroundColor | ||
labelColor: GrowlMorph theme textColor ] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
Class { | ||
#name : #OPExportCanvasDialog, | ||
#superclass : #FDSaveFileDialog, | ||
#instVars : [ | ||
'zoomLabel', | ||
'zoomText', | ||
'zoomPercentageLabel' | ||
], | ||
#category : #'OpenPonk-Spec' | ||
} | ||
|
||
{ #category : #specs } | ||
OPExportCanvasDialog class >> defaultSpec [ | ||
|
||
^ SpecColumnLayout composed | ||
newRow: [ :r | | ||
r | ||
newColumn: [ :c | c add: #bookmarksList ] width: 150; | ||
newColumn: [ :c | | ||
c add: #currentFolderLabel height: self toolbarHeight. | ||
c add: #filesList ] ]; | ||
newRow: [ :r | | ||
r | ||
add: #nameLabel width: 50; | ||
add: #nameText; | ||
add: #filtersDropList width: 200 ] | ||
height: self toolbarHeight; | ||
newRow: [ :r | | ||
r | ||
add: #zoomLabel width: 50; | ||
add: #zoomText width: 40; | ||
add: #zoomPercentageLabel. | ||
r newColumn: [ :c | ]. | ||
self dialogButtonsLayout: r ] | ||
height: self toolbarHeight; | ||
yourself | ||
] | ||
|
||
{ #category : #actions } | ||
OPExportCanvasDialog >> confirm [ | ||
|
||
| zoomNumber file | | ||
file := self selectedEntry. | ||
file ifNil: [ ^ self ]. | ||
zoomNumber := (NumberParser | ||
parse: zoomText text | ||
onError: [ TRCamera new defaultCameraScale * 100 ]) | ||
/ 100. | ||
zoomNumber < 0.01 ifTrue: [ | ||
zoomNumber := TRCamera new defaultCameraScale ]. | ||
onConfirmBlock cull: file cull: zoomNumber. | ||
self delete | ||
] | ||
|
||
{ #category : #initialization } | ||
OPExportCanvasDialog >> initializePresenter [ | ||
|
||
super initializePresenter. | ||
self initializeZoom | ||
] | ||
|
||
{ #category : #initialization } | ||
OPExportCanvasDialog >> initializeWidgets [ | ||
|
||
super initializeWidgets. | ||
(zoomLabel := self newLabel) label: 'Zoom: '. | ||
(zoomText := self newTextInput) autoAccept: true. | ||
(zoomPercentageLabel := self newLabel) label: ' %'. | ||
self focusOrder: { | ||
nameText. | ||
filtersDropList. | ||
zoomText. | ||
cancelButton. | ||
confirmButton } | ||
] | ||
|
||
{ #category : #initialization } | ||
OPExportCanvasDialog >> initializeZoom [ | ||
|
||
zoomText | ||
text: '100'; | ||
whenTextIsAccepted: [ :text | | ||
zoomText text: ((text select: #isDigit) takeFirst: 4) ] | ||
] | ||
|
||
{ #category : #accessing } | ||
OPExportCanvasDialog >> zoomLabel [ | ||
|
||
^ zoomLabel | ||
] | ||
|
||
{ #category : #accessing } | ||
OPExportCanvasDialog >> zoomPercentageLabel [ | ||
|
||
^ zoomPercentageLabel | ||
] | ||
|
||
{ #category : #accessing } | ||
OPExportCanvasDialog >> zoomText [ | ||
|
||
^ zoomText | ||
] |
This file was deleted.
Oops, something went wrong.