add get-gl-client-size
to canvas%
GL scaling in a canvas depends on a combination of the `gl-config%` setting and the platform, so `get-gl-client-size` takes into account both.
This commit is contained in:
parent
018dbd6add
commit
d1736765b6
|
@ -100,6 +100,20 @@ The @racket[gl-config] argument determines properties of an OpenGL
|
|||
}
|
||||
|
||||
|
||||
@defmethod[(get-gl-client-size) (values dimension-integer? dimension-integer?)]{
|
||||
|
||||
Returns the canvas's drawing-area dimensions in OpenGL units for a
|
||||
@racket[canvas%] instance with the @racket['gl] style.
|
||||
|
||||
The result is the same as @method[canvas<%> get-unscaled-client-size]
|
||||
in a canvas without the @racket['gl] style or on Windows and Unix. On
|
||||
Mac OS X, the result can be the same as @method[window<%>
|
||||
get-client-size] if the @racket[gl-config%] specification provided on
|
||||
creation does not specify high-resolution mode.
|
||||
|
||||
@history[#:added "1.16]}
|
||||
|
||||
|
||||
@defmethod[(get-scroll-page [which (or/c 'horizontal 'vertical)])
|
||||
positive-dimension-integer?]{
|
||||
|
||||
|
|
|
@ -158,7 +158,8 @@ a viewport size for OpenGL drawing in @racket[canvas%] instance with
|
|||
the @racket['gl] style. On Mac OS X, however, the viewport will match
|
||||
the scaled size unless the canvas is created with a
|
||||
@racket[gl-config%] specification that is adjusted to high-resolution
|
||||
mode via @method[gl-config% set-hires-mode].
|
||||
mode via @method[gl-config% set-hires-mode]. See also
|
||||
@xmethod[canvas% get-gl-client-size].
|
||||
|
||||
@history[#:added "1.13"]}
|
||||
|
||||
|
|
|
@ -30,4 +30,4 @@
|
|||
|
||||
(define pkg-authors '(mflatt robby))
|
||||
|
||||
(define version "1.15")
|
||||
(define version "1.16")
|
||||
|
|
|
@ -134,6 +134,8 @@
|
|||
(if ctx
|
||||
(send ctx call-as-current thunk)
|
||||
(fail))))
|
||||
(define/public (get-gl-client-size)
|
||||
(send wx get-gl-client-size))
|
||||
(define accept-tab-focus
|
||||
(entry-point
|
||||
(case-lambda
|
||||
|
|
|
@ -884,6 +884,15 @@
|
|||
(define cw (->long (NSSize-width cs)))
|
||||
(define ch (->long (NSSize-height cs)))
|
||||
(values cw ch))
|
||||
|
||||
(define/public (get-gl-client-size)
|
||||
(if (or (not is-gl?)
|
||||
(tell #:type _BOOL content-cocoa wantsBestResolutionOpenGLSurface))
|
||||
(get-scaled-client-size)
|
||||
(let ([x (box 0)]
|
||||
[y (box 0)])
|
||||
(get-client-size x y)
|
||||
(values (unbox x) (unbox y)))))
|
||||
|
||||
(define/override (get-cursor-width-delta)
|
||||
0)
|
||||
|
|
|
@ -504,7 +504,13 @@
|
|||
(define wb (box #f))
|
||||
(define hb (box #f))
|
||||
(get-client-size wb hb)
|
||||
(values (->screen (unbox wb)) (->screen (unbox hb))))
|
||||
(define s (if gtk3?
|
||||
(gtk_widget_get_scale_factor gtk)
|
||||
1))
|
||||
(values (* s (->screen (unbox wb))) (* s (->screen (unbox hb)))))
|
||||
|
||||
(define/public (get-gl-client-size)
|
||||
(get-scaled-client-size))
|
||||
|
||||
(define/override (get-client-gtk) client-gtk)
|
||||
(define/override (get-container-gtk) container-gtk)
|
||||
|
|
|
@ -491,6 +491,9 @@
|
|||
(let ([r (GetClientRect (get-client-hwnd))])
|
||||
(values (- (RECT-right r) (RECT-left r))
|
||||
(- (RECT-bottom r) (RECT-top r)))))
|
||||
|
||||
(define/public (get-gl-client-size)
|
||||
(get-scaled-client-size))
|
||||
|
||||
(define/public (get-size w h)
|
||||
(let ([r (GetWindowRect (get-client-hwnd))])
|
||||
|
|
Loading…
Reference in New Issue
Block a user