I just tried to do some fine tuning on the inset offsets (minimalistic and classic so far).

1. I have decoupled the outer and inner offset at the beginning and at the end of the inset.

2. I have changed the outer offset to 1px.

I like the smaller spaces better. Now they cannot be mistaken for spaces anymore even with small font-sizes.

Though I have a non-high resolution display. Maybe it does not look as good on a high-res display. If so, maybe there should be an adjustment for high-res displays?

Daniel
From 93f644687e9d5fc161b24eb89dc35e1095278633 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Ram=C3=B6ller?= <d....@web.de>
Date: Mon, 17 Oct 2016 01:21:01 +0200
Subject: [PATCH] Some inset offset fine tuning: - Make outer inset offset
 independent of inner. - Reduced the outer offset.

---
 src/frontends/qt4/GuiFontMetrics.cpp |  4 ++--
 src/frontends/qt4/GuiPainter.cpp     |  6 +++---
 src/insets/Inset.h                   |  6 +++++-
 src/insets/InsetText.cpp             | 13 ++++++++-----
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/src/frontends/qt4/GuiFontMetrics.cpp 
b/src/frontends/qt4/GuiFontMetrics.cpp
index eade8cc..29f8f3b 100644
--- a/src/frontends/qt4/GuiFontMetrics.cpp
+++ b/src/frontends/qt4/GuiFontMetrics.cpp
@@ -254,7 +254,7 @@ void GuiFontMetrics::rectText(docstring const & str,
 {
        static int const d = Inset::TEXT_TO_INSET_OFFSET / 2;
 
-       w = width(str) + Inset::TEXT_TO_INSET_OFFSET;
+       w = width(str) + Inset::TEXT_TO_INSET_OFFSET_INSIDE + 
Inset::TEXT_TO_INSET_OFFSET_INSIDE;
        ascent = metrics_.ascent() + d;
        descent = metrics_.descent() + d;
 }
@@ -265,7 +265,7 @@ void GuiFontMetrics::buttonText(docstring const & str,
        int & w, int & ascent, int & descent) const
 {
        rectText(str, w, ascent, descent);
-       w += Inset::TEXT_TO_INSET_OFFSET;
+       w += Inset::TEXT_TO_INSET_OFFSET_INSIDE;
 }
 
 
diff --git a/src/frontends/qt4/GuiPainter.cpp b/src/frontends/qt4/GuiPainter.cpp
index e613f3f..23d4e73 100644
--- a/src/frontends/qt4/GuiPainter.cpp
+++ b/src/frontends/qt4/GuiPainter.cpp
@@ -593,10 +593,10 @@ void GuiPainter::buttonText(int x, int y, docstring const 
& str,
        FontMetrics const & fm = theFontMetrics(font);
        fm.buttonText(str, width, ascent, descent);
 
-       static int const d = Inset::TEXT_TO_INSET_OFFSET / 2;
+       static int const d = Inset::TEXT_TO_INSET_OFFSET_OUTSIDE;
 
-       button(x + d, y - ascent, width - Inset::TEXT_TO_INSET_OFFSET, descent 
+ ascent, mouseHover);
-       text(x + Inset::TEXT_TO_INSET_OFFSET, y, str, font);
+       button(x + d, y - ascent, width - Inset::TEXT_TO_INSET_OFFSET_OUTSIDE, 
descent + ascent, mouseHover);
+       text(x + Inset::TEXT_TO_INSET_OFFSET_OUTSIDE + 
Inset::TEXT_TO_INSET_OFFSET_INSIDE, y, str, font);
 }
 
 
diff --git a/src/insets/Inset.h b/src/insets/Inset.h
index 48ad7be..34ba4e9 100644
--- a/src/insets/Inset.h
+++ b/src/insets/Inset.h
@@ -574,7 +574,11 @@ public:
        ///
        virtual ColorCode labelColor() const;
        //
-       enum { TEXT_TO_INSET_OFFSET = 4 };
+       enum {
+               TEXT_TO_INSET_OFFSET = 4,
+               TEXT_TO_INSET_OFFSET_INSIDE = 2,
+               TEXT_TO_INSET_OFFSET_OUTSIDE = 1
+       };
 
 protected:
        /// Constructors
diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index df4f6e2..e30d07a 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -208,7 +208,8 @@ void InsetText::metrics(MetricsInfo & mi, Dimension & dim) 
const
        mi.base.textwidth += 2 * TEXT_TO_INSET_OFFSET;
        dim.asc += TEXT_TO_INSET_OFFSET;
        dim.des += TEXT_TO_INSET_OFFSET;
-       dim.wid += 2 * TEXT_TO_INSET_OFFSET;
+       // cursor position after inset
+       dim.wid += 2 * (TEXT_TO_INSET_OFFSET_INSIDE + 
TEXT_TO_INSET_OFFSET_OUTSIDE);
 }
 
 
@@ -216,10 +217,10 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
 {
        TextMetrics & tm = pi.base.bv->textMetrics(&text_);
 
-       int const w = tm.width() + TEXT_TO_INSET_OFFSET;
+       int const w = tm.width() + 2 * TEXT_TO_INSET_OFFSET_INSIDE;
        int const yframe = y - TEXT_TO_INSET_OFFSET - tm.ascent();
        int const h = tm.height() + 2 * TEXT_TO_INSET_OFFSET;
-       int const xframe = x + TEXT_TO_INSET_OFFSET / 2;
+       int const xframe = x + TEXT_TO_INSET_OFFSET_OUTSIDE;
        bool change_drawn = false;
        if (drawFrame_ || pi.full_repaint) {
                if (pi.full_repaint)
@@ -251,7 +252,8 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
                                            pi.backgroundColor(this, false));
                // The change tracking cue must not be inherited
                Changer dummy2 = make_change(pi.change_, Change());
-               tm.draw(pi, x + TEXT_TO_INSET_OFFSET, y);
+               // text position within inset
+               tm.draw(pi, x + TEXT_TO_INSET_OFFSET_INSIDE + 
TEXT_TO_INSET_OFFSET_OUTSIDE, y);
        }
        if (canPaintChange(*pi.base.bv) && (!change_drawn || 
pi.change_.deleted()))
                // Do not draw the change tracking cue if already done by 
RowPainter and
@@ -680,7 +682,8 @@ void InsetText::getArgs(otexstream & os, OutputParams const 
& runparams_in,
 void InsetText::cursorPos(BufferView const & bv,
                CursorSlice const & sl, bool boundary, int & x, int & y) const
 {
-       x = bv.textMetrics(&text_).cursorX(sl, boundary) + TEXT_TO_INSET_OFFSET;
+       // cursor position within inset
+       x = bv.textMetrics(&text_).cursorX(sl, boundary) + 
TEXT_TO_INSET_OFFSET_INSIDE + TEXT_TO_INSET_OFFSET_OUTSIDE;
        y = bv.textMetrics(&text_).cursorY(sl, boundary);
 }
 
-- 
2.9.0.windows.1

Reply via email to