libui/GTK: fix drawmatrix transform order to match Windows. fixes rotation.
This commit is contained in:
parent
c5872dab7d
commit
dd529f0f5c
|
@ -25,35 +25,41 @@ static void c2m(cairo_matrix_t *c, uiDrawMatrix *m)
|
||||||
void uiDrawMatrixTranslate(uiDrawMatrix *m, double x, double y)
|
void uiDrawMatrixTranslate(uiDrawMatrix *m, double x, double y)
|
||||||
{
|
{
|
||||||
cairo_matrix_t c;
|
cairo_matrix_t c;
|
||||||
|
cairo_matrix_t tmp;
|
||||||
|
|
||||||
m2c(m, &c);
|
m2c(m, &c);
|
||||||
cairo_matrix_translate(&c, x, y);
|
cairo_matrix_init_translate(&tmp, x, y);
|
||||||
|
cairo_matrix_multiply(&c, &c, &tmp);
|
||||||
c2m(&c, m);
|
c2m(&c, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiDrawMatrixScale(uiDrawMatrix *m, double xCenter, double yCenter, double x, double y)
|
void uiDrawMatrixScale(uiDrawMatrix *m, double xCenter, double yCenter, double x, double y)
|
||||||
{
|
{
|
||||||
cairo_matrix_t c;
|
cairo_matrix_t c;
|
||||||
|
cairo_matrix_t tmp;
|
||||||
double xt, yt;
|
double xt, yt;
|
||||||
|
|
||||||
m2c(m, &c);
|
m2c(m, &c);
|
||||||
xt = x;
|
xt = x;
|
||||||
yt = y;
|
yt = y;
|
||||||
scaleCenter(xCenter, yCenter, &xt, &yt);
|
scaleCenter(xCenter, yCenter, &xt, &yt);
|
||||||
cairo_matrix_translate(&c, xt, yt);
|
cairo_matrix_init_translate(&tmp, xt, yt);
|
||||||
cairo_matrix_scale(&c, x, y);
|
cairo_matrix_scale(&tmp, x, y);
|
||||||
cairo_matrix_translate(&c, -xt, -yt);
|
cairo_matrix_translate(&tmp, -xt, -yt);
|
||||||
|
cairo_matrix_multiply(&c, &c, &tmp);
|
||||||
c2m(&c, m);
|
c2m(&c, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiDrawMatrixRotate(uiDrawMatrix *m, double x, double y, double amount)
|
void uiDrawMatrixRotate(uiDrawMatrix *m, double x, double y, double amount)
|
||||||
{
|
{
|
||||||
cairo_matrix_t c;
|
cairo_matrix_t c;
|
||||||
|
cairo_matrix_t tmp;
|
||||||
|
|
||||||
m2c(m, &c);
|
m2c(m, &c);
|
||||||
cairo_matrix_translate(&c, x, y);
|
cairo_matrix_init_translate(&tmp, x, y);
|
||||||
cairo_matrix_rotate(&c, amount);
|
cairo_matrix_rotate(&tmp, amount);
|
||||||
cairo_matrix_translate(&c, -x, -y);
|
cairo_matrix_translate(&tmp, -x, -y);
|
||||||
|
cairo_matrix_multiply(&c, &c, &tmp);
|
||||||
c2m(&c, m);
|
c2m(&c, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -594,7 +594,7 @@ void SetupScreenRects(int width, int height)
|
||||||
|
|
||||||
switch (ScreenRotation)
|
switch (ScreenRotation)
|
||||||
{
|
{
|
||||||
case 1: // 90\B0
|
case 1: // 90°
|
||||||
{
|
{
|
||||||
uiDrawMatrixTranslate(&TopScreenTrans, -TopScreenRect.X, -TopScreenRect.Y);
|
uiDrawMatrixTranslate(&TopScreenTrans, -TopScreenRect.X, -TopScreenRect.Y);
|
||||||
uiDrawMatrixRotate(&TopScreenTrans, 0, 0, M_PI/2.0f);
|
uiDrawMatrixRotate(&TopScreenTrans, 0, 0, M_PI/2.0f);
|
||||||
|
@ -612,7 +612,7 @@ void SetupScreenRects(int width, int height)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: // 180\B0
|
case 2: // 180°
|
||||||
{
|
{
|
||||||
uiDrawMatrixTranslate(&TopScreenTrans, -TopScreenRect.X, -TopScreenRect.Y);
|
uiDrawMatrixTranslate(&TopScreenTrans, -TopScreenRect.X, -TopScreenRect.Y);
|
||||||
uiDrawMatrixRotate(&TopScreenTrans, 0, 0, M_PI);
|
uiDrawMatrixRotate(&TopScreenTrans, 0, 0, M_PI);
|
||||||
|
@ -624,7 +624,7 @@ void SetupScreenRects(int width, int height)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: // 270\B0
|
case 3: // 270°
|
||||||
{
|
{
|
||||||
uiDrawMatrixTranslate(&TopScreenTrans, -TopScreenRect.X, -TopScreenRect.Y);
|
uiDrawMatrixTranslate(&TopScreenTrans, -TopScreenRect.X, -TopScreenRect.Y);
|
||||||
uiDrawMatrixRotate(&TopScreenTrans, 0, 0, -M_PI/2.0f);
|
uiDrawMatrixRotate(&TopScreenTrans, 0, 0, -M_PI/2.0f);
|
||||||
|
|
Loading…
Reference in New Issue