Merge remote-tracking branch 'nana_jinhao/hotfixes-1.0.1' into hotfixes
This commit is contained in:
commit
ee744db1c5
@ -434,10 +434,10 @@ namespace nana
|
||||
unsigned height;
|
||||
};
|
||||
|
||||
class area_rotator
|
||||
class rectangle_rotator
|
||||
{
|
||||
public:
|
||||
area_rotator(bool rotated, const ::nana::rectangle& area);
|
||||
rectangle_rotator(bool rotated, const ::nana::rectangle& area);
|
||||
|
||||
int x() const;
|
||||
int & x_ref();
|
||||
@ -454,7 +454,7 @@ namespace nana
|
||||
private:
|
||||
bool rotated_;
|
||||
::nana::rectangle area_;
|
||||
};//end class area_rotator
|
||||
};//end class rectangle_rotator
|
||||
|
||||
enum class arrange
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/gui/widgets/listbox.hpp
|
||||
* @contributors: Ariel Vina-Rodriguez
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/gui/widgets/scroll.hpp
|
||||
* @contributors: Ariel Vina-Rodriguez
|
||||
*/
|
||||
#ifndef NANA_GUI_WIDGET_SCROLL_HPP
|
||||
#define NANA_GUI_WIDGET_SCROLL_HPP
|
||||
@ -73,7 +74,7 @@ namespace nana
|
||||
enum{ none, highlight, actived, selected };
|
||||
};
|
||||
|
||||
typedef nana::paint::graphics& graph_reference;
|
||||
using graph_reference = paint::graphics&;
|
||||
const static unsigned fixedsize = 16; // make it part of a new "metric" in the widget_scheme
|
||||
|
||||
drawer(metrics_type& m);
|
||||
@ -437,12 +438,7 @@ namespace nana
|
||||
/// @return true if the vlaue is changed.
|
||||
bool make_scroll(bool forward)
|
||||
{
|
||||
if(this->get_drawer_trigger().make_step(forward, 3)) // set this 3 in the metrics of the widget scheme ?
|
||||
{
|
||||
API::refresh_window(this->handle());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this->make_step(forward, 3); // set this 3 in the metrics of the widget scheme ?
|
||||
}
|
||||
|
||||
/// \brief Increase/decrease values by a page as if it is scrolled page up.
|
||||
@ -450,12 +446,7 @@ namespace nana
|
||||
/// @return true if the vlaue is changed.
|
||||
bool make_page_scroll(bool forward)
|
||||
{
|
||||
if(this->get_drawer_trigger().make_step(forward, range()-1))
|
||||
{
|
||||
API::refresh_window(this->handle());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this->make_step(forward, range() - 1);
|
||||
}
|
||||
|
||||
};//end class scroll
|
||||
|
@ -765,65 +765,65 @@ namespace nana
|
||||
}
|
||||
//end struct rectangle
|
||||
|
||||
//class area_rotator
|
||||
area_rotator::area_rotator(bool rotated, const ::nana::rectangle& area)
|
||||
//class rectangle_rotator
|
||||
rectangle_rotator::rectangle_rotator(bool rotated, const ::nana::rectangle& area)
|
||||
: rotated_(rotated),
|
||||
area_(area)
|
||||
{}
|
||||
|
||||
int area_rotator::x() const
|
||||
int rectangle_rotator::x() const
|
||||
{
|
||||
return (rotated_ ? area_.y : area_.x);
|
||||
}
|
||||
|
||||
int & area_rotator::x_ref()
|
||||
int & rectangle_rotator::x_ref()
|
||||
{
|
||||
return (rotated_ ? area_.y : area_.x);
|
||||
}
|
||||
|
||||
int area_rotator::y() const
|
||||
int rectangle_rotator::y() const
|
||||
{
|
||||
return (rotated_ ? area_.x : area_.y);
|
||||
}
|
||||
|
||||
int & area_rotator::y_ref()
|
||||
int & rectangle_rotator::y_ref()
|
||||
{
|
||||
return (rotated_ ? area_.x : area_.y);
|
||||
}
|
||||
|
||||
unsigned area_rotator::w() const
|
||||
unsigned rectangle_rotator::w() const
|
||||
{
|
||||
return (rotated_ ? area_.height : area_.width);
|
||||
}
|
||||
|
||||
unsigned & area_rotator::w_ref()
|
||||
unsigned & rectangle_rotator::w_ref()
|
||||
{
|
||||
return (rotated_ ? area_.height : area_.width);
|
||||
}
|
||||
|
||||
unsigned area_rotator::h() const
|
||||
unsigned rectangle_rotator::h() const
|
||||
{
|
||||
return (rotated_ ? area_.width : area_.height);
|
||||
}
|
||||
|
||||
unsigned & area_rotator::h_ref()
|
||||
unsigned & rectangle_rotator::h_ref()
|
||||
{
|
||||
return (rotated_ ? area_.width : area_.height);
|
||||
}
|
||||
|
||||
int area_rotator::right() const
|
||||
int rectangle_rotator::right() const
|
||||
{
|
||||
return (rotated_ ? area_.y + static_cast<int>(area_.height) : area_.x + static_cast<int>(area_.width));
|
||||
}
|
||||
|
||||
int area_rotator::bottom() const
|
||||
int rectangle_rotator::bottom() const
|
||||
{
|
||||
return (rotated_ ? area_.x + static_cast<int>(area_.width) : area_.y + static_cast<int>(area_.height));
|
||||
}
|
||||
|
||||
const ::nana::rectangle& area_rotator::result() const
|
||||
const ::nana::rectangle& rectangle_rotator::result() const
|
||||
{
|
||||
return area_;
|
||||
}
|
||||
//end class area_rotator
|
||||
//end class rectangle_rotator
|
||||
}
|
||||
|
@ -985,7 +985,7 @@ namespace nana
|
||||
const bool vert = (kind::arrange != kind_of_division);
|
||||
|
||||
auto area_margined = margin_area();
|
||||
area_rotator area(vert, area_margined);
|
||||
rectangle_rotator area(vert, area_margined);
|
||||
auto area_px = area.w();
|
||||
|
||||
auto fa = _m_fixed_and_adjustable(kind_of_division, area_px);
|
||||
@ -1001,7 +1001,7 @@ namespace nana
|
||||
if(!child->display) //Ignore the division if the corresponding field is not displayed.
|
||||
continue;
|
||||
|
||||
area_rotator child_area(vert, child->field_area);
|
||||
rectangle_rotator child_area(vert, child->field_area);
|
||||
child_area.x_ref() = static_cast<int>(position);
|
||||
child_area.y_ref() = area.y();
|
||||
child_area.h_ref() = area.h();
|
||||
@ -1591,7 +1591,7 @@ namespace nana
|
||||
return;
|
||||
|
||||
const bool vert = (::nana::cursor::size_we != splitter_cursor_);
|
||||
auto area_px = area_rotator(vert, div_owner->margin_area()).w();
|
||||
auto area_px = rectangle_rotator(vert, div_owner->margin_area()).w();
|
||||
int delta = (vert ? splitter_.pos().y - begin_point_.y : splitter_.pos().x - begin_point_.x);
|
||||
|
||||
int total_pixels = static_cast<int>(left_pixels_ + right_pixels_);
|
||||
@ -1632,8 +1632,8 @@ namespace nana
|
||||
{
|
||||
const bool vert = (::nana::cursor::size_we != splitter_cursor_);
|
||||
|
||||
area_rotator left(vert, leaf_left_->field_area);
|
||||
area_rotator right(vert, leaf_right_->field_area);
|
||||
rectangle_rotator left(vert, leaf_left_->field_area);
|
||||
rectangle_rotator right(vert, leaf_right_->field_area);
|
||||
auto area_px = right.right() - left.x();
|
||||
auto right_px = static_cast<int>(limit_px(leaf_right_, init_weight_.get_value(area_px), static_cast<unsigned>(area_px)));
|
||||
|
||||
@ -1643,7 +1643,7 @@ namespace nana
|
||||
else if (pos > limited_range.right())
|
||||
pos = limited_range.right();
|
||||
|
||||
area_rotator sp_r(vert, field_area);
|
||||
nana::rectangle_rotator sp_r(vert, field_area);
|
||||
sp_r.x_ref() = pos;
|
||||
|
||||
left.w_ref() = static_cast<unsigned>(pos - left.x());
|
||||
@ -1659,7 +1659,7 @@ namespace nana
|
||||
leaf_right_->collocate(wd);
|
||||
|
||||
//Set the leafs' weight
|
||||
area_rotator area(vert, div_owner->field_area);
|
||||
rectangle_rotator area(vert, div_owner->field_area);
|
||||
|
||||
double imd_rate = 100.0 / static_cast<int>(area.w());
|
||||
leaf_left_->weight.assign_percent(imd_rate * static_cast<int>(left.w()));
|
||||
@ -1674,14 +1674,14 @@ namespace nana
|
||||
splitter_.move(this->field_area);
|
||||
}
|
||||
private:
|
||||
area_rotator _m_update_splitter_range()
|
||||
rectangle_rotator _m_update_splitter_range()
|
||||
{
|
||||
const bool vert = (cursor::size_ns == splitter_cursor_);
|
||||
|
||||
area_rotator area(vert, div_owner->margin_area());
|
||||
rectangle_rotator area(vert, div_owner->margin_area());
|
||||
|
||||
area_rotator left(vert, leaf_left_->field_area);
|
||||
area_rotator right(vert, leaf_right_->field_area);
|
||||
rectangle_rotator left(vert, leaf_left_->field_area);
|
||||
rectangle_rotator right(vert, leaf_right_->field_area);
|
||||
|
||||
const int left_base = left.x(), right_base = right.right();
|
||||
int pos = left_base;
|
||||
|
@ -52,20 +52,11 @@ namespace nana
|
||||
pos = screen_pos.x;
|
||||
}
|
||||
|
||||
if(scale >= fixedsize * 2)
|
||||
{
|
||||
if(pos < static_cast<int>(fixedsize))
|
||||
const auto bound_pos = static_cast<int>(scale >= fixedsize * 2 ? fixedsize : scale / 2);
|
||||
if (pos < bound_pos)
|
||||
return buttons::first;
|
||||
if(pos > static_cast<int>(scale - fixedsize))
|
||||
if (pos > static_cast<int>(scale) - bound_pos)
|
||||
return buttons::second;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(pos < static_cast<int>(scale / 2))
|
||||
return buttons::first;
|
||||
if(pos > static_cast<int>(scale / 2))
|
||||
return buttons::second;
|
||||
}
|
||||
|
||||
if(metrics_.scroll_length)
|
||||
{
|
||||
@ -100,7 +91,7 @@ namespace nana
|
||||
metrics_.scroll_pos = pos;
|
||||
auto value_max = metrics_.peak - metrics_.range;
|
||||
metrics_.value = pos * value_max / scroll_area;
|
||||
if(metrics_.value < metrics_.peak - metrics_.range)
|
||||
if(metrics_.value < value_max)
|
||||
{
|
||||
int selfpos = static_cast<int>(metrics_.value * scroll_area / value_max);
|
||||
int nextpos = static_cast<int>((metrics_.value + 1) * scroll_area / value_max);
|
||||
@ -115,8 +106,9 @@ namespace nana
|
||||
|
||||
void drawer::auto_scroll()
|
||||
{
|
||||
if(_m_check())
|
||||
{
|
||||
if (!_m_check())
|
||||
return;
|
||||
|
||||
if(buttons::forward == metrics_.what)
|
||||
{ //backward
|
||||
if(metrics_.value <= metrics_.range)
|
||||
@ -132,7 +124,6 @@ namespace nana
|
||||
metrics_.value += (metrics_.range-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawer::draw(graph_reference graph, buttons what)
|
||||
{
|
||||
@ -141,26 +132,20 @@ namespace nana
|
||||
|
||||
_m_background(graph);
|
||||
|
||||
::nana::rectangle r(graph.size());
|
||||
if(vertical_)
|
||||
{
|
||||
r.y = r.height - fixedsize;
|
||||
r.height = fixedsize;
|
||||
}
|
||||
else
|
||||
{
|
||||
r.x = r.width - fixedsize;
|
||||
r.width = fixedsize;
|
||||
}
|
||||
rectangle_rotator r(vertical_, graph.size());
|
||||
r.x_ref() = static_cast<int>(r.w() - fixedsize);
|
||||
r.w_ref() = fixedsize;
|
||||
|
||||
int state = ((_m_check() == false || what == buttons::none) ? states::none : states::highlight);
|
||||
int moused_state = (_m_check() ? (metrics_.pressed ? states::selected : states::actived) : states::none);
|
||||
|
||||
auto result = r.result();
|
||||
|
||||
//draw first
|
||||
_m_draw_button(graph, { 0, 0, r.width, r.height }, buttons::first, (buttons::first == what ? moused_state : state));
|
||||
_m_draw_button(graph, { 0, 0, result.width, result.height }, buttons::first, (buttons::first == what ? moused_state : state));
|
||||
|
||||
//draw second
|
||||
_m_draw_button(graph, r, buttons::second, (buttons::second == what ? moused_state : state));
|
||||
_m_draw_button(graph, result, buttons::second, (buttons::second == what ? moused_state : state));
|
||||
|
||||
//draw scroll
|
||||
_m_draw_scroll(graph, (buttons::scroll == what ? moused_state : states::highlight));
|
||||
@ -171,33 +156,33 @@ namespace nana
|
||||
{
|
||||
graph.rectangle(true, {0xf0, 0xf0, 0xf0});
|
||||
|
||||
if(metrics_.pressed && _m_check())
|
||||
{
|
||||
int x = 0, y = 0;
|
||||
unsigned width = graph.width(), height = graph.height();
|
||||
if (!metrics_.pressed || !_m_check())
|
||||
return;
|
||||
|
||||
nana::rectangle_rotator r(vertical_, graph.size());
|
||||
if(metrics_.what == buttons::forward)
|
||||
{
|
||||
*(vertical_ ? &y : &x) = fixedsize;
|
||||
*(vertical_ ? &height: &width) = metrics_.scroll_pos;
|
||||
r.x_ref() = static_cast<int>(fixedsize);
|
||||
r.w_ref() = metrics_.scroll_pos;
|
||||
}
|
||||
else if(buttons::backward == metrics_.what)
|
||||
{
|
||||
*(vertical_ ? &y : &x) = static_cast<int>(fixedsize + metrics_.scroll_pos + metrics_.scroll_length);
|
||||
*(vertical_ ? &height: &width) = static_cast<unsigned>((vertical_ ? graph.height() : graph.width()) - (fixedsize * 2 + metrics_.scroll_pos + metrics_.scroll_length));
|
||||
r.x_ref() = static_cast<int>(fixedsize + metrics_.scroll_pos + metrics_.scroll_length);
|
||||
r.w_ref() = static_cast<unsigned>((vertical_ ? graph.height() : graph.width()) - (fixedsize * 2 + metrics_.scroll_pos + metrics_.scroll_length));
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
if(width && height)
|
||||
graph.rectangle({ x, y, width, height }, true, {0xDC, 0xDC, 0xDC});
|
||||
}
|
||||
auto result = r.result();
|
||||
if (!result.empty())
|
||||
graph.rectangle(result, true, static_cast<color_rgb>(0xDCDCDC));
|
||||
}
|
||||
|
||||
void drawer::_m_button_frame(graph_reference graph, rectangle r, int state)
|
||||
{
|
||||
if(state)
|
||||
{
|
||||
if (!state)
|
||||
return;
|
||||
|
||||
::nana::color clr{0x97, 0x97, 0x97}; //highlight
|
||||
switch(state)
|
||||
{
|
||||
@ -213,7 +198,6 @@ namespace nana
|
||||
graph.set_color(clr);
|
||||
|
||||
r.pare_off(2);
|
||||
|
||||
if(vertical_)
|
||||
{
|
||||
unsigned half = r.width / 2;
|
||||
@ -226,10 +210,8 @@ namespace nana
|
||||
graph.rectangle({r.x, r.y + static_cast<int>(r.height - half), r.width, half}, true);
|
||||
r.height -= half;
|
||||
}
|
||||
//graph.shadow_rectangle(x, y, width, height, 0xFFFFFF, color_x, !vertical_);
|
||||
graph.gradual_rectangle(r, colors::white, clr, !vertical_);
|
||||
}
|
||||
}
|
||||
|
||||
bool drawer::_m_check() const
|
||||
{
|
||||
@ -271,20 +253,11 @@ namespace nana
|
||||
{
|
||||
if(_m_check())
|
||||
{
|
||||
::nana::rectangle r(graph.size());
|
||||
rectangle_rotator r(vertical_, graph.size());
|
||||
r.x_ref() = static_cast<int>(fixedsize + metrics_.scroll_pos);
|
||||
r.w_ref() = static_cast<unsigned>(metrics_.scroll_length);
|
||||
|
||||
if(vertical_)
|
||||
{
|
||||
r.y = fixedsize + metrics_.scroll_pos;
|
||||
r.height = static_cast<unsigned>(metrics_.scroll_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
r.x = fixedsize + metrics_.scroll_pos;
|
||||
r.width = static_cast<unsigned>(metrics_.scroll_length);
|
||||
}
|
||||
|
||||
_m_button_frame(graph, r, state);
|
||||
_m_button_frame(graph, r.result(), state);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user