Merge pull request #1206 from jheinen/master

gr: implement title location
This commit is contained in:
Josef Heinen 2017-10-24 20:06:00 +02:00 committed by GitHub
commit 7cf40b16df

View File

@ -863,9 +863,20 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
GR.savestate() GR.savestate()
if sp[:title] != "" if sp[:title] != ""
gr_set_font(sp[:titlefont]) gr_set_font(sp[:titlefont])
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP) loc = sp[:title_location]
if loc == :left
xpos = viewport_plotarea[1]
halign = GR.TEXT_HALIGN_LEFT
elseif loc == :right
xpos = viewport_plotarea[2]
halign = GR.TEXT_HALIGN_RIGHT
else
xpos = gr_view_xcenter()
halign = GR.TEXT_HALIGN_CENTER
end
GR.settextalign(halign, GR.TEXT_VALIGN_TOP)
gr_set_textcolor(sp[:foreground_color_title]) gr_set_textcolor(sp[:foreground_color_title])
gr_text(gr_view_xcenter(), viewport_subplot[4], sp[:title]) gr_text(xpos, viewport_subplot[4], sp[:title])
end end
if xaxis[:guide] != "" if xaxis[:guide] != ""