diff options
-rwxr-xr-x | NxWidgets/ChangeLog.txt | 5 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/include/cimage.hxx | 32 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/src/cimage.cxx | 52 | ||||
-rw-r--r-- | NxWidgets/nxwm/include/cstartwindow.hxx | 2 | ||||
-rw-r--r-- | NxWidgets/nxwm/src/cstartwindow.cxx | 2 | ||||
-rw-r--r-- | nuttx/ChangeLog | 5 | ||||
-rw-r--r-- | nuttx/drivers/input/ads7843e.c | 42 | ||||
-rw-r--r-- | nuttx/drivers/input/ads7843e.h | 3 | ||||
-rw-r--r-- | nuttx/drivers/input/stmpe11.h | 1 | ||||
-rw-r--r-- | nuttx/drivers/input/stmpe11_tsc.c | 48 | ||||
-rw-r--r-- | nuttx/drivers/input/tsc2007.c | 34 | ||||
-rw-r--r-- | nuttx/drivers/input/tsc2007.h | 2 |
12 files changed, 189 insertions, 39 deletions
diff --git a/NxWidgets/ChangeLog.txt b/NxWidgets/ChangeLog.txt index 8dd65d78b..0cb95cc13 100755 --- a/NxWidgets/ChangeLog.txt +++ b/NxWidgets/ChangeLog.txt @@ -66,3 +66,8 @@ never restart the Calibration window. * NxWM::CTaskbar: On a failure to start an application, the application icon CImage was being deleted twice. +* NXWidgets::CImage: Now handles mouse click callbacks. CImage is now really + a button. Probably should separate basic imaging functionality as CImage + and create a new CImageButton. +* NxWM::CStartWindow: Now ignores any close application button presses + (You can't close the start window).
\ No newline at end of file diff --git a/NxWidgets/libnxwidgets/include/cimage.hxx b/NxWidgets/libnxwidgets/include/cimage.hxx index a1c282393..0b7be14f2 100644 --- a/NxWidgets/libnxwidgets/include/cimage.hxx +++ b/NxWidgets/libnxwidgets/include/cimage.hxx @@ -134,6 +134,33 @@ namespace NXWidgets virtual void drawBorder(CGraphicsPort *port); /** + * Redraws the button. + * + * @param x The x coordinate of the click. + * @param y The y coordinate of the click. + */ + + virtual void onClick(nxgl_coord_t x, nxgl_coord_t y); + + /** + * Raises an action event and redraws the button. + * + * @param x The x coordinate of the mouse. + * @param y The y coordinate of the mouse. + */ + + virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y); + + /** + * Redraws the button. + * + * @param x The x coordinate of the mouse. + * @param y The y coordinate of the mouse. + */ + + virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y); + + /** * Copy constructor is protected to prevent usage. */ @@ -199,10 +226,7 @@ namespace NXWidgets * @param highlightOn True(1), the image will be highlighted */ - inline void highlight(bool highlightOn) - { - m_highlighted = highlightOn; - } + void highlight(bool highlightOn); }; } diff --git a/NxWidgets/libnxwidgets/src/cimage.cxx b/NxWidgets/libnxwidgets/src/cimage.cxx index 0ca6f571e..7d9e0ee4e 100644 --- a/NxWidgets/libnxwidgets/src/cimage.cxx +++ b/NxWidgets/libnxwidgets/src/cimage.cxx @@ -358,6 +358,58 @@ void CImage::drawBorder(CGraphicsPort *port) } /** + * Control the highlight state. + * + * @param highlightOn True(1), the image will be highlighted + */ + +void CImage::highlight(bool highlightOn) +{ + if (m_highlighted != highlightOn) + { + m_highlighted = highlightOn; + redraw(); + } +} + +/** + * Redraws the button. + * + * @param x The x coordinate of the click. + * @param y The y coordinate of the click. + */ + +void CImage::onClick(nxgl_coord_t x, nxgl_coord_t y) +{ + redraw(); +} + +/** + * Raises an action event and redraws the button. + * + * @param x The x coordinate of the mouse. + * @param y The y coordinate of the mouse. + */ + +void CImage::onRelease(nxgl_coord_t x, nxgl_coord_t y) +{ + m_widgetEventHandlers->raiseActionEvent(); + redraw(); +} + +/** + * Redraws the button. + * + * @param x The x coordinate of the mouse. + * @param y The y coordinate of the mouse. + */ + +void CImage::onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y) +{ + redraw(); +} + +/** * Set the horizontal position of the bitmap. Zero is the left edge * of the bitmap and values >0 will move the bit map to the right. * This method is useful for horizontal scrolling a large bitmap diff --git a/NxWidgets/nxwm/include/cstartwindow.hxx b/NxWidgets/nxwm/include/cstartwindow.hxx index 5e4fa7564..a04a4f1a5 100644 --- a/NxWidgets/nxwm/include/cstartwindow.hxx +++ b/NxWidgets/nxwm/include/cstartwindow.hxx @@ -92,7 +92,7 @@ namespace NxWM void minimize(void); /** - * Called when the window minimize close is pressed. + * Called when the window close button is pressed. */ void close(void); diff --git a/NxWidgets/nxwm/src/cstartwindow.cxx b/NxWidgets/nxwm/src/cstartwindow.cxx index 8da71b2b5..f907f6718 100644 --- a/NxWidgets/nxwm/src/cstartwindow.cxx +++ b/NxWidgets/nxwm/src/cstartwindow.cxx @@ -356,7 +356,7 @@ void CStartWindow::minimize(void) void CStartWindow::close(void) { - m_taskbar->stopApplication(static_cast<IApplication*>(this)); + // Do nothing... you can't close the start window!!! } /** diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 42ab7ec85..54b257785 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -2746,4 +2746,7 @@ other logic can use the defaults. * graphics/nxtk/nxtk_events.c: Fixed an important but in the logic that translates the mouse/touchscreen position data for framed windows and toolbars. - + * drivers/input/stmpe11_tsc.c, tsc2007.c, and ads7843e.c: Need to keep track of + when if positional data is valid. When the touch is released, the X/Y position + of the release must be the same as the X/Y position of the last touch (se that + the release occurs in the same window as the last touch). diff --git a/nuttx/drivers/input/ads7843e.c b/nuttx/drivers/input/ads7843e.c index ed42e2275..4db412ea4 100644 --- a/nuttx/drivers/input/ads7843e.c +++ b/nuttx/drivers/input/ads7843e.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/input/ads7843e.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. * Authors: Gregory Nutt <gnutt@nuttx.org> * Diego Sanchez <dsanchez@nx-engineering.com> * @@ -383,9 +383,12 @@ static int ads7843e_sample(FAR struct ads7843e_dev_s *priv, if (sample->contact == CONTACT_UP) { - /* Next.. no contact. Increment the ID so that next contact ID will be unique */ + /* Next.. no contact. Increment the ID so that next contact ID + * will be unique. X/Y positions are no longer valid. + */ priv->sample.contact = CONTACT_NONE; + priv->sample.valid = false; priv->id++; } else if (sample->contact == CONTACT_DOWN) @@ -584,15 +587,28 @@ static void ads7843e_worker(FAR void *arg) priv->sample.contact = CONTACT_UP; } + + /* It is a pen down event. If the last loss-of-contact event has not been + * processed yet, then we have to ignore the pen down event (or else it will + * look like a drag event) + */ + + else if (priv->sample.contact == CONTACT_UP) + { + goto errout; + } else { - /* Handle all pen down events. First, sample positional values. */ + /* Handle pen down events. First, sample positional values. */ priv->sample.x = ads7843e_sendcmd(priv, ADS7843_CMD_XPOSITION); priv->sample.y = ads7843e_sendcmd(priv, ADS7843_CMD_YPOSITION); - (void)ads7843e_sendcmd(priv, ADS7843_CMD_ENABPINIRQ); - /* If this is the first (acknowledged) pend down report, then report + /* The X/Y positional data is now valid */ + + priv->sample.valid = true; + + /* If this is the first (acknowledged) pen down report, then report * this as the first contact. If contact == CONTACT_DOWN, it will be * set to set to CONTACT_MOVE after the contact is first sampled. */ @@ -621,6 +637,7 @@ static void ads7843e_worker(FAR void *arg) /* Exit, re-enabling ADS7843E interrupts */ errout: + (void)ads7843e_sendcmd(priv, ADS7843_CMD_ENABPINIRQ); config->enable(config, true); } @@ -856,9 +873,20 @@ static ssize_t ads7843e_read(FAR struct file *filep, FAR char *buffer, size_t le if (sample.contact == CONTACT_UP) { - /* Pen is now up */ + /* Pen is now up. Is the positional data valid? This is important to + * know because the release will be sent to the window based on its + * last positional data. + */ - report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID; + if (sample.valid) + { + report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID | + TOUCH_POS_VALID | TOUCH_PRESSURE_VALID; + } + else + { + report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID; + } } else if (sample.contact == CONTACT_DOWN) { diff --git a/nuttx/drivers/input/ads7843e.h b/nuttx/drivers/input/ads7843e.h index 7a534099e..030d1cb33 100644 --- a/nuttx/drivers/input/ads7843e.h +++ b/nuttx/drivers/input/ads7843e.h @@ -1,7 +1,7 @@ /******************************************************************************************** * drivers/input/ads7843e.h * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * References: @@ -115,6 +115,7 @@ struct ads7843e_sample_s { uint8_t id; /* Sampled touch point ID */ uint8_t contact; /* Contact state (see enum ads7843e_contact_e) */ + bool valid; /* True: x,y contain valid, sampled data */ uint16_t x; /* Measured X position */ uint16_t y; /* Measured Y position */ }; diff --git a/nuttx/drivers/input/stmpe11.h b/nuttx/drivers/input/stmpe11.h index 5a93f9463..b637ec644 100644 --- a/nuttx/drivers/input/stmpe11.h +++ b/nuttx/drivers/input/stmpe11.h @@ -111,6 +111,7 @@ struct stmpe11_sample_s { uint8_t id; /* Sampled touch point ID */ uint8_t contact; /* Contact state (see enum stmpe11_contact_e) */ + bool valid; /* True: x,y,z contain valid, sampled data */ uint16_t x; /* Measured X position */ uint16_t y; /* Measured Y position */ uint8_t z; /* Measured Z index */ diff --git a/nuttx/drivers/input/stmpe11_tsc.c b/nuttx/drivers/input/stmpe11_tsc.c index c5aae3830..70eb11259 100644 --- a/nuttx/drivers/input/stmpe11_tsc.c +++ b/nuttx/drivers/input/stmpe11_tsc.c @@ -242,6 +242,7 @@ static int stmpe11_sample(FAR struct stmpe11_dev_s *priv, */ priv->sample.contact = CONTACT_NONE; + priv->sample.valid = false; priv->id++; } else if (sample->contact == CONTACT_DOWN) @@ -537,27 +538,35 @@ static ssize_t stmpe11_read(FAR struct file *filep, FAR char *buffer, size_t len if (sample.contact == CONTACT_UP) { - /* Pen is now up */ + /* Pen is now up. Is the positional data valid? This is important to + * know because the release will be sent to the window based on its + * last positional data. + */ - report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID; - } - else - { - if (sample.contact == CONTACT_DOWN) + if (sample.valid) { - /* First contact */ - - report->point[0].flags = TOUCH_DOWN | TOUCH_ID_VALID | + report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID | TOUCH_POS_VALID | TOUCH_PRESSURE_VALID; } - else /* if (sample->contact == CONTACT_MOVE) */ + else { - /* Movement of the same contact */ - - report->point[0].flags = TOUCH_MOVE | TOUCH_ID_VALID | - TOUCH_POS_VALID | TOUCH_PRESSURE_VALID; + report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID; } } + else if (sample.contact == CONTACT_DOWN) + { + /* First contact */ + + report->point[0].flags = TOUCH_DOWN | TOUCH_ID_VALID | + TOUCH_POS_VALID | TOUCH_PRESSURE_VALID; + } + else /* if (sample->contact == CONTACT_MOVE) */ + { + /* Movement of the same contact */ + + report->point[0].flags = TOUCH_MOVE | TOUCH_ID_VALID | + TOUCH_POS_VALID | TOUCH_PRESSURE_VALID; + } ret = SIZEOF_TOUCH_SAMPLE_S(1); @@ -996,17 +1005,18 @@ void stmpe11_tscworker(FAR struct stmpe11_dev_s *priv, uint8_t intsta) /* When we see a big difference, snap to the new x/y thresholds */ - priv->threshx = x; - priv->threshy = y; + priv->threshx = x; + priv->threshy = y; /* Update the x/y position in the sample data */ - priv->sample.x = priv->threshx; - priv->sample.y = priv->threshy; + priv->sample.x = priv->threshx; + priv->sample.y = priv->threshy; /* Update the Z pressure index */ - priv->sample.z = stmpe11_getreg8(priv, STMPE11_TSC_DATAZ); + priv->sample.z = stmpe11_getreg8(priv, STMPE11_TSC_DATAZ); + priv->sample.valid = true; /* If this is the first (acknowledged) pen down report, then report * this as the first contact. If contact == CONTACT_DOWN, it will be diff --git a/nuttx/drivers/input/tsc2007.c b/nuttx/drivers/input/tsc2007.c index dcf743821..07acb5371 100644 --- a/nuttx/drivers/input/tsc2007.c +++ b/nuttx/drivers/input/tsc2007.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/input/tsc2007.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * References: @@ -142,6 +142,7 @@ struct tsc2007_sample_s { uint8_t id; /* Sampled touch point ID */ uint8_t contact; /* Contact state (see enum tsc2007_contact_e) */ + bool valid; /* True: x,y,pressure contain valid, sampled data */ uint16_t x; /* Measured X position */ uint16_t y; /* Measured Y position */ uint16_t pressure; /* Calculated pressure */ @@ -314,9 +315,12 @@ static int tsc2007_sample(FAR struct tsc2007_dev_s *priv, if (sample->contact == CONTACT_UP) { - /* Next.. no contract. Increment the ID so that next contact ID will be unique */ + /* Next.. no contact. Increment the ID so that next contact ID + * will be unique. X/Y positions are no longer valid. + */ priv->sample.contact = CONTACT_NONE; + priv->sample.valid = false; priv->id++; } else if (sample->contact == CONTACT_DOWN) @@ -586,6 +590,16 @@ static void tsc2007_worker(FAR void *arg) goto errout; } } + + /* It is a pen down event. If the last loss-of-contact event has not been + * processed yet, then we have to ignore the pen down event (or else it will + * look like a drag event) + */ + + else if (priv->sample.contact == CONTACT_UP) + { + goto errout; + } else { /* Handle all pen down events. First, sample X, Y, Z1, and Z2 values. @@ -678,6 +692,7 @@ static void tsc2007_worker(FAR void *arg) priv->sample.x = x; priv->sample.y = y; priv->sample.pressure = pressure; + priv->sample.valid = true; } /* Note the availability of new measurements */ @@ -956,9 +971,20 @@ static ssize_t tsc2007_read(FAR struct file *filep, FAR char *buffer, size_t len if (sample.contact == CONTACT_UP) { - /* Pen is now up */ + /* Pen is now up. Is the positional data valid? This is important to + * know because the release will be sent to the window based on its + * last positional data. + */ - report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID; + if (sample.valid) + { + report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID | + TOUCH_POS_VALID | TOUCH_PRESSURE_VALID; + } + else + { + report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID; + } } else { diff --git a/nuttx/drivers/input/tsc2007.h b/nuttx/drivers/input/tsc2007.h index 052ce76d2..76d5962bf 100644 --- a/nuttx/drivers/input/tsc2007.h +++ b/nuttx/drivers/input/tsc2007.h @@ -1,7 +1,7 @@ /******************************************************************************************** * drivers/input/tsc2007.h * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * References: |