mirror of
https://github.com/zhongyang219/MusicPlayer2.git
synced 2026-10-17 05:20:33 +08:00
将TopMostClicked函数改为GlobalLButtonUp和GlobalLButtonDown
This commit is contained in:
@@ -72,11 +72,6 @@ bool UiElement::ComboBox::LButtonUp(CPoint point)
|
||||
show_drop_list = !show_drop_list;
|
||||
return true;
|
||||
}
|
||||
if (show_drop_list && rect_drop_list.PtInRect(point))
|
||||
{
|
||||
drop_list->LButtonUp(point);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -121,8 +116,9 @@ bool UiElement::ComboBox::MouseLeave()
|
||||
return false;
|
||||
}
|
||||
|
||||
void UiElement::ComboBox::TopMostClicked(CPoint point)
|
||||
bool UiElement::ComboBox::GlobalLButtonUp(CPoint point)
|
||||
{
|
||||
bool rtn = false;
|
||||
if (!rect.PtInRect(point) && IsShown() && IsEnable())
|
||||
{
|
||||
if (show_drop_list && rect_drop_list.PtInRect(point))
|
||||
@@ -136,10 +132,21 @@ void UiElement::ComboBox::TopMostClicked(CPoint point)
|
||||
if (m_selection_changed_trigger)
|
||||
m_selection_changed_trigger(this);
|
||||
}
|
||||
rtn = true;
|
||||
}
|
||||
show_drop_list = false;
|
||||
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
|
||||
bool UiElement::ComboBox::GlobalLButtonDown(CPoint point)
|
||||
{
|
||||
if (IsShown() && IsEnable() && show_drop_list && rect_drop_list.PtInRect(point))
|
||||
{
|
||||
drop_list->LButtonDown(point);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UiElement::ComboBox::AddString(const std::wstring& str)
|
||||
|
||||
@@ -13,7 +13,8 @@ namespace UiElement
|
||||
virtual bool LButtonDown(CPoint point) override;
|
||||
virtual bool MouseMove(CPoint point) override;
|
||||
virtual bool MouseLeave() override;
|
||||
virtual void TopMostClicked(CPoint point) override;
|
||||
virtual bool GlobalLButtonUp(CPoint point) override;
|
||||
virtual bool GlobalLButtonDown(CPoint point) override;
|
||||
|
||||
void AddString(const std::wstring& str);
|
||||
void SetCurSel(int index);
|
||||
|
||||
@@ -138,10 +138,24 @@ void UiElement::Element::ClearRect()
|
||||
//rect = CRect();
|
||||
}
|
||||
|
||||
void UiElement::Element::TopMostClicked(CPoint point)
|
||||
bool UiElement::Element::GlobalLButtonUp(CPoint point)
|
||||
{
|
||||
for (auto& child : childLst)
|
||||
child->TopMostClicked(point);
|
||||
{
|
||||
if (child->GlobalLButtonUp(point))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UiElement::Element::GlobalLButtonDown(CPoint point)
|
||||
{
|
||||
for (auto& child : childLst)
|
||||
{
|
||||
if (child->GlobalLButtonDown(point))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
UiElement::Element* UiElement::Element::RootElement()
|
||||
|
||||
@@ -68,7 +68,8 @@ namespace UiElement
|
||||
CRect GetRect() const; //获取此元素在界面中的矩形区域
|
||||
void SetRect(CRect _rect);
|
||||
virtual void ClearRect();
|
||||
virtual void TopMostClicked(CPoint point); //鼠标左键点击时响应,用于隐藏元素顶层的显示
|
||||
virtual bool GlobalLButtonUp(CPoint point); //响应全局鼠标左键抬起事件
|
||||
virtual bool GlobalLButtonDown(CPoint point); //响应全局鼠标左键按下事件
|
||||
|
||||
//遍历所有界面元素
|
||||
//visible_only为true时,遇到stackElement时,只遍历stackElement下面可见的子节点
|
||||
|
||||
@@ -212,8 +212,11 @@ bool UiElement::Volume::MouseWheel(int delta, CPoint point)
|
||||
return false;
|
||||
}
|
||||
|
||||
void UiElement::Volume::TopMostClicked(CPoint point)
|
||||
bool UiElement::Volume::GlobalLButtonUp(CPoint point)
|
||||
{
|
||||
bool rtn = false;
|
||||
volumn_up_btn.pressed = false;
|
||||
volumn_down_btn.pressed = false;
|
||||
if (!rect.PtInRect(point) && IsShown())
|
||||
{
|
||||
//如果已经显示了音量调整按钮,则点击音量调整时保持音量调整按钮的显示
|
||||
@@ -221,13 +224,13 @@ void UiElement::Volume::TopMostClicked(CPoint point)
|
||||
{
|
||||
if (volumn_up_btn.rect.PtInRect(point))
|
||||
{
|
||||
m_show_volume_adj = true;
|
||||
CPlayer::GetInstance().MusicControl(Command::VOLUME_ADJ, theApp.m_nc_setting_data.volum_step);
|
||||
rtn = true;
|
||||
}
|
||||
else if (volumn_down_btn.rect.PtInRect(point))
|
||||
{
|
||||
m_show_volume_adj = true;
|
||||
CPlayer::GetInstance().MusicControl(Command::VOLUME_ADJ, -theApp.m_nc_setting_data.volum_step);
|
||||
rtn = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -235,6 +238,24 @@ void UiElement::Volume::TopMostClicked(CPoint point)
|
||||
}
|
||||
}
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
|
||||
bool UiElement::Volume::GlobalLButtonDown(CPoint point)
|
||||
{
|
||||
bool rtn = false;
|
||||
if (IsShown() && IsEnable() && m_show_volume_adj)
|
||||
{
|
||||
if (volumn_up_btn.rect.PtInRect(point))
|
||||
{
|
||||
volumn_up_btn.pressed = true;
|
||||
}
|
||||
else if (volumn_down_btn.rect.PtInRect(point))
|
||||
{
|
||||
volumn_down_btn.pressed = true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UiElement::Volume::FromXmlNode(tinyxml2::XMLElement* xml_node)
|
||||
|
||||
@@ -14,7 +14,8 @@ namespace UiElement
|
||||
virtual bool MouseMove(CPoint point) override;
|
||||
virtual bool MouseWheel(int delta, CPoint point) override;
|
||||
|
||||
virtual void TopMostClicked(CPoint point) override;
|
||||
virtual bool GlobalLButtonUp(CPoint point) override;
|
||||
virtual bool GlobalLButtonDown(CPoint point) override;
|
||||
virtual void FromXmlNode(tinyxml2::XMLElement* xml_node);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -338,7 +338,8 @@ wstring CUserUi::GetUIName()
|
||||
bool CUserUi::LButtonUp(CPoint point)
|
||||
{
|
||||
auto root_element = GetMouseEventResponseElement();
|
||||
root_element->TopMostClicked(point);
|
||||
if (root_element->GlobalLButtonUp(point))
|
||||
return true;
|
||||
if (!CPlayerUIBase::LButtonUp(point) && !CPlayerUIBase::PointInMenubarArea(point) && !CPlayerUIBase::PointInTitlebarArea(point))
|
||||
{
|
||||
//显示了面板,且不是全屏面板的情况下,点击面板以外的地方关闭面板
|
||||
@@ -360,12 +361,14 @@ bool CUserUi::LButtonUp(CPoint point)
|
||||
bool CUserUi::LButtonDown(CPoint point)
|
||||
{
|
||||
m_mouse_clicked_point = point;
|
||||
auto root_element = GetMouseEventResponseElement();
|
||||
if (root_element->GlobalLButtonDown(point))
|
||||
return true;
|
||||
if (!CPlayerUIBase::LButtonDown(point))
|
||||
{
|
||||
bool rtn = false;
|
||||
if (!CPlayerUIBase::PointInMenubarArea(point) && !CPlayerUIBase::PointInTitlebarArea(point))
|
||||
{
|
||||
auto root_element = GetMouseEventResponseElement();
|
||||
rtn = root_element->LButtonDown(point);
|
||||
}
|
||||
return rtn;
|
||||
@@ -422,7 +425,7 @@ bool CUserUi::RButtonUp(CPoint point)
|
||||
{
|
||||
auto root_element = GetMouseEventResponseElement();
|
||||
rtn = root_element->RButtonUp(point);
|
||||
root_element->TopMostClicked(point);
|
||||
root_element->GlobalLButtonUp(point);
|
||||
}
|
||||
if (!rtn)
|
||||
rtn = CPlayerUIBase::RButtonUp(point);
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
</verticalLayout>
|
||||
</scrollArea>
|
||||
<horizontalLayout height="28" margin-top="8">
|
||||
<button key="settings" show_text="true"/>
|
||||
<text id="tipInfoText" type="userDefine" height="20"/>
|
||||
<button id="okBtn" icon="ok" text="%(TXT_APPLY)" height="28" show_text="true"/>
|
||||
<button id="cancelBtn" icon="cancel" text="%(TXT_CLOSE)" show_text="true"/>
|
||||
|
||||
Reference in New Issue
Block a user