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:
Máximo Castañeda
2022-11-13 04:04:30 +00:00
committed by waddlesplash
parent 423e3645e1
commit 241f109ccb
7 changed files with 199 additions and 4 deletions
+12
View File
@@ -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();