From b0cc1940d3c741d86a1640a6a814cd82a624b450 Mon Sep 17 00:00:00 2001
From: Gennady Pospelov <g.pospelov@fz-juelich.de>
Date: Thu, 1 Mar 2018 11:58:52 +0100
Subject: [PATCH] Temporary hack to avoid ColorMap triggering splitter jump

---
 .../Views/IntensityDataWidgets/ColorMap.cpp   | 19 +++++++++++++++----
 .../Views/IntensityDataWidgets/ColorMap.h     |  1 +
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/GUI/coregui/Views/IntensityDataWidgets/ColorMap.cpp b/GUI/coregui/Views/IntensityDataWidgets/ColorMap.cpp
index 9675079f282..c786698fb02 100644
--- a/GUI/coregui/Views/IntensityDataWidgets/ColorMap.cpp
+++ b/GUI/coregui/Views/IntensityDataWidgets/ColorMap.cpp
@@ -23,6 +23,8 @@
 
 namespace {
 const int replot_update_interval = 10;
+const int colorbar_width_logz = 50;
+const int colorbar_width = 80;
 }
 
 ColorMap::ColorMap(QWidget* parent)
@@ -31,7 +33,8 @@ ColorMap::ColorMap(QWidget* parent)
     , m_colorMap(nullptr), m_colorScale(nullptr)
     , m_updateTimer(new UpdateTimer(replot_update_interval, this))
     , m_colorMapEvent(new ColorMapEvent(this))
-    , m_block_update(true)
+    , m_colorBarLayout(new  QCPLayoutGrid)
+    , m_block_update(true)    
 {
     initColorMap();
 
@@ -118,6 +121,7 @@ void ColorMap::setMouseTrackingEnabled(bool enable)
 //! sets logarithmic scale
 void ColorMap::setLogz(bool logz)
 {
+    m_colorBarLayout->setMinimumSize(logz ? colorbar_width_logz : colorbar_width,10);
     ColorMapUtils::setLogz(m_colorScale, logz);
 }
 
@@ -269,6 +273,13 @@ void ColorMap::initColorMap()
     m_colorScale = new QCPColorScale(m_customPlot);
     m_colorMap->setColorScale(m_colorScale);
 
+    m_colorBarLayout->addElement(0,0, m_colorScale);
+    m_colorBarLayout->setMinimumSize(colorbar_width_logz,10);
+    m_colorBarLayout->setMargins(QMargins(0,0,0,0));
+
+    m_colorScale->axis()->axisRect()->setMargins(QMargins(0,0,0,0));
+    m_colorScale->axis()->axisRect()->setAutoMargins(QCP::msNone);
+
     m_colorScale->setBarWidth(Constants::plot_colorbar_size);
     m_colorScale->axis()->setTickLabelFont(
         QFont(QFont().family(), Constants::plot_tick_label_size));
@@ -433,12 +444,12 @@ void ColorMap::setDataRangeFromItem(IntensityDataItem* item)
 
 void ColorMap::setColorScaleVisible(bool visibility_flag)
 {
-    m_colorScale->setVisible(visibility_flag);
+    m_colorBarLayout->setVisible(visibility_flag);
     if (visibility_flag) {
         // add it to the right of the main axis rect
-        m_customPlot->plotLayout()->addElement(0, 1, m_colorScale);
+        m_customPlot->plotLayout()->addElement(0, 1, m_colorBarLayout);
     } else {
-        m_customPlot->plotLayout()->take(m_colorScale);
+        m_customPlot->plotLayout()->take(m_colorBarLayout);
         m_customPlot->plotLayout()->simplify();
     }
 }
diff --git a/GUI/coregui/Views/IntensityDataWidgets/ColorMap.h b/GUI/coregui/Views/IntensityDataWidgets/ColorMap.h
index 8289f0716bf..0f9faafd948 100644
--- a/GUI/coregui/Views/IntensityDataWidgets/ColorMap.h
+++ b/GUI/coregui/Views/IntensityDataWidgets/ColorMap.h
@@ -120,6 +120,7 @@ private:
     QCPColorScale* m_colorScale;
     UpdateTimer* m_updateTimer;
     ColorMapEvent* m_colorMapEvent;
+    QCPLayoutGrid* m_colorBarLayout;
 
     bool m_block_update;
 };
-- 
GitLab