View: provide the transform between different coordinate spaces
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 <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
423e3645e1
commit
241f109ccb
@@ -70,6 +70,16 @@ enum {
|
||||
B_FONT_ALL = 0x000001FF
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
B_CURRENT_STATE_COORDINATES,
|
||||
B_PREVIOUS_STATE_COORDINATES,
|
||||
B_VIEW_COORDINATES,
|
||||
B_PARENT_VIEW_DRAW_COORDINATES,
|
||||
B_PARENT_VIEW_COORDINATES,
|
||||
B_WINDOW_COORDINATES,
|
||||
B_SCREEN_COORDINATES
|
||||
} coordinate_space;
|
||||
|
||||
// view flags
|
||||
const uint32 B_FULL_UPDATE_ON_RESIZE = 0x80000000UL; /* 31 */
|
||||
const uint32 _B_RESERVED1_ = 0x40000000UL; /* 30 */
|
||||
@@ -324,6 +334,8 @@ public:
|
||||
void ScaleBy(double x, double y);
|
||||
void RotateBy(double angleRadians);
|
||||
|
||||
BAffineTransform TransformTo(coordinate_space basis) const;
|
||||
|
||||
void PushState();
|
||||
void PopState();
|
||||
|
||||
|
||||
@@ -358,6 +358,7 @@ enum {
|
||||
// transformation in addition to origin/scale
|
||||
AS_VIEW_SET_TRANSFORM,
|
||||
AS_VIEW_GET_TRANSFORM,
|
||||
AS_VIEW_GET_PARENT_COMPOSITE,
|
||||
|
||||
AS_VIEW_AFFINE_TRANSLATE,
|
||||
AS_VIEW_AFFINE_SCALE,
|
||||
|
||||
@@ -45,6 +45,7 @@ enum {
|
||||
B_VIEW_WHICH_VIEW_COLOR_BIT = 0x00100000,
|
||||
B_VIEW_WHICH_LOW_COLOR_BIT = 0x00200000,
|
||||
B_VIEW_WHICH_HIGH_COLOR_BIT = 0x00400000,
|
||||
B_VIEW_PARENT_COMPOSITE_BIT = 0x00800000,
|
||||
|
||||
B_VIEW_ALL_BITS = 0x00ffffff,
|
||||
|
||||
@@ -131,6 +132,11 @@ class ViewState {
|
||||
float scale;
|
||||
BAffineTransform transform;
|
||||
|
||||
// composite transformation stack
|
||||
BPoint parent_composite_origin;
|
||||
float parent_composite_scale;
|
||||
BAffineTransform parent_composite_transform;
|
||||
|
||||
// line modes
|
||||
join_mode line_join;
|
||||
cap_mode line_cap;
|
||||
|
||||
Reference in New Issue
Block a user