aboutsummaryrefslogtreecommitdiffstats
path: root/src/gwin/gwm.c
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-05-10 18:20:05 +1000
committerinmarket <andrewh@inmarket.com.au>2014-05-10 18:20:05 +1000
commit5544202a26da6ec74c51eb1bac9499d434b133ba (patch)
tree5533f2b5854270c94e395e6693272735559cf8a0 /src/gwin/gwm.c
parent890653111b978f13b9f168c7308926d7e6a04e6c (diff)
downloaduGFX-5544202a26da6ec74c51eb1bac9499d434b133ba.tar.gz
uGFX-5544202a26da6ec74c51eb1bac9499d434b133ba.tar.bz2
uGFX-5544202a26da6ec74c51eb1bac9499d434b133ba.zip
All compiling.
Containers and Frames still to be tested.
Diffstat (limited to 'src/gwin/gwm.c')
-rw-r--r--src/gwin/gwm.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/gwin/gwm.c b/src/gwin/gwm.c
index 682dcb2d..c5e0f956 100644
--- a/src/gwin/gwm.c
+++ b/src/gwin/gwm.c
@@ -208,15 +208,20 @@ static void WM_Redraw(GHandle gh, int flags) {
}
static void WM_Size(GHandle gh, coord_t w, coord_t h) {
+ // Give it a minimum size
+ if (w < MIN_WIN_WIDTH) w = MIN_WIN_WIDTH;
+ if (h < MIN_WIN_HEIGHT) h = MIN_WIN_HEIGHT;
+
#if GWIN_NEED_CONTAINERS
- // For a child window - convert to absolute size
- if (gh->parent)
- ((const gcontainerVMT *)gh->parent->vmt)->Size2Screen(gh, &w, &h);
+ if (gh->parent) {
+ // Clip to the container
+ if (gh->x+w > gh->parent->x+gh->parent->width) w = gh->parent->x + gh->parent->width - gh->x;
+ if (gh->y+h > gh->parent->y+gh->parent->height) h = gh->parent->y + gh->parent->height - gh->y;
+ ((const gcontainerVMT *)gh->parent->vmt)->AdjustSize(gh, &w, &h);
+ }
#endif
- // Clip to the screen and give it a minimum size
- if (w < MIN_WIN_WIDTH) w = MIN_WIN_WIDTH;
- if (h < MIN_WIN_HEIGHT) h = MIN_WIN_HEIGHT;
+ // Clip to the screen
if (gh->x+w > gdispGGetWidth(gh->display)) w = gdispGGetWidth(gh->display) - gh->x;
if (gh->y+h > gdispGGetHeight(gh->display)) h = gdispGGetHeight(gh->display) - gh->y;
@@ -238,9 +243,20 @@ static void WM_Size(GHandle gh, coord_t w, coord_t h) {
static void WM_Move(GHandle gh, coord_t x, coord_t y) {
#if GWIN_NEED_CONTAINERS
- // For a child window - convert to absolute position
- if (gh->parent)
- ((const gcontainerVMT *)gh->parent->vmt)->Pos2Screen(gh, &x, &y);
+ if (gh->parent) {
+ // Clip to the parent
+ if (x < 0) x = 0;
+ if (y < 0) y = 0;
+ if (x > gh->parent->width-gh->width) x = gh->parent->width-gh->width;
+ if (y > gh->parent->height-gh->height) y = gh->parent->height-gh->height;
+
+ // Allow the parent to adjust it
+ ((const gcontainerVMT *)gh->parent->vmt)->AdjustPosition(gh, &x, &y);
+
+ // Convert to absolute position
+ x += gh->parent->x;
+ y += gh->parent->y;
+ }
#endif
// Clip to the screen