Quark #

Modules #

Quark v1.4.0 Documentation

Contents

quark/window #

WEvent #

Window lifecycle event.

type WEvent = Event<Window>

Interface: Options #

Options #

options.frame? #

init window params

frame?: types.Rect

options.title? #

init window title

title?: string

options.backgroundColor? #

init window background color

backgroundColor?: types.Color

options.navigationColor? #

Is need draw navigation buttons for android.

navigationColor?: types.Color

options.enableCAPA? #

Whether to enable CAPA for GPU rendering, default is true.

enableCAPA?: boolean

options.enableCAPAQuantizeCoverage? #

Whether to enable CAPA quantized coverage for GPU rendering, default is false.

enableCAPAQuantizeCoverage?: boolean

Class: NativeWindow #

NativeWindow #

Extends: Notification

nativewindow.scale #

The scaling ratio of the physical pixel size of the window to the drawing size

readonly scale: number

nativewindow.defaultScale #

The default recommended scaling ratio between window physical pixels and drawing size

readonly defaultScale: number

nativewindow.fsp #

Current drawing frame rate

readonly fsp: Uint

nativewindow.atomPixel #

Atom pixel size, Exp: 1 / scale

readonly atomPixel: number

nativewindow.root #

The only root view in the window

readonly root: Root

nativewindow.activeView #

Current active focus view

readonly activeView: View

nativewindow.navigationRect #

Navigation rect, possibly in the Android bottom navigation button area

readonly navigationRect: types.Rect

nativewindow.size #

  • Set the logical size of the window. When this value changes, the change event will be triggered.
  • When both width and height are set to zero, the most comfortable default display size is automatically set.
  • If the width is set to non-zero, it means the width is fixed, and the height is automatically set according to the window ratio.
  • If the height is set to non-zero, it means the height is fixed, and the width is automatically set according to the window ratio.
    size: types.Vec2

nativewindow.backgroundColor #

The background color for the window

backgroundColor: types.Color

nativewindow.surfaceSize #

Window physical surface pixel size

surfaceSize: types.Vec2

nativewindow.debugMode #

Get or set whether to enable the debug mode, In debug mode, the view boundary and layout boundary will be drawn

debugMode: boolean

nativewindow.nextFrame(cb) #

When rendering next frame call, if a frame render is not complete, it will be wait for complete.

nextFrame(cb: Function): this

nativewindow.activate() #

Activate the display window or taking the window to the foreground

activate(): this

nativewindow.close() #

To close or destroy the window

close(): void

nativewindow.pending() #

Taking window to background and pending

pending(): void

nativewindow.requestFullscreen(fullscreen) #

Request to enter or exit full screen mode

requestFullscreen(fullscreen: boolean): void

Parameters:

  • fullscreen — - true: enter full screen, false: exit full screen

nativewindow.setCursorStyle(style) #

Setting the mouse cursor style

setCursorStyle(style: types.CursorStyle): void

nativewindow.constructor(opts?) #

constructor(opts?: Options)

Class: Window #

Window #

Extends: NativeWindow

window.onChange #

Trigger when to change window size

window.onBackground #

Trigger when into background

window.onForeground #

Trigger when into foreground

window.onClose #

Trigger when closed window

window.rootCtr #

The only root view controller in the window

readonly rootCtr: ViewController

window.render(vdom) #

Create a view or view controller DOM by vdom

render(vdom: VirtualDOM): DOM

Returns:

Example:

import {Application,Window,ViewController} from 'quark'
import * as http from 'quark/http'
import * as buffer from 'quark/buffer'
class MyCtr extends ViewController<{param: number}, {data?: Uint8Array}> {
    triggerLoad() {
        return http
            .get('http://192.168.1.100:1026/README.md?param=' + this.props.param)
            .then(e=>this.setState({data:e.data}));
    }
    render() {
        return (
            <box width={100} height={100} backgroundColor="#f00">
                {this.state.data&&buffer.toString(this.state.data)}
            </box>
        )
    }
}
new Application();
new Window().activate().render(
    <MyCtr param={10} />
);