remove conversion constructors of point,size and rectangle
This commit is contained in:
@@ -528,124 +528,25 @@ namespace nana
|
||||
return (px_color().value != other.px_color().value);
|
||||
}
|
||||
|
||||
color operator+(const color& x, const color& y)
|
||||
{
|
||||
double a = x.a_ + y.a_;
|
||||
auto r = static_cast<unsigned>(x.r_ + y.r_);
|
||||
auto g = static_cast<unsigned>(x.g_ + y.g_);
|
||||
auto b = static_cast<unsigned>(x.b_ + y.b_);
|
||||
|
||||
return color{
|
||||
r > 255 ? 255 : r,
|
||||
g > 255 ? 255 : g,
|
||||
b > 255 ? 255 : b,
|
||||
a > 1.0 ? 1.0 : a };
|
||||
}
|
||||
//end class color
|
||||
//struct point
|
||||
point::point():x(0), y(0){}
|
||||
point::point(int x, int y):x(x), y(y){}
|
||||
point::point(const rectangle& r)
|
||||
: x(r.x), y(r.y)
|
||||
{}
|
||||
|
||||
point& point::operator=(const rectangle& r)
|
||||
{
|
||||
x = r.x;
|
||||
y = r.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool point::operator==(const point& rhs) const
|
||||
{
|
||||
return ((x == rhs.x) && (y == rhs.y));
|
||||
}
|
||||
|
||||
bool point::operator!=(const point& rhs) const
|
||||
{
|
||||
return ((x != rhs.x) || (y != rhs.y));
|
||||
}
|
||||
|
||||
bool point::operator<(const point& rhs) const
|
||||
{
|
||||
return ((y < rhs.y) || (y == rhs.y && x < rhs.x));
|
||||
}
|
||||
|
||||
bool point::operator<=(const point& rhs) const
|
||||
{
|
||||
return ((y < rhs.y) || (y == rhs.y && x <= rhs.x));
|
||||
}
|
||||
|
||||
bool point::operator>(const point& rhs) const
|
||||
{
|
||||
return ((y > rhs.y) || (y == rhs.y && x > rhs.x));
|
||||
}
|
||||
|
||||
bool point::operator>=(const point& rhs) const
|
||||
{
|
||||
return ((y > rhs.y) || (y == rhs.y && x >= rhs.x));
|
||||
}
|
||||
|
||||
point point::operator-(const point& rhs) const
|
||||
{
|
||||
return{x - rhs.x, y - rhs.y};
|
||||
}
|
||||
|
||||
point point::operator+(const point& rhs) const
|
||||
{
|
||||
return{ x + rhs.x, y + rhs.y };
|
||||
}
|
||||
|
||||
point& point::operator-=(const point& rhs)
|
||||
{
|
||||
x -= rhs.x;
|
||||
y -= rhs.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
point& point::operator+=(const point& rhs)
|
||||
{
|
||||
x += rhs.x;
|
||||
y += rhs.y;
|
||||
return *this;
|
||||
}
|
||||
//end struct point
|
||||
|
||||
//struct upoint
|
||||
upoint::upoint():x(0), y(0){}
|
||||
upoint::upoint(unsigned x, unsigned y):x(x), y(y){}
|
||||
|
||||
bool upoint::operator==(const upoint& rhs) const
|
||||
{
|
||||
return ((x == rhs.x) && (y == rhs.y));
|
||||
}
|
||||
|
||||
bool upoint::operator!=(const upoint& rhs) const
|
||||
{
|
||||
return ((x != rhs.x) || (y != rhs.y));
|
||||
}
|
||||
|
||||
bool upoint::operator<(const upoint& rhs) const
|
||||
{
|
||||
return ((y < rhs.y) || (y == rhs.y && x < rhs.x));
|
||||
}
|
||||
|
||||
bool upoint::operator<=(const upoint& rhs) const
|
||||
{
|
||||
return ((y < rhs.y) || (y == rhs.y && x <= rhs.x));
|
||||
}
|
||||
|
||||
bool upoint::operator>(const upoint& rhs) const
|
||||
{
|
||||
return ((y > rhs.y) || (y == rhs.y && x > rhs.x));
|
||||
}
|
||||
|
||||
bool upoint::operator>=(const upoint& rhs) const
|
||||
{
|
||||
return ((y > rhs.y) || (y == rhs.y && x >= rhs.x));
|
||||
}
|
||||
//end struct upoint
|
||||
|
||||
//struct size
|
||||
size::size():width(0), height(0){}
|
||||
size::size(value_type width, value_type height) : width(width), height(height){}
|
||||
size::size(const rectangle& r)
|
||||
: width(r.width), height(r.height)
|
||||
{}
|
||||
|
||||
size& size::operator=(const rectangle& r)
|
||||
{
|
||||
width = r.width;
|
||||
height = r.height;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool size::empty() const
|
||||
{
|
||||
@@ -657,6 +558,12 @@ namespace nana
|
||||
return (0 <= pos.x && pos.x < static_cast<int>(width) && 0 <= pos.y && pos.y < static_cast<int>(height));
|
||||
}
|
||||
|
||||
size& size::shift()
|
||||
{
|
||||
std::swap(width, height);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool size::operator==(const size& rhs) const
|
||||
{
|
||||
return (width == rhs.width) && (height == rhs.height);
|
||||
@@ -714,19 +621,38 @@ namespace nana
|
||||
return *this;
|
||||
}
|
||||
|
||||
rectangle& rectangle::set_pos(const point& pos)
|
||||
point rectangle::position() const
|
||||
{
|
||||
x = pos.x;
|
||||
y = pos.y;
|
||||
return{ x, y };
|
||||
}
|
||||
|
||||
rectangle& rectangle::position(const point& p)
|
||||
{
|
||||
x = p.x;
|
||||
y = p.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
size rectangle::dimension() const
|
||||
{
|
||||
return{width, height};
|
||||
}
|
||||
|
||||
rectangle& rectangle::dimension(const size& sz)
|
||||
{
|
||||
width = sz.width;
|
||||
height = sz.height;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*
|
||||
rectangle& rectangle::set_size(const size& sz)
|
||||
{
|
||||
width = sz.width;
|
||||
height = sz.height;
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
|
||||
rectangle& rectangle::pare_off(int pixels)
|
||||
{
|
||||
@@ -763,6 +689,13 @@ namespace nana
|
||||
{
|
||||
return (0 == width) || (0 == height);
|
||||
}
|
||||
|
||||
rectangle& rectangle::shift()
|
||||
{
|
||||
std::swap(x, y);
|
||||
std::swap(width, height);
|
||||
return *this;
|
||||
}
|
||||
//end struct rectangle
|
||||
|
||||
//class rectangle_rotator
|
||||
|
||||
@@ -354,8 +354,8 @@ namespace nana
|
||||
|
||||
void basic_window::_m_init_pos_and_size(basic_window* parent, const rectangle& r)
|
||||
{
|
||||
pos_owner = pos_root = r;
|
||||
dimension = r;
|
||||
pos_owner = pos_root = r.position();
|
||||
dimension = r.dimension();
|
||||
|
||||
if (parent)
|
||||
pos_root += parent->pos_root;
|
||||
|
||||
@@ -999,7 +999,7 @@ namespace detail
|
||||
|
||||
if (msgwnd->dimension.is_hit(arg.pos))
|
||||
{
|
||||
msgwnd->set_action(mouse_action::over);
|
||||
msgwnd->set_action(mouse_action::hovered);
|
||||
if ((::nana::mouse::left_button == arg.button) && (pressed_wd == msgwnd))
|
||||
{
|
||||
click_arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||
@@ -1065,7 +1065,7 @@ namespace detail
|
||||
if (pressed_wd == msgwnd)
|
||||
msgwnd->set_action(mouse_action::pressed);
|
||||
else if (mouse_action::pressed != msgwnd->flags.action)
|
||||
msgwnd->set_action(mouse_action::over);
|
||||
msgwnd->set_action(mouse_action::hovered);
|
||||
}
|
||||
arg_mouse arg;
|
||||
assign_arg(arg, msgwnd, message, pmdec);
|
||||
@@ -1084,7 +1084,7 @@ namespace detail
|
||||
if (pressed_wd == msgwnd)
|
||||
msgwnd->set_action(mouse_action::pressed);
|
||||
else if (mouse_action::pressed != msgwnd->flags.action)
|
||||
msgwnd->set_action(mouse_action::over);
|
||||
msgwnd->set_action(mouse_action::hovered);
|
||||
|
||||
hovered_wd = msgwnd;
|
||||
arg.evt_code = event_code::mouse_enter;
|
||||
|
||||
@@ -1300,7 +1300,7 @@ namespace nana
|
||||
if (stretch_all_)
|
||||
{
|
||||
if (from_r.width == to_r.width && from_r.height == to_r.height)
|
||||
method_->paste(from_r, dst, to_r);
|
||||
method_->paste(from_r, dst, to_r.position());
|
||||
else
|
||||
method_->stretch(from_r, dst, to_r);
|
||||
|
||||
@@ -1392,7 +1392,7 @@ namespace nana
|
||||
if (top_)
|
||||
{
|
||||
src_r.height = top_;
|
||||
method_->paste(src_r, dst, to_r);
|
||||
method_->paste(src_r, dst, to_r.position());
|
||||
}
|
||||
if (bottom_)
|
||||
{
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace nana
|
||||
if (!x_pointed_)
|
||||
return;
|
||||
|
||||
x_state_ = ::nana::mouse_action::over;
|
||||
x_state_ = ::nana::mouse_action::hovered;
|
||||
refresh(graph);
|
||||
API::dev::lazy_refresh();
|
||||
|
||||
@@ -387,7 +387,7 @@ namespace nana
|
||||
}
|
||||
|
||||
panels_.emplace_back();
|
||||
widget * w=wdg.get();
|
||||
auto wdg = wdg.get();
|
||||
panels_.back().widget_ptr.swap(wdg);
|
||||
|
||||
for (auto & pn : panels_)
|
||||
@@ -395,7 +395,7 @@ namespace nana
|
||||
if (pn.widget_ptr)
|
||||
pn.widget_ptr->move(r);
|
||||
}
|
||||
return w;
|
||||
return wdg;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1358,7 +1358,7 @@ namespace API
|
||||
{
|
||||
case nana::mouse_action::normal:
|
||||
return (is_focused ? nana::element_state::focus_normal : nana::element_state::normal);
|
||||
case nana::mouse_action::over:
|
||||
case nana::mouse_action::hovered:
|
||||
return (is_focused ? nana::element_state::focus_hovered : nana::element_state::hovered);
|
||||
case nana::mouse_action::pressed:
|
||||
return nana::element_state::pressed;
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace nana
|
||||
|
||||
if(ui_el_.what == ui_el_.item_root)
|
||||
{
|
||||
_m_item_bground(graph, r.x + 1, r.y, r.width - 2, r.height, (state == mouse_action::pressed ? mouse_action::pressed : mouse_action::over));
|
||||
_m_item_bground(graph, r.x + 1, r.y, r.width - 2, r.height, (state == mouse_action::pressed ? mouse_action::pressed : mouse_action::hovered));
|
||||
graph.rectangle(r, false, static_cast<color_rgb>(0x3C7FB1));
|
||||
if(state == mouse_action::pressed)
|
||||
{
|
||||
@@ -114,8 +114,8 @@ namespace nana
|
||||
mouse_action state_arrow, state_name;
|
||||
if(mouse_action::pressed != state)
|
||||
{
|
||||
state_arrow = (ui_el_.what == ui_el_.item_arrow ? mouse_action::over : mouse_action::normal);
|
||||
state_name = (ui_el_.what == ui_el_.item_name ? mouse_action::over : mouse_action::normal);
|
||||
state_arrow = (ui_el_.what == ui_el_.item_arrow ? mouse_action::hovered : mouse_action::normal);
|
||||
state_name = (ui_el_.what == ui_el_.item_name ? mouse_action::hovered : mouse_action::normal);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -170,7 +170,7 @@ namespace nana
|
||||
nana::color clr_top(static_cast<color_rgb>(0xEAEAEA)), clr_bottom(static_cast<color_rgb>(0xDCDCDC));
|
||||
switch(state)
|
||||
{
|
||||
case mouse_action::over:
|
||||
case mouse_action::hovered:
|
||||
clr_top.from_rgb(0xdf, 0xf2, 0xfc);
|
||||
clr_bottom.from_rgb(0xa9, 0xda, 0xf5);
|
||||
break;
|
||||
|
||||
@@ -1270,7 +1270,7 @@ namespace nana
|
||||
if(size.width > attr.area.width || size.height > attr.area.height)
|
||||
{
|
||||
nana::size fit_size;
|
||||
nana::fit_zoom(size, attr.area, fit_size);
|
||||
nana::fit_zoom(size, attr.area.dimension(), fit_size);
|
||||
|
||||
attr.area.x += (attr.area.width - fit_size.width) / 2;
|
||||
attr.area.y += (attr.area.height - fit_size.height) / 2;
|
||||
@@ -1442,8 +1442,9 @@ namespace nana
|
||||
virtual bool comp_attribute(component_t comp, comp_attribute_t& attr) const override
|
||||
{
|
||||
attr.area = node_r_;
|
||||
if(impl_->data.comp_placer->locate(comp, node_attr_, &attr.area))
|
||||
if (impl_->data.comp_placer->locate(comp, node_attr_, &attr.area))
|
||||
{
|
||||
attr.mouse_pointed = node_attr_.mouse_pointed;
|
||||
attr.area.x += pos_.x;
|
||||
attr.area.y += pos_.y;
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user