Mercurial > hg > octave-lyh
changeset 15484:0133339a51c3
hide baseline when bar group is made invisible
* __bar__.m (bars): Add listener for "visible" property. Pass additinal
info for "showbaseline" listener.
(show_baseline): New arg, prop. Handle "visibile" property for
baseline.
author | Pantxo <pantxo.diribarne@gmail.com> |
---|---|
date | Wed, 03 Oct 2012 11:06:48 -0400 |
parents | b95690c001f8 |
children | d5c04a5c8817 |
files | scripts/plot/private/__bar__.m |
diffstat | 1 files changed, 16 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/private/__bar__.m +++ b/scripts/plot/private/__bar__.m @@ -231,7 +231,8 @@ addproperty ("basevalue", hg, "data", base_value); addproperty ("baseline", hg, "data", h_baseline); - addlistener (hg, "showbaseline", @show_baseline); + addlistener (hg, "showbaseline", {@show_baseline, "showbl"}); + addlistener (hg, "visible", {@show_baseline, "visib"}); addlistener (hg, "basevalue", @move_baseline); addproperty ("barwidth", hg, "data", width); @@ -317,20 +318,27 @@ endfor endfunction -function show_baseline (h, d) +function show_baseline (h, d, prop = "") persistent recursion = false; - + ## Don't allow recursion if (! recursion) unwind_protect recursion = true; hlist = get (h, "bargroup"); - showbaseline = get (h, "showbaseline"); - for hh = hlist(:)' - if (hh != h) - set (hh, "showbaseline", showbaseline); + if (strcmp (prop, "showbl")) + showbaseline = get (h, "showbaseline"); + for hh = hlist(:)' + if (hh != h) + set (hh, "showbaseline", showbaseline); + endif + endfor + elseif (strcmp (prop, "visib")) + showbaseline = "on"; + if (all (strcmp (get (hlist, "visible"), "off"))) + showbaseline = "off"; endif - endfor + endif set (get (h, "baseline"), "visible", showbaseline); unwind_protect_cleanup recursion = false;