Squashed commit of the following:
apps/graphics/twm4nx: In the Icon Manager, do not use the window name to identify which button press corresponds to which Window. Window names are not unique. Instead, it now keeps track of thich row x column was assigned to the window name. That row x column uniquely associates a window with a button and does not depend on the window name in any way. apps/graphics/twm4nx: Fix an error in event notification sent by the Icon Manager when a window is selected. apps/graphics/twm4nx: Correct logic in Icon Manager for the case where the number of windows causes the Icon Manager to increase in size by one row.
This commit is contained in:
parent
eeb5d4433c
commit
d91fb4e8c9
@ -62,10 +62,47 @@ STATUS
|
||||
CONFIG_TWM4XN_NXTERM, there will now be a "NuttShell" enty in the Main
|
||||
Menu. When pressed, this will bring up an NSH session in a Twm4Nx
|
||||
window.
|
||||
2019-05-14: We can now move an icon on the desktop. Includes logic to
|
||||
avoid collisions with other icons and with the background image. That
|
||||
later is an issue. The background image image widget needs to be
|
||||
removed; it can occlude a dektop icon. We need to paint the image
|
||||
directly on the background without the use of a widget.
|
||||
|
||||
Some known bugs yet-to-fixed. Surely there are more as will be revealed
|
||||
by additional testing:
|
||||
Issues:
|
||||
Here are all known issues and features that are missing:
|
||||
|
||||
1. There is no way to resize a window
|
||||
2. The logic to move an icon on the desk top does not work.
|
||||
3. There is no calibration screen for touchscreen calibration.
|
||||
TWM Compatibilities Issues:
|
||||
1. There is no way to resize a window. Resizing events should be be
|
||||
generated when user pulls to right, left, top, bottom, etc. None of
|
||||
that is implemented.
|
||||
2. Right click should bring up a window list
|
||||
3. For TWM-like behavior, a window frame and toolbar should be highlighted
|
||||
when the window has focus.
|
||||
4. A right click on the toolbar should bring up a window-specific menu.
|
||||
|
||||
Other issues/bugs
|
||||
5. There is no calibration screen for touchscreen calibration. I have
|
||||
been working with a system where the touchscreen naturally matches
|
||||
up with the display and no calibration is required. But the general
|
||||
case requires calibration.
|
||||
6. Icon drag movement is fairly smooth, but I think there may be issues
|
||||
with the window drag movement. it is hard to tell because of
|
||||
limitations in the touchscreen performance on the system that I am
|
||||
working with.
|
||||
7. Icom drag movement includes logic to avoid collisions with other
|
||||
icons and with the background image. That later is an issue. The
|
||||
background image image widget needs to be removed; it can occlude a
|
||||
dektop icon. We need to paint the image directly on the background
|
||||
without the use of a widget.
|
||||
8. More issues with the background image: I absords touchscreen
|
||||
presses without doing anything. It should bring-up the main menu
|
||||
menu just as any other region of the background. This would be easy
|
||||
to fix, but just replacing the background image widget is the better
|
||||
solution.
|
||||
9. The Icon Manager currently used the default window width. That is
|
||||
set half of the display width which is okay for the display I am using,
|
||||
but it really needs to set a width that is appropriate for the number
|
||||
of columns and the size of a generic name string.
|
||||
|
||||
Enhancement Ideas:
|
||||
10. How about a full-screen mode?
|
||||
|
@ -91,7 +91,6 @@ CIconMgr::CIconMgr(CTwm4Nx *twm4nx, uint8_t ncolumns)
|
||||
m_eventq = (mqd_t)-1; // No widget message queue yet
|
||||
m_head = (FAR struct SWindowEntry *)0; // Head of the winow list
|
||||
m_tail = (FAR struct SWindowEntry *)0; // Tail of the winow list
|
||||
m_active = (FAR struct SWindowEntry *)0; // No active window
|
||||
m_window = (FAR CWindow *)0; // No icon manager Window
|
||||
m_buttons = (FAR NXWidgets::CButtonArray *)0; // The button array
|
||||
m_nColumns = ncolumns; // Max columns per row
|
||||
@ -212,65 +211,48 @@ bool CIconMgr::addWindow(FAR CWindow *cwin)
|
||||
// Allocate a new icon manager entry
|
||||
|
||||
FAR struct SWindowEntry *wentry =
|
||||
(FAR struct SWindowEntry *)malloc(sizeof(struct SWindowEntry));
|
||||
(FAR struct SWindowEntry *)std::malloc(sizeof(struct SWindowEntry));
|
||||
|
||||
if (wentry == (FAR struct SWindowEntry *)0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
wentry->flink = NULL;
|
||||
wentry->iconmgr = this;
|
||||
wentry->active = false;
|
||||
wentry->down = false;
|
||||
wentry->cwin = cwin;
|
||||
wentry->pos.x = -1;
|
||||
wentry->pos.y = -1;
|
||||
wentry->flink = NULL;
|
||||
wentry->cwin = cwin;
|
||||
wentry->row = -1;
|
||||
wentry->column = -1;
|
||||
|
||||
// Insert the new entry into the list
|
||||
|
||||
insertEntry(wentry, cwin);
|
||||
|
||||
// Increment the window count
|
||||
// Increment the window count, calculate the new number of rows
|
||||
|
||||
m_nWindows++;
|
||||
|
||||
// The height of one row of the Icon Manager Window is determined (mostly)
|
||||
// by the font height
|
||||
uint8_t oldrows = m_nrows == 0 ? 1 : m_nrows;
|
||||
m_nrows = (m_nWindows + m_nColumns - 1) / m_nColumns;
|
||||
|
||||
nxgl_coord_t rowHeight = getRowHeight();
|
||||
// Did the number of rows change?
|
||||
|
||||
// Increase the height of the Icon Manager window, if necessary
|
||||
// REVISIT: Should also set an optimal width. Currently just uses
|
||||
// the defaults set when the window was created!
|
||||
|
||||
struct nxgl_size_s windowSize;
|
||||
if (!m_window->getWindowSize(&windowSize))
|
||||
if (oldrows != m_nrows)
|
||||
{
|
||||
twmerr("ERROR: Failed to get window size\n");
|
||||
// Yes.. Resize the button array and containing window to account for the
|
||||
// change in the number of windows
|
||||
|
||||
if (!resizeIconManager())
|
||||
{
|
||||
twmerr("ERROR: resizeIconManager failed\n");
|
||||
removeWindow(cwin);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nxgl_coord_t newHeight = rowHeight * m_nWindows;
|
||||
if (newHeight != windowSize.h)
|
||||
{
|
||||
// Set the new window height. Since we are not changing the
|
||||
// width, we don't need to call resizeFrame()
|
||||
// No.. Just re-label the buttons
|
||||
|
||||
windowSize.h = rowHeight * m_nWindows;
|
||||
m_window->setWindowSize(&windowSize);
|
||||
}
|
||||
}
|
||||
|
||||
// Pack the windows
|
||||
|
||||
pack();
|
||||
|
||||
// If no other window is active, then mark this as the active window
|
||||
|
||||
if (m_active == NULL)
|
||||
{
|
||||
m_active = wentry;
|
||||
labelButtons();
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -297,72 +279,81 @@ void CIconMgr::removeWindow(FAR CWindow *cwin)
|
||||
m_nWindows--;
|
||||
std::free(wentry);
|
||||
|
||||
// Repack the button array without the removed window
|
||||
// Check if the number of rows in the button array changed
|
||||
|
||||
pack();
|
||||
uint8_t oldrows = m_nrows == 0 ? 1 : m_nrows;
|
||||
m_nrows = (m_nWindows + m_nColumns - 1) / m_nColumns;
|
||||
uint8_t newrows = m_nrows == 0 ? 1 : m_nrows;
|
||||
|
||||
// Did the number of rows change?
|
||||
|
||||
if (oldrows != newrows)
|
||||
{
|
||||
// Yes.. Resize the button array to account for the change in the
|
||||
// number of windows
|
||||
|
||||
if (!resizeIconManager())
|
||||
{
|
||||
twmerr("ERROR: resizeIconManager failed\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No.. Just re-label the buttons
|
||||
|
||||
labelButtons();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pack the icon manager windows following an addition or deletion
|
||||
* Resize the button array and containing window
|
||||
*
|
||||
* @return True if the button array was resized successfully
|
||||
*/
|
||||
|
||||
void CIconMgr::pack(void)
|
||||
bool CIconMgr::resizeIconManager(void)
|
||||
{
|
||||
// Get the number of rows in the button array after the change
|
||||
// Get the number of rows in the button array but there needs to be at
|
||||
// least one row
|
||||
|
||||
uint8_t oldrows = m_nrows == 0 ? 1 : m_nrows;
|
||||
uint8_t newrows = (m_nWindows + m_nColumns - 1) / m_nColumns;
|
||||
uint8_t newrows = m_nrows == 0 ? 1 : m_nrows;
|
||||
|
||||
// Have the number of rows changed?
|
||||
// Resize the window. It will change only in height so we not have to
|
||||
// have to use resizeFrame().
|
||||
|
||||
if (oldrows != newrows)
|
||||
struct nxgl_size_s windowSize;
|
||||
if (!m_window->getWindowSize(&windowSize))
|
||||
{
|
||||
// Yes.. save the new number of rows
|
||||
twmerr("ERROR: Failed to get old window size\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_nrows = newrows;
|
||||
nxgl_coord_t rowHeight = getRowHeight();
|
||||
windowSize.h = newrows * rowHeight;
|
||||
if (!m_window->setWindowSize(&windowSize))
|
||||
{
|
||||
twmerr("ERROR: Failed to set new window size\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// We have to show at least one row in any case
|
||||
m_window->synchronize();
|
||||
|
||||
if (newrows == 0)
|
||||
{
|
||||
newrows = 1;
|
||||
}
|
||||
// Redimension the button array
|
||||
|
||||
// Resize the window. It has changed only in height so we not have to
|
||||
// have to use resizeFrame().
|
||||
|
||||
struct nxgl_size_s windowSize;
|
||||
if (!m_window->getWindowSize(&windowSize))
|
||||
{
|
||||
twmerr("ERROR: Failed to get old window size\n");
|
||||
return;
|
||||
}
|
||||
|
||||
nxgl_coord_t rowHeight = getRowHeight();
|
||||
windowSize.h = newrows * rowHeight;
|
||||
if (!m_window->setWindowSize(&windowSize))
|
||||
{
|
||||
twmerr("ERROR: Failed to set new window size\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Redimension the button array
|
||||
|
||||
nxgl_coord_t buttonWidth = windowSize.w / m_nColumns;
|
||||
|
||||
if (!m_buttons->resizeArray(m_nColumns, newrows, buttonWidth,
|
||||
rowHeight))
|
||||
{
|
||||
twmerr("ERROR: CButtonArray::resizeArray failed\n");
|
||||
return;
|
||||
}
|
||||
nxgl_coord_t buttonWidth = windowSize.w / m_nColumns;
|
||||
if (!m_buttons->resizeArray(m_nColumns, newrows, buttonWidth,
|
||||
rowHeight))
|
||||
{
|
||||
twmerr("ERROR: CButtonArray::resizeArray failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Re-apply all of the button labels
|
||||
|
||||
labelButtons();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -399,7 +390,9 @@ void CIconMgr::sort(void)
|
||||
}
|
||||
while (!done);
|
||||
|
||||
pack();
|
||||
// Re-apply the button labels in the new order
|
||||
|
||||
labelButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -696,6 +689,11 @@ void CIconMgr::labelButtons(void)
|
||||
|
||||
m_buttons->setText(colndx, rowndx, string);
|
||||
|
||||
// Assign this button to the window
|
||||
|
||||
swin->row = rowndx;
|
||||
swin->column = colndx;
|
||||
|
||||
// Advance to the next window
|
||||
|
||||
swin = swin->flink;
|
||||
@ -826,29 +824,6 @@ FAR struct SWindowEntry *CIconMgr::findEntry(FAR CWindow *cwin)
|
||||
return wentry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set active window
|
||||
*
|
||||
* @active Window to become active.
|
||||
*/
|
||||
|
||||
void CIconMgr::active(FAR struct SWindowEntry *wentry)
|
||||
{
|
||||
wentry->active = true;
|
||||
m_active = wentry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set window inactive
|
||||
*
|
||||
* @active windows to become inactive.
|
||||
*/
|
||||
|
||||
void CIconMgr::inactive(FAR struct SWindowEntry *wentry)
|
||||
{
|
||||
wentry->active = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Free window list entry.
|
||||
*/
|
||||
@ -879,30 +854,26 @@ void CIconMgr::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
|
||||
|
||||
if (m_buttons->isButtonClicked(column, row))
|
||||
{
|
||||
// Get the text associated with this button
|
||||
|
||||
const NXWidgets::CNxString string = m_buttons->getText(column, row);
|
||||
|
||||
// Now find the window with this name
|
||||
// Now find the window assigned to this row x colum
|
||||
|
||||
for (FAR struct SWindowEntry *swin = m_head;
|
||||
swin != (FAR struct SWindowEntry *)0;
|
||||
swin = swin->flink)
|
||||
{
|
||||
// Check if the button string is the same as the window name
|
||||
// Compare row and column
|
||||
|
||||
if (string.compareTo(swin->cwin->getWindowName()) == 0)
|
||||
if (row == swin->row && column == swin->column)
|
||||
{
|
||||
// Got it... send an event message
|
||||
|
||||
struct SEventMsg msg;
|
||||
msg.obj = (FAR void *)this;
|
||||
msg.obj = swin->cwin;
|
||||
msg.pos.x = e.getX();
|
||||
msg.pos.y = e.getY();
|
||||
msg.context = EVENT_CONTEXT_ICONMGR;
|
||||
msg.handler = (FAR void *)0;
|
||||
|
||||
// Got it. Is the window Iconified?
|
||||
// Is the window Iconified?
|
||||
|
||||
if (swin->cwin->isIconified())
|
||||
{
|
||||
|
@ -637,25 +637,10 @@ void CResize::endResize(FAR CWindow *cwin)
|
||||
|
||||
if (cwin->isIconMgr())
|
||||
{
|
||||
// Adjust the Icon Manager button array to account for the resize
|
||||
|
||||
CIconMgr *iconMgr = cwin->getIconMgr();
|
||||
DEBUGASSERT(iconMgr != (CIconMgr *)0);
|
||||
|
||||
unsigned int currcol = iconMgr->getNumberOfColumns();
|
||||
if (currcol == 0)
|
||||
{
|
||||
currcol = 1;
|
||||
}
|
||||
|
||||
struct nxgl_size_s iconMgrSize;
|
||||
iconMgr->getSize(&iconMgrSize);
|
||||
|
||||
// REVISIT: The following is nonsense
|
||||
|
||||
iconMgrSize.w = (unsigned int)
|
||||
((m_dragsize.w * (unsigned long)iconMgr->getNumberOfColumns()) / currcol);
|
||||
|
||||
cwin->resizeFrame(&iconMgrSize, &pos);
|
||||
iconMgr->pack();
|
||||
iconMgr->resizeIconManager();
|
||||
}
|
||||
|
||||
cwin->raiseWindow();
|
||||
|
@ -62,27 +62,22 @@
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CNxTkWindow; // Forward reference
|
||||
class CButtonArray; // Forward reference
|
||||
class CWidgetEventHandler; // Forward reference
|
||||
class CWidgetEventArgs; // Forward reference
|
||||
struct SRlePaletteBitmap; // Forward reference
|
||||
class CNxTkWindow; // Forward reference
|
||||
class CButtonArray; // Forward reference
|
||||
class CWidgetEventHandler; // Forward reference
|
||||
class CWidgetEventArgs; // Forward reference
|
||||
struct SRlePaletteBitmap; // Forward reference
|
||||
}
|
||||
|
||||
namespace Twm4Nx
|
||||
{
|
||||
struct SWindowEntry
|
||||
{
|
||||
FAR struct SWindowEntry *flink;
|
||||
FAR struct SWindowEntry *blink;
|
||||
FAR CWindow *cwin;
|
||||
FAR CIconMgr *iconmgr;
|
||||
nxgl_point_s pos;
|
||||
nxgl_size_s size;
|
||||
int row;
|
||||
int col;
|
||||
bool active;
|
||||
bool down;
|
||||
FAR struct SWindowEntry *flink; /**< Forward link to next window entry */
|
||||
FAR struct SWindowEntry *blink; /**< Backward link to previous window entry */
|
||||
FAR CWindow *cwin; /**< The window payload */
|
||||
int row; /**< X position in the button array */
|
||||
int column;
|
||||
};
|
||||
|
||||
class CIconMgr : protected NXWidgets::CWidgetEventHandler,
|
||||
@ -96,7 +91,6 @@ namespace Twm4Nx
|
||||
NXWidgets::CNxString m_name; /**< The Icon Manager name */
|
||||
FAR struct SWindowEntry *m_head; /**< Head of the window list */
|
||||
FAR struct SWindowEntry *m_tail; /**< Tail of the window list */
|
||||
FAR struct SWindowEntry *m_active; /**< The active entry */
|
||||
FAR struct CWindow *m_window; /**< Parent window */
|
||||
FAR NXWidgets::CButtonArray *m_buttons; /**< The contained button array */
|
||||
uint16_t m_nWindows; /**< The number of windows in the icon mgr. */
|
||||
@ -157,22 +151,6 @@ namespace Twm4Nx
|
||||
|
||||
FAR struct SWindowEntry *findEntry(FAR CWindow *cwin);
|
||||
|
||||
/**
|
||||
* Set active window
|
||||
*
|
||||
* @param wentry Window to become active.
|
||||
*/
|
||||
|
||||
void active(FAR struct SWindowEntry *wentry);
|
||||
|
||||
/**
|
||||
* Set window inactive
|
||||
*
|
||||
* @param wentry windows to become inactive.
|
||||
*/
|
||||
|
||||
void inactive(FAR struct SWindowEntry *wentry);
|
||||
|
||||
/**
|
||||
* Free window list entry.
|
||||
*/
|
||||
@ -319,10 +297,12 @@ namespace Twm4Nx
|
||||
}
|
||||
|
||||
/**
|
||||
* Pack the icon manager windows following an addition or deletion
|
||||
* Resize the button array, possibly adjusting the window height
|
||||
*
|
||||
* @return True if the button array was resized successfully
|
||||
*/
|
||||
|
||||
void pack(void);
|
||||
bool resizeIconManager(void);
|
||||
|
||||
/**
|
||||
* sort the windows
|
||||
|
Loading…
x
Reference in New Issue
Block a user