apps/graphics/twm4nx: During resizing, when the tool bar is drawn, the toolbar background must be redraw before the butttons and title are redrawn.

This commit is contained in:
Gregory Nutt 2019-05-16 16:39:13 -06:00
parent 6fe1d62624
commit 5fc0e6c1a8
2 changed files with 45 additions and 13 deletions

View File

@ -950,10 +950,27 @@ bool CWindow::createToolbar(void)
} }
// 5. Fill the entire tool bar with the background color from the // 5. Fill the entire tool bar with the background color from the
// current widget system. // current widget style.
// Get the graphics port for drawing on the background window if (!fillToolbar())
{
delete m_toolbar;
m_toolbar = (FAR NXWidgets::CNxToolbar *)0;
return false;
}
return true;
}
/**
* Fill the toolbar background color
*/
bool CWindow::fillToolbar(void)
{
// Get the graphics port for drawing on the toolbar
FAR NXWidgets::CWidgetControl *control = m_toolbar->getWidgetControl();
NXWidgets::CGraphicsPort *port = control->getGraphicsPort(); NXWidgets::CGraphicsPort *port = control->getGraphicsPort();
// Get the size of the window // Get the size of the window
@ -961,13 +978,12 @@ bool CWindow::createToolbar(void)
struct nxgl_size_s windowSize; struct nxgl_size_s windowSize;
if (!m_toolbar->getSize(&windowSize)) if (!m_toolbar->getSize(&windowSize))
{ {
delete m_toolbar; twmerr("ERROR: Failed to get the size of the toolbar\n");
m_toolbar = (FAR NXWidgets::CNxToolbar *)0;
return false; return false;
} }
// Get the background color of the current widget system. // Get the background color of the current widget style.
// REVISIT: No widgets yet, using the the non-shadowed border color // REVISIT: Using the the non-shadowed border color
port->drawFilledRect(0, 0, windowSize.w, windowSize.h, port->drawFilledRect(0, 0, windowSize.w, windowSize.h,
CONFIG_NXTK_BORDERCOLOR1); CONFIG_NXTK_BORDERCOLOR1);
@ -995,8 +1011,7 @@ bool CWindow::updateToolbarLayout(void)
return false; return false;
} }
// Create the title bar windows // Set up the toolbar horizontal spacing
// Set up the toolbar horizonal spacing
m_tbRightX = winsize.w; m_tbRightX = winsize.w;
@ -1041,14 +1056,25 @@ bool CWindow::updateToolbarLayout(void)
titleSize.h = m_tbHeight; titleSize.h = m_tbHeight;
titleSize.w = m_tbRightX - m_tbLeftX - CONFIG_TWM4NX_TOOLBAR_HSPACING + 1; titleSize.w = m_tbRightX - m_tbLeftX - CONFIG_TWM4NX_TOOLBAR_HSPACING + 1;
bool success = m_tbTitle->resize(titleSize.w, titleSize.h); if (!m_tbTitle->resize(titleSize.w, titleSize.h))
if (!success)
{ {
twmerr("ERROR: Failed to resize title\n"); twmerr("ERROR: Failed to resize title\n");
return false;
} }
// Fill the entire tool bar with the background color from the current
// widget style.
if (!fillToolbar())
{
twmerr("ERROR: Failed to fill the toolbar\n");
return false;
}
// Enable and re-draw all of the toolbar widgets
enableToolbarWidgets(); enableToolbarWidgets();
return success; return true;
} }
/** /**
@ -1073,7 +1099,7 @@ bool CWindow::disableToolbarWidgets(void)
} }
/** /**
* Enable toolbar widget drawing and widget events. * Enable and redraw toolbar widget drawing and widget events.
*/ */
bool CWindow::enableToolbarWidgets(void) bool CWindow::enableToolbarWidgets(void)

View File

@ -236,6 +236,12 @@ namespace Twm4Nx
bool createToolbar(void); bool createToolbar(void);
/**
* Fill the toolbar background color
*/
bool fillToolbar(void);
/** /**
* Update the toolbar layout, resizing the title text window and * Update the toolbar layout, resizing the title text window and
* repositioning all windows on the toolbar. * repositioning all windows on the toolbar.
@ -316,7 +322,7 @@ namespace Twm4Nx
/** /**
* This function is called if the mouse left button is released or * This function is called if the mouse left button is released or
* if the touchscrreen touch is lost. This indicates that the * if the touchscreen touch is lost. This indicates that the
* movement sequence is complete. * movement sequence is complete.
* *
* This function overrides the virtual IEventTap::dropEvent method. * This function overrides the virtual IEventTap::dropEvent method.