241f109ccb
There's currently no way for an application to convert between view and drawing coordinates with a drawing states stack without keeping track of all the transformations itself, which is not very convenient for helper or library functions. Handle other spaces too, for good measure. Change-Id: Ic8404a1c111e273fff1eebf2f9f59f58246b796c Reviewed-on: https://review.haiku-os.org/c/haiku/+/5775 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: waddlesplash <waddlesplash@gmail.com>
71 lines
3.2 KiB
Plaintext
71 lines
3.2 KiB
Plaintext
/*
|
|
* Copyright 2010 Haiku, Inc. All rights reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*
|
|
* Authors:
|
|
* Alex Wilson, yourpalal2@gmail.com
|
|
*/
|
|
|
|
|
|
/*!
|
|
\page interface_intro Introduction to the Interface Kit
|
|
\ingroup interface
|
|
|
|
\section Overview
|
|
|
|
The Interface Kit holds all the classes you'll need to develop a GUI.
|
|
Building on the messaging facilities provided by the Application Kit,
|
|
the Interface Kit can be used to create a responsive and attractive
|
|
graphical user interface.
|
|
|
|
The most important class in the Interface Kit is the BView class, which
|
|
handles drawing and user interaction. Pointer and keyboard events are
|
|
processed in this class.
|
|
|
|
Another important class is the BWindow class, which holds BViews and makes
|
|
them visible to the user. The BWindow class also handles BView focusing
|
|
and BMessage dispatching, among other things.
|
|
|
|
A new addition Haiku has added over the BeOS API is the Layout API, which
|
|
is based around the BLayoutItem and BLayout classes. These classes will
|
|
take care of making sure all your GUI widgets end up where you want them,
|
|
with enough space to be useful. You can start learning the Layout API
|
|
by reading the \ref layout_intro.
|
|
|
|
\section coordinatespaces Coordinate spaces
|
|
|
|
All APIs using coordinates (such as BRect or BPoint) refer to
|
|
a specific space where these coordinates are interpreted. BView and
|
|
BWindow provide various conversion function to translate coordinates
|
|
between different spaces, as needed, or provide separate methods such as
|
|
BView Bounds() and Frame(), returning results in different spaces as needed.
|
|
|
|
The initial coordinate space, from which all others are derived, is the
|
|
screen space. Its origin is at the center of the screen's top-left pixel.
|
|
Coordinates can be converted between this and a specific window or view
|
|
space using the ConvertToScreen and ConvertFromScreen methods of
|
|
the corresponding object.
|
|
|
|
Each BWindow has its own coordinate space. Its origin is at the center of
|
|
the top-left pixel of the window client area (just inside the window border).
|
|
Root level views added to the window have their frame rectangle defined in
|
|
this space.
|
|
|
|
Each BView also gets its own coordinate space. The origin is initially at the
|
|
top left of the view, but this can be changed by scrolling the view
|
|
(programatically using ScrollBy or ScrollTo, or by the user acting on a scrollbar).
|
|
|
|
Additionally, each BView also has a drawing space. This is further transformed
|
|
from the BView coordinate space by calls to SetOrigin, SetScale, SetTransform,
|
|
ScaleBy, RotateBy, and TranslateBy. The effects of the first two of these
|
|
methods are independant from the other four, and it's not recommended to mix
|
|
the two types of transformations in the same BView. Note that this is the only space
|
|
that can be scaled and rotated, and translated by non-integer units. All other
|
|
coordinate spaces are only translations of the screen one and remain aligned on pixels.
|
|
|
|
All drawing operations in a BView use coordinates specified in the drawing space.
|
|
However, the update rect passed to the Draw method (or passed to the Invalidate
|
|
method) is in the BView base coordinate space. Conversion between the two can
|
|
be done using the affine transform returned by BView::TransformTo.
|
|
*/
|