[−][src]Trait pugl_sys::PuglViewTrait
The central trait for an object of a pugl "UI"
A UI implementation needs to have an object to manage the state of
the UI as well as serving as an interface to the actual
application. Such an object must implement the required methods of
PuglViewTrait
. The provided methods
focus_in()
and
focus_out()
as wellas
[timer_event()
](#method.timer_event] can be implmentat
optionally.
All the other provided methods should not be reimplemented.
Required methods
pub fn event(&mut self, ev: Event) -> Status
[src]
Called if an event happened that is to be processed.
The data of the Event
comes withe the argument ev
.
Shall return a result Status
.
pub fn exposed(&mut self, expose: &ExposeArea, cr: &Context)
[src]
Called when a part of the view needs to be redrawn due to an exposure.
The cr
reference can be used to draw on.
The expose
argument provides information on the area that
needs to be redrawn.
pub fn resize(&mut self, size: Size)
[src]
Called when the view has been resized
The UI should relayout its contents to make it fit the size
provided by size
.
pub fn close_request(&mut self)
[src]
Called when the view is requested to close by the window system
The UI should exit the event loop before the next cycle after this method has been called.
pub fn view(&self) -> PuglViewFFI
[src]
Returns a handle to the window system's view
Provided methods
pub fn focus_in(&mut self) -> Status
[src]
Called when the view recieves the focus
Should be reimplemented if the application needs to react on getting the focus.
Shall return a result Status.
pub fn focus_out(&mut self) -> Status
[src]
Called when the view gives the focus away
Should be reimplemented if the application needs to react on giving the focus away.
Shall return a result Status.
pub fn timer_event(&mut self, _id: usize) -> Status
[src]
Called when a timer launched by
start_timer()
finished.
Should be reimplemented if the application at some point calls
start_timer()
Shall return a result Status.
pub fn world(&self) -> *mut PuglWorldImpl
[src]
Returns a pointer to the PugleWorld
pub fn post_redisplay(&self) -> Status
[src]
Request a redisplay for the entire view.
This will cause an expose event to be dispatched later. If called from within the event handler, the expose should arrive at the end of the current event loop iteration, though this is not strictly guaranteed on all platforms. If called elsewhere, an expose will be enqueued to be processed in the next event loop iteration.
pub fn post_redisplay_rect(&self, pos: Coord, size: Size) -> Status
[src]
Request a redisplay of the given rectangle within the view.
This has the same semantics as post_redisplay()
,
but allows giving a precise region for redrawing only a
portion of the view.
pub fn get_frame(&self) -> Rect
[src]
Get the current position and size of the view.
The position is in screen coordinates with an upper left origin.
pub fn set_frame(&self, frame: Rect) -> Status
[src]
Set the current position and size of the view.
The position is in screen coordinates with an upper left origin.
pub fn set_default_size(&self, width: i32, height: i32) -> Status
[src]
Set the default size of the view.
This should be called before show_window()
and
realize()
to set the default size of
the view, which will be the initial size of the window if this
is a top level view.
pub fn set_min_size(&self, width: i32, height: i32) -> Status
[src]
Set the minimum size of the view.
If an initial minimum size is known, this should be called
before realize()
and show_window()
to avoid stutter, though it can be called afterwards as well.
pub fn set_max_size(&self, width: i32, height: i32) -> Status
[src]
Set the maximum size of the view.
If an initial maximum size is known, this should be called
before realize()
and show_window()
to
avoid stutter, though it can be called afterwards as well.
pub fn set_aspect_ratio(
&self,
min_x: i32,
min_y: i32,
max_x: i32,
max_y: i32
) -> Status
[src]
&self,
min_x: i32,
min_y: i32,
max_x: i32,
max_y: i32
) -> Status
Set the view aspect ratio range.
The x and y values here represent a ratio of width to height. To set a fixed aspect ratio, set the minimum and maximum values to the same ratio. Note that setting different minimum and maximum constraints does not currenty work on MacOS (the minimum is used), so only setting a fixed aspect ratio works properly across all platforms.
If an initial aspect ratio is known, this should be called
before realize()
and show_window()
to avoid stutter,
though it can be called afterwards as well
pub fn is_resizable(&self) -> bool
[src]
Returns true iff the window is resizable
pub fn make_resizable(&self) -> Status
[src]
Make the view resizable.
This should be called before [show_window()
](#method.show_window) and realize()
.
pub fn is_ignoring_key_repeats(&self) -> ViewHintBool
[src]
Returns a ViewHintBool
whether the view is ignoring
key repeats.
pub fn set_ignore_key_repeats(&self, value: ViewHintBool) -> Status
[src]
Gives the view the hint whether it should ignore key repeats.
pub fn red_bits(&self) -> u32
[src]
Returns the number of bits for the red channel of the view
pub fn green_bits(&self) -> u32
[src]
Returns the number of bits for the green channel of the view
pub fn blue_bits(&self) -> u32
[src]
Returns the number of bits for the blue channel of the view
pub fn alpha_bits(&self) -> u32
[src]
Returns the number of bits for the alpha channel of the view
pub fn depth_bits(&self) -> u32
[src]
Returns the number of bits for the depth buffer of the view
pub fn stencil_bits(&self) -> u32
[src]
Returns the number of bits for the stencil buffer of the view
pub fn samples(&self) -> u32
[src]
Returns the number of samples per pixel
pub fn double_buffer(&self) -> bool
[src]
Returns true iff double buffering should be used
pub fn set_double_buffer(&self, yn: bool) -> Status
[src]
Sets whether double buffering should be used
pub fn swap_interval(&self) -> ViewHintInt
[src]
Returns number of frames between buffer swaps
pub fn refresh_rate(&self) -> ViewHintInt
[src]
Returns the refresh rate in Hz
pub fn set_window_title(&self, title: &str) -> Status
[src]
Sets the window title
pub fn realize(&self) -> Status
[src]
Realize a view by creating a corresponding system view or window.
After this call, the (initially invisible) underlying system
view exists and can be accessed with
PuglView::native_window()
.
There is currently no corresponding unrealize function, the
system view will be destroyed along with the view when the
PuglView
is dropped.
The view should be fully configured using the above functions before this is called. This function may only be called once per view.
pub fn show_window(&self) -> Status
[src]
Show the view.
If the view has not yet been realized, the first call to this function will do so automatically.
If the view is currently hidden, it will be shown and possibly raised to the top depending on the platform.
pub fn hide_window(&self) -> Status
[src]
Hide the current window
pub fn is_visible(&self) -> bool
[src]
Return true iff the view is currently visible.
pub fn set_cursor(&self, c: Cursor) -> Status
[src]
Set the mouse cursor.
This changes the system cursor that is displayed when the pointer is inside the view. May fail if setting the cursor is not supported on this system, for example if compiled on X11 without Xcursor support.
pub fn update(&self, timeout: f64) -> Status
[src]
Update by processing events from the window system.
This function is a single iteration of the main loop, and should be called repeatedly to update all views.
If timeout
is zero, then this function will not block.
Plugins should always use a timeout of zero to avoid blocking
the host.
If a positive timeout
is given, then events will be
processed for that amount of time, starting from when this
function was called.
If a negative timeout
is given, this function will block
indefinitely until an event occurs.
For continuously animating programs, a timeout that is a reasonable fraction of the ideal frame period should be used, to minimise input latency by ensuring that as many input events are consumed as possible before drawing.
Returns
Status::Success
if events are read,
Status::Failure
if not, or an error.
pub fn start_timer(&self, id: usize, timeout: f64) -> Status
[src]
Activate a repeating timer event.
This starts a timer which will send a PuglEventTimer to view every timeout seconds. This can be used to perform some action in a view at a regular interval with relatively low frequency. Note that the frequency of timer events may be limited by how often puglUpdate() is called.
If the given timer already exists, it is replaced.
Parameters
-
id
– The identifier for this timer. This is an application-specific ID that should be a low number, typically the value of a constant or enum that starts from- There is a platform-specific limit to the number of supported timers, and overhead associated with each, so applications should create only a few timers and perform several tasks in one if necessary.
-
timeout
– The period, in seconds, of this timer. This is not guaranteed to have a resolution better than 10ms (the maximum timer resolution on Windows) and may be rounded up if it is too short. On X11 and MacOS, a resolution of about 1ms can usually be relied on.
Returns
Status::Success
or Status::Failure
if timers are not
supported on the system
pub fn stop_timer(&self, id: usize) -> Status
[src]
Stop an active timer
Parameters
id
– The ID previously passed tostart_timer()
Returns
Status::Success
or Status::Failure
if no such timer was found.