buggy zoom to fit.
This commit is contained in:
parent
a746bef31c
commit
b5227d3af6
1 changed files with 23 additions and 6 deletions
17
pixler.bas
17
pixler.bas
|
|
@ -133,6 +133,23 @@ do
|
||||||
state.zoom=1
|
state.zoom=1
|
||||||
state.offsetx=(_width/2)-(_width(layers(0).ihandle)/2)
|
state.offsetx=(_width/2)-(_width(layers(0).ihandle)/2)
|
||||||
state.offsety=(_height/2)-(_height(layers(0).ihandle)/2)
|
state.offsety=(_height/2)-(_height(layers(0).ihandle)/2)
|
||||||
|
|
||||||
|
case "f","F"
|
||||||
|
' --- ZOOM TO FIT ("f") OR OVERFLOW SHORTEST SIDE ("F") ---
|
||||||
|
' 1. Calculate and choose the fitting ratio based on the lowercase/uppercase state
|
||||||
|
if (((_width-(showtoolbox and 70)-(showcommands and 250)) \ _width(layers(0).ihandle))<((_height-(showcolorpicker and 20)) \ _height(layers(0).ihandle)) xor (keyin="F")) then
|
||||||
|
state.zoom=((_width-(showtoolbox and 70)-(showcommands and 250)) \ _width(layers(0).ihandle))
|
||||||
|
else
|
||||||
|
state.zoom=((_height-(showcolorpicker and 20)) \ _height(layers(0).ihandle))
|
||||||
|
end if
|
||||||
|
|
||||||
|
' 2. Clamp the zoom factor within safe limits (1 to 20)
|
||||||
|
if state.zoom<1 then state.zoom=1 else if state.zoom>20 then state.zoom=20
|
||||||
|
|
||||||
|
' 3. Center the canvas inside the viewport (overflowing sides will center-clip perfectly)
|
||||||
|
state.offsetx=(showtoolbox and 70)+(((_width-(showtoolbox and 70)-(showcommands and 250)) \ 2)-((_width(layers(0).ihandle)*state.zoom) \ 2))
|
||||||
|
state.offsety=(((_height-(showcolorpicker and 20)) \ 2)-((_height(layers(0).ihandle)*state.zoom) \ 2))
|
||||||
|
|
||||||
case "t"
|
case "t"
|
||||||
showtoolbox=not showtoolbox
|
showtoolbox=not showtoolbox
|
||||||
case "c"
|
case "c"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue