improve visualization of group caption

This commit is contained in:
Jinhao 2018-01-13 10:49:37 +08:00
parent 970872c96f
commit 48be0b4b07
3 changed files with 31 additions and 3 deletions

View File

@ -301,6 +301,8 @@ namespace API
void window_size(window, const size&); void window_size(window, const size&);
size window_outline_size(window); size window_outline_size(window);
void window_outline_size(window, const size&); void window_outline_size(window, const size&);
nana::optional<rectangle> window_rectangle(window);
bool get_window_rectangle(window, rectangle&); bool get_window_rectangle(window, rectangle&);
bool track_window_size(window, const size&, bool true_for_max); ///< Sets the minimum or maximum tracking size of a window. bool track_window_size(window, const size&, bool true_for_max); ///< Sets the minimum or maximum tracking size of a window.
void window_enabled(window, bool); void window_enabled(window, bool);

View File

@ -821,6 +821,15 @@ namespace API
} }
} }
nana::optional<rectangle> window_rectangle(window wd)
{
auto iwd = reinterpret_cast<basic_window*>(wd);
internal_scope_guard lock;
if (restrict::wd_manager().available(iwd))
return rectangle(iwd->pos_owner, iwd->dimension);
return{};
}
bool get_window_rectangle(window wd, rectangle& r) bool get_window_rectangle(window wd, rectangle& r)
{ {
auto iwd = reinterpret_cast<basic_window*>(wd); auto iwd = reinterpret_cast<basic_window*>(wd);

View File

@ -208,8 +208,8 @@ namespace nana{
outter[field_title] << impl_->caption; outter[field_title] << impl_->caption;
outter.collocate(); outter.collocate();
impl_->caption.transparent(true);
color pbg = API::bgcolor(this->parent()); color pbg = API::bgcolor(this->parent());
impl_->caption.bgcolor(pbg.blend(colors::black, 0.025)); impl_->caption.bgcolor(pbg.blend(colors::black, 0.025));
this->bgcolor(pbg.blend(colors::black, 0.05)); this->bgcolor(pbg.blend(colors::black, 0.05));
@ -222,10 +222,27 @@ namespace nana{
auto gap_px = impl_->gap - 1; auto gap_px = impl_->gap - 1;
graph.rectangle(true, API::bgcolor(this->parent())); graph.rectangle(true, API::bgcolor(this->parent()));
graph.round_rectangle(rectangle(point(gap_px, impl_->caption_dimension.height / 2),
nana::size(graph.width() - 2 * gap_px, graph.height() - impl_->caption_dimension.height / 2 - gap_px) auto const top_round_line = static_cast<int>(impl_->caption_dimension.height) / 2;
graph.round_rectangle(rectangle(point(gap_px, top_round_line),
nana::size(graph.width() - 2 * gap_px, graph.height() - top_round_line - gap_px)
), ),
3, 3, colors::gray_border, true, this->bgcolor()); 3, 3, colors::gray_border, true, this->bgcolor());
auto opt_r = API::window_rectangle(impl_->caption);
if (opt_r)
{
rectangle grad_r{ opt_r->position(), nana::size{ opt_r->width, static_cast<unsigned>(top_round_line - opt_r->y) } };
grad_r.y += top_round_line / 2;
grad_r.x -= 2;
grad_r.width += 4;
graph.gradual_rectangle(grad_r,
API::bgcolor(this->parent()), this->bgcolor(), true
);
}
}); });
} }