NxWidgets::CGlyphSliderHorizontal: No longer uses a hard-coded slider height; the slider height is now provided as a parameter, replacing the widget height which is now calculated from the glip image height
This commit is contained in:
parent
1f87d19f7d
commit
ea791a350e
23
Kconfig
23
Kconfig
@ -1153,6 +1153,29 @@ config NXWM_MEDIAPLAYER_VOLUMESTEP
|
||||
---help---
|
||||
This increment in volume, up or down, when the volume bar is clicked.
|
||||
|
||||
config NXWM_MEDIAPLAYER_MINVOLUMEHEIGHT
|
||||
int "Minimum Player Volume Minimum Height"
|
||||
default 6
|
||||
---help---
|
||||
The height of the slider is automatically calculated from the height
|
||||
of the grip image. However, we will not let the height of the grip
|
||||
get smaller than this value.
|
||||
|
||||
NOTE: This width includes the size of the slider upper and lower
|
||||
borders.
|
||||
|
||||
config NXWM_MEDIAPLAYER_CUSTOM_COLORS
|
||||
bool "Select Custom Media Player Colors"
|
||||
default n
|
||||
|
||||
if NXWM_MEDIAPLAYER_CUSTOM_COLORS
|
||||
|
||||
config NXWM_MEDIAPLAYER_VOLUMECOLOR
|
||||
hex "Media Volume Slide Color
|
||||
default 0x0
|
||||
|
||||
endif # NXWM_MEDIAPLAYER_CUSTOM_COLORS
|
||||
|
||||
config NXWM_MEDIAPLAYER_BORDERS
|
||||
bool "Media Player Button Borders"
|
||||
default n
|
||||
|
@ -174,16 +174,19 @@ namespace NXWidgets
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The widget control instance for the window.
|
||||
* @param control The widget control instance for the window.
|
||||
* @param x The x coordinate of the slider, relative to its parent.
|
||||
* @param y The y coordinate of the slider, relative to its parent.
|
||||
* @param width The width of the slider.
|
||||
* @param height The height of the slider.
|
||||
* @param thickness The thickness of the slider.
|
||||
* @param gripBitmap The slider grip image
|
||||
* @param fillColor The color to use when filling the grip
|
||||
* @param fill True: The grip will be filled with fillColor
|
||||
*/
|
||||
|
||||
CGlyphSliderHorizontal(CWidgetControl *pWidgetControl,
|
||||
CGlyphSliderHorizontal(CWidgetControl *control,
|
||||
nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
|
||||
nxgl_coord_t height, IBitmap *pGripBitmap,
|
||||
nxgl_coord_t thickness, IBitmap *gripBitmap,
|
||||
nxwidget_pixel_t fillColor, bool fill = true);
|
||||
|
||||
/**
|
||||
|
@ -170,7 +170,7 @@ namespace NXWidgets
|
||||
|
||||
protected:
|
||||
CWidgetControl *m_widgetControl; /**< The controlling widget for the display */
|
||||
CRect m_rect; /**< Rectange bounding the widget. */
|
||||
CRect m_rect; /**< Rectangle bounding the widget. */
|
||||
|
||||
// Dragging variables
|
||||
|
||||
|
@ -79,6 +79,7 @@
|
||||
#include <cstdint>
|
||||
#include <cstdbool>
|
||||
|
||||
#include "ibitmap.hxx"
|
||||
#include "cwidgetcontrol.hxx"
|
||||
#include "cglyphsliderhorizontal.hxx"
|
||||
#include "cglyphsliderhorizontalgrip.hxx"
|
||||
@ -98,20 +99,24 @@ using namespace NXWidgets;
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The controlling widget for the display
|
||||
* @param control The widget control instance for the window.
|
||||
* @param x The x coordinate of the slider, relative to its parent.
|
||||
* @param y The y coordinate of the slider, relative to its parent.
|
||||
* @param width The width of the slider.
|
||||
* @param height The height of the slider.
|
||||
* @param thickness The thickness of the slider.
|
||||
* @param gripBitmap The slider grip image
|
||||
* @param fillColor The color to use when filling the grip
|
||||
* @param fill True: The grip will be filled with fillColor
|
||||
*/
|
||||
|
||||
CGlyphSliderHorizontal::CGlyphSliderHorizontal(CWidgetControl * pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
IBitmap * pGripBitmap,
|
||||
nxwidget_pixel_t fillColor, bool fill)
|
||||
:CNxWidget(pWidgetControl, x, y, width, height, WIDGET_DRAGGABLE)
|
||||
CGlyphSliderHorizontal::CGlyphSliderHorizontal(CWidgetControl *control,
|
||||
nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
|
||||
nxgl_coord_t thickness, IBitmap *gripBitmap,
|
||||
nxwidget_pixel_t fillColor, bool fill)
|
||||
:CNxWidget(control, x, y, width, thickness, WIDGET_DRAGGABLE)
|
||||
{
|
||||
// Initialize state data
|
||||
|
||||
m_minimumValue = 0;
|
||||
m_maximumValue = 0;
|
||||
m_contentSize = 0;
|
||||
@ -120,22 +125,39 @@ CGlyphSliderHorizontal::CGlyphSliderHorizontal(CWidgetControl * pWidgetControl,
|
||||
m_pageSize = 1;
|
||||
m_fillColor = fillColor;
|
||||
m_fill = fill;
|
||||
m_barThickness = 8;
|
||||
m_barThickness = thickness;
|
||||
|
||||
// Correct the height of the widget. The widget height was initially set
|
||||
// to the thickness of the grip. But the grip image is normally a little
|
||||
// taller than the slider is thick.
|
||||
//
|
||||
// Do use the resize method here; we are not ready for the resize events.
|
||||
|
||||
nxgl_coord_t gripHeight = gripBitmap->getHeight() + 4;
|
||||
if (gripHeight > thickness)
|
||||
{
|
||||
// Reset the widget height to the height of the grip image
|
||||
|
||||
m_rect.setHeight(gripHeight);
|
||||
}
|
||||
|
||||
// Set widget attributes
|
||||
|
||||
m_flags.permeable = false;
|
||||
m_flags.borderless = false;
|
||||
m_flags.doubleClickable = false;
|
||||
|
||||
// Create grip
|
||||
// Set the "gutter" width
|
||||
|
||||
CRect rect;
|
||||
getClientRect(rect);
|
||||
m_gutterWidth = rect.getWidth();
|
||||
|
||||
// Create grip
|
||||
// Create the grip
|
||||
|
||||
m_grip = new CGlyphSliderHorizontalGrip(pWidgetControl, x, y,
|
||||
width, height, pGripBitmap);
|
||||
m_grip = new CGlyphSliderHorizontalGrip(control, x, y,
|
||||
gripBitmap->getWidth() + 4,
|
||||
gripHeight, gripBitmap);
|
||||
m_grip->setBorderless(true);
|
||||
m_grip->addWidgetEventHandler(this);
|
||||
addWidget(m_grip);
|
||||
|
@ -158,10 +158,10 @@ CNxWidget::CNxWidget(CWidgetControl *pWidgetControl,
|
||||
|
||||
// Dragging values
|
||||
|
||||
m_grabPointX = 0;
|
||||
m_grabPointY = 0;
|
||||
m_newX = 0;
|
||||
m_newY = 0;
|
||||
m_grabPointX = 0;
|
||||
m_grabPointY = 0;
|
||||
m_newX = 0;
|
||||
m_newY = 0;
|
||||
|
||||
// Set initial flag values
|
||||
|
||||
@ -177,24 +177,24 @@ CNxWidget::CNxWidget(CWidgetControl *pWidgetControl,
|
||||
|
||||
// Set hierarchy pointers
|
||||
|
||||
m_parent = (CNxWidget *)NULL;
|
||||
m_focusedChild = (CNxWidget *)NULL;
|
||||
m_parent = (CNxWidget *)NULL;
|
||||
m_focusedChild = (CNxWidget *)NULL;
|
||||
|
||||
// Double-click
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &m_lastClickTime);
|
||||
m_lastClickX = 0;
|
||||
m_lastClickY = 0;
|
||||
m_doubleClickBounds = DOUBLE_CLICK_BOUNDS;
|
||||
m_lastClickX = 0;
|
||||
m_lastClickY = 0;
|
||||
m_doubleClickBounds = DOUBLE_CLICK_BOUNDS;
|
||||
|
||||
// Set border size to 1 line
|
||||
|
||||
m_borderSize.top = 1;
|
||||
m_borderSize.right = 1;
|
||||
m_borderSize.bottom = 1;
|
||||
m_borderSize.left = 1;
|
||||
m_borderSize.top = 1;
|
||||
m_borderSize.right = 1;
|
||||
m_borderSize.bottom = 1;
|
||||
m_borderSize.left = 1;
|
||||
|
||||
m_widgetEventHandlers = new CWidgetEventHandlerList(this);
|
||||
m_widgetEventHandlers = new CWidgetEventHandlerList(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -648,6 +648,14 @@
|
||||
# define CONFIG_NXWM_MEDIAPLAYER_VOLUMESTEP 5
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NXWM_MEDIAPLAYER_MINVOLUMEHEIGHT
|
||||
# define CONFIG_NXWM_MEDIAPLAYER_MINVOLUMEHEIGHT 6
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NXWM_MEDIAPLAYER_VOLUMECOLOR
|
||||
# define CONFIG_NXWM_MEDIAPLAYER_VOLUMECOLOR MKRGB(63,90,192)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NXWM_MEDIAPLAYER_ICON
|
||||
# define CONFIG_NXWM_MEDIAPLAYER_ICON NxWM::g_mediaplayerBitmap
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user