summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-07-16 11:11:55 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-07-16 11:11:55 -0600
commit789172023edd1e4d082824983cb4ac8c59d00b95 (patch)
treee8d88c24026c15cd19094464bffc823e19407480
parent8e932634ac53d6ac42d60d805ccee4e2e285aa72 (diff)
downloadnuttx-789172023edd1e4d082824983cb4ac8c59d00b95.tar.gz
nuttx-789172023edd1e4d082824983cb4ac8c59d00b95.tar.bz2
nuttx-789172023edd1e4d082824983cb4ac8c59d00b95.zip
NxWM::CMediaPlayer: Fix of state related bugs + Size if CLabel is increased (in preparation for becoming a CListBox)
-rw-r--r--NxWidgets/libnxwidgets/include/cimage.hxx5
-rw-r--r--NxWidgets/libnxwidgets/include/cscaledbitmap.hxx4
-rw-r--r--NxWidgets/libnxwidgets/include/cscrollbarhorizontal.hxx14
-rw-r--r--NxWidgets/libnxwidgets/include/cscrollbarvertical.hxx12
-rw-r--r--NxWidgets/libnxwidgets/include/csliderhorizontal.hxx22
-rw-r--r--NxWidgets/libnxwidgets/include/cslidervertical.hxx22
-rw-r--r--NxWidgets/libnxwidgets/include/islider.hxx14
-rw-r--r--NxWidgets/libnxwidgets/src/cglyphsliderhorizontal.cxx13
-rw-r--r--NxWidgets/libnxwidgets/src/cscaledbitmap.cxx2
-rw-r--r--NxWidgets/libnxwidgets/src/cscrollbarhorizontal.cxx14
-rw-r--r--NxWidgets/libnxwidgets/src/cscrollbarvertical.cxx16
-rw-r--r--NxWidgets/libnxwidgets/src/csliderhorizontal.cxx4
-rw-r--r--NxWidgets/libnxwidgets/src/cslidervertical.cxx4
-rw-r--r--NxWidgets/nxwm/include/cmediaplayer.hxx28
-rw-r--r--NxWidgets/nxwm/include/nxwmconfig.hxx12
-rw-r--r--NxWidgets/nxwm/src/cmediaplayer.cxx337
-rw-r--r--apps/NxWidgets/Kconfig42
-rw-r--r--nuttx/configs/sama5d4-ek/nxwm/defconfig2
18 files changed, 361 insertions, 206 deletions
diff --git a/NxWidgets/libnxwidgets/include/cimage.hxx b/NxWidgets/libnxwidgets/include/cimage.hxx
index e485f6d9d..ee72617ac 100644
--- a/NxWidgets/libnxwidgets/include/cimage.hxx
+++ b/NxWidgets/libnxwidgets/include/cimage.hxx
@@ -1,7 +1,7 @@
/****************************************************************************
* NxWidgets/libnxwidgets/include/cimage.hxx
*
- * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -218,6 +218,9 @@ namespace NXWidgets
/**
* Destructor.
+ *
+ * NOTE: That the contained bitmap image is not destroyed when the image
+ * container is destroyed.
*/
virtual inline ~CImage() { }
diff --git a/NxWidgets/libnxwidgets/include/cscaledbitmap.hxx b/NxWidgets/libnxwidgets/include/cscaledbitmap.hxx
index 8cb25ae75..e6944ad4c 100644
--- a/NxWidgets/libnxwidgets/include/cscaledbitmap.hxx
+++ b/NxWidgets/libnxwidgets/include/cscaledbitmap.hxx
@@ -1,7 +1,7 @@
/****************************************************************************
* NxWidgets/libnxwidgets/include/cscaledbitmap.hxx
*
- * Copyright (C) 2013 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -75,7 +75,7 @@ namespace NXWidgets
FAR IBitmap *m_bitmap; /**< The bitmap that is being scaled */
struct nxgl_size_s m_size; /**< Scaled size of the image */
FAR uint8_t *m_rowCache[2]; /**< Two cached rows of the image */
- int m_row; /**< Row number of the first cached row */
+ unsigned int m_row; /**< Row number of the first cached row */
b16_t m_xScale; /**< X scale factor */
b16_t m_yScale; /**< Y scale factor */
diff --git a/NxWidgets/libnxwidgets/include/cscrollbarhorizontal.hxx b/NxWidgets/libnxwidgets/include/cscrollbarhorizontal.hxx
index f6c3be3c3..65ab5b416 100644
--- a/NxWidgets/libnxwidgets/include/cscrollbarhorizontal.hxx
+++ b/NxWidgets/libnxwidgets/include/cscrollbarhorizontal.hxx
@@ -1,7 +1,7 @@
/****************************************************************************
* NxWidgets/libnxwidgets/include/cscrollbarhorizontal.hxx
*
- * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -171,7 +171,7 @@ namespace NXWidgets
* @return The smallest value.
*/
- const nxgl_coord_t getMinimumValue(void) const;
+ const int getMinimumValue(void) const;
/**
* Get the largest value that the slider can represent.
@@ -179,7 +179,7 @@ namespace NXWidgets
* @return The largest value.
*/
- const nxgl_coord_t getMaximumValue(void) const;
+ const int getMaximumValue(void) const;
/**
* Get the current value of the slider.
@@ -187,7 +187,7 @@ namespace NXWidgets
* @return The current slider value.
*/
- const nxgl_coord_t getValue(void) const;
+ const int getValue(void) const;
/**
* Get the value represented by the height of the grip.
@@ -206,7 +206,7 @@ namespace NXWidgets
* @param value The smallest value.
*/
- void setMinimumValue(const nxgl_coord_t value);
+ void setMinimumValue(const int value);
/**
* Set the largest value that the slider can represent.
@@ -214,7 +214,7 @@ namespace NXWidgets
* @param value The largest value.
*/
- void setMaximumValue(const nxgl_coord_t value);
+ void setMaximumValue(const int value);
/**
* Set the value that of the slider. This will reposition
@@ -223,7 +223,7 @@ namespace NXWidgets
* @param value The new value.
*/
- void setValue(const nxgl_coord_t value);
+ void setValue(const int value);
/**
* Set the value that of the slider. This will reposition and redraw
diff --git a/NxWidgets/libnxwidgets/include/cscrollbarvertical.hxx b/NxWidgets/libnxwidgets/include/cscrollbarvertical.hxx
index 37649e970..47c0cc260 100644
--- a/NxWidgets/libnxwidgets/include/cscrollbarvertical.hxx
+++ b/NxWidgets/libnxwidgets/include/cscrollbarvertical.hxx
@@ -170,7 +170,7 @@ namespace NXWidgets
* @return The smallest value.
*/
- const nxgl_coord_t getMinimumValue(void) const;
+ const int getMinimumValue(void) const;
/**
* Get the largest value that the slider can represent.
@@ -178,7 +178,7 @@ namespace NXWidgets
* @return The largest value.
*/
- const nxgl_coord_t getMaximumValue(void) const;
+ const int getMaximumValue(void) const;
/**
* Get the current value of the slider.
@@ -186,7 +186,7 @@ namespace NXWidgets
* @return The current slider value.
*/
- const nxgl_coord_t getValue(void) const;
+ const int getValue(void) const;
/**
* Get the value represented by the height of the grip.
@@ -205,7 +205,7 @@ namespace NXWidgets
* @param value The smallest value.
*/
- void setMinimumValue(const nxgl_coord_t value);
+ void setMinimumValue(const int value);
/**
* Set the largest value that the slider can represent.
@@ -213,7 +213,7 @@ namespace NXWidgets
* @param value The largest value.
*/
- void setMaximumValue(const nxgl_coord_t value);
+ void setMaximumValue(const int value);
/**
* Set the value that of the slider. This will reposition
@@ -222,7 +222,7 @@ namespace NXWidgets
* @param value The new value.
*/
- void setValue(const nxgl_coord_t value);
+ void setValue(const int value);
/**
* Set the value that of the slider. This will reposition and redraw
diff --git a/NxWidgets/libnxwidgets/include/csliderhorizontal.hxx b/NxWidgets/libnxwidgets/include/csliderhorizontal.hxx
index ea0c8dc18..dd03203e1 100644
--- a/NxWidgets/libnxwidgets/include/csliderhorizontal.hxx
+++ b/NxWidgets/libnxwidgets/include/csliderhorizontal.hxx
@@ -1,7 +1,7 @@
/****************************************************************************
* NxWidgets/libnxwidgets/include/csliderhorizontal.hxx
*
- * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -110,8 +110,8 @@ namespace NXWidgets
{
protected:
CSliderHorizontalGrip *m_grip; /**< Pointer to the grip. */
- nxgl_coord_t m_minimumValue; /**< Minimum value that the grip can represent. */
- nxgl_coord_t m_maximumValue; /**< Maximum value that the grip can represent. */
+ int m_minimumValue; /**< Minimum value that the grip can represent. */
+ int m_maximumValue; /**< Maximum value that the grip can represent. */
int32_t m_value; /**< Current value of the slider. */
nxgl_coord_t m_minimumGripWidth; /**< Smallest width that the grip can become */
nxgl_coord_t m_pageSize; /**< Value of a page of data, used when clicking
@@ -124,7 +124,7 @@ namespace NXWidgets
* Get the maximum possible value that the slider can represent. Useful when
* using the slider as a scrollbar, as the height of the grip prevents the full
* range of values being accessed (intentionally).
- * The returned value is bitshfted left 16 places for more accuracy in fixed-point
+ * The returned value is shifted left 16 places for more accuracy in fixed-point
* calculations.
*
* @return The maximum possible value that the slider can represent.
@@ -218,7 +218,7 @@ namespace NXWidgets
* @return The smallest value.
*/
- inline const nxgl_coord_t getMinimumValue(void) const
+ inline const int getMinimumValue(void) const
{
return m_minimumValue;
}
@@ -229,7 +229,7 @@ namespace NXWidgets
* @return The largest value.
*/
- inline const nxgl_coord_t getMaximumValue(void) const
+ inline const int getMaximumValue(void) const
{
return m_maximumValue;
}
@@ -240,7 +240,7 @@ namespace NXWidgets
* return The current slider value.
*/
- inline const nxgl_coord_t getValue(void) const
+ inline const int getValue(void) const
{
return m_value >> 16;
}
@@ -265,7 +265,7 @@ namespace NXWidgets
* @param value The smallest value.
*/
- inline void setMinimumValue(const nxgl_coord_t value)
+ inline void setMinimumValue(const int value)
{
m_minimumValue = value;
m_contentSize = m_maximumValue - m_minimumValue + 1;
@@ -278,7 +278,7 @@ namespace NXWidgets
* @param value The largest value.
*/
- inline void setMaximumValue(const nxgl_coord_t value)
+ inline void setMaximumValue(const int value)
{
m_maximumValue = value;
m_contentSize = m_maximumValue - m_minimumValue + 1;
@@ -292,11 +292,11 @@ namespace NXWidgets
* @param value The new value.
*/
- void setValue(const nxgl_coord_t value);
+ void setValue(const int value);
/**
* Set the value that of the slider. This will reposition and redraw
- * the grip. The supplied value should be bitshifted left 16 places.
+ * the grip. The supplied value should be shifted left 16 places.
* This ensures greater accuracy than the standard setValue() method if
* the slider is being used as a scrollbar.
*
diff --git a/NxWidgets/libnxwidgets/include/cslidervertical.hxx b/NxWidgets/libnxwidgets/include/cslidervertical.hxx
index f08010f3c..a63611823 100644
--- a/NxWidgets/libnxwidgets/include/cslidervertical.hxx
+++ b/NxWidgets/libnxwidgets/include/cslidervertical.hxx
@@ -1,7 +1,7 @@
/****************************************************************************
* NxWidgets/libnxwidgets/include/cslidervertical.hxx
*
- * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -110,8 +110,8 @@ namespace NXWidgets
{
protected:
CSliderVerticalGrip* m_grip; /**< Pointer to the grip. */
- nxgl_coord_t m_minimumValue; /**< Minimum value that the grip can represent. */
- nxgl_coord_t m_maximumValue; /**< Maximum value that the grip can represent. */
+ int m_minimumValue; /**< Minimum value that the grip can represent. */
+ int m_maximumValue; /**< Maximum value that the grip can represent. */
int32_t m_value; /**< Current value of the slider. */
nxgl_coord_t m_minimumGripHeight; /**< Smallest height that the grip can become. */
nxgl_coord_t m_pageSize; /**< Value of a page of data, used when clicking
@@ -124,7 +124,7 @@ namespace NXWidgets
* Get the maximum possible value that the slider can represent. Useful when
* using the slider as a scrollbar, as the height of the grip prevents the full
* range of values being accessed (intentionally).
- * The returned value is bitshfted left 16 places for more accuracy in fixed-point
+ * The returned value is shifted left 16 places for more accuracy in fixed-point
* calculations.
*
* @return The maximum possible value that the slider can represent.
@@ -219,7 +219,7 @@ namespace NXWidgets
* @return The smallest value.
*/
- inline const nxgl_coord_t getMinimumValue(void) const
+ inline const int getMinimumValue(void) const
{
return m_minimumValue;
}
@@ -230,7 +230,7 @@ namespace NXWidgets
* @return The largest value.
*/
- inline const nxgl_coord_t getMaximumValue(void) const
+ inline const int getMaximumValue(void) const
{
return m_maximumValue;
}
@@ -240,7 +240,7 @@ namespace NXWidgets
* return The current slider value.
*/
- inline const nxgl_coord_t getValue(void) const
+ inline const int getValue(void) const
{
return m_value >> 16;
}
@@ -265,7 +265,7 @@ namespace NXWidgets
* @param value The smallest value.
*/
- inline void setMinimumValue(const nxgl_coord_t value)
+ inline void setMinimumValue(const int value)
{
m_minimumValue = value;
m_contentSize = m_maximumValue - m_minimumValue + 1;
@@ -278,7 +278,7 @@ namespace NXWidgets
* @param value The largest value.
*/
- inline void setMaximumValue(const nxgl_coord_t value)
+ inline void setMaximumValue(const int value)
{
m_maximumValue = value;
m_contentSize = m_maximumValue - m_minimumValue + 1;
@@ -292,11 +292,11 @@ namespace NXWidgets
* @param value The new value.
*/
- void setValue(const nxgl_coord_t value);
+ void setValue(const int value);
/**
* Set the value that of the slider. This will reposition and redraw
- * the grip. The supplied value should be bitshifted left 16 places.
+ * the grip. The supplied value should be shifted left 16 places.
* This ensures greater accuracy than the standard setValue() method if
* the slider is being used as a scrollbar.
*
diff --git a/NxWidgets/libnxwidgets/include/islider.hxx b/NxWidgets/libnxwidgets/include/islider.hxx
index 1577e9898..1069c5bd1 100644
--- a/NxWidgets/libnxwidgets/include/islider.hxx
+++ b/NxWidgets/libnxwidgets/include/islider.hxx
@@ -1,7 +1,7 @@
/****************************************************************************
* NxWidgets/libnxwidgets/include/islider.hxx
*
- * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -114,7 +114,7 @@ namespace NXWidgets
* @return The smallest value.
*/
- virtual const nxgl_coord_t getMinimumValue(void) const = 0;
+ virtual const int getMinimumValue(void) const = 0;
/**
* Get the largest value that the slider can represent.
@@ -122,7 +122,7 @@ namespace NXWidgets
* @return The largest value.
*/
- virtual const nxgl_coord_t getMaximumValue(void) const = 0;
+ virtual const int getMaximumValue(void) const = 0;
/**
* Get the current value of the slider.
@@ -130,7 +130,7 @@ namespace NXWidgets
* return The current slider value.
*/
- virtual const nxgl_coord_t getValue(void) const = 0;
+ virtual const int getValue(void) const = 0;
/**
* Get the value represented by the height of the grip.
@@ -149,7 +149,7 @@ namespace NXWidgets
* @param value The smallest value.
*/
- virtual void setMinimumValue(const nxgl_coord_t value) = 0;
+ virtual void setMinimumValue(const int value) = 0;
/**
* Set the largest value that the slider can represent.
@@ -157,7 +157,7 @@ namespace NXWidgets
* @param value The largest value.
*/
- virtual void setMaximumValue(const nxgl_coord_t value) = 0;
+ virtual void setMaximumValue(const int value) = 0;
/**
* Set the value that of the slider. This will reposition
@@ -166,7 +166,7 @@ namespace NXWidgets
* @param value The new value.
*/
- virtual void setValue(const nxgl_coord_t value) = 0;
+ virtual void setValue(const int value) = 0;
/**
* Set the value that of the slider. This will reposition and redraw
diff --git a/NxWidgets/libnxwidgets/src/cglyphsliderhorizontal.cxx b/NxWidgets/libnxwidgets/src/cglyphsliderhorizontal.cxx
index 786cbec9f..0430a541f 100644
--- a/NxWidgets/libnxwidgets/src/cglyphsliderhorizontal.cxx
+++ b/NxWidgets/libnxwidgets/src/cglyphsliderhorizontal.cxx
@@ -1,4 +1,3 @@
-
/****************************************************************************
* NxWidgets/libnxwidgets/src/cglyphsliderhorizontal.cxx
*
@@ -142,20 +141,19 @@ CGlyphSliderHorizontal::CGlyphSliderHorizontal(CWidgetControl * pWidgetControl,
}
/**
- * Set the value that of the slider. This will reposition
- * and redraw the grip.
+ * Set the value of the slider. This will reposition and redraw the grip.
*
* @param value The new value.
*/
-void CGlyphSliderHorizontal::setValue(const nxgl_coord_t value)
+void CGlyphSliderHorizontal::setValue(const int value)
{
- setValueWithBitshift((int32_t) value << 16);
+ setValueWithBitshift((int32_t)value << 16);
}
/**
* Set the value that of the slider. This will reposition and redraw
- * the grip. The supplied value should be bitshifted left 16 places.
+ * the grip. The supplied value should be shifted left 16 places.
* This ensures greater accuracy than the standard setValue() method if
* the slider is being used as a scrollbar.
*
@@ -260,7 +258,7 @@ nxgl_coord_t CGlyphSliderHorizontal::getMinimumStep(void) const
* Get the maximum possible value that the slider can represent. Useful when
* using the slider as a scrollbar, as the height of the grip prevents the full
* range of values being accessed (intentionally).
- * The returned value is bitshfted left 16 places for more accuracy in fixed-point
+ * The returned value is shifted left 16 places for more accuracy in fixed-point
* calculations.
*
* @return The maximum possible value that the slider can represent.
@@ -499,5 +497,6 @@ void CGlyphSliderHorizontal::onClick(nxgl_coord_t x, nxgl_coord_t y)
setValueWithBitshift(m_value - (m_pageSize << 16));
}
+
redraw();
}
diff --git a/NxWidgets/libnxwidgets/src/cscaledbitmap.cxx b/NxWidgets/libnxwidgets/src/cscaledbitmap.cxx
index ad0bd1953..eb8217434 100644
--- a/NxWidgets/libnxwidgets/src/cscaledbitmap.cxx
+++ b/NxWidgets/libnxwidgets/src/cscaledbitmap.cxx
@@ -1,7 +1,7 @@
/****************************************************************************
* NxWidgets/libnxwidgets/src/cscaledbitmap.hxx
*
- * Copyright (C) 2013 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
diff --git a/NxWidgets/libnxwidgets/src/cscrollbarhorizontal.cxx b/NxWidgets/libnxwidgets/src/cscrollbarhorizontal.cxx
index 236ab4594..90c28d2d4 100644
--- a/NxWidgets/libnxwidgets/src/cscrollbarhorizontal.cxx
+++ b/NxWidgets/libnxwidgets/src/cscrollbarhorizontal.cxx
@@ -1,7 +1,7 @@
/****************************************************************************
* NxWidgets/libnxwidgets/include/cscrollbarhorizontal.hxx
*
- * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -162,7 +162,7 @@ CScrollbarHorizontal::CScrollbarHorizontal(CWidgetControl *pWidgetControl,
* @return The smallest value.
*/
-const nxgl_coord_t CScrollbarHorizontal::getMinimumValue(void) const
+const int CScrollbarHorizontal::getMinimumValue(void) const
{
return m_slider->getMinimumValue();
}
@@ -173,7 +173,7 @@ const nxgl_coord_t CScrollbarHorizontal::getMinimumValue(void) const
* @return The largest value.
*/
-const nxgl_coord_t CScrollbarHorizontal::getMaximumValue(void) const
+const int CScrollbarHorizontal::getMaximumValue(void) const
{
return m_slider->getMaximumValue();
}
@@ -184,7 +184,7 @@ const nxgl_coord_t CScrollbarHorizontal::getMaximumValue(void) const
* @return The current slider value.
*/
-const nxgl_coord_t CScrollbarHorizontal::getValue(void) const
+const int CScrollbarHorizontal::getValue(void) const
{
return m_slider->getValue();
}
@@ -209,7 +209,7 @@ const nxgl_coord_t CScrollbarHorizontal::getPageSize(void) const
* @param value The smallest value.
*/
-void CScrollbarHorizontal::setMinimumValue(const nxgl_coord_t value)
+void CScrollbarHorizontal::setMinimumValue(const int value)
{
m_slider->setMinimumValue(value);
}
@@ -220,7 +220,7 @@ void CScrollbarHorizontal::setMinimumValue(const nxgl_coord_t value)
* @param value The largest value.
*/
-void CScrollbarHorizontal::setMaximumValue(const nxgl_coord_t value)
+void CScrollbarHorizontal::setMaximumValue(const int value)
{
m_slider->setMaximumValue(value);
}
@@ -232,7 +232,7 @@ void CScrollbarHorizontal::setMaximumValue(const nxgl_coord_t value)
* @param value The new value.
*/
-void CScrollbarHorizontal::setValue(const nxgl_coord_t value)
+void CScrollbarHorizontal::setValue(const int value)
{
m_slider->setValue(value);
}
diff --git a/NxWidgets/libnxwidgets/src/cscrollbarvertical.cxx b/NxWidgets/libnxwidgets/src/cscrollbarvertical.cxx
index e287b14f2..307f6bc2a 100644
--- a/NxWidgets/libnxwidgets/src/cscrollbarvertical.cxx
+++ b/NxWidgets/libnxwidgets/src/cscrollbarvertical.cxx
@@ -1,7 +1,7 @@
/****************************************************************************
* NxWidgets/libnxwidgets/include/cscrollbarhorizontal.hxx
*
- * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -160,7 +160,7 @@ CScrollbarVertical::CScrollbarVertical(CWidgetControl *pWidgetControl,
* @return The smallest value.
*/
-const nxgl_coord_t CScrollbarVertical::getMinimumValue(void) const
+const int CScrollbarVertical::getMinimumValue(void) const
{
return m_slider->getMinimumValue();
}
@@ -171,7 +171,7 @@ const nxgl_coord_t CScrollbarVertical::getMinimumValue(void) const
* @return The largest value.
*/
-const nxgl_coord_t CScrollbarVertical::getMaximumValue(void) const
+const int CScrollbarVertical::getMaximumValue(void) const
{
return m_slider->getMaximumValue();
}
@@ -182,7 +182,7 @@ const nxgl_coord_t CScrollbarVertical::getMaximumValue(void) const
* @return The current slider value.
*/
-const nxgl_coord_t CScrollbarVertical::getValue(void) const
+const int CScrollbarVertical::getValue(void) const
{
return m_slider->getValue();
}
@@ -207,7 +207,7 @@ const nxgl_coord_t CScrollbarVertical::getPageSize(void) const
* @param value The smallest value.
*/
-void CScrollbarVertical::setMinimumValue(const nxgl_coord_t value)
+void CScrollbarVertical::setMinimumValue(const int value)
{
m_slider->setMinimumValue(value);
}
@@ -218,7 +218,7 @@ void CScrollbarVertical::setMinimumValue(const nxgl_coord_t value)
* @param value The largest value.
*/
-void CScrollbarVertical::setMaximumValue(const nxgl_coord_t value)
+void CScrollbarVertical::setMaximumValue(const int value)
{
m_slider->setMaximumValue(value);
}
@@ -230,7 +230,7 @@ void CScrollbarVertical::setMaximumValue(const nxgl_coord_t value)
* @param value The new value.
*/
-void CScrollbarVertical::setValue(const nxgl_coord_t value)
+void CScrollbarVertical::setValue(const int value)
{
m_slider->setValue(value);
}
@@ -381,7 +381,7 @@ void CScrollbarVertical::onResize(nxgl_coord_t width, nxgl_coord_t height)
{
// Remember current values
- nxgl_coord_t value = getValue();
+ int value = getValue();
bool events = raisesEvents();
// Disable event raising
diff --git a/NxWidgets/libnxwidgets/src/csliderhorizontal.cxx b/NxWidgets/libnxwidgets/src/csliderhorizontal.cxx
index 4462d6e74..b1444828b 100644
--- a/NxWidgets/libnxwidgets/src/csliderhorizontal.cxx
+++ b/NxWidgets/libnxwidgets/src/csliderhorizontal.cxx
@@ -1,7 +1,7 @@
/****************************************************************************
* NxWidgets/libnxwidgets/src/csliderhorizontal.cxx
*
- * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -137,7 +137,7 @@ CSliderHorizontal::CSliderHorizontal(CWidgetControl *pWidgetControl,
* @param value The new value.
*/
-void CSliderHorizontal::setValue(const nxgl_coord_t value)
+void CSliderHorizontal::setValue(const int value)
{
setValueWithBitshift((int32_t)value << 16);
}
diff --git a/NxWidgets/libnxwidgets/src/cslidervertical.cxx b/NxWidgets/libnxwidgets/src/cslidervertical.cxx
index 9b9b0f91a..a9f40a68c 100644
--- a/NxWidgets/libnxwidgets/src/cslidervertical.cxx
+++ b/NxWidgets/libnxwidgets/src/cslidervertical.cxx
@@ -1,7 +1,7 @@
/****************************************************************************
* NxWidgets/libnxwidgets/src/cslidervertical.cxx
*
- * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -138,7 +138,7 @@ CSliderVertical::CSliderVertical(CWidgetControl *pWidgetControl,
* @param value The new value.
*/
-void CSliderVertical::setValue(const nxgl_coord_t value)
+void CSliderVertical::setValue(const int value)
{
setValueWithBitshift((int32_t)value << 16);
}
diff --git a/NxWidgets/nxwm/include/cmediaplayer.hxx b/NxWidgets/nxwm/include/cmediaplayer.hxx
index 6d803b537..bf4ff61f4 100644
--- a/NxWidgets/nxwm/include/cmediaplayer.hxx
+++ b/NxWidgets/nxwm/include/cmediaplayer.hxx
@@ -117,6 +117,7 @@ namespace NxWM
enum EMediaPlayerState m_state; /**< Media player current state */
enum EMediaPlayerState m_prevState; /**< Media player previous state */
enum EPendingRelease m_pending; /**< Pending image release event */
+ unsigned int m_level; /**< Current volume level */
/**
* Cached constructor parameters.
@@ -148,6 +149,7 @@ namespace NxWM
NXWidgets::CRlePaletteBitmap *m_pauseBitmap; /**< Bitmap for the pause control */
NXWidgets::CRlePaletteBitmap *m_rewindBitmap; /**< Bitmap for the rewind control */
NXWidgets::CRlePaletteBitmap *m_fforwardBitmap; /**< Bitmap for the fast forward control */
+ NXWidgets::CRlePaletteBitmap *m_volumeBitmap; /**< Volume control grip bitmap */
/**
* Calculator geometry. This stuff does not really have to be retained
@@ -156,7 +158,6 @@ namespace NxWM
struct nxgl_size_s m_windowSize; /**< The size of the media player window */
struct nxgl_size_s m_textSize; /**< The size of the media player textbox */
- struct nxgl_point_s m_textPos; /**< The position of the media player textbox */
/**
* Select the geometry of the media player given the current window size.
@@ -185,6 +186,15 @@ namespace NxWM
void close(void);
/**
+ * Redraw all widgets. Called from redraw() and also on any state
+ * change.
+ *
+ * @param state The new state to enter.
+ */
+
+ void redrawWidgets(void);
+
+ /**
* Transition to a new media player state.
*
* @param state The new state to enter.
@@ -193,8 +203,14 @@ namespace NxWM
void setMediaPlayerState(enum EMediaPlayerState state);
/**
- * Handle a widget action event. This includes a image pre/release
- * release events and volume slider change events.
+ * Set the new volume level based on the position of the volume slider.
+ */
+
+ void setVolumeLevel(void);
+
+ /**
+ * Handle a widget action event. For this application, that means image
+ * pre-release events.
*
* @param e The event data.
*/
@@ -216,6 +232,12 @@ namespace NxWM
void handleReleaseOutsideEvent(const NXWidgets::CWidgetEventArgs &e);
+ /**
+ * Handle changes in the volume level.
+ */
+
+ void handleValueChangeEvent(const NXWidgets::CWidgetEventArgs &e);
+
public:
/**
* CMediaPlayer constructor
diff --git a/NxWidgets/nxwm/include/nxwmconfig.hxx b/NxWidgets/nxwm/include/nxwmconfig.hxx
index c6781bcd5..40689c0f5 100644
--- a/NxWidgets/nxwm/include/nxwmconfig.hxx
+++ b/NxWidgets/nxwm/include/nxwmconfig.hxx
@@ -1,7 +1,7 @@
/****************************************************************************
* NxWidgets/nxwm/include/nxwmconfig.hxx
*
- * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -628,12 +628,20 @@
* Default: CONFIG_NXWM_DEFAULT_FONTID
*/
+#ifndef CONFIG_NXWM_MEDIAPLAYER_MEDIAPATH
+# define CONFIG_NXWM_MEDIAPLAYER_MEDIAPATH "/mnt/sdcard"
+#endif
+
#ifndef CONFIG_NXWM_MEDIAPLAYER_BACKGROUNDCOLOR
# define CONFIG_NXWM_MEDIAPLAYER_BACKGROUNDCOLOR CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR
#endif
#ifndef CONFIG_NXWM_MEDIAPLAYER_XSPACING
-# define CONFIG_NXWM_MEDIAPLAYER_XSPACING 16
+# define CONFIG_NXWM_MEDIAPLAYER_XSPACING 12
+#endif
+
+#ifndef CONFIG_NXWM_MEDIAPLAYER_YSPACING
+# define CONFIG_NXWM_MEDIAPLAYER_YSPACING 8
#endif
#ifndef CONFIG_NXWM_MEDIAPLAYER_ICON
diff --git a/NxWidgets/nxwm/src/cmediaplayer.cxx b/NxWidgets/nxwm/src/cmediaplayer.cxx
index d72707654..cf44e6f7b 100644
--- a/NxWidgets/nxwm/src/cmediaplayer.cxx
+++ b/NxWidgets/nxwm/src/cmediaplayer.cxx
@@ -102,6 +102,7 @@ CMediaPlayer::CMediaPlayer(CTaskbar *taskbar, CApplicationWindow *window)
m_pauseBitmap = (NXWidgets::CRlePaletteBitmap *)0;
m_rewindBitmap = (NXWidgets::CRlePaletteBitmap *)0;
m_fforwardBitmap = (NXWidgets::CRlePaletteBitmap *)0;
+ m_volumeBitmap = (NXWidgets::CRlePaletteBitmap *)0;
// Initial state is stopped
@@ -190,6 +191,11 @@ CMediaPlayer::~CMediaPlayer(void)
delete m_fforwardBitmap;
}
+ if (m_volumeBitmap)
+ {
+ delete m_volumeBitmap;
+ }
+
// Although we didn't create it, we are responsible for deleting the
// application window
@@ -263,9 +269,14 @@ bool CMediaPlayer::run(void)
void CMediaPlayer::stop(void)
{
- // Just disable further drawing
+ // Just disable further drawing on all widgets
m_text->disableDrawing();
+ m_play->disableDrawing();
+ m_pause->disableDrawing();
+ m_rewind->disableDrawing();
+ m_fforward->disableDrawing();
+ m_volume->disableDrawing();
}
/**
@@ -303,20 +314,27 @@ void CMediaPlayer::hide(void)
/**
* Redraw the entire window. The application has been maximized or
* otherwise moved to the top of the hierarchy. This method is call from
- * CTaskbar when the application window must be displayed
+ * CTaskbar when the application window must be displayed.
*/
void CMediaPlayer::redraw(void)
{
- // Redraw widgets (only). Only one of the Play and Pause images should
- // have drawing enabled.
+ // Get the widget control associated with the application window
- m_text->redraw();
- m_play->redraw();
- m_pause->redraw();
- m_rewind->redraw();
- m_fforward->redraw();
- m_volume->redraw();
+ NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
+
+ // Get the CCGraphicsPort instance for this window
+
+ NXWidgets::CGraphicsPort *port = control->getGraphicsPort();
+
+ // Fill the entire window with the background color
+
+ port->drawFilledRect(0, 0, m_windowSize.w, m_windowSize.h,
+ CONFIG_NXWM_MEDIAPLAYER_BACKGROUNDCOLOR);
+
+ // Redraw all widgets
+
+ redrawWidgets();
}
/**
@@ -345,16 +363,6 @@ void CMediaPlayer::setGeometry(void)
// Get the size of the window
(void)window->getSize(&m_windowSize);
-
- // Get the size of the text box. Same width as the m_keypad
-
- m_textSize.w = m_windowSize.w - 10;
- m_textSize.h = 36;
-
- // Now position the text box
-
- m_textPos.x = 5;
- m_textPos.y = 5;
}
/**
@@ -379,13 +387,68 @@ bool CMediaPlayer::createPlayer(void)
NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
- // Create a label to show some text. A simple label is used
- // because the power of a text box is un-necessary in this application.
+ // Work out all of the vertical placement first. In order to do that, we
+ // will need create all of the bitmaps first so that we an use the bitmap
+ // height in the calculation.
+
+ m_playBitmap = new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_MPLAYER_PLAY_ICON);
+ m_pauseBitmap = new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_MPLAYER_PAUSE_ICON);
+ m_rewindBitmap = new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_MPLAYER_REW_ICON);
+ m_fforwardBitmap = new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_MPLAYER_FWD_ICON);
+ m_volumeBitmap = new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_MPLAYER_VOL_ICON);
+
+ if (!m_playBitmap || !m_pauseBitmap || !m_rewindBitmap ||
+ !m_fforwardBitmap || !m_volumeBitmap)
+ {
+ gdbg("ERROR: Failed to one or more bitmaps\n");
+ return false;
+ }
+
+ // Control image height. Use the same height for all images
+
+ nxgl_coord_t controlH = m_playBitmap->getHeight();
+
+ if (controlH < m_pauseBitmap->getHeight())
+ {
+ controlH = m_pauseBitmap->getHeight();
+ }
+
+ if (controlH < m_rewindBitmap->getHeight())
+ {
+ controlH = m_rewindBitmap->getHeight();
+ }
+
+ if (controlH < m_fforwardBitmap->getHeight())
+ {
+ controlH = m_fforwardBitmap->getHeight();
+ }
+
+ controlH += 8;
+
+ // Place the volume slider at a comfortable distance from the bottom of
+ // the display
+
+ nxgl_coord_t volumeTop = m_windowSize.h - m_volumeBitmap->getHeight() -
+ CONFIG_NXWM_MEDIAPLAYER_YSPACING;
+
+ // Place the player controls just above that. The list box will then end
+ // just above the controls.
+
+ nxgl_coord_t controlTop = volumeTop - controlH -
+ CONFIG_NXWM_MEDIAPLAYER_YSPACING;
+
+ // The list box will then end just above the controls. The end of the
+ // list box is the same as its height because the origin is zero.
+
+ nxgl_coord_t textHeight = controlTop - CONFIG_NXWM_MEDIAPLAYER_YSPACING;
+
+ // Create a label to show some text.
+ // Note that the list box will extend all of the way to the edges of the
+ // display and is only limited at the bottom by the player controls.
+
+ m_text = new NXWidgets::
+ CLabel(control, 0, 0, m_windowSize.w, textHeight, "0");
- m_text = new NXWidgets::CLabel(control,
- m_textPos.x, m_textPos.y,
- m_textSize.w, m_textSize.h,
- "0");
if (!m_text)
{
gdbg("ERROR: Failed to create CLabel\n");
@@ -409,13 +472,7 @@ bool CMediaPlayer::createPlayer(void)
m_text->setText("Coming soon...");
- // Create all bitmaps
-
- m_playBitmap = new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_MPLAYER_PLAY_ICON);
- m_pauseBitmap = new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_MPLAYER_PAUSE_ICON);
- m_rewindBitmap = new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_MPLAYER_REW_ICON);
- m_fforwardBitmap = new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_MPLAYER_FWD_ICON);
-
+ // Control image widths.
// Image widths will depend on if the images will be bordered or not
nxgl_coord_t playControlW;
@@ -423,7 +480,8 @@ bool CMediaPlayer::createPlayer(void)
nxgl_coord_t fforwardControlW;
#ifdef CONFIG_NXWM_MEDIAPLAYER_BORDERS
- // Set the width to the widest image
+ // Use the same width for all control images. Set the width to the width
+ // of the widest image
nxgl_coord_t imageW = m_playBitmap->getWidth();
@@ -450,7 +508,6 @@ bool CMediaPlayer::createPlayer(void)
fforwardControlW = imageW;
#else
-
// Use the bitmap image widths for the image widths (plus a bit)
playControlW = m_playBitmap->getWidth() + 8;
@@ -467,35 +524,19 @@ bool CMediaPlayer::createPlayer(void)
}
#endif
- // Use the same height for all images
-
- nxgl_coord_t controlH = m_playBitmap->getHeight();
-
- if (controlH < m_pauseBitmap->getHeight())
- {
- controlH = m_pauseBitmap->getHeight();
- }
-
- if (controlH < m_rewindBitmap->getHeight())
- {
- controlH = m_rewindBitmap->getHeight();
- }
-
- if (controlH < m_fforwardBitmap->getHeight())
- {
- controlH = m_fforwardBitmap->getHeight();
- }
-
- controlH += 8;
-
// Create the Play image
nxgl_coord_t playControlX = (m_windowSize.w >> 1) - (playControlW >> 1);
- uint32_t controlY = (180 * m_windowSize.h) >> 8;
m_play = new NXWidgets::
- CImage(control, playControlX, (nxgl_coord_t)controlY,
- playControlW, controlH, m_playBitmap);
+ CImage(control, playControlX, controlTop, playControlW, controlH,
+ m_playBitmap);
+
+ if (!m_play)
+ {
+ gdbg("ERROR: Failed to create play control\n");
+ return false;
+ }
// Configure the Play image
@@ -515,8 +556,14 @@ bool CMediaPlayer::createPlayer(void)
// Create the Pause image (at the same position ans size as the Play image)
m_pause = new NXWidgets::
- CImage(control, playControlX, (nxgl_coord_t)controlY,
- playControlW, controlH, m_pauseBitmap);
+ CImage(control, playControlX, controlTop, playControlW, controlH,
+ m_pauseBitmap);
+
+ if (!m_pause)
+ {
+ gdbg("ERROR: Failed to create pause control\n");
+ return false;
+ }
// Configure the Pause image (hidden and disabled initially)
@@ -539,8 +586,14 @@ bool CMediaPlayer::createPlayer(void)
CONFIG_NXWM_MEDIAPLAYER_XSPACING;
m_rewind = new NXWidgets::
- CStickyImage(control, rewControlX, (nxgl_coord_t)controlY,
- rewindControlW, controlH, m_rewindBitmap);
+ CStickyImage(control, rewControlX, controlTop, rewindControlW,
+ controlH, m_rewindBitmap);
+
+ if (!m_rewind)
+ {
+ gdbg("ERROR: Failed to create rewind control\n");
+ return false;
+ }
// Configure the Rewind image
@@ -563,8 +616,14 @@ bool CMediaPlayer::createPlayer(void)
CONFIG_NXWM_MEDIAPLAYER_XSPACING;
m_fforward = new NXWidgets::
- CStickyImage(control, fwdControlX, (nxgl_coord_t)controlY,
- fforwardControlW, controlH, m_fforwardBitmap);
+ CStickyImage(control, fwdControlX, controlTop, fforwardControlW,
+ controlH, m_fforwardBitmap);
+
+ if (!m_fforward)
+ {
+ gdbg("ERROR: Failed to create fast forward control\n");
+ return false;
+ }
// Configure the Forward image
@@ -583,20 +642,22 @@ bool CMediaPlayer::createPlayer(void)
// Create the Volume control
- NXWidgets::CRlePaletteBitmap *volBitmap = new NXWidgets::
- CRlePaletteBitmap(&CONFIG_NXWM_MPLAYER_VOL_ICON);
-
uint32_t volumeControlX = (9 * m_windowSize.w) >> 8;
- uint32_t volumeControlY = (232 * m_windowSize.h) >> 8;
m_volume = new NXWidgets::
CGlyphSliderHorizontal(control,
(nxgl_coord_t)volumeControlX,
- (nxgl_coord_t)volumeControlY,
+ volumeTop,
(nxgl_coord_t)(m_windowSize.w - 2 * volumeControlX),
- volBitmap->getHeight() + 4, volBitmap,
+ m_volumeBitmap->getHeight() + 4, m_volumeBitmap,
MKRGB(63, 90,192));
+ if (!m_volume)
+ {
+ gdbg("ERROR: Failed to create volume control\n");
+ return false;
+ }
+
// Configure the volume control
m_volume->disableDrawing();
@@ -604,25 +665,19 @@ bool CMediaPlayer::createPlayer(void)
m_volume->setMaximumValue(100);
m_volume->setValue(15);
- // Register to get events from the mouse clicks on the Forward image
+ // Register to get events from the value changes in the volume slider
m_volume->addWidgetEventHandler(this);
- // Redraw the background once only
- // Get the CCGraphicsPort instance for this window
-
- NXWidgets::CGraphicsPort *port = control->getGraphicsPort();
-
- // Fill the entire window with the background color
-
- port->drawFilledRect(0, 0, m_windowSize.w, m_windowSize.h,
- CONFIG_NXWM_MEDIAPLAYER_BACKGROUNDCOLOR);
-
// Make sure that all widgets are setup for the STOPPED state. Among other this,
// this will enable drawing in the play widget (only)
setMediaPlayerState(MPLAYER_STOPPED);
+ // Set the volume level
+
+ setVolumeLevel();
+
// Enable drawing in the text, rewind, fast-forward and drawing widgets.
m_text->enableDrawing();
@@ -633,7 +688,6 @@ bool CMediaPlayer::createPlayer(void)
// And redraw all of the widgets that are enabled
redraw();
-
return true;
}
@@ -656,6 +710,54 @@ void CMediaPlayer::close(void)
}
/**
+ * Redraw all widgets. Called from redraw() and also on any state
+ * change.
+ *
+ * @param state The new state to enter.
+ */
+
+void CMediaPlayer::redrawWidgets(void)
+{
+ // Redraw widgets. We have to re-enable drawing all all widgets since
+ // drawing was disabled by the hide() method.
+
+ m_text->enableDrawing();
+ m_text->redraw();
+
+ // Only one of the Play and Pause images should have drawing enabled.
+
+ if (m_state != MPLAYER_STOPPED && m_prevState == MPLAYER_PLAYING)
+ {
+ // Playing... show the pause button
+ // REVISIT: Really only available if there is a selected file in the list box
+
+ m_pause->enableDrawing();
+ m_pause->redraw();
+ }
+ else
+ {
+ // Paused or Stopped... show the play button
+
+ m_play->enableDrawing();
+ m_play->redraw();
+ }
+
+ // Rewind and play buttons are only shown if we are not STOPPED
+
+ if (m_state != MPLAYER_STOPPED)
+ {
+ m_rewind->enableDrawing();
+ m_rewind->redraw();
+
+ m_fforward->enableDrawing();
+ m_fforward->redraw();
+ }
+
+ m_volume->enableDrawing();
+ m_volume->redraw();
+}
+
+/**
* Transition to a new media player state.
*
* @param state The new state to enter.
@@ -663,6 +765,10 @@ void CMediaPlayer::close(void)
void CMediaPlayer::setMediaPlayerState(enum EMediaPlayerState state)
{
+ // Stop drawing on all widgets
+
+ stop();
+
// Handle according to the new state
switch (state)
@@ -676,14 +782,13 @@ void CMediaPlayer::setMediaPlayerState(enum EMediaPlayerState state)
m_text->enable();
// Play image enabled and ready to start playing
+ // REVISIT: Really only available if there is a selected file in the list box
m_play->enable();
m_play->show();
- m_play->enableDrawing();
// Pause image is disabled and hidden
- m_pause->disableDrawing();
m_pause->disable();
m_pause->hide();
@@ -710,7 +815,6 @@ void CMediaPlayer::setMediaPlayerState(enum EMediaPlayerState state)
// Play image hidden and disabled
- m_play->disableDrawing();
m_play->disable();
m_play->hide();
@@ -718,7 +822,6 @@ void CMediaPlayer::setMediaPlayerState(enum EMediaPlayerState state)
m_pause->enable();
m_pause->show();
- m_pause->enableDrawing();
// Fast forward image is enabled and ready for use
@@ -729,8 +832,6 @@ void CMediaPlayer::setMediaPlayerState(enum EMediaPlayerState state)
m_rewind->enable();
m_rewind->setStuckSelection(false);
-
- m_volume->enable();
break;
case MPLAYER_PAUSED: // Playing a media file but paused
@@ -745,25 +846,19 @@ void CMediaPlayer::setMediaPlayerState(enum EMediaPlayerState state)
m_play->enable();
m_play->show();
- m_play->enableDrawing();
// Pause image is disabled and hidden
- m_pause->disableDrawing();
m_pause->disable();
m_pause->hide();
// Fast forward image is enabled and ready for use
- m_fforward->enable();
m_fforward->setStuckSelection(false);
// Rewind image is enabled and ready for use
- m_rewind->enable();
m_rewind->setStuckSelection(false);
-
- m_volume->enable();
break;
case MPLAYER_FFORWARD: // Fast forwarding through a media file */
@@ -777,7 +872,6 @@ void CMediaPlayer::setMediaPlayerState(enum EMediaPlayerState state)
{
// Play image hidden and disabled
- m_play->disableDrawing();
m_play->disable();
m_play->hide();
@@ -785,7 +879,6 @@ void CMediaPlayer::setMediaPlayerState(enum EMediaPlayerState state)
m_pause->enable();
m_pause->show();
- m_pause->enableDrawing();
}
else
{
@@ -793,26 +886,20 @@ void CMediaPlayer::setMediaPlayerState(enum EMediaPlayerState state)
m_play->enable();
m_play->show();
- m_play->enableDrawing();
// Pause image is hidden and disabled
- m_pause->disableDrawing();
m_pause->disable();
m_pause->hide();
}
// Fast forward image is enabled, highlighted and ready for use
- m_fforward->enable();
m_fforward->setStuckSelection(true);
// Rewind is enabled and ready for use
- m_rewind->enable();
m_rewind->setStuckSelection(false);
-
- m_volume->enable();
break;
case MPLAYER_FREWIND: // Rewinding a media file
@@ -826,7 +913,6 @@ void CMediaPlayer::setMediaPlayerState(enum EMediaPlayerState state)
{
// Play image hidden and disabled
- m_play->disableDrawing();
m_play->disable();
m_play->hide();
@@ -834,7 +920,6 @@ void CMediaPlayer::setMediaPlayerState(enum EMediaPlayerState state)
m_pause->enable();
m_pause->show();
- m_pause->enableDrawing();
}
else
{
@@ -842,36 +927,48 @@ void CMediaPlayer::setMediaPlayerState(enum EMediaPlayerState state)
m_play->enable();
m_play->show();
- m_play->enableDrawing();
// Pause image is hidden and disabled
- m_pause->disableDrawing();
m_pause->disable();
m_pause->hide();
}
// Fast forward image is enabled and ready for use
- m_fforward->enable();
m_fforward->setStuckSelection(false);
// Rewind image is enabled, highlighted, and ready for use
- m_rewind->enable();
m_rewind->setStuckSelection(true);
-
- m_volume->enable();
break;
default:
break;
}
+
+ // Re-enable drawing and redraw all widgets for the new state
+
+ redrawWidgets();
+}
+
+/**
+ * Set the new volume level based on the position of the volume slider.
+ */
+
+void CMediaPlayer::setVolumeLevel(void)
+{
+ // Current volume level values. This is already pre-scaled in the range 0-100
+
+ m_level = m_volume->getValue();
+
+ // Now, provide the new volume setting to the NX Player
+#warning Missing logic
}
/**
- * Handle a widget action event. This includes a image pre/release
- * release events and volume slider change events.
+ * Handle a widget action event. For this application, that means image
+ * pre-release events.
*
* @param e The event data.
*/
@@ -952,11 +1049,6 @@ void CMediaPlayer::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
}
}
}
-
- if (m_volume->isClicked())
- {
-printf("Volume clicked\n"); // REMOVE ME
- }
}
/**
@@ -999,6 +1091,15 @@ void CMediaPlayer::handleReleaseOutsideEvent(const NXWidgets::CWidgetEventArgs &
}
/**
+ * Handle changes in the volume level.
+ */
+
+void CMediaPlayer::handleValueChangeEvent(const NXWidgets::CWidgetEventArgs &e)
+{
+ setVolumeLevel();
+}
+
+/**
* CMediaPlayerFactory Constructor
*
* @param taskbar. The taskbar instance used to terminate the console
diff --git a/apps/NxWidgets/Kconfig b/apps/NxWidgets/Kconfig
index 2bd8ea02d..a1a6803e4 100644
--- a/apps/NxWidgets/Kconfig
+++ b/apps/NxWidgets/Kconfig
@@ -311,7 +311,7 @@ config NXWM
if NXWM
-menu "NxWM General settings"
+menu "NxWM General Settings"
config NXWM_LARGE_ICONS
bool "Use large icons"
@@ -675,7 +675,9 @@ config NXWM_STARTWINDOW_STACKSIZE
endmenu # Start Window Configuration
-menuconfig NXWM_NXCONSOLE
+menu "NxConsole Window Settings"
+
+config NXWM_NXCONSOLE
bool "NxConsole Window"
default y
---help---
@@ -759,6 +761,7 @@ config NXWM_NXCONSOLE_ICON
endif # NXWM_NXCONSOLE_ICON
endif # NXWM_NXCONSOLE
+endmenu # NxConsole Window Settings
menu "NxWM Touchscreen Configuration"
@@ -771,7 +774,7 @@ config NXWM_TOUCHSCREEN
if NXWM_TOUCHSCREEN
-comment "Touchscreen device settings"
+comment "Touchscreen Device Settings"
config NXWM_TOUCHSCREEN_DEVINIT
bool "Touchscreen Device Initialization"
@@ -844,7 +847,7 @@ config NXWM_KEYBOARD
if NXWM_KEYBOARD
-comment "Keyboard device settings"
+comment "Keyboard Device Settings"
config NXWM_KEYBOARD_DEVPATH
string "Keyboard Device Path"
@@ -880,7 +883,7 @@ config NXWM_KEYBOARD_LISTENERSTACK
endif # NXWM_KEYBOARD
endmenu # NxWM Keyboard Configuration
-menu "NxWM Calibration display settings"
+menu "NxWM Calibration Display Settings"
config NXWM_CALIBRATION_MARGIN
int "Calibration Margin"
@@ -1045,9 +1048,9 @@ config NXWM_CALIBRATION_LISTENERSTACK
---help---
Calibration listener thread stack size. Default 2048
-endmenu # NxWM Calibration display settings
+endmenu # NxWM Calibration Display Settings
-menu "NxWM Hex Calculator display settings"
+menu "NxWM Hex Calculator Display Settings"
config NXWM_HEXCALCULATOR_CUSTOM_COLORS
bool "Custom Hex Calculator Colors"
@@ -1103,7 +1106,9 @@ config NXWM_HEXCALCULATOR_FONTID
NxWM font ID (NXWM_DEFAULT_FONTID). Default: 0
endif # NXWM_HEXCALCULATOR_FONTID
-endmenu # NxWM Hex Calculator display settings
+endmenu # NxWM Hex Calculator Display Dettings
+
+menu "NxWM Media Player Display Settings"
config NXWM_MEDIAPLAYER
bool "NxWM Media Player"
@@ -1119,13 +1124,28 @@ config NXWM_MEDIAPLAYER
if NXWM_MEDIAPLAYER
+config NXWM_MEDIAPLAYER_MEDIAPATH
+ string "Path to media"
+ default "/mnt/sdcard"
+ ---help---
+ This is the full path to the mount point of the storage device
+ containing all of the media files accessible by the media player.
+
config NXWM_MEDIAPLAYER_XSPACING
- int "Media Player Button Spacing"
+ int "Media Player Horizontal Spacing"
default 12
---help---
- This is the space between play, forward, and reverse buttons in
+ This is the space between play, forward, and reverse controls in
units of pixels.
+config NXWM_MEDIAPLAYER_YSPACING
+ int "Media Player Vertical Spacing"
+ default 8
+ ---help---
+ This is the space between vertical element: (1) list box, (2) play,
+ forward, and reverse controls, and the volume slider in units of
+ lines.
+
config NXWM_MEDIAPLAYER_BORDERS
bool "Media Player Button Borders"
default n
@@ -1135,4 +1155,6 @@ config NXWM_MEDIAPLAYER_BORDERS
then have buttons with boarders might make more sense.
endif # NXWM_MEDIAPLAYER
+endmenu # NxWM Media Player Display Settings
+
endif # NXWM
diff --git a/nuttx/configs/sama5d4-ek/nxwm/defconfig b/nuttx/configs/sama5d4-ek/nxwm/defconfig
index 4e23452cc..93d48ae43 100644
--- a/nuttx/configs/sama5d4-ek/nxwm/defconfig
+++ b/nuttx/configs/sama5d4-ek/nxwm/defconfig
@@ -1397,7 +1397,7 @@ CONFIG_NXWM_HEXCALCULATOR_CUSTOM_FONTID=y
CONFIG_NXWM_HEXCALCULATOR_FONTID=6
CONFIG_NXWM_MEDIAPLAYER=y
CONFIG_NXWM_MEDIAPLAYER_XSPACING=4
-CONFIG_NXWM_MEDIAPLAYER_BORDERS=y
+# CONFIG_NXWM_MEDIAPLAYER_BORDERS is not set
#
# Platform-specific Support