A BaseView is a rectangle within the views View hierarchy. It is the base
class for ContainerView, ScrollView.
The base view for all different views.
Process: Main
BaseView is an [EventEmitter][event-emitter].
optionsObject (optional)vibrantboolean (optional) - Enables the vibrant visual effect. Default isfalse.blurredboolean (optional) - Enables the blurred visual effect. Default isfalse.
Creates the new base view.
Objects created with new BaseView emit the following events:
Returns:
eventEventtypestring - The type of the event. Possible values are:left-mouse-down,right-mouse-down,other-mouse-down,left-mouse-up,right-mouse-up,other-mouse-up,mouse-move,mouse-enter,mouse-leave.timestampInteger - Time when event was created, starts from when machine was booted.buttonInteger - The mouse button being pressed,1is for left button,2is for right button,3is for middle button.positionInViewPoint - Relative position inside the view where the event happened.positionInWindowPoint - Relative position inside the window.
Emitted when pressing mouse buttons. Calling event.preventDefault() will prevent the view from receiving the mouse down event.
Returns:
eventEventtypestring - The type of the event. Possible values are:left-mouse-down,right-mouse-down,other-mouse-down,left-mouse-up,right-mouse-up,other-mouse-up,mouse-move,mouse-enter,mouse-leave.timestampInteger - Time when event was created, starts from when machine was booted.buttonInteger - The mouse button being pressed,1is for left button,2is for right button,3is for middle button.positionInViewPoint - Relative position inside the view where the event happened.positionInWindowPoint - Relative position inside the window.
Emitted when releasing mouse buttons. Calling event.preventDefault() will prevent the view from receiving the mouse down event.
Returns:
eventEventtypestring - The type of the event. Possible values are:left-mouse-down,right-mouse-down,other-mouse-down,left-mouse-up,right-mouse-up,other-mouse-up,mouse-move,mouse-enter,mouse-leave.timestampInteger - Time when event was created, starts from when machine was booted.buttonInteger - The mouse button being pressed,1is for left button,2is for right button,3is for middle button.positionInViewPoint - Relative position inside the view where the event happened.positionInWindowPoint - Relative position inside the window.
Emitted when user moves mouse in the view.
Returns:
eventEventtypestring - The type of the event. Possible values are:left-mouse-down,right-mouse-down,other-mouse-down,left-mouse-up,right-mouse-up,other-mouse-up,mouse-move,mouse-enter,mouse-leave.timestampInteger - Time when event was created, starts from when machine was booted.buttonInteger - The mouse button being pressed,1is for left button,2is for right button,3is for middle button.positionInViewPoint - Relative position inside the view where the event happened.positionInWindowPoint - Relative position inside the window.
Emitted when mouse enters the view.
Returns:
eventEventtypestring - The type of the event. Possible values are:left-mouse-down,right-mouse-down,other-mouse-down,left-mouse-up,right-mouse-up,other-mouse-up,mouse-move,mouse-enter,mouse-leave.timestampInteger - Time when event was created, starts from when machine was booted.buttonInteger - The mouse button being pressed,1is for left button,2is for right button,3is for middle button.positionInViewPoint - Relative position inside the view where the event happened.positionInWindowPoint - Relative position inside the window.
Emitted when mouse leaves the view.
Returns:
eventEvent
Emitted when the mouse capture on view has been released.
Returns:
eventEventoldSizeSize - Size the view was before.newSizeSize - Size the view is being resized to.
Emitted when the view's size has been changed.
The BaseView class has the following static methods:
Returns BaseView[] - An array of all created views.
idInteger
Returns BaseView | null - The view with the given id.
Objects created with new BaseView have the following properties:
A Integer property representing the unique ID of the view. Each ID is unique among all BaseView instances of the entire Electron application.
A boolean property that determines whether this view is (or inherits from) ContainerView.
A Integer representing z-index to set. Has no effect until parent's view.rearrangeChildViews() is called.
A Boolean representing whether this BaseView receives any mouse input. Any BaseView
with clickThrough = true will still display but won't receive any mouse events.
Objects created with new BaseView have the following instance methods:
boundsRectangle - The target position and size of the view, relative to its parent.optionsObject (optional)fromBoundsRectangle (optional) - The initial position and size of the view, relative to its parent.durationFloat (optional) - A duration of the animation (in seconds). Default is 1.0.timingFunctionstring (optional) - One of the following values:linear,easeIn,easeOut,easeInEaseOut,default. Default islinear.timingControlPointsObject (optional)x1Float (optional) - A floating point number representing the x position of the c1 control point.y1Float (optional) - A floating point number representing the y position of the c1 control point.x2Float (optional) - A floating point number representing the x position of the c2 control point.y2Float (optional) - A floating point number representing the y position of the c2 control point.
Resizes and moves the view to the supplied bounds relative to its parent.
In case one of the values : duration, timingFunction, timingControlPoints is specified, the resizing / moving is animated.
It's possible to specify a function that defines the pacing of an animation as a timing curve.
The function maps an input time normalized to the range [0,1] to an output time also in the range [0,1].
You can specify a media timing function by supplying your own cubic Bézier curve control points using the timingControlPoints options or by using one of the predefined timing functions.
You can configure the timing function with the predefined timing function specified by name:
linear- Linear pacing, which causes an animation to occur evenly over its durationeaseIn- Ease-in pacing, which causes an animation to begin slowly and then speed up as it progresseseaseOut- Ease-out pacing, which causes an animation to begin quickly and then slow as it progresseseaseInEaseOut- Ease-in-ease-out pacing, which causes an animation to begin slowly, accelerate through the middle of its duration, and then slow again before completingdefault- Similar to 3t^2 - 2t^3, one of the basic Hermite blending functions.
When you supply your own cubic Bézier curve control points, then the function is modeled as a cubic Bézier curve. The end points of the Bézier curve are automatically set to (0.0,0.0) and (1.0,1.0). The control points defining the Bézier curve are: [(0.0,0.0), (c1x,c1y), (c2x,c2y), (1.0,1.0)].
Returns Rectangle
Returns the position and size of the view, relative to its parent.
fromBaseView
Returns Point - Offset from from view.
Converts (0, 0) point from the coordinate system of a given from to that of the view.
both from and the view must belong to the same BrowserWindow.
Returns Point - Offset the window that owns the view.
Converts (0, 0) point from window base coordinates to that of the view.
visibleboolean - Whether this view is visible. Default istrue.
Returns boolean - Whether the view is visible.
Returns boolean - Whether the view and its parent are visible.
Move the keyboard focus to the view.
Returns boolean - Whether this view currently has the focus.
focusableboolean - Whether this view can be focused on.
Returns boolean - Returns true if this view is focusable, enabled and drawn.
colorstring - Color in#aarrggbbor#argbform. The alpha channel is optional.
Change the background color of the view.
materialstring - Can beappearanceBased,light,dark,titlebar. Default isappearanceBased.
Sets the material shown by the vibrant view.
appearanceBased- The default material for the view’s effective appearance.light- The material with a light effect. *dark- The material with a dark effect. *titlebar- The material for a window’s titlebar.
This function works when view is created with vibrant option.
Returns string - The material shown by the vibrant view.
This function works when view is created with vibrant option.
modestring - Can bebehindWindow,withinWindow. Default isbehindWindow.
Sets whether the vibrant view blends with what's either behind or within the window.
behindWindow- The mode that blends and blurs the vibrant view with the contents behind the window, such as the desktop or other windows.withinWindow- The mode that blends and blurs the vibrant view with contents behind the view in the current window only.
This function works when view is created with vibrant option.
Returns string - Whether the vibrant view blends with what's either behind or within the window.
This function works when view is created with vibrant option.
redFloat - The red component of the color .greenFloat - The green component of the color .blueFloat - The blue component of the color .alphaFloat - The opacity value of the color .
Sets a color for blurred view from the specified components in the sRGB colorspace.
This function works when view is created with blurred option.
whiteFloat - The grayscale value of the color. Default is 1.0.alphaFloat - The opacity value of the color . Default is 0.7.
Sets a color for blurred view using the given opacity and grayscale values.
The layer will be tinted using the tint color. By default it is a 70% White Color.
This function works when view is created with blurred option.
whiteFloat - The grayscale value of the color. Default is 1.0.alphaFloat - The opacity value of the color . Default is 0.7.
Sets a color for blurred view with the specified white and alpha values in the GenericGamma22 colorspace.
This function works when view is created with blurred option.
radiusFloat - The strength of the Gaussian Blur filter. Default is 20.
This function works when view is created with blurred option.
Returns Float - The strength of the Gaussian Blur filter.
This function works when view is created with blurred option.
factorFloat - The saturation of the colors (To get more vibrant colors). Default is 2.0.
This function works when view is created with blurred option.
Returns Float - The saturation factor.
This function works when view is created with blurred option.
Set mouse capture to the view.
Release mouse capture if the view has mouse capture.
Returns boolean - Whether the view has mouse capture.
Enable mouse events.
enableboolean - Whether the mouse tracking is enabled. Default isfalse.
Returns boolean - Whether the mouse tracking is enabled.
optionsObjectradiusNumber - Radius of each corner that is rounded.topLeftBoolean (optional) - Iftrue, top left corner will be rounded withradiusvalue.falseby default.topRightBoolean (optional) - Iftrue, top right corner will be rounded withradiusvalue.falseby default.bottomLeftBoolean (optional) - Iftrue, bottom left corner will be rounded withradiusvalue.falseby default.bottomRightBoolean (optional) - Iftrue, bottom right corner will be rounded withradiusvalue.falseby default.
optionsObjectleftNumber (optional) - How many pixels to clip from the left side of the browser view.topNumber (optional) - How many pixels to clip from the top of the browser view.rightNumber (optional) - How many pixels to clip from the right side of the browser view.bottomNumber (optional) - How many pixels to clip from the bottom side of the browser view.
Makes the scaling of the view equal to the window's base coordinate system.
optionsObjectscaleXnumber (optional) - Specifies the x value for the new unit size.scaleYnumber (optional) - Specifies the y value for the new unit size.adjustFramestring (optional) - Adjusts the bounds (frame) to the scaled bounds.anchorXstring (optional) - The x coordinate of the anchor point when scaling. It can be one of the following values:left,center,right. It can be also the number between 1 and 100 (specifying the percentage).anchorYstring (optional) - The y coordinate of the anchor point when scaling. It can be one of the following values:top,center,bottom. It can be also the number between 1 and 100 (specifying the percentage).animationObject (optional)durationFloat (optional) - A duration of the animation (in seconds). Default is 1.0.timingFunctionstring (optional) - One of the following values:linear,easeIn,easeOut,easeInEaseOut,default. Default islinear.timingControlPointsObject (optional)x1Float (optional) - A floating point number representing the x position of the c1 control point.y1Float (optional) - A floating point number representing the y position of the c1 control point.x2Float (optional) - A floating point number representing the x position of the c2 control point.y2Float (optional) - A floating point number representing the y position of the c2 control point.
Scales the view’s coordinate system so that the unit square scales to the specified dimensions.
In case when animation is specified, the scaling and resizing / moving is animated.
The function does the simultaneous translation animation to keep the view's anchor during the zoom animation.
It's possible to specify a function that defines the pacing of an animation as a timing curve.
The function maps an input time normalized to the range [0,1] to an output time also in the range [0,1].
You can specify a media timing function by supplying your own cubic Bézier curve control points using the timingControlPoints options or by using one of the predefined timing functions.
You can configure the timing function with the predefined timing function specified by name:
linear- Linear pacing, which causes an animation to occur evenly over its durationeaseIn- Ease-in pacing, which causes an animation to begin slowly and then speed up as it progresseseaseOut- Ease-out pacing, which causes an animation to begin quickly and then slow as it progresseseaseInEaseOut- Ease-in-ease-out pacing, which causes an animation to begin slowly, accelerate through the middle of its duration, and then slow again before completingdefault- Similar to 3t^2 - 2t^3, one of the basic Hermite blending functions.
When you supply your own cubic Bézier curve control points, then the function is modeled as a cubic Bézier curve. The end points of the Bézier curve are automatically set to (0.0,0.0) and (1.0,1.0). The control points defining the Bézier curve are: [(0.0,0.0), (c1x,c1y), (c2x,c2y), (1.0,1.0)].
Returns the unit square scale of x dimension.
Returns the unit square scale of x dimension.
opacitynumber - between 0.0 (fully transparent) and 1.0 (fully opaque)optionsObject (optional)durationFloat (optional) - A duration of the animation (in seconds). Default is 1.0.timingFunctionstring (optional) - One of the following values:linear,easeIn,easeOut,easeInEaseOut,default. Default islinear.timingControlPointsObject (optional)x1Float (optional) - A floating point number representing the x position of the c1 control point.y1Float (optional) - A floating point number representing the y position of the c1 control point.x2Float (optional) - A floating point number representing the x position of the c2 control point.y2Float (optional) - A floating point number representing the y position of the c2 control point.
Sets the opacity of the view. Out of bound number values are clamped to the [0, 1] range.
In case one of the values : duration, timingFunction, timingControlPoints is specified, the opacity change is animated.
Returns number - between 0.0 (fully transparent) and 1.0 (fully opaque).
Returns BaseView || null - The parent view, otherwise returns null.
Returns BrowserWindow || null - The window that the view belongs to, otherwise returns null.
Note: The view can belongs to either a view or a window.