Thun/docs/VUI-docs/build/html/display.html

286 lines
18 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Display &#8212; Joy VUI 0.1 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Viewer" href="viewer.html" />
<link rel="prev" title="Core" href="core.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<span class="target" id="module-joy.vui.display"></span><div class="section" id="display">
<h1>Display<a class="headerlink" href="#display" title="Permalink to this headline"></a></h1>
<p>This module implements a simple visual display system modeled on Oberon.</p>
<p>Refer to Chapter 4 of the Project Oberon book for more information.</p>
<p>There is a Display object that manages a pygame surface and N vertical
tracks each of which manages zero or more viewers.</p>
<dl class="class">
<dt id="joy.vui.display.Display">
<em class="property">class </em><code class="descclassname">joy.vui.display.</code><code class="descname">Display</code><span class="sig-paren">(</span><em>screen</em>, <em>lookup</em>, <em>*track_ratios</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Display"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Display" title="Permalink to this definition"></a></dt>
<dd><p>Manage tracks and viewers on a screen (Pygame surface.)</p>
<p>The size and number of tracks are defined by passing in at least two
ratios, e.g. Display(screen, 1, 4, 4) would create three tracks, one
small one on the left and two larger ones of the same size, each four
times wider than the left one.</p>
<p>All tracks take up the whole height of the display screen. Tracks
manage zero or more Viewers. When you “grow” a viewer a new track is
created that overlays or hides one or two existing tracks, and when
the last viewer in an overlay track is closed the track closes too
and reveals the hidden tracks (and their viewers, if any.)</p>
<p>In order to facilitate command underlining while mouse dragging the
lookup parameter must be a function that accepts a string and returns
a Boolean indicating whether that string is a valid Joy function name.
Typically you pass in the __contains__ method of the Joy dict. This
is a case of breaking “loose coupling” to gain efficiency, as otherwise
we would have to e.g. send some sort of lookup message to the
World context object, going through the whole Display.broadcast()
machinery, etc. Not something you want to do on each MOUSEMOTION
event.</p>
<dl class="method">
<dt id="joy.vui.display.Display.at">
<code class="descname">at</code><span class="sig-paren">(</span><em>x</em>, <em>y</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Display.at"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Display.at" title="Permalink to this definition"></a></dt>
<dd><p>Return the viewer (which can be a Track) at the x, y location,
along with the relative-to-viewer-surface x and y coordinates.
If there is no viewer at the location the Track will be returned
instead.</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Display.broadcast">
<code class="descname">broadcast</code><span class="sig-paren">(</span><em>message</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Display.broadcast"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Display.broadcast" title="Permalink to this definition"></a></dt>
<dd><p>Broadcast a message to all viewers (except the sender) and all
registered handlers.</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Display.change_viewer">
<code class="descname">change_viewer</code><span class="sig-paren">(</span><em>viewer</em>, <em>y</em>, <em>relative=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Display.change_viewer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Display.change_viewer" title="Permalink to this definition"></a></dt>
<dd><p>Adjust the top of the viewer to a new y within the boundaries of
its neighbors.</p>
<p>If relative is False new_y should be in screen coords, else new_y
should be relative to the top of the viewer.</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Display.close_viewer">
<code class="descname">close_viewer</code><span class="sig-paren">(</span><em>viewer</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Display.close_viewer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Display.close_viewer" title="Permalink to this definition"></a></dt>
<dd><p>Close the viewer.</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Display.dispatch_event">
<code class="descname">dispatch_event</code><span class="sig-paren">(</span><em>event</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Display.dispatch_event"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Display.dispatch_event" title="Permalink to this definition"></a></dt>
<dd><p>Display event handling.</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Display.done_resizing">
<code class="descname">done_resizing</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Display.done_resizing"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Display.done_resizing" title="Permalink to this definition"></a></dt>
<dd><p>Helper method called directly by <code class="docutils literal notranslate"><span class="pre">MenuViewer.mouse_up()</span></code> to (hackily)
update the display when done resizing a viewer.</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Display.focus">
<code class="descname">focus</code><span class="sig-paren">(</span><em>viewer</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Display.focus"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Display.focus" title="Permalink to this definition"></a></dt>
<dd><p>Set system focus to a given viewer (or no viewer if a track.)</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Display.grow_viewer">
<code class="descname">grow_viewer</code><span class="sig-paren">(</span><em>viewer</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Display.grow_viewer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Display.grow_viewer" title="Permalink to this definition"></a></dt>
<dd><p>Cause the viewer to take up its whole track or, if it does
already, take up another track, up to the whole screen.</p>
<p>This is the inverse of closing a viewer. “Growing” a viewer
actually creates a new copy and a new track to hold it. The old
tracks and viewers are retained, and they get restored when the
covering track closes, which happens automatically when the last
viewer in the covering track is closed.</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Display.init_text">
<code class="descname">init_text</code><span class="sig-paren">(</span><em>pt</em>, <em>x</em>, <em>y</em>, <em>filename</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Display.init_text"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Display.init_text" title="Permalink to this definition"></a></dt>
<dd><p>Open and return a <code class="docutils literal notranslate"><span class="pre">TextViewer</span></code> on a given file (which must be present
in the <code class="docutils literal notranslate"><span class="pre">JOYHOME</span></code> directory.)</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Display.iter_viewers">
<code class="descname">iter_viewers</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Display.iter_viewers"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Display.iter_viewers" title="Permalink to this definition"></a></dt>
<dd><p>Iterate through all viewers yielding (viewer, x, y) three-tuples.
The x and y coordinates are screen pixels of the top-left corner
of the viewer.</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Display.open_viewer">
<code class="descname">open_viewer</code><span class="sig-paren">(</span><em>x</em>, <em>y</em>, <em>class_</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Display.open_viewer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Display.open_viewer" title="Permalink to this definition"></a></dt>
<dd><p>Open a viewer of <a href="#id1"><span class="problematic" id="id2">class_</span></a> at the x, y location on the display,
return the viewer.</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Display.redraw">
<code class="descname">redraw</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Display.redraw"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Display.redraw" title="Permalink to this definition"></a></dt>
<dd><p>Redraw all tracks (which will redraw all viewers.)</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="joy.vui.display.Track">
<em class="property">class </em><code class="descclassname">joy.vui.display.</code><code class="descname">Track</code><span class="sig-paren">(</span><em>surface</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Track"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Track" title="Permalink to this definition"></a></dt>
<dd><p>Manage a vertical strip of the display, and the viewers on it.</p>
<dl class="method">
<dt id="joy.vui.display.Track.broadcast">
<code class="descname">broadcast</code><span class="sig-paren">(</span><em>message</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Track.broadcast"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Track.broadcast" title="Permalink to this definition"></a></dt>
<dd><p>Broadcast a message to all viewers on this track (except the sender.)</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Track.change_viewer">
<code class="descname">change_viewer</code><span class="sig-paren">(</span><em>viewer</em>, <em>new_y</em>, <em>relative=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Track.change_viewer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Track.change_viewer" title="Permalink to this definition"></a></dt>
<dd><p>Adjust the top of the viewer to a new y within the boundaries of
its neighbors.</p>
<p>If relative is False new_y should be in screen coords, else new_y
should be relative to the top of the viewer.</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Track.close_viewer">
<code class="descname">close_viewer</code><span class="sig-paren">(</span><em>viewer</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Track.close_viewer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Track.close_viewer" title="Permalink to this definition"></a></dt>
<dd><p>Close the viewer, reuse the freed space.</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Track.draw">
<code class="descname">draw</code><span class="sig-paren">(</span><em>rect=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Track.draw"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Track.draw" title="Permalink to this definition"></a></dt>
<dd><p>Draw the track onto its surface, clearing all content.</p>
<p>If rect is passed only draw to that area. This supports e.g.
closing a viewer that then exposes part of the track.</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Track.open_viewer">
<code class="descname">open_viewer</code><span class="sig-paren">(</span><em>y</em>, <em>class_</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Track.open_viewer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Track.open_viewer" title="Permalink to this definition"></a></dt>
<dd><p>Open and return a viewer of class at y.</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Track.redraw">
<code class="descname">redraw</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Track.redraw"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Track.redraw" title="Permalink to this definition"></a></dt>
<dd><p>Redraw the track and all of its viewers.</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Track.split">
<code class="descname">split</code><span class="sig-paren">(</span><em>y</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Track.split"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Track.split" title="Permalink to this definition"></a></dt>
<dd><p>Split the Track at the y coordinate and return the height
available for a new viewer. Tracks manage a vertical strip of
the display screen so they dont resize their surface when split.</p>
</dd></dl>
<dl class="method">
<dt id="joy.vui.display.Track.viewer_at">
<code class="descname">viewer_at</code><span class="sig-paren">(</span><em>y</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/vui/display.html#Track.viewer_at"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.vui.display.Track.viewer_at" title="Permalink to this definition"></a></dt>
<dd><p>Return the viewer at y along with the viewer-relative y coordinate,
if theres no viewer at y return this track and y.</p>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="index.html">Joy VUI</a></h1>
<h3>Navigation</h3>
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="core.html">Core</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Display</a></li>
<li class="toctree-l1"><a class="reference internal" href="viewer.html">Viewer</a></li>
<li class="toctree-l1"><a class="reference internal" href="text_viewer.html">Text Viewer</a></li>
<li class="toctree-l1"><a class="reference internal" href="stack_viewer.html">Stack Viewer</a></li>
<li class="toctree-l1"><a class="reference internal" href="persist_task.html">Persist Task</a></li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="index.html">Documentation overview</a><ul>
<li>Previous: <a href="core.html" title="previous chapter">Core</a></li>
<li>Next: <a href="viewer.html" title="next chapter">Viewer</a></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, Simon Forman.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 1.8.5</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.9</a>
|
<a href="_sources/display.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>