YSTest
PreAlpha_b400_20130424
The YSLib Test Project
首页
相关页面
模块
命名空间
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
ColorPicker.cpp
浏览该文件的文档.
1
/*
2
Copyright by FrankHB 2012 - 2013.
3
4
This file is part of the YSLib project, and may only be used,
5
modified, and distributed under the terms of the YSLib project
6
license, LICENSE.TXT. By continuing to use, modify, or distribute
7
this file you indicate that you have read the license and
8
understand and accept it fully.
9
*/
10
28
#include "
ColorPicker.h
"
29
#include <
YSLib/UI/YBrush.h
>
30
31
YSL_BEGIN
32
33
YSL_BEGIN_NAMESPACE
(UI)
34
35
namespace
36
{
37
yconstexpr
Size
track_size
(112, 16);
38
yconstexpr
Size
label_size
(44, 20);
39
}
40
41
ColorBox::ColorBox
(
const
Point
& pt,
Color
c)
42
: DialogPanel({pt, 200, 96}),
43
ctlColorArea
({164, 32, 32, 32}),
trRed
({4, 24,
track_size
}),
44
trGreen
({4, 48,
track_size
}),
trBlue
({4, 72,
track_size
}),
45
lblRed
({120, 24,
label_size
}),
lblGreen
({120, 48,
label_size
}),
46
lblBlue
({120, 72,
label_size
})
47
{
48
const
auto
update_color([
this
](ScrollEventArgs&&){
49
SetColor(
Color
(
trRed
.GetValue(),
trGreen
.GetValue(),
50
trBlue
.GetValue()));
51
});
52
53
AddWidgets
(*
this
,
ctlColorArea
,
trRed
,
trGreen
,
trBlue
,
lblRed
,
lblGreen
,
54
lblBlue
),
55
trRed
.SetMaxValue(255),
56
trGreen
.SetMaxValue(255),
57
trBlue
.SetMaxValue(255),
58
yunseq
(
59
FetchEvent<Paint>(
ctlColorArea
).Add(BorderBrush(),
BoundaryPriority
),
60
trRed
.GetScroll() += update_color,
61
trGreen
.GetScroll() += update_color,
62
trBlue
.GetScroll() += update_color
63
);
64
SetColor(c);
65
}
66
67
Color
&
68
ColorBox::GetColorRef()
const
69
{
70
const
auto
p(
ctlColorArea
.Background.target<SolidBrush>());
71
72
if
(!p)
73
throw
LoggedEvent(
"Invalid brush found @ ColorBox::GetColor"
);
74
return
p->Color;
75
}
76
77
void
78
ColorBox::SetColor
(
Color
c)
79
{
80
GetColorRef() = c,
81
trRed
.SetValue(c.GetR()),
82
trGreen
.SetValue(c.GetG()),
83
trBlue
.SetValue(c.GetB());
84
yunseq
(
lblRed
.Text =
"R: "
+
to_string
(c.GetR()),
85
lblGreen
.Text =
"G: "
+
to_string
(c.GetG()),
86
lblBlue
.Text =
"B: "
+
to_string
(c.GetB()));
87
Invalidate
(
ctlColorArea
),
88
Invalidate
(
trRed
),
Invalidate
(
trGreen
),
Invalidate
(
trBlue
),
89
Invalidate
(
lblRed
),
Invalidate
(
lblGreen
),
Invalidate
(
lblBlue
);
90
}
91
92
YSL_END_NAMESPACE
(UI)
93
94
YSL_END
95
YSTest_ARM9
source
ColorPicker.cpp
生成于 2013年 四月 24日 星期三 18:41:27 , 为 YSTest使用
1.8.2