Tuesday, May 22nd 2018, 2:13am UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Date of registration: Jan 22nd 2018

Posts: 3

1

Monday, January 22nd 2018, 11:14am

Updating to version 5.42.9 made my listboxes background transparent

Hi everyone,
I use the Keil Middleware with emWin. The last days I updated to version 5.42.9 and now all my LISTBOX widgets have a transparent background. I use a custom skin. What can cause this behaviour? Here is my relevant code.

C/C++ Source code

1
viewWin =  WM_CreateWindow(0, 0, XSIZE_PHYS, YSIZE_PHYS, WM_CF_SHOW, displaySettingsViewWinCallback, 0);


C/C++ Source code

1
2
skinSelector = DROPDOWN_CreateEx(SKIN_SELECTOR_POS_X_px, SKIN_SELECTOR_POS_Y_px, SKIN_SELECTOR_WIDTH, SKIN_SELECTOR_HEIGHT, viewWin, WM_CF_SHOW, DROPDOWN_CF_AUTOSCROLLBAR, SKIN_DROPDOWN_ID);
skinDropdownMenue(skinSelector);


C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const SCROLLBAR_SKINFLEX_PROPS scrollbarSkinLight =
{
	{BG_COLOR_LIGHT, TEXT_COLOR_LIGHT, BG_COLOR_LIGHT}, 
	{BG_COLOR_LIGHT, BG_COLOR_LIGHT},
	{BG_COLOR_LIGHT, BG_COLOR_LIGHT},
	{BG_COLOR_LIGHT, BG_COLOR_LIGHT},
	TEXT_COLOR_LIGHT,
	BG_COLOR_LIGHT, 
};

void enableScrollbarDefaultSkins(void)
{
	SCROLLBAR_SetDefaultSkin(SCROLLBAR_SKIN_FLEX);
	DROPDOWN_SetDefaultSkin(DROPDOWN_SKIN_FLEX); 
	
	SCROLLBAR_SetSkinFlexProps(&scrollbarSkinLight, SLIDER_SKINFLEX_PI_PRESSED);
	SCROLLBAR_SetSkinFlexProps(&scrollbarSkinLight, SLIDER_SKINFLEX_PI_UNPRESSED);  
}


C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const DROPDOWN_SKINFLEX_PROPS dropDownSkinLight = 
{
	{TEXT_COLOR_LIGHT, GUI_RED, GUI_RED},
	{GUI_RED, GUI_RED}, 
	{GUI_RED, GUI_RED}, 	
	TEXT_COLOR_LIGHT, 				
	TEXT_COLOR_LIGHT, 				 
	TEXT_COLOR_LIGHT,
	1 
};

const DROPDOWN_SKINFLEX_PROPS dropDownSkinDark = 
{
	{GUI_GREEN, GUI_GREEN, GUI_GREEN}, 
	{GUI_GREEN, GUI_GREEN},
	{GUI_GREEN, GUI_GREEN}, 
	TEXT_COLOR_DARK,   
	TEXT_COLOR_DARK, 
	TEXT_COLOR_DARK, 	
	1
};


void skinDropdownMenue(DROPDOWN_Handle dropdown)
{
	//Do not skin invalid dropdowns
	if(dropdown == 0)
    	return;
	
	DROPDOWN_SetFont(dropdown, &GUI_FontMerge16BGo);
	DROPDOWN_SetScrollbarWidth(dropdown, 32);
	DROPDOWN_SetItemSpacing(dropdown, 15);
	DROPDOWN_SetTextAlign(dropdown, GUI_TA_VCENTER);
	DROPDOWN_SetTextHeight(dropdown, 23);
	DROPDOWN_SetAutoScroll(dropdown, true);
	
	if(viewSettings.scheme == GAUGE_VIEW_DARK_SCHEME)
	{   
    	DROPDOWN_SetSkinFlexProps(&dropDownSkinDark, DROPDOWN_SKINFLEX_PI_ENABLED);
    	DROPDOWN_SetSkinFlexProps(&dropDownSkinDark, DROPDOWN_SKINFLEX_PI_EXPANDED);
    	DROPDOWN_SetSkinFlexProps(&dropDownSkinDark, DROPDOWN_SKINFLEX_PI_FOCUSED);
	}
	else
	{   	
    	DROPDOWN_SetSkinFlexProps(&dropDownSkinLight, DROPDOWN_SKINFLEX_PI_ENABLED);
    	DROPDOWN_SetSkinFlexProps(&dropDownSkinLight, DROPDOWN_SKINFLEX_PI_EXPANDED);
    	DROPDOWN_SetSkinFlexProps(&dropDownSkinLight, DROPDOWN_SKINFLEX_PI_FOCUSED);
	}
}


Here are some screenshots of the device

https://picload.org/view/ddidcdra/edit.jpg.html
https://picload.org/view/ddidcdrl/editbright.jpg.html

This post has been edited 2 times, last edit by "Jonathan Schubert" (Jan 22nd 2018, 11:25am)


SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 584

2

Monday, January 22nd 2018, 4:46pm

Hi,

Yes, this is a bug in this version and is already fixed in newer versions.

As a workaround you can set the has-trans flag by calling WM_SetHasTrans(hWidget) where hWidget is the handle of the LISTBOX. The next release of the KEIL MDK package will contain the bugfix for this.

Regards
Sven

Date of registration: Jan 22nd 2018

Posts: 3

3

Tuesday, January 23rd 2018, 9:37am

Hi Sven,
thank you for the fast reply. I already downgrade my emWin version to 5.36.6 where everything works as expected. I also tried your bugfix but it didn't work for me. I tried:

C/C++ Source code

1
2
3
4
5
void skinDropdownMenue(DROPDOWN_Handle dropdown)
{
   ... Code as previously
  	WM_SetHasTrans(dropdown);
}

and

C/C++ Source code

1
2
3
4
5
6
void skinDropdownMenue(DROPDOWN_Handle dropdown)
{
   ... Code as previously
	LISTBOX_Handle list = DROPDOWN_GetListbox(dropdown);
	WM_SetHasTrans(list);
}


For the future is there a published list of known bugs for emWin?

Many Thanks,
Jonathan

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 584

4

Tuesday, January 23rd 2018, 3:39pm

Hi Jonathan,

Indeed, it is not as easy as I thought. The LISTBOX gets created on runtime and is not available right after the DROPDOWN has been created.

You might want to try this as a workaround:

C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include "DIALOG.h"

/*********************************************************************
*
*   	Static code
*
**********************************************************************
*/
/*********************************************************************
*
*   	_cbBk
*/
static void _cbBk(WM_MESSAGE * pMsg) {
  switch (pMsg->MsgId) {
  case WM_PAINT:
	GUI_DrawGradientH(0, 0, LCD_GetXSize() - 1, LCD_GetYSize() - 1, GUI_BLACK, GUI_LIGHTGRAY);
	break;
  default:
	WM_DefaultProc(pMsg);
	break;
  }
}

/*********************************************************************
*
*   	_cbDropDown
*/
static int _LBOwnerDraw(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo) {
  int r;
  //
  // Set the trans flag
  //
  WM_SetHasTrans(pDrawItemInfo->hWin);
  //
  // Draw the LISTBOX in it default look
  //
  r = LISTBOX_OwnerDraw(pDrawItemInfo);
  //
  // Clear the trans flag again to make sure the rest will be drawn properly.
  //
  WM_ClrHasTrans(pDrawItemInfo->hWin);
  return r;
}

/*********************************************************************
*
*   	_cbDropDown
*/
static void _cbDropDown(WM_MESSAGE * pMsg) {
  WM_HWIN hListBox;
  static int _Once;

  switch (pMsg->MsgId) {
  default:
	//
	// Handle anything by the default callback of DROPDOWN widget.
	// We are just here to manage the LISTBOX.
	//
	DROPDOWN_Callback(pMsg);
	//
	// Check for LISTBOX handle
	//
	hListBox = DROPDOWN_GetListbox(pMsg->hWin);
	if (hListBox) {
  	//
  	// Make sure we set the owner draw function only once because the owner
  	// draw function invalidates the LISTBOX and would cause an endless loop.
  	//
  	if (_Once == 0) {
    	LISTBOX_SetOwnerDraw(hListBox, _LBOwnerDraw);
    	_Once = 1;
  	}
	} else if (_Once) {
  	//
  	// If no LB is present, but the _Once flag is set, restore it to 0.
  	//
  	_Once = 0;
	}
	break;
  }
}

/*********************************************************************
*
*   	Public code
*
**********************************************************************
*/
/*********************************************************************
*
*   	MainTask
*/
void MainTask(void) {
  WM_HWIN hDropdown;

  GUI_Init();
  WM_SetCallback(WM_HBKWIN, _cbBk);
  hDropdown = DROPDOWN_CreateEx(10, 10, 120, 200, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_DROPDOWN0);
  //
  // Set a callback function for the DROPDOWN widget.
  //
  WM_SetCallback(hDropdown, _cbDropDown);

  DROPDOWN_SetFont(hDropdown,GUI_FONT_24_1);
  DROPDOWN_SetBkColor(hDropdown, DROPDOWN_CI_UNSEL, GUI_RED);
  DROPDOWN_SetBkColor(hDropdown, DROPDOWN_CI_SELFOCUS, GUI_LIGHTGRAY);
  DROPDOWN_SetTextColor(hDropdown, EDIT_CI_ENABLED, GUI_BLACK);
  DROPDOWN_SetTextAlign(hDropdown, GUI_TA_LEFT | GUI_TA_VCENTER);
  DROPDOWN_AddString(hDropdown,"A");
  DROPDOWN_AddString(hDropdown,"B");
  DROPDOWN_AddString(hDropdown,"C");
  DROPDOWN_AddString(hDropdown,"D");
  DROPDOWN_AddString(hDropdown,"E");
  DROPDOWN_AddString(hDropdown,"F");
  DROPDOWN_AddString(hDropdown,"G");
  DROPDOWN_AddString(hDropdown,"H");
  DROPDOWN_SetSel(hDropdown, 0);

  while (1) {
	GUI_Delay(100);
  }
}


Regards
Sven