Skip to content

Commit 0ac999d

Browse files
authoredApr 13, 2020
Add scroll_container formspec element (redo) (#9101)
New formspec elements: - `scroll_container[<X>,<Y>;<W>,<H>;<scrollbar name>;<orientation>;<scroll factor>]` - `scroll_container_end[]` Other elements can be embedded in this element. Scrollbar must be placed manually.
1 parent 6cf15cf commit 0ac999d

File tree

11 files changed

+411
-50
lines changed

11 files changed

+411
-50
lines changed
 

Diff for: ‎build/android/jni/Android.mk

+1
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ LOCAL_SRC_FILES := \
194194
jni/src/gui/guiPasswordChange.cpp \
195195
jni/src/gui/guiPathSelectMenu.cpp \
196196
jni/src/gui/guiScrollBar.cpp \
197+
jni/src/gui/guiScrollContainer.cpp \
197198
jni/src/gui/guiSkin.cpp \
198199
jni/src/gui/guiTable.cpp \
199200
jni/src/gui/guiVolumeChange.cpp \

Diff for: ‎doc/lua_api.txt

+20
Original file line numberDiff line numberDiff line change
@@ -2102,6 +2102,26 @@ Elements
21022102
* End of a container, following elements are no longer relative to this
21032103
container.
21042104

2105+
### `scroll_container[<X>,<Y>;<W>,<H>;<scrollbar name>;<orientation>;<scroll factor>]`
2106+
2107+
* Start of a scroll_container block. All contained elements will ...
2108+
* take the scroll_container coordinate as position origin,
2109+
* be additionally moved by the current value of the scrollbar with the name
2110+
`scrollbar name` times `scroll factor` along the orientation `orientation` and
2111+
* be clipped to the rectangle defined by `X`, `Y`, `W` and `H`.
2112+
* `orientation`: possible values are `vertical` and `horizontal`.
2113+
* `scroll factor`: optional, defaults to `0.1`.
2114+
* Nesting is possible.
2115+
* Some elements might work a little different if they are in a scroll_container.
2116+
* Note: If you want the scroll_container to actually work, you also need to add a
2117+
scrollbar element with the specified name. Furthermore, it is highly recommended
2118+
to use a scrollbaroptions element on this scrollbar.
2119+
2120+
### `scroll_container_end[]`
2121+
2122+
* End of a scroll_container, following elements are no longer bound to this
2123+
container.
2124+
21052125
### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;]`
21062126

21072127
* Show an inventory list if it has been sent to the client. Nothing will

Diff for: ‎games/minimal/mods/test/formspec.lua

+67-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
local color = minetest.colorize
22

3+
local hypertext = minetest.formspec_escape([[
4+
<global halign=justify valign=center background=#CCF color=#444 actioncolor=darkblue margin=10>
5+
<center><bigger>Furnace</bigger></center>
6+
<style color=black>Furnaces</style> are <action name="crafting">crafted</action> and used by the player for the purpose of cooking food and <action name="smelting">smelting</action> various items.
7+
<item name=default:furnace float=right width=128 rotate=yes>
8+
<style color=black>Type:</style> Solid block
9+
<style color=black>Drops:</style> Itself
10+
<style color=black>Physics:</style> No
11+
<style color=black>Luminance:</style> Inactive:No Active:Yes (8)
12+
<style color=black>Flammable:</style> No
13+
<style color=black>Generated:</style> No
14+
<style color=black>Renewable:</style> Yes
15+
<style color=black>Stackable:</style> Yes (99)
16+
<style color=black>Itemstring:</style> default:furnace default:furnace_active
17+
<big>Usage</big>
18+
The furnace menu can be accessed by <action name="using">using</action> the furnace.
19+
The furnace has 3 <action name="inventory">inventories</action>: An input slot, a fuel slot and 4 output slots. The fire in the furnace will automatically start when there is a smeltable item in the input slot and a fuel in the fuel slot.
20+
As long as the fire is on, the furnace will smelt any smeltable item in the input slot, one by one, until it is empty. When the fire goes off, it will smelt the next item until there are no smeltable items and no fuel items left.
21+
The current stage of cooking can be seen by <action name="pointing">pointing</action> the furnace or by viewing the furnace menu. In the furnace menu, the flame symbol roughly shows the remaining burning time. The arrow symbol shows the progress of the current smelting process.
22+
<big>Renewing</big>
23+
Furnaces can be crafted from e.g. <action name="default:cobblestone">cobblestone</action>, a renewable resource.
24+
<big>Crafting</big>
25+
Sorry no way to display crafting yet in formspec pages.
26+
<big>Fuel</big>
27+
See <action name="smelting">Smelting</action> for a list of furnace fuels.
28+
<big>Recipes</big>
29+
See the <action name="smelting">Smelting</action> page.
30+
]])
31+
32+
333
local clip_fs = [[
434
style_type[label,button,image_button,item_image_button,
535
tabheader,scrollbar,table,animated_image
@@ -188,13 +218,48 @@ Number]
188218
animated_image[3,4.25;1,1;;test_animation.png;4;0;3]
189219
animated_image[5.5,0.5;5,2;;test_animation.png;4;100]
190220
animated_image[5.5,2.75;5,2;;test_animation.jpg;4;100]
191-
]]
221+
]],
222+
223+
"formspec_version[3]"..
224+
"size[12,12]"..
225+
"button[8.5,1;1,1;bla;Bla]"..
226+
"box[1,1;8,6;#00aa]"..
227+
"scroll_container[1,1;8,6;scrbar;vertical]"..
228+
"button[0,1;1,1;lorem;Lorem]"..
229+
"button[0,10;1,1;ipsum;Ipsum]"..
230+
"pwdfield[2,2;1,1;lorem2;Lorem]"..
231+
"list[current_player;main;4,4;1,5;]"..
232+
"box[2,5;3,2;#ffff00]"..
233+
"image[1,10;3,2;bubble.png]"..
234+
"image[3,1;bubble.png]"..
235+
"item_image[2,6;3,2;default:mese]"..
236+
"label[2,15;bla Bli\nfoo bar]"..
237+
"item_image_button[2,3;1,1;default:dirt_with_grass;itemimagebutton;ItemImageButton]"..
238+
"tooltip[0,11;3,2;Buz;#f00;#000]"..
239+
"box[0,11;3,2;#00ff00]"..
240+
"hypertext[3,13;3,3;;" .. hypertext .. "]" ..
241+
"container[0,18]"..
242+
"box[1,2;3,2;#0a0a]"..
243+
"scroll_container[1,2;3,2;scrbar2;horizontal;0.06]"..
244+
"button[0,0;6,1;butnest;Nest]"..
245+
"label[10,0.5;nest]"..
246+
"scroll_container_end[]"..
247+
"scrollbar[1,0;3.5,0.3;horizontal;scrbar2;0]"..
248+
"container_end[]"..
249+
"dropdown[0,6;2;hmdrpdwn;apple,bulb;1]"..
250+
"image_button[0,4;2,2;bubble.png;bubblebutton;bbbbtt;false;true;heart.png]"..
251+
"box[1,22.5;4,1;#a00a]"..
252+
"scroll_container_end[]"..
253+
"scrollbaroptions[max=170]".. -- lowest seen pos is: 0.1*170+6=23 (factor*max+height)
254+
"scrollbar[7.5,0;0.3,4;vertical;scrbar;0]"..
255+
"scrollbar[8,0;0.3,4;vertical;scrbarhmmm;0]"..
256+
"dropdown[0,6;2;hmdrpdwnnn;apple,bulb;1]",
192257
}
193258

194259
local function show_test_formspec(pname, page_id)
195260
page_id = page_id or 2
196261

197-
local fs = pages[page_id] .. "tabheader[0,0;6,0.65;maintabs;Real Coord,Styles,Noclip,MiscEle;" .. page_id .. ";false;false]"
262+
local fs = pages[page_id] .. "tabheader[0,0;8,0.65;maintabs;Real Coord,Styles,Noclip,MiscEle,Scroll Container;" .. page_id .. ";false;false]"
198263

199264
minetest.show_formspec(pname, "test:formspec", fs)
200265
end

Diff for: ‎src/gui/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ set(gui_SRCS
1616
${CMAKE_CURRENT_SOURCE_DIR}/guiPasswordChange.cpp
1717
${CMAKE_CURRENT_SOURCE_DIR}/guiPathSelectMenu.cpp
1818
${CMAKE_CURRENT_SOURCE_DIR}/guiScrollBar.cpp
19+
${CMAKE_CURRENT_SOURCE_DIR}/guiScrollContainer.cpp
1920
${CMAKE_CURRENT_SOURCE_DIR}/guiSkin.cpp
2021
${CMAKE_CURRENT_SOURCE_DIR}/guiTable.cpp
2122
${CMAKE_CURRENT_SOURCE_DIR}/guiHyperText.cpp

0 commit comments

Comments
 (0)
Please sign in to comment.