From 54e13125860b124535c48e93b8001cd1aab25d8f Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 9 Apr 2018 12:12:00 +0100 Subject: ppd value list jumps around on selecting scrolled entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the whole list is emptied and refilled on every selection, which causes visible jumps on selecting scrolled entries as its cleared, then refilled and the same position selected again. seems we need this just for the case that the custom value was selected/unselected Change-Id: I01e72cd9377027c5fd598b02dee27b682f1b92af Reviewed-on: https://gerrit.libreoffice.org/52630 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- vcl/unx/generic/print/prtsetup.cxx | 21 ++++++++++++++++++++- vcl/unx/generic/print/prtsetup.hxx | 5 +++++ vcl/unx/gtk3/gtk3gtkinst.cxx | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) (limited to 'vcl/unx') diff --git a/vcl/unx/generic/print/prtsetup.cxx b/vcl/unx/generic/print/prtsetup.cxx index 9fbbdd0617d4..2762cba2a716 100644 --- a/vcl/unx/generic/print/prtsetup.cxx +++ b/vcl/unx/generic/print/prtsetup.cxx @@ -288,6 +288,9 @@ RTSDevicePage::RTSDevicePage(weld::Widget* pPage, RTSDialog* pParent) , m_xSpaceBox(m_xBuilder->weld_combo_box_text("colorspace")) , m_xDepthBox(m_xBuilder->weld_combo_box_text("colordepth")) { + m_aReselectCustomIdle.SetInvokeHandler(LINK(this, RTSDevicePage, ImplHandleReselectHdl)); + m_aReselectCustomIdle.SetDebugName("RTSDevicePage m_aReselectCustomIdle"); + m_xPPDKeyBox->set_size_request(m_xPPDKeyBox->get_approximate_digit_width() * 32, m_xPPDKeyBox->get_height_rows(12)); @@ -438,7 +441,7 @@ IMPL_LINK( RTSDevicePage, SelectHdl, weld::TreeView&, rBox, void ) if (pKey && pValue) { m_pParent->m_aJobData.m_aContext.setValue( pKey, pValue ); - FillValueBox( pKey ); + ValueBoxChanged(pKey); } } m_pParent->SetDataModified( true ); @@ -469,13 +472,29 @@ void RTSDevicePage::FillValueBox( const PPDKey* pKey ) } pValue = m_pParent->m_aJobData.m_aContext.getValue( pKey ); m_xPPDValueBox->select_id(OUString::number(reinterpret_cast(pValue))); + + ValueBoxChanged(pKey); +} + +IMPL_LINK_NOARG(RTSDevicePage, ImplHandleReselectHdl, Timer*, void) +{ + //in case selected entry is now not visible select it again to scroll it into view + m_xPPDValueBox->select(m_xPPDValueBox->get_selected_index()); +} + +void RTSDevicePage::ValueBoxChanged( const PPDKey* pKey ) +{ + const PPDValue* pValue = m_pParent->m_aJobData.m_aContext.getValue(pKey); if (pValue->m_bCustomOption) { m_pCustomValue = pValue; m_pParent->m_aJobData.m_aContext.setValue(pKey, pValue); m_xCustomEdit->set_text(m_pCustomValue->m_aCustomOption); m_xCustomEdit->show(); + m_aReselectCustomIdle.Start(); } + else + m_xCustomEdit->hide(); } int SetupPrinterDriver(weld::Window* pParent, ::psp::PrinterInfo& rJobData) diff --git a/vcl/unx/generic/print/prtsetup.hxx b/vcl/unx/generic/print/prtsetup.hxx index 8162150447a9..d9f2f67df911 100644 --- a/vcl/unx/generic/print/prtsetup.hxx +++ b/vcl/unx/generic/print/prtsetup.hxx @@ -20,6 +20,7 @@ #ifndef INCLUDED_VCL_GENERIC_PRINT_PRTSETUP_HXX #define INCLUDED_VCL_GENERIC_PRINT_PRTSETUP_HXX +#include #include #include #include @@ -114,9 +115,13 @@ private: std::unique_ptr m_xDepthBox; void FillValueBox( const ::psp::PPDKey* ); + void ValueBoxChanged( const ::psp::PPDKey* ); + + Idle m_aReselectCustomIdle; DECL_LINK(SelectHdl, weld::TreeView&, void); DECL_LINK(ModifyHdl, weld::Entry&, void); + DECL_LINK(ImplHandleReselectHdl, Timer*, void); public: RTSDevicePage(weld::Widget* pPage, RTSDialog* pDialog); ~RTSDevicePage(); diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index f646b70d7d2a..e3e961ecf4ca 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -2737,6 +2737,7 @@ public: { GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1); gtk_tree_selection_select_path(gtk_tree_view_get_selection(m_pTreeView), path); + gtk_tree_view_scroll_to_cell(m_pTreeView, path, nullptr, false, 0, 0); gtk_tree_path_free(path); } else -- cgit