On Friday, July 19, 2024 at 6:27:36 AM UTC-4 Edward K. Ream wrote:

On Thu, Jul 18, 2024 at 9:06 PM Thomas Passin <[email protected]> wrote:

Meanwhile, here's an improvement on my script for "render-focused".  The 
cognitive dissonance is gone, unnecessary or redundant code is gone, and it 
works with VR even if VR is already open in some other layout.


It works for me!  Thanks.

Next, I'd like to replace the vx switch. Leo's plugins manager can tell us 
whether VR or VR3 is running.


Not if both are enabled, which I sometimes do.  I envision the script 
reworked into a function whose argument specifies whether to use VR or 
VR3.  Then two commands could be created using that function, one for VR 
and one for VR3.

Actually there's still a bug about which version to use.  The fixed script 
is below.   All these scripts have a big problem, though. They don't play 
together and they are not reversible.  For example, Jacob's "quadrants" 
script adds a new splitter.  If you run one of these other layout scripts, 
that splitter hangs around with no widget because the other scripts don't 
know about it.  I'm going to start a new thread about how we might deal 
with this general problem.

"""Change layout to Gates # 3 "render-focused"."""
# ref: 
https://gist.github.com/gatesphere/82c9f67ca7b65d09e85208e0b2f7eca1#file-render-focused

from leo.core.leoQt import Orientation
import leo.plugins.viewrendered as vx
PLUGIN = 'VR3' if 'ed3' in vx.__name__ else 'VR'
if PLUGIN == 'VR3':
    Controller = vx.ViewRenderedController3
    cmd = 'vr3-show'
else:
    Controller = vx.ViewRenderedController
    cmd = 'vr-toggle'

gui = g.app.gui

ms = gui.find_widget_by_name(c, 'main_splitter')
ss = gui.find_widget_by_name(c, 'secondary_splitter')
lf = gui.find_widget_by_name(c, 'logFrame')
edf = gui.find_widget_by_name(c, 'bodyFrame')

init_orientation = ms.orientation()
if init_orientation != Orientation.Horizontal:
    ms.setOrientation(Orientation.Horizontal)
ss.setOrientation(Orientation.Vertical)

ms.addWidget(lf)  # Temporarily to get body to be second
ss.addWidget(edf)
ss.addWidget(lf)

h = c.hash()
vrx = vx.controllers.get(h)

if not vrx:
    vx.controllers[h] = vrx = Controller(c)

ms.addWidget(vrx)
if vrx.isHidden():
    c.doCommandByName(cmd)

ss.setSizes([100_000] * len(ss.sizes()))
ms.setSizes([100_000] * len(ms.sizes()))

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/c109af1f-4012-4a13-934c-df272d17dd39n%40googlegroups.com.

Reply via email to