请问emwin做仿苹果亮度调节控件色差问题
最近搞起了emwin,设计一个类似于苹果ios控制栏上的亮度调节控件,其中用到了圆角矩形。现在遇到白色部分颜色跟背景色相减变暗了。我想要纯白的,请问程序还需要如何设计?谢谢
/*********************************************************************
* *
* SEGGER Microcontroller GmbH *
* Solutions for real time microcontroller applications *
* *
**********************************************************************
* *
* C-file generated by: *
* *
* GUI_Builder for emWin version 5.50 *
* Compiled Jun 11 2019, 16:51:25 *
* (c) 2019 Segger Microcontroller GmbH *
* *
**********************************************************************
* *
* Internet: www.segger.comSupport: support@segger.com *
* *
**********************************************************************
*/
// USER START (Optionally insert additional includes)
#include "my_Anim.h"
#include "switchWin.h"
// USER END
#include "DIALOG.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define ID_WINDOW_0 (GUI_ID_USER + 0x00)
// USER START (Optionally insert additional defines)
// USER END
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
// USER START (Optionally insert additional static data)
// USER END
/*********************************************************************
*
* _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ WINDOW_CreateIndirect, "Window_ctrl_", ID_WINDOW_0, 0, 0, 240, 240, 0, 0x0, 0 }
// USER START (Optionally insert additional widgets)
// USER END
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
// USER START (Optionally insert additional static code)
extern GUI_CONST_STORAGE GUI_BITMAP bmicon_light;
// USER END
#define IMG_BRIGHTNESS_X 11
#define DRAW_BRIGHTNESS_X 10
#define DRAW_BRIGHTNESS_Y 187
#define DRAW_BRIGHTNESS_XSIZE 220+2
#define DRAW_BRIGHTNESS_YSIZE 40+2
static int _DrawSkinFlex(const WIDGET_ITEM_DRAW_INFO* pDrawItemInfo) {
int x;
int y;
static int brightnessWidth = 0;
switch (pDrawItemInfo->Cmd)
{
case WIDGET_ITEM_DRAW_THUMB:
brightnessWidth = pDrawItemInfo->x1;
return 0;
case WIDGET_ITEM_DRAW_TICKS:
return 0;
case WIDGET_ITEM_DRAW_FOCUS:
return 0;
case WIDGET_ITEM_DRAW_SHAFT:
char str;
snprintf(str, sizeof(str), "x0:%d,y0:%d,x1:%d,y1:%d\r\n", pDrawItemInfo->x0, pDrawItemInfo->y0, pDrawItemInfo->x1, pDrawItemInfo->y1);
GUI_X_Log(str);
GUI_SetDrawMode(GUI_DM_NORMAL);
////GUI_AA_FillRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0, brightnessWidth, pDrawItemInfo->y1, (pDrawItemInfo->y1 - pDrawItemInfo->y0) / 2);
GUI_FillRect(pDrawItemInfo->x0, pDrawItemInfo->y0, brightnessWidth, pDrawItemInfo->y1);
GUI_SetDrawMode(GUI_DM_XOR);
GUI_AA_FillRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0, pDrawItemInfo->x1, pDrawItemInfo->y1, (pDrawItemInfo->y1 - pDrawItemInfo->y0) / 2);
GUI_SetDrawMode(GUI_DM_NORMAL);
GUI_SetColor(GUI_MAKE_COLOR(0x00343434));
//GUI_SetColor(GUI_BLACK);
GUI_AA_FillRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0, pDrawItemInfo->x1, pDrawItemInfo->y1, (pDrawItemInfo->y1 - pDrawItemInfo->y0) / 2-2);
GUI_InvertRect(pDrawItemInfo->x0, pDrawItemInfo->y0, brightnessWidth, pDrawItemInfo->y1);
//GUI_FillRect(pDrawItemInfo->x0, pDrawItemInfo->y0, brightnessWidth, pDrawItemInfo->y1);
//GUI_DrawBitmap(&bmicon_light, IMG_BRIGHTNESS_X, pDrawItemInfo->y0);
return 0;
default:
//return SLIDER_DrawSkinFlex(pDrawItemInfo);
break;
}
}
/*********************************************************************
*
* _cbDialog
*/
static void _cbDialog(WM_MESSAGE* pMsg) {
// USER START (Optionally insert additional variables)
static WM_HWIN hSlider = NULL;
int NCode;
static int Value;
// USER END
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
WINDOW_SetBkColor(pMsg->hWin, GUI_BLACK);
SLIDER_SetDefaultSkin(_DrawSkinFlex);
hSlider = SLIDER_Create(DRAW_BRIGHTNESS_X, DRAW_BRIGHTNESS_Y, DRAW_BRIGHTNESS_XSIZE, DRAW_BRIGHTNESS_YSIZE, pMsg->hWin, GUI_ID_SLIDER0, WM_CF_SHOW, 0);
SLIDER_SetWidth(hSlider,0);
SLIDER_SetRange(hSlider, 0, 100);
WM_SetFocus(hSlider);
// USER END
break;
case WM_NOTIFY_PARENT:
NCode = pMsg->Data.v;
switch (NCode)
{
case WM_NOTIFICATION_VALUE_CHANGED:
Value = SLIDER_GetValue(pMsg->hWinSrc);
break;
}
break;
// USER START (Optionally insert additional message handling)
case WM_TOUCH:
touchSwitchWIn(pMsg, NULL, NULL, CreateWindow_clock_, NULL);
case WM_PAINT:
//GUI_SetColor(GUI_MAKE_COLOR(0x00343434));
//GUI_AA_FillRoundedRect(DRAW_BRIGHTNESS_X, DRAW_BRIGHTNESS_Y, DRAW_BRIGHTNESS_X + DRAW_BRIGHTNESS_XSIZE, DRAW_BRIGHTNESS_Y + DRAW_BRIGHTNESS_YSIZE, DRAW_BRIGHTNESS_YSIZE / 2);
//GUI_SetColor(GUI_WHITE);
//GUI_AA_FillRoundedRect(DRAW_BRIGHTNESS_X, DRAW_BRIGHTNESS_Y, DRAW_BRIGHTNESS_X + (DRAW_BRIGHTNESS_XSIZE/100)*Value, DRAW_BRIGHTNESS_Y + DRAW_BRIGHTNESS_YSIZE, DRAW_BRIGHTNESS_YSIZE / 2);
//GUI_DrawBitmap(&bmicon_light, IMG_BRIGHTNESS_X, IMG_BRIGHTNESS_Y);
//GUI_SetFont(&GUI_Font13H_ASCII);
//GUI_SetColor(GUI_WHITE);
//GUI_GotoXY(0,100);
//GUI_DispDecMin(Value);
char str;
snprintf(str, sizeof(str), "Value = %d\r\n", Value);
GUI_X_Log(str);
break;
// USER END
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* CreateWindow_ctrl_
*/
WM_HWIN CreateWindow_ctrl_(void);
WM_HWIN CreateWindow_ctrl_(void) {
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
WM_DisableWindow(hWin);
return hWin;
}
// USER START (Optionally insert additional public code)
// USER END
/*************************** End of file ****************************/
页:
[1]