Thread: Dragline Control
-
December 2nd, 2017, 00:27 #1
Archangel
- Join Date
- Apr 2008
- Location
- Virginia Beach
- Posts
- 3,096
Dragline Control
Modifications and Updates:
1: 12/2/17-Fixed the offset that was being determined when the drag was completed. Previously, the amount of growth/shrinkage of the control did not match the user's expectations based upon the visual distance between where he started and finished the drag. This has now been corrected in the lua file (attachment two below). No other changes are necessary.
This post describes a control template called the dragline that implements vertical resizing of the parent control (which should be vertically immediately above the dragline). In practice, the user can drag the dragline up to shrink the size of the control and down to increase the vertical size of the control. The dragline works in harmony with a scrollbar, as well. Based upon CoreRPG, the dragline should operate just fine with CoreRPG or any ruleset based upon CoreRPG.
- As for the rest of the window below the dynamically-resized control, you have three options for this. For controls at the bottom of a window, you won't need to worry about any controls beneath. So, in this case, you won't need to do anything other than linking the resized control (called the parent) and the dragline, as I will explain below.
- In the situation where your window form has a fixed amount of space you want to dedicate to a pair of vertically-stacked text boxes, you can place the dragline between them, and it will grow the top box and shrink the bottom box on a downward drag, or it will shrink the top box and grow the bottom box on an upward drag.
- The last option is for all other situations and relies upon an anchor control below the dragline. If you use this option, the dragline will reposition the anchor control to follow the resizing of the dragline's parent control, and the remainder of the controls anchored to the anchor control will offset themselves accordingly.
To use the dragline, you will have to place an icon graphic file (provided below as vertical_size_arrows.png) into your extension folder and add a few supporting elements into your extension's xml file. First, to provide useful visual feedback to the user during the drag, you need to make an icon resource definition that invokes the icon graphic we spoke about:
Code:<icon name="vertical_size_arrows" file="vertical_size_arrows.png" />
Code:<template name="dragger"> <genericcontrol> <invisible /> <anchored position="insidetopleft" height="10" width="20" /> <icon>vertical_size_arrows</icon> </genericcontrol> </template>
Third, to support the tooltip text for the dragline, you need to add the following string resource definition:
Code:<string name="dragline_tooltip_dragparent">Drag this line upward to reduce the height of the field above or downward to increase the height</string> <string name="dragline_tooltip_dragboth">Drag this line upward to reduce the height of the field above and reduce the height of the field below or downward to increase the height of the field above and reduce the height of the field below</string>
Code:<anchored position="insidetopleft" offset="5" height="60"> <right offset="-10" /> </anchored>
Code:<anchored position="insidetopleft" offset="5"> <height>60</height> <right offset="-10" /> </anchored>
For a persistent method of height control (that is, the control remembers the last-dragged size), the dragline supports several options.
- If the application for a dragline is such that you would expect all of the control's instances to be the same size no matter which window they are in, you can save the height setting in the campaign's registry by adding the following tag to the parent control's xml declaration:
Code:<persist>campaign</persist>
- or you can save the height setting in the user's registry by using this tag instead:
Code:<persist>user</persist>
- To have each usage of the control retain its own unique height setting after the window closes, use the following tag to store the height in the database along with the other window contents, and put it in every resizable control for which you want a separately stored value (for the curious, it will be stored in the campaign database in a field called 'height'):
Code:<persist></persist>
- If you want to control the name of the field used to store the height for some reason, place the name as the contents of the persist tag like this:
Code:<persist>size</persist>
Here is an example of a vertically-resizable control from my Generators extension that uses all of these features:
Code:<basicstring name="preprocessor"> <empty textres="generator_emptyforward" /> <anchored position="insidetopleft" offset="5"> <height>60</height> <right offset="-10" /> </anchored> <invisible /> <multilinespacing>20</multilinespacing> <persist>ysize</persist> </basicstring>
The fifth thing you may want to do is provide a second vertically-resized control by using the <target> tag of the dragline. An example would look like this:
Code:<target>secondcontrol</target>
Alternatively, if you want to have the controls beneath the resizing control to reposition dynamically with the resized control, you do so by identifying a <mooring> control in the dragline (see step six). This control need not be visible. An example might be:
Code:<mooring>tabletoplabelanchor</mooring>
Code:<template name="horizontal_dragline"> <genericcontrol> <anchored height="5"> <top anchor="bottom" relation="absolute" offset="3" /> <left /> <right /> </anchored> <frame name="quiescentdragline" /> <script>dragline_script.lua</script> </genericcontrol> </template>
Last edited by Bidmaron; January 14th, 2018 at 18:37.
-
December 2nd, 2017, 00:28 #2
Archangel
- Join Date
- Apr 2008
- Location
- Virginia Beach
- Posts
- 3,096
The following shows a dragline definition with the parent preprocessor control of the example above:
Code:<horizontal_dragline name="drag_line"> <anchored> <top> <parent>preprocessor</parent> </top> </anchored> <mooring>tabletoplabelanchor</mooring> <tooltip textres="generator_tooltip_dragpreprocessor" /> </horizontal_dragline>
Here is my complete window definition for the Generators extension that uses a resizable preprocessor box and the moored options (I omitted the script for the window, as it has no bearing on the dragline):
Code:<windowclass name="table_main" merge="join"> <sheetdata merge="join"> <basicstring name="preprocessor"> <empty textres="generator_emptyforward" /> <anchored position="insidetopleft" offset="5"> <height>60</height> <right offset="-10" /> </anchored> <invisible /> <multilinespacing>20</multilinespacing> <persist>ysize</persist> </basicstring> <stringcontrol name="label_iterations"> <anchored to="label_output" width="20"> <top /> <left anchor="right" offset="10" /> </anchored> <invisible /> <font>sheetlabelmini</font> <static textres="generator_label_iteration" /> <tooltip textres="table_tooltip_iteration" /> </stringcontrol> <scrollbar name="preprocessorbar"> <anchored to="preprocessor" /> <target>preprocessor</target> </scrollbar> <horizontal_dragline name="drag_line"> <anchored> <top> <parent>preprocessor</parent> </top> </anchored> <mooring>tabletoplabelanchor</mooring> <tooltip textres="generator_tooltip_dragpreprocessor" /> </horizontal_dragline> <line_column name="divider3" /> <string_column_full name="postprocessor"> <empty textres="generator_emptyafterward" /> <invisible /> </string_column_full> </sheetdata> </windowclass>
Here is how the Generator window looks with the 60 height specified. The generator you see in the window is a nonsense generator I am using simply to test my code, so please ignore the bogosity in the table elements themselves.
Original Height.png
Here is a screenshot showing the tooltip if the user hovers over the dragline:
With Tooltip.png
Here is a screenshot showing the user performing a drag of the dragline to increase the size:
Dragging.png
Note the dragger control attached to the cursor that gives the user visual feedback on the drag itself.
Here is a screenshot showing the window after making the preprocessor taller:
Bigger.png
If you run into any problems, let me know in this thread, and I will respond. If it is a problem with the code itself, I will look into it and post a fix when I can get around to it.
If there are any other features you'd like, post me in this thread, and I will take it under advisement.
In the future, I intend to develop a window column resizing tool that will do horizontally what the dragline does vertically in most respects. Let me know in this thread if there are any features you'd like to see in that. Currently, I plan to have it grow one column at the expense of the column on the other side of the verticaldrag, or, if you hold down control, have the column to the left grow or shrink and the window width changes accordingly.Last edited by Bidmaron; December 2nd, 2017 at 13:20.
-
December 2nd, 2017, 02:57 #3
Archangel
- Join Date
- Apr 2008
- Location
- Virginia Beach
- Posts
- 3,096
Currently, the drag does not register the vertical distance correctly, and I have not figured out the reason for the inaccuracy. It appears that the distance is consistently 5-10 pixels too high on screen. So, when you drag down, it doesn't grow enough, and when you drag up, it shrinks too much.
No other known issues.Last edited by Bidmaron; December 2nd, 2017 at 05:30.
-
December 2nd, 2017, 04:26 #4
Archangel
- Join Date
- Apr 2008
- Location
- Virginia Beach
- Posts
- 3,096
Possible improvements/adds/changes:
Double-clicking the drag-line auto-sizes the parent control so that all contents exactly fit in the control.
-
December 2nd, 2017, 05:18 #5
-
December 2nd, 2017, 05:28 #6
Archangel
- Join Date
- Apr 2008
- Location
- Virginia Beach
- Posts
- 3,096
I fixed it. The problem was that the drag implementation requires that you offset the mouse a small amount before it considers a drag to have begun. As a result, my starting coordinates were never right because the drag start did not happen where the user perceived but where the system registered start of drag.
To fix it, I had to add onHover and onHoverUpdate handlers to record the actual mouse starting location for the drag. I will repost the script file tomorrow.
-
December 2nd, 2017, 06:58 #7
Nice. Thank you. I can't wait to give it a go.
Current Projects:
Always...
Community Contributions:
Extensions: Bardic Inspiration, Druid Wild Shapes, Local Dice Tower, Library Field Filters
Tutorial Blog Series: "A Neophyte Tackles (coding) the FG Extension".
-
December 2nd, 2017, 13:22 #8
Archangel
- Join Date
- Apr 2008
- Location
- Virginia Beach
- Posts
- 3,096
Minty, it really is not as complicated as all this thread may make it seem. It is basically like adding any other template-based control: You create the control inheriting the template, tweak the xml tags, add the files provided into your extension, make a few xml declarations, and you are in business. Once you use the first dragline, it is then very easy to use it again.
-
December 2nd, 2017, 13:59 #9
Its always nice to make things do something that no one has made them do though...
-
January 13th, 2018, 19:34 #10
Bidmaron.
Thank you again for engineering this control. I am finally getting around to employing it within my extension.
I would like to ensure you get credit for your work and so would like to place crediting (and copyright?) information in any and all files specific to the dragline, either .xml or .lua, that I add to implement the control. Would it be possible to provide the text you'd like me to place as a header comment in the files?
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks