Several patches from Petteri Aimonen (mostly NxWidgets)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5324 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
afdb39b3b9
commit
8c6c3e53e9
@ -182,4 +182,21 @@
|
||||
* libnxwidgets/src/cnxserver.cxx: Reduce delay to allow NX server
|
||||
to start. One second was un-necessarily long. Reduced to 50 MS.
|
||||
Reduction suggested by Petteri Aimonen.
|
||||
|
||||
* tools/bitmap_converter.py: This script converts from any image type
|
||||
supported by Python imaging library to the RLE-encoded format used by
|
||||
NxWidgets.
|
||||
* NxWidgets/nxwm/src/capplicationwindow.cxx: If the "desktop" is empty,
|
||||
users have no need to minimize any windows. If the buttons are small,
|
||||
it's easy to hit minimize button accidentally when trying to close an
|
||||
application. Contributed by Petteri Aimonen.
|
||||
* NxWidgets/nxwm/src/ctaskbar.cxx: Add an option to eliminate the
|
||||
background image. Contributed by Petteri Aimonen.
|
||||
* NxWidgets/nxwm/src/chexcalculator.cxx and NxWidgets/nxwm/src/cstartwindow.cxx:
|
||||
The config settings CONFIG_NXWM_STARTWINDOW_ICON and CONFIG_NXWM_HEXCALCULATOR_ICON
|
||||
allow changing the icons used for these applications. However, to declare symbols
|
||||
for these icons user would need to modify NxWidgets header files.
|
||||
This commit adds a simple forward declaration to the relevant files, based on the
|
||||
configured icon. If the icon does not exist, linker will give an error about it.
|
||||
Contributed by Petteri Aimonen.
|
||||
* NxWidgets/nxwm/src/ctaskbar.cxx: Highlight the current window in the task bar.
|
||||
Contributed by Petteri Aimonen.
|
||||
|
16
Kconfig
16
Kconfig
@ -308,6 +308,14 @@ config NXWM_TASKBAR_WIDTH
|
||||
---help---
|
||||
Task bar thickness (either vertical or horizontal). Default: 25 + 2*spacing
|
||||
|
||||
config NXWM_DISABLE_MINIMIZE
|
||||
bool "Disable Minimize Button"
|
||||
default n
|
||||
---help---
|
||||
If the "desktop" is empty, users have no need to minimize any windows. If the buttons
|
||||
are small, it's easy to hit minimize button accidentally when trying to close an
|
||||
application.
|
||||
|
||||
comment "Tool Bar Configuration"
|
||||
|
||||
config NXWM_TOOLBAR_HEIGHT
|
||||
@ -319,8 +327,16 @@ config NXWM_TOOLBAR_HEIGHT
|
||||
|
||||
comment "Background Image"
|
||||
|
||||
config NXWM_DISABLE_BACKGROUND_IMAGE
|
||||
bool "Disable Background Image"
|
||||
default n if !NXWM_DISABLE_MINIMIZE
|
||||
default y if NXWM_DISABLE_MINIMIZE
|
||||
---help---
|
||||
Disable support for the "Desktop" background image.
|
||||
|
||||
config NXWM_BACKGROUND_IMAGE
|
||||
string "Background Image"
|
||||
depends on !NXWM_DISABLE_BACKGROUND_IMAGE
|
||||
---help---
|
||||
The name of the image to use in the background window. Default:
|
||||
NXWidgets::g_nuttxBitmap
|
||||
|
@ -241,6 +241,7 @@ bool CApplicationWindow::open(void)
|
||||
m_stopImage->addWidgetEventHandler(this);
|
||||
}
|
||||
|
||||
#ifndef CONFIG_NXWM_DISABLE_MINIMIZE
|
||||
// Create MINIMIZE application bitmap container
|
||||
|
||||
m_minimizeBitmap = new NXWidgets::CRlePaletteBitmap(&g_minimizeBitmap);
|
||||
@ -289,6 +290,7 @@ bool CApplicationWindow::open(void)
|
||||
|
||||
m_minimizeImage->setBorderless(true);
|
||||
m_minimizeImage->addWidgetEventHandler(this);
|
||||
#endif
|
||||
|
||||
// The rest of the toolbar will hold the left-justified application label
|
||||
// Create the default font instance
|
||||
@ -364,11 +366,15 @@ void CApplicationWindow::redraw(void)
|
||||
m_stopImage->setRaisesEvents(true);
|
||||
}
|
||||
|
||||
// Draw the minimize image
|
||||
// Draw the minimize image (which may not be present if this is a
|
||||
// mimimization is disabled)
|
||||
|
||||
if (m_minimizeImage)
|
||||
{
|
||||
m_minimizeImage->enableDrawing();
|
||||
m_minimizeImage->redraw();
|
||||
m_minimizeImage->setRaisesEvents(true);
|
||||
}
|
||||
|
||||
// And finally draw the window label
|
||||
|
||||
@ -392,10 +398,14 @@ void CApplicationWindow::hide(void)
|
||||
m_stopImage->setRaisesEvents(false);
|
||||
}
|
||||
|
||||
// Disable the minimize image
|
||||
// Disable the minimize image(which may not be present if this is a
|
||||
// mimimization is disabled)
|
||||
|
||||
if (m_minimizeImage)
|
||||
{
|
||||
m_minimizeImage->disableDrawing();
|
||||
m_minimizeImage->setRaisesEvents(false);
|
||||
}
|
||||
|
||||
// Disable the window label
|
||||
|
||||
@ -570,7 +580,7 @@ void CApplicationWindow::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
|
||||
|
||||
// Check the minimize image (only if the stop application image is not pressed)
|
||||
|
||||
else if (m_minimizeImage->isClicked())
|
||||
else if (m_minimizeImage && m_minimizeImage->isClicked())
|
||||
{
|
||||
// Notify the controlling logic that the application should be miminsed
|
||||
|
||||
|
@ -191,6 +191,8 @@ namespace NxWM
|
||||
* CHexCalculator Method Implementations
|
||||
********************************************************************************************/
|
||||
|
||||
extern const struct NXWidgets::SRlePaletteBitmap CONFIG_NXWM_HEXCALCULATOR_ICON;
|
||||
|
||||
using namespace NxWM;
|
||||
|
||||
/**
|
||||
|
@ -71,6 +71,8 @@ FAR const char *NxWM::g_startWindowMqName = CONFIG_NXWM_STARTWINDOW_MQNAME;
|
||||
* CStartWindow Method Implementations
|
||||
********************************************************************************************/
|
||||
|
||||
extern const struct NXWidgets::SRlePaletteBitmap CONFIG_NXWM_STARTWINDOW_ICON;
|
||||
|
||||
using namespace NxWM;
|
||||
|
||||
/**
|
||||
|
@ -991,6 +991,7 @@ bool CTaskbar::createBackgroundWindow(void)
|
||||
|
||||
bool CTaskbar::createBackgroundImage(void)
|
||||
{
|
||||
#ifndef CONFIG_NXWM_DISABLE_BACKGROUND_IMAGE
|
||||
// Get the size of the display
|
||||
|
||||
struct nxgl_size_s windowSize;
|
||||
@ -1054,6 +1055,8 @@ bool CTaskbar::createBackgroundImage(void)
|
||||
|
||||
m_backImage->setBorderless(true);
|
||||
m_backImage->setRaisesEvents(false);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1128,6 +1131,10 @@ bool CTaskbar::redrawTaskbarWindow(void)
|
||||
image->disableDrawing();
|
||||
image->setRaisesEvents(false);
|
||||
|
||||
// Highlight the icon for the top-most window
|
||||
|
||||
image->highlight(m_slots.at(i).app == m_topApp);
|
||||
|
||||
// Get the size of the icon image
|
||||
|
||||
NXWidgets::CRect rect;
|
||||
@ -1302,8 +1309,12 @@ bool CTaskbar::redrawBackgroundWindow(void)
|
||||
|
||||
// Then re-draw the background image on the window
|
||||
|
||||
if (m_backImage)
|
||||
{
|
||||
m_backImage->enableDrawing();
|
||||
m_backImage->redraw();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1330,6 +1341,10 @@ bool CTaskbar::redrawApplicationWindow(IApplication *app)
|
||||
|
||||
raiseTopApplication();
|
||||
|
||||
// Redraw taskbar
|
||||
|
||||
redrawTaskbarWindow();
|
||||
|
||||
// Every application provides a method to obtain its application window
|
||||
|
||||
IApplicationWindow *appWindow = app->getWindow();
|
||||
|
51
tools/README.txt
Executable file
51
tools/README.txt
Executable file
@ -0,0 +1,51 @@
|
||||
NxWidgets/tools README File
|
||||
===========================
|
||||
|
||||
addobjs.sh
|
||||
----------
|
||||
|
||||
$0 will add all object (.o) files in directory to an archive.
|
||||
|
||||
Usage: tools/addobjs.sh [OPTIONS] <lib-path> <obj-dir>
|
||||
|
||||
Where:
|
||||
<lib-path> is the full, absolute path to the library to use
|
||||
<obj-dir> is full path to the directory containing the object files to be added
|
||||
OPTIONS include:
|
||||
-p Prefix to use. For example, to use arm-elf-ar, add '-p arm-elf-'
|
||||
-w Use Windows style paths insted of POSIX paths
|
||||
-d Enable script debug
|
||||
-h Show this usage information
|
||||
|
||||
bitmap_converter.py
|
||||
-------------------
|
||||
|
||||
This script converts from any image type supported by Python imaging library to
|
||||
the RLE-encoded format used by NxWidgets.
|
||||
|
||||
indent.sh
|
||||
---------
|
||||
|
||||
This script uses the Linux 'indent' utility to re-format C source files
|
||||
to match the coding style that I use. It differs from my coding style in that
|
||||
|
||||
- I normally put the traiing */ of a multi-line comment on a separate line,
|
||||
- I usually align things vertically (like '='in assignments.
|
||||
|
||||
install.sh
|
||||
----------
|
||||
|
||||
Install a unit test in the NuttX source tree"
|
||||
|
||||
USAGE: tools/install.sh <apps-directory-path> <test-sub-directory>
|
||||
|
||||
Where:
|
||||
<apps-directory-path> is the full, absolute path to the NuttX apps/ directory
|
||||
<test-sub-directory> is the name of a sub-directory in the UnitTests directory
|
||||
|
||||
zipme.sh
|
||||
--------
|
||||
|
||||
Pack up the NxWidgets tarball for release.
|
||||
|
||||
USAGE: tools/zipme.sh <version>
|
148
tools/bitmap_converter.py
Executable file
148
tools/bitmap_converter.py
Executable file
@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
'''This script converts from any image type supported by
|
||||
Python imaging library to the RLE-encoded format used by
|
||||
NxWidgets.
|
||||
'''
|
||||
|
||||
from PIL import Image
|
||||
|
||||
def get_palette(img, maxcolors = 255):
|
||||
'''Returns a list of colors. If there are too many colors in the image,
|
||||
the least used are removed.
|
||||
'''
|
||||
img = img.convert("RGB")
|
||||
colors = img.getcolors(65536)
|
||||
colors.sort(key = lambda c: -c[0])
|
||||
return [c[1] for c in colors[:maxcolors]]
|
||||
|
||||
def write_palette(outfile, palette):
|
||||
'''Write the palette (normal and hilight) to the output file.'''
|
||||
|
||||
outfile.write('static const NXWidgets::nxwidget_pixel_t palette[BITMAP_PALETTESIZE] =\n');
|
||||
outfile.write('{\n')
|
||||
|
||||
for i in range(0, len(palette), 4):
|
||||
outfile.write(' ');
|
||||
for r, g, b in palette[i:i+4]:
|
||||
outfile.write('MKRGB(%3d,%3d,%3d), ' % (r, g, b))
|
||||
outfile.write('\n');
|
||||
|
||||
outfile.write('};\n\n')
|
||||
|
||||
outfile.write('static const NXWidgets::nxwidget_pixel_t hilight_palette[BITMAP_PALETTESIZE] =\n');
|
||||
outfile.write('{\n')
|
||||
|
||||
for i in range(0, len(palette), 4):
|
||||
outfile.write(' ');
|
||||
for r, g, b in palette[i:i+4]:
|
||||
r = min(255, r + 50)
|
||||
g = min(255, g + 50)
|
||||
b = min(255, b + 50)
|
||||
outfile.write('MKRGB(%3d,%3d,%3d), ' % (r, g, b))
|
||||
outfile.write('\n');
|
||||
|
||||
outfile.write('};\n\n')
|
||||
|
||||
|
||||
def quantize(color, palette):
|
||||
'''Return the color index to closest match in the palette.'''
|
||||
try:
|
||||
return palette.index(color)
|
||||
except ValueError:
|
||||
# No exact match, search for the closest
|
||||
def distance(color2):
|
||||
return sum([(a - b)**2 for a, b in zip(color, color2)])
|
||||
|
||||
return palette.index(min(palette, key = distance));
|
||||
|
||||
def encode_row(img, palette, y):
|
||||
'''RLE-encode one row of image data.'''
|
||||
entries = []
|
||||
color = None
|
||||
repeats = 0
|
||||
|
||||
for x in range(0, img.size[0]):
|
||||
c = quantize(img.getpixel((x, y)), palette)
|
||||
if c == color:
|
||||
repeats += 1
|
||||
else:
|
||||
if color is not None:
|
||||
entries.append((repeats, color))
|
||||
|
||||
repeats = 1
|
||||
color = c
|
||||
|
||||
if color is not None:
|
||||
entries.append((repeats, color))
|
||||
|
||||
return entries
|
||||
|
||||
def write_image(outfile, img, palette):
|
||||
'''Write the image contents to the output file.'''
|
||||
|
||||
outfile.write('static const NXWidgets::SRlePaletteBitmapEntry bitmap[] =\n');
|
||||
outfile.write('{\n');
|
||||
|
||||
for y in range(0, img.size[1]):
|
||||
entries = encode_row(img, palette, y)
|
||||
row = ""
|
||||
for r, c in entries:
|
||||
if len(row) > 60:
|
||||
outfile.write(' ' + row + '\n')
|
||||
row = ""
|
||||
|
||||
row += '{%3d, %3d}, ' % (r, c)
|
||||
|
||||
row += ' ' * (73 - len(row))
|
||||
outfile.write(' ' + row + '/* Row %d */\n' % y)
|
||||
|
||||
outfile.write('};\n\n');
|
||||
|
||||
def write_descriptor(outfile, name):
|
||||
'''Write the public descriptor structure for the image.'''
|
||||
|
||||
outfile.write('extern const struct NXWidgets::SRlePaletteBitmap g_%s =\n' % name)
|
||||
outfile.write('{\n')
|
||||
outfile.write(' CONFIG_NXWIDGETS_BPP,\n')
|
||||
outfile.write(' CONFIG_NXWIDGETS_FMT,\n')
|
||||
outfile.write(' BITMAP_PALETTESIZE,\n')
|
||||
outfile.write(' BITMAP_WIDTH,\n')
|
||||
outfile.write(' BITMAP_HEIGHT,\n')
|
||||
outfile.write(' {palette, hilight_palette},\n')
|
||||
outfile.write(' bitmap\n')
|
||||
outfile.write('};\n')
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
import os.path
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print "Usage: bitmap_converter.py source.png output.cxx"
|
||||
sys.exit(1)
|
||||
|
||||
img = Image.open(sys.argv[1])
|
||||
outfile = open(sys.argv[2], 'w')
|
||||
palette = get_palette(img)
|
||||
|
||||
outfile.write(
|
||||
'''
|
||||
/* Automatically NuttX bitmap file. */
|
||||
/* Generated from %(src)s by bitmap_converter.py. */
|
||||
|
||||
#include <nxconfig.hxx>
|
||||
#include <crlepalettebitmap.hxx>
|
||||
|
||||
#define BITMAP_WIDTH %(width)s
|
||||
#define BITMAP_HEIGHT %(height)s
|
||||
#define BITMAP_PALETTESIZE %(palettesize)s
|
||||
|
||||
''' % {'src': sys.argv[1], 'width': img.size[0], 'height': img.size[1],
|
||||
'palettesize': len(palette)}
|
||||
)
|
||||
|
||||
name = os.path.splitext(os.path.basename(sys.argv[1]))[0]
|
||||
|
||||
write_palette(outfile, palette)
|
||||
write_image(outfile, img, palette)
|
||||
write_descriptor(outfile, name)
|
@ -39,6 +39,8 @@
|
||||
|
||||
function ShowUsage()
|
||||
{
|
||||
echo ""
|
||||
echo "Install a unit test in the NuttX source tree"
|
||||
echo ""
|
||||
echo "USAGE: $0 <apps-directory-path> <test-sub-directory>"
|
||||
echo ""
|
||||
|
Loading…
Reference in New Issue
Block a user