forked from Mirrors/apostrophe
Set text view padding in Python instead of CSS
Otherwise scrolling calculations will be slightly offset, as the CSS padding is added *on top* of any other margin.github/fork/yochananmarqos/patch-1
parent
81f9104d9f
commit
ddcf76df47
|
@ -31,8 +31,6 @@
|
||||||
.uberwriter-window .uberwriter-editor {
|
.uberwriter-window .uberwriter-editor {
|
||||||
font-family: 'Fira Mono', monospace;
|
font-family: 'Fira Mono', monospace;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
padding-top: 80px;
|
|
||||||
padding-bottom: 16px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.uberwriter-window.small .uberwriter-editor {
|
.uberwriter-window.small .uberwriter-editor {
|
||||||
|
|
|
@ -84,8 +84,6 @@ class TextView(Gtk.TextView):
|
||||||
|
|
||||||
# Focus mode
|
# Focus mode
|
||||||
self.focus_mode = False
|
self.focus_mode = False
|
||||||
self.original_top_margin = self.props.top_margin
|
|
||||||
self.original_bottom_margin = self.props.bottom_margin
|
|
||||||
self.connect('button-release-event', self.on_button_release_event)
|
self.connect('button-release-event', self.on_button_release_event)
|
||||||
|
|
||||||
# Hemingway mode
|
# Hemingway mode
|
||||||
|
@ -127,8 +125,8 @@ class TextView(Gtk.TextView):
|
||||||
self.props.top_margin = height / 2
|
self.props.top_margin = height / 2
|
||||||
self.props.bottom_margin = height / 2
|
self.props.bottom_margin = height / 2
|
||||||
else:
|
else:
|
||||||
self.props.top_margin = self.original_top_margin
|
self.props.top_margin = 80
|
||||||
self.props.bottom_margin = self.original_bottom_margin
|
self.props.bottom_margin = 64
|
||||||
|
|
||||||
def on_button_release_event(self, _widget, _event):
|
def on_button_release_event(self, _widget, _event):
|
||||||
if self.focus_mode:
|
if self.focus_mode:
|
||||||
|
@ -159,7 +157,7 @@ class TextView(Gtk.TextView):
|
||||||
|
|
||||||
If mark is unspecified, the cursor is used."""
|
If mark is unspecified, the cursor is used."""
|
||||||
|
|
||||||
margin = 80
|
margin = 32
|
||||||
scrolled_window = self.get_ancestor(Gtk.ScrolledWindow.__gtype__)
|
scrolled_window = self.get_ancestor(Gtk.ScrolledWindow.__gtype__)
|
||||||
if not scrolled_window:
|
if not scrolled_window:
|
||||||
return
|
return
|
||||||
|
|
|
@ -701,7 +701,7 @@ class Window(Gtk.ApplicationWindow):
|
||||||
"""
|
"""
|
||||||
bg_color = self.get_style_context().get_background_color(Gtk.StateFlags.ACTIVE)
|
bg_color = self.get_style_context().get_background_color(Gtk.StateFlags.ACTIVE)
|
||||||
|
|
||||||
lg_top = cairo.LinearGradient(0, 0, 0, 35) # pylint: disable=no-member
|
lg_top = cairo.LinearGradient(0, 0, 0, 32) # pylint: disable=no-member
|
||||||
lg_top.add_color_stop_rgba(
|
lg_top.add_color_stop_rgba(
|
||||||
0, bg_color.red, bg_color.green, bg_color.blue, 1)
|
0, bg_color.red, bg_color.green, bg_color.blue, 1)
|
||||||
lg_top.add_color_stop_rgba(
|
lg_top.add_color_stop_rgba(
|
||||||
|
@ -710,12 +710,12 @@ class Window(Gtk.ApplicationWindow):
|
||||||
width = self.scrolled_window.get_allocation().width
|
width = self.scrolled_window.get_allocation().width
|
||||||
height = self.scrolled_window.get_allocation().height
|
height = self.scrolled_window.get_allocation().height
|
||||||
|
|
||||||
cr.rectangle(0, 0, width, 35)
|
cr.rectangle(0, 0, width, 32)
|
||||||
cr.set_source(lg_top)
|
cr.set_source(lg_top)
|
||||||
cr.fill()
|
cr.fill()
|
||||||
cr.rectangle(0, height - 35, width, height)
|
cr.rectangle(0, height - 32, width, height)
|
||||||
|
|
||||||
lg_btm = cairo.LinearGradient(0, height - 35, 0, height) # pylint: disable=no-member
|
lg_btm = cairo.LinearGradient(0, height - 32, 0, height) # pylint: disable=no-member
|
||||||
lg_btm.add_color_stop_rgba(
|
lg_btm.add_color_stop_rgba(
|
||||||
1, bg_color.red, bg_color.green, bg_color.blue, 1)
|
1, bg_color.red, bg_color.green, bg_color.blue, 1)
|
||||||
lg_btm.add_color_stop_rgba(
|
lg_btm.add_color_stop_rgba(
|
||||||
|
|
Loading…
Reference in New Issue