29 #include YFM_YSLib_UI_YStyle
30 #include YFM_YSLib_UI_YWindow
31 #include YFM_YSLib_UI_YGUI
33 using namespace ystdex;
44 const auto&
g(pc.Target);
45 const auto& pt(pc.Location);
46 const auto&
r(pc.ClipArea);
47 const SPos x1(pt.X + 1), y1(pt.Y + 1), x2(pt.X + s.
Width - 1),
70 const auto&
g(pc.Target);
71 const auto& pt(pc.Location);
72 const auto&
bounds(pc.ClipArea);
73 SDst x(pt.X), y(pt.Y);
82 for(
SDst i(0); i < half_size; ++i)
91 for(
SDst i(0); i < half_size; ++i)
103 SPos x(bounds.
X), y(bounds.
Y);
110 ? (bounds.
Width - half_size) : (bounds.
Width + half_size)) / 2;
111 y += (bounds.
Height + 1) / 2;
116 ? (bounds.
Height - half_size) : (bounds.
Height + half_size)) / 2;
117 x += (bounds.
Width + 1) / 2;
129 const SPos xmin(r.
X + 4), xmax(xmin + r.
Width - 8),
130 ymin(r.
Y + 4), ymax(ymin + r.
Height - 8);
133 DrawLineSeg(g, bounds, xmax - 1, ymin, xmin - 1, ymax, c);
144 p3(r.
X + r.
Width - 2, r.
Y + 1);
165 const u8 r(c.GetR()),
g(c.GetG()), b(c.GetB()),
166 min_color(min(min(
r,
g), b)), max_color(max(max(
r,
g), b));
171 if(min_color == max_color)
172 l = decltype(
hsl_t::l)(min_color) / 0x100;
175 const unsigned p(max_color + min_color);
184 const mid_t q(max_color - min_color);
186 s = q / (p < 0x100 ? p : 0x200 - p);
189 else if(
g == max_color)
190 h = (b -
r) / q + 0x2;
191 else if(b == max_color)
192 h = (
r -
g) / q + 0x4;
196 return {h * 60,
s,
l};
202 YAssert(IsInInterval<Hue>(c.
h, 0, 360),
"Invalid hue found."),
206 return MakeGray(c.
l > 255.F / 0x100 ? 0xFF : c.
l * 0x100);
210 mid_t t2((c.
l < 0.5F ? c.
l * (1 + c.
s) : (c.
l + c.
s - c.
l * c.
s)) * 0x100),
211 t1((c.
l * 0x200) - t2);
212 mid_t tmp[3]{c.
h + 120, c.
h, c.
h - 120}; \
216 for(
size_t i(0); i < 3; ++i)
220 else if(tmp[i] > 360)
223 dc[i] = t1 + (t2 - t1) * tmp[i] / 60;
224 else if(tmp[i] < 180)
226 else if(tmp[i] < 240)
227 dc[i] = t1 + (t2 - t1) * (240 - tmp[i]) / 60;
233 return Color(dc[0], dc[1], dc[2]);
240 YAssert(IsInInterval<Hue>(c.
h, 0, 360),
"Invalid hue found.");
242 c.
h = delta < 360 ? delta : delta - 360;
288 pair<Drawing::Color, Drawing::Color>
289 Palette::GetPair(Palette::ColorListType::size_type n1,
290 Palette::ColorListType::size_type n2)
const
308 YAssert(!empty(),
"No style found.");
311 const auto& table(
current->second);
312 auto i(table.find(key));
314 if(i == table.cend())
316 const auto& de_table(cbegin()->
second);
318 i = de_table.find(key);
319 if(i == de_table.end())
322 i->second(std::move(e));
339 const auto i(find(name));
341 current = i == cend() ? cbegin() : i;
void DrawVLineSeg(const Graphics &g, const Rect &bounds, SPos x, SPos y1, SPos y2, Color c)
描画竖直线段。
YF_API HandlerTable & FetchDefault()
取默认样式处理器表。
YF_API void DrawCross(const Graphics &, const Rect &, const Rect &, Color)
在指定图形接口上下文中使用指定颜色描画交叉直线段(“×”)。
YF_API GUIState & FetchGUIState()
取默认图形用户界面公共状态。
YF_API void DrawRectRoundCorner(const PaintContext &pc, const Size &s, Color)
绘制部件边框用空心标准矩形。
std::uint16_t SDst
屏幕坐标距离。
key second key first void operator()(PaintEventArgs &&) const
YF_API void DrawTick(const Graphics &, const Rect &, const Rect &, Color, Color)
hsl_t ColorToHSL(Color c)
GBinaryGroup< SPos > Point
屏幕二维点(直角坐标表示)。
void DrawLineSeg(const Graphics &g, const Rect &bounds, SPos x1, SPos y1, SPos x2, SPos y2, Color c)
描画线段:在区域 ds 绘制端点为 p1(x1, y1) 和 p2(x2, y2) 的线段。
yconstfn const string & name
void DrawHLineSeg(const Graphics &g, const Rect &bounds, SPos y, SPos x1, SPos x2, Color c)
描画水平线段。
unordered_map< Key, Handler, ystdex::combined_hash< Key >> HandlerTable
样式处理器表。
PaintEventArgs &&void Switch(const string &)
void DrawPoint(const Graphics &g, const Rect &bounds, SPos x, SPos y, Color c)
描画点。
YF_API void DrawArrow(const Graphics &, const Rect &, SDst=4, Rotation=RDeg0, Color=ColorSpace::Black)
在指定图形接口上下文上描画箭头。
bool is_undereferenceable(const any_input_iterator< _type, _tDifference, _tPointer, _tReference > &i)
void Remove(const string &)
Color HSLToColor(hsl_t c)
YF_API void RectDrawArrow(const PaintContext &, SDst, Rotation=RDeg0, Color=ColorSpace::Black)
在指定上下文的矩形中画箭头。
YF_API Color RollColor(hsl_t, Hue)
色调偏移。
static auto second(const _tIterator &i) -> decltype((i->second))
bool IsInClosedInterval(_type i, _type b) ynothrow
判断 i 是否在闭区间 [FetchZero<_type>(), b] 中。
Styles::StyleMap Styles
样式映射。
GBinaryGroup< SPos > Vec
屏幕二维向量(直角坐标表示)。
#define YAssert(_expr, _msg)
pair< std::type_index, StyleItem > Key
标识查找样式的键。