29 #include YFM_YSLib_UI_ExStyle
30 #include YFM_YSLib_UI_YGUI
31 #include YFM_YSLib_Service_YBlit
32 #include YFM_YSLib_UI_Button
33 #include YFM_YSLib_UI_Selector
39 using namespace Drawing;
52 RectDrawButton_Aoi(
const PaintContext& pc, Size
s, Hue base_hue,
53 CursorState cursor_state,
bool is_enabled,
bool is_focused)
55 const bool inside(cursor_state != CursorState::Outside);
56 const auto roll([=](
bool b,
MonoType gr,
const hsl_t& hsl){
57 return MakeGrayOrColor(
RollColor(hsl, base_hue), gr, inside || b);
59 const auto&
g(pc.Target);
63 if(
YB_LIKELY(s.Width > 2 && s.Height > 2))
66 const auto&
bounds(pc.ClipArea);
68 yunseq(pt.X += 1, pt.Y += 1, s.Width -= 2, s.Height -= 2);
70 {11.304688F, 0.990431F, 0.591797F}) : MakeGray(244));
73 if(s.Width > 2 && s.Height > 2)
75 Rect rp(pt.X + 1, pt.Y + 1, s.Width - 2, (s.Height - 2) / 2);
78 roll({}, 239, {39.132872F, 0.920000F, 0.951172F}));
83 roll({}, 214, {29.523438F, 0.969231F, 0.873047F}));
92 *dst =
Color(d.GetR() ^ tc.GetR(), d.GetG() ^ tc.GetG(),
93 d.GetB() ^ tc.GetB());
103 enum SelectorIndex_Aoi
105 SelectorIndex_Aoi_C1 = 4,
106 SelectorIndex_Aoi_C2 = 8,
107 SelectorIndex_Aoi_C3 = 11,
108 SelectorIndex_Aoi_End = 14
111 enum ControlState :
yimpl(
size_t)
113 ControlState_Focused = 0,
114 ControlState_Enabled = 1,
115 ControlState_Locked = 2,
116 ControlState_Ticked = 3
121 RectDrawSelector_Aoi(
void(*
f)(
const PaintContext&,
const Size&,
const bool[],
122 const Color[],
size_t),
const PaintContext& pc, Thumb& tmb,
bool is_ticked)
124 const Hue base_hue(tmb.GetHue());
125 const auto roll([=](
float h,
float s,
float l){
128 const Color colors[]{MakeGray(177), MakeGray(143), roll(2.3F, .315F, .486F),
129 roll(25.9F, .519F, .359F), MakeGray(246), MakeGray(244),
130 roll(2.1F, .737F, .925F), roll(20.8F, .743F, .863F),
131 roll(32.7F, .073F, .704F), roll(23.9F, .914F, .725F),
132 roll(25.5F, .905F, .669F), MakeGray(232), roll(20.F, .934F, .88F),
133 roll(20.8F, .923F, .847F)};
140 case CursorState::Outside:
142 case CursorState::Over:
147 YAssert(
false,
"Invalid state found.");
150 }(tmb.GetCursorState()));
155 RectDrawCheckBox_Aoi(
const PaintContext& pc, CheckBox& cb)
157 RectDrawSelector_Aoi([](
const PaintContext& pc,
const Size& s,
158 const bool cst[],
const Color ccs[],
size_t c_idx){
159 const auto&
g(pc.Target);
160 const auto& pt(pc.Location);
161 const auto&
bounds(pc.ClipArea);
163 const bool is_enabled(cst[ControlState_Enabled]);
173 + (cst[ControlState_Locked] || cst[ControlState_Focused]
174 ? 2 : is_enabled ? c_idx : 0)]);
184 if(cst[ControlState_Ticked])
186 : MakeGray(190), is_enabled ?
Color(108, 166, 208)
188 }, pc, cb, cb.IsTicked());
192 RectDrawRadioBox_Aoi(
const PaintContext& pc, RadioBox& rb)
194 RectDrawSelector_Aoi([](
const PaintContext& pc,
const Size& s,
195 const bool cst[],
const Color ccs[],
size_t c_idx){
196 const auto&
g(pc.Target);
197 const SDst rad(min(s.Width / 2, s.Height / 2));
198 const auto pt(pc.Location + Size(rad, rad));
199 const auto&
bounds(pc.ClipArea);
200 const Rect
r(pc.Location, s);
201 const bool is_enabled(cst[ControlState_Enabled]);
210 + (cst[ControlState_Locked] || cst[ControlState_Focused]
211 ? 2 : is_enabled ? c_idx : 0)]);
216 ccs[SelectorIndex_Aoi_C2 + c_idx]);
218 ccs[SelectorIndex_Aoi_C3 + c_idx]);
221 if(cst[ControlState_Ticked])
224 }, pc, rb, rb.IsSelected());
239 tmb(ystdex::polymorphic_downcast<Thumb&>(e.GetSender()));
241 RectDrawButton_Aoi(e,
GetSizeOf(tmb), tmb.GetHue(),
247 RectDrawCheckBox_Aoi(e,
248 ystdex::polymorphic_downcast<CheckBox&>(e.GetSender()));
253 RectDrawRadioBox_Aoi(e,
254 ystdex::polymorphic_downcast<RadioBox&>(e.GetSender()));
pt pt Y const IWidget &wgt const IWidget &wgt GetSizeOf
无效化:使相对于部件的子部件的指定区域在直接和间接的窗口缓冲区中无效。
YF_API void FillCircle(const Graphics &, const Rect &, const Point &, SDst, Color c)
填充圆形。
YF_API GUIState & FetchGUIState()
取默认图形用户界面公共状态。
YF_API void FillRect(const Graphics &g, const Rect &, Color c)
填充标准矩形。
bool IsFocusedByShell(const IWidget &wgt, const GUIState &st=FetchGUIState())
判断指定部件是否被句柄指定的图形用户界面状态锁定为独立焦点。
YF_API void DrawRectRoundCorner(const PaintContext &pc, const Size &s, Color)
绘制部件边框用空心标准矩形。
std::uint16_t SDst
屏幕坐标距离。
YF_API void DrawTick(const Graphics &, const Rect &, const Rect &, Color, Color)
CursorState
指针设备光标相对于控件的状态。
bounds c YF_API void DrawCircle(const Graphics &, const Rect &, const Point &, SDst, Color c)
描画圆形。
#define yunseq
无序列依赖表达式组求值。
YF_API bool IsFocused(const IWidget &)
判断部件是否取得焦点。
unordered_map< Key, Handler, ystdex::combined_hash< Key >> HandlerTable
样式处理器表。
bool IsEnabled(const IWidget &wgt)
判断部件是否为可用的控件。
YF_API void InitExStyles()
初始化扩展样式。
bool TransformRect(const Graphics &g, const Point &pt, const Size &s, _fTransformPixel tp)
以像素为单位变换标准矩形。
YF_API Color RollColor(hsl_t, Hue)
色调偏移。
Styles::StyleMap Styles
样式映射。
p1 p1 p2 p2 c YF_API void DrawRect(const Graphics &g, const Rect &bounds, const Point &pt, const Size &s, Color c)
描画标准矩形。
#define YAssert(_expr, _msg)