diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-04-14 20:13:17 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-04-15 20:44:49 +0200 |
commit | d1da1c59d196b7f6037b7e0820b81fc527d56a4c (patch) | |
tree | e5ee0df76dceb2f43a7d0a83db525978d5f95c7d /vcl/source | |
parent | fbfda267e8f4b55dff30a3827bff760565f36fdb (diff) |
tdf#148349 add a way to call the user's attention to a widget
Change-Id: I2846155a44f3e51ddd8cc1acd81e84a38b4d3934
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133030
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/app/salvtables.cxx | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 263c29ff5eea..a8fdaf2a7978 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -559,6 +559,79 @@ VclPtr<VirtualDevice> SalInstanceWidget::create_virtual_device() const DeviceFormat::DEFAULT); } +class SalFlashAttention +{ +private: + VclPtr<vcl::Window> m_xWidget; + Timer m_aFlashTimer; + Color m_aOrigControlBackground; + Wallpaper m_aOrigBackground; + bool m_bOrigControlBackground; + int m_nFlashCount; + + void SetFlash() + { + Color aColor(Application::GetSettings().GetStyleSettings().GetHighlightColor()); + m_xWidget->SetControlBackground(aColor); + } + + void ClearFlash() + { + if (m_bOrigControlBackground) + m_xWidget->SetControlBackground(m_aOrigControlBackground); + else + m_xWidget->SetControlBackground(); + } + + void Flash() + { + constexpr int FlashesWanted = 1; + + if (m_nFlashCount % 2 == 0) + ClearFlash(); + else + SetFlash(); + + if (m_nFlashCount == FlashesWanted * 2) + return; + + ++m_nFlashCount; + + m_aFlashTimer.Start(); + } + + DECL_LINK(FlashTimeout, Timer*, void); + +public: + SalFlashAttention(VclPtr<vcl::Window> xWidget) + : m_xWidget(xWidget) + , m_aFlashTimer("SalFlashAttention") + , m_bOrigControlBackground(false) + , m_nFlashCount(1) + { + m_aFlashTimer.SetTimeout(150); + m_aFlashTimer.SetInvokeHandler(LINK(this, SalFlashAttention, FlashTimeout)); + } + + void Start() + { + m_bOrigControlBackground = m_xWidget->IsControlBackground(); + if (m_bOrigControlBackground) + m_aOrigControlBackground = m_xWidget->GetControlBackground(); + m_aFlashTimer.Start(); + } + + ~SalFlashAttention() { ClearFlash(); } +}; + +IMPL_LINK_NOARG(SalFlashAttention, FlashTimeout, Timer*, void) { Flash(); } + +void SalInstanceWidget::call_attention_to() +{ + m_xFlashAttention.reset(new SalFlashAttention(m_xWidget)); + m_xFlashAttention->Start(); +} + css::uno::Reference<css::datatransfer::dnd::XDropTarget> SalInstanceWidget::get_drop_target() { return m_xWidget->GetDropTarget(); @@ -6356,6 +6429,14 @@ SalInstanceComboBoxWithEdit::SalInstanceComboBoxWithEdit(::ComboBox* pComboBox, bool SalInstanceComboBoxWithEdit::has_entry() const { return true; } +void SalInstanceComboBoxWithEdit::call_attention_to() +{ + Edit* pEdit = m_xComboBox->GetSubEdit(); + assert(pEdit); + m_xFlashAttention.reset(new SalFlashAttention(pEdit)); + m_xFlashAttention->Start(); +} + bool SalInstanceComboBoxWithEdit::changed_by_direct_pick() const { return m_bInSelect && !m_xComboBox->IsModifyByKeyboard() && !m_xComboBox->IsTravelSelect(); |