提交 42b070fc 编写于 作者: W wangtiantian

IssueNo:https://gitee.com/openharmony/graphic_ui/issues/I460NL

Description:fix margin bug
Sig:graphic
Feature or Bugfix:Bugfix
Binary Source:No
Signed-off-by: Nwangtiantian <wangtiantian19@huawei.com>
上级 a1b9c238
......@@ -146,26 +146,11 @@ void UIButton::SetStyleForState(uint8_t key, int64_t value, ButtonState state)
style_ = buttonStyles_[RELEASED];
int16_t width = GetWidth();
int16_t height = GetHeight();
int16_t x = GetX();
int16_t y = GetY();
buttonStyles_[state]->SetStyle(key, value);
switch (key) {
case STYLE_BORDER_WIDTH: {
SetWidth(width);
SetHeight(height);
break;
}
case STYLE_PADDING_LEFT:
case STYLE_PADDING_RIGHT: {
SetWidth(width);
break;
}
case STYLE_PADDING_TOP:
case STYLE_PADDING_BOTTOM: {
SetHeight(height);
break;
}
default:
break;
}
Rect rect(x, y, x + width - 1, y + height - 1);
UpdateRectInfo(key, rect);
}
}
......
......@@ -206,21 +206,37 @@ void UIView::SetStyle(uint8_t key, int64_t value)
}
int16_t width = GetWidth();
int16_t height = GetHeight();
int16_t x = GetX();
int16_t y = GetY();
style_->SetStyle(key, value);
Rect rect(x, y, x + width - 1, y + height - 1);
UpdateRectInfo(key, rect);
}
void UIView::UpdateRectInfo(uint8_t key, const Rect& rect)
{
switch (key) {
case STYLE_BORDER_WIDTH: {
SetWidth(width);
SetHeight(height);
SetWidth(rect.GetWidth());
SetHeight(rect.GetHeight());
break;
}
case STYLE_PADDING_LEFT:
case STYLE_PADDING_RIGHT: {
SetWidth(width);
SetWidth(rect.GetWidth());
break;
}
case STYLE_PADDING_TOP:
case STYLE_PADDING_BOTTOM: {
SetHeight(height);
SetHeight(rect.GetHeight());
break;
}
case STYLE_MARGIN_LEFT: {
SetX(rect.GetX());
break;
}
case STYLE_MARGIN_TOP: {
SetY(rect.GetY());
break;
}
default:
......
......@@ -1702,6 +1702,7 @@ protected:
uint8_t GetMixOpaScale() const;
bool IsInvalid(float percent);
void DrawViewBounds(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea);
void UpdateRectInfo(uint8_t key, const Rect& rect);
private:
Rect rect_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册