fix issue that progress is incorrect when it is resized
This commit is contained in:
parent
77f7bdb37c
commit
14cc7cdaa1
@ -91,19 +91,26 @@ namespace nana
|
||||
{
|
||||
return value_px_;
|
||||
}
|
||||
|
||||
bool value_px_sync()
|
||||
{
|
||||
if (widget_)
|
||||
{
|
||||
auto value_px = (widget_->size().width - border_px * 2) * value_ / max_;
|
||||
|
||||
if (value_px != value_px_)
|
||||
{
|
||||
value_px_ = value_px;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
void _m_try_refresh()
|
||||
{
|
||||
if (nullptr == widget_)
|
||||
return;
|
||||
|
||||
auto value_px = (widget_->size().width - border_px * 2) * value_ / max_;
|
||||
|
||||
if (value_px != value_px_)
|
||||
{
|
||||
value_px_ = value_px;
|
||||
if (value_px_sync())
|
||||
API::refresh_window(*widget_);
|
||||
}
|
||||
}
|
||||
private:
|
||||
nana::progress * widget_{ nullptr };
|
||||
@ -144,6 +151,9 @@ namespace nana
|
||||
auto rt_bground = rt_val;
|
||||
if (false == progress_->unknown(nullptr))
|
||||
{
|
||||
//Sync the value_px otherwise the progress is incorrect when it is resized.
|
||||
progress_->value_px_sync();
|
||||
|
||||
rt_bground.x = static_cast<int>(progress_->value_px()) + static_cast<int>(border_px);
|
||||
rt_bground.width -= progress_->value_px();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user