Skip to content

Commit

Permalink
Unset the "pane" flag in the nested toolbar templates.
Browse files Browse the repository at this point in the history
The flag appears to have unexpected side effects when set for child
windows within a nested structure.
  • Loading branch information
steve-fryatt committed Dec 31, 2021
1 parent 32454f6 commit fa64ac7
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Chapters/ch04-column-headings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ ENDPROC</code>
</section>


<section>
<section id="sect-col-head-align">
<title>Out of alignment</title>

<p>Unfortunately, any satisfaction with our new example is likely to be short-lived. If the width of the main window is reduced, and then the horizontal scroll bar used to shift the work area, we can quickly see that things go out of alignment as shown in <reference id="fig-col-head-alignment"/>. The main window&rsquo;s work area moves with the scroll bars as expected, but the toolbar&rsquo;s content remains where it was.</p>
Expand Down
58 changes: 55 additions & 3 deletions Chapters/ch05-the-nested-wimp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,18 @@
</section>


<section>
<section id="sect-nest-wimp-recreate">
<title>Re-creating our toolbar</title>

<p>To see how the Nested Wimp works, we&rsquo;ll re-create our column-heading toolbar from <reference id="chap-col-head">the last chapter</reference> using its functionality &ndash; it looked as seen in <reference id="fig-nest-wimp-reminder"/>. There will be no changes required to the templates, so we can launch straight in to the code &ndash;taking <reference id="dl-col-head-2"/> as our base.</p>
<p>To see how the Nested Wimp works, we&rsquo;ll re-create our column-heading toolbar from <reference id="chap-col-head">the last chapter</reference> using its functionality &ndash; it looked as seen in <reference id="fig-nest-wimp-reminder"/>. We will take <reference id="dl-col-head-2"/> as our base.</p>

<image id="fig-nest-wimp-reminder" file="nest-wimp-reminder.png" title="The toolbar that we&rsquo;ll be re-creating"/>

<p>The first thing that we will need to change is our application&rsquo;s <file>!Run</file> file. Since we will be using the Nested Wimp, we need to check that it is actually present on the system &ndash; which we do as seen in <reference id="list-nest-wimp-run"/>.</p>
<p>Starting with the <file>Templates</file> file, we will need to make a small change to the toolbar window: it is not necessary to set the &lsquo;window is a pane&rsquo; flag for nested windows, as the behaviour is implicit in the nesting, so we will untick <icon>Pane</icon> in the Toolbar window&rsquo;s flags as seen in <reference id="fig-nest-wimp-template"/>. The <icon>Moveable</icon> flag remains unset; there are no other changes.</p>

<image id="fig-nest-wimp-template" file="nest-wimp-template.png" title="The toolbar no longer needs the pane flag set"/>

<p>The next thing that we will need to change is our application&rsquo;s <file>!Run</file> file. Since we will be using the Nested Wimp, we need to check that it is actually present on the system &ndash; which we do as seen in <reference id="list-nest-wimp-run"/>.</p>

<code id="list-nest-wimp-run" lang="obey" title="The !Run file must test for the Nested Wimp">Set PaneDemo$Dir &lt;Obey$Dir&gt;

Expand Down Expand Up @@ -366,6 +370,54 @@ ENDPROC</code>

<download id="dl-nest-wimp-scroll" file="NestedScroll" title="Column headings with the Nested Wimp" compatibility="armv7"/>
</section>


<section>
<title>A fixed toolbar</title>

<p>If we wanted to implement the fixed &lsquo;URL bar&rsquo; from <reference id="chap-top-bar"/> with the Nested Wimp, how would we go about modifying the example above? The first thing to do is to fetch the old toolbar template from that chapter, returning to the bar with two action buttons and a writeable icon. As with the <reference id="sect-nest-wimp-recreate">column heading bar above</reference>, we will need to unset the &lsquo;window is a pane&rsquo; flag, but otherwise the template is unchanged.</p>

<p>If we look back at the changes required in <reference id="sect-col-head-align"/> to make the toolbar&rsquo;s work area follow the work area of the main window, we can see that it was simply a case of adding a single line to keep the horizontal scroll offsets in step.</p>

<code lang="bbcbasic">toolbar%!20 = main%!20 : REM X Scroll Offset</code>

<p>We can remove this line from <function>PROCopen_main_window</function>, but with the Nested Wimp there&rsquo;s one more change that needs to be made. In the nesting flags, we set the anchor point for the X scroll offset to %00 &ndash; for &ldquo;link to the work area of the parent&rdquo;. However, we no longer want the bar to scroll with the main window.</p>

<p>Instead, we should set the horizontal scroll anchor to %01, for &ldquo;link to the left or bottom (<maths>X0</maths> or <maths>Y0</maths>) of the parent&rsquo;s visible area&rdquo;. This will ensure that the left-hand end of the bar, where the two action buttons are, will remain visible as the main window changes shape.</p>

<p>The updated part of <function>PROCopen_main_window</function> to handle the opening of the toolbar pabe can be seen in <reference id="list-nest-wimp-open-fixed"/>.</p>

<code id="list-nest-wimp-open-fixed" lang="bbcbasic" title="Opening the toolbar with a fixed scroll offset">REM Get the toolbar details

!toolbar% = ToolBarWindow%
SYS &quot;Wimp_GetWindowState&quot;,,toolbar%

REM Find the height of the toolbar pane's visible area.

bar_height% = toolbar%!16 - toolbar%!8 : REM Visible Area Y1 - Y0

REM Move the toolbar pane so that it's in the correct X and Y position
REM relative to where the main window is to go.

toolbar%!4 = main%!4 : REM Visible Area X0
toolbar%!8 = main%!16 - bar_height% : REM Visible Area Y0
toolbar%!12 = main%!12 : REM Visible Area X1
toolbar%!16 = main%!16 : REM Visible Area Y1

REM Open the toolbox pane at the top of the stack, nested into the main window.

toolbar%!28 = -1

SYS &quot;Wimp_OpenWindow&quot;,,toolbar%, &amp;4B534154, !main%, &amp;09A90000</code>

<p>When run, the application should look as seen in <reference id="fig-nest-wimp-fixed"/> &ndash; again, indistinguishable from the one that we built in <reference id="chap-top-bar"/> from a user&rsquo;s perspective.</p>

<image id="fig-nest-wimp-fixed" file="nest-wimp-fixed.png" title="The buttonbar, handled by the Nested Wimp" />

<p>The complete application can be found in <reference id="dl-nest-wimp-fixed"/>.</p>

<download id="dl-nest-wimp-fixed" file="NestedFixed" title="A fixed toolbar with the Nested Wimp" compatibility="armv7"/>
</section>
</chapter>
</manual>

24 changes: 24 additions & 0 deletions Downloads/Chapter05/NestedFixed/!PaneDemo/!Boot,feb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
| >!Boot
|
| Copyright 2021, Stephen Fryatt (info@stevefryatt.org.uk)
|
| This file is part of PaneDemo:
|
| http://www.stevefryatt.org.uk/risc-os/panes
|
| Permission is hereby granted, free of charge, to any person obtaining
| a copy of this software and associated documentation files (the
| "Software"), to deal in the Software without restriction, including
| without limitation the rights to use, copy, modify, merge, publish,
| distribute, sublicense, and/or sell copies of the Software, and to
| permit persons to whom the Software is furnished to do so.
|
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
| OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
| CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
| TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

If "<PaneDemo$Dir>"="" Then Set PaneDemo$Dir <Obey$Dir>
29 changes: 29 additions & 0 deletions Downloads/Chapter05/NestedFixed/!PaneDemo/!Run,feb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
| >!Run
|
| Copyright 2021, Stephen Fryatt (info@stevefryatt.org.uk)
|
| This file is part of PaneDemo:
|
| http://www.stevefryatt.org.uk/risc-os/panes
|
| Permission is hereby granted, free of charge, to any person obtaining
| a copy of this software and associated documentation files (the
| "Software"), to deal in the Software without restriction, including
| without limitation the rights to use, copy, modify, merge, publish,
| distribute, sublicense, and/or sell copies of the Software, and to
| permit persons to whom the Software is furnished to do so.
|
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
| OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
| CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
| TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Set PaneDemo$Dir <Obey$Dir>

RMEnsure WindowManager 3.80 Error PaneDemo requires the Nested Window Manager.

WimpSlot -min 96K -max 96K
Run <PaneDemo$Dir>.!RunImage
Binary file not shown.
Binary file not shown.
Binary file modified Downloads/Chapter05/NestedScroll/!PaneDemo/Templates,fec
Binary file not shown.
Binary file added Images/Chapter05/nest-wimp-fixed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/Chapter05/nest-wimp-template.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fa64ac7

Please sign in to comment.