This repository was archived by the owner on Dec 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGtkScrolledWindow.lua
More file actions
65 lines (54 loc) · 1.38 KB
/
Copy pathGtkScrolledWindow.lua
File metadata and controls
65 lines (54 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
local lgi = require("lgi")
local Gtk = lgi.require("Gtk", "3.0")
local App = Gtk.Application({
application_id = "com.github.Miqueas.Lua-GTK3-Examples.GtkScrolledWindow"
})
function App:on_startup()
Gtk.ApplicationWindow({
application = self,
default_width = 400,
default_height = 400
})
end
function App:on_activate()
self.active_window:set_titlebar(Gtk.HeaderBar({
visible = true,
show_close_button = true,
title = "GtkScrolledWindow"
}))
local Grid = Gtk.Grid({
visible = true,
column_homogeneous = true,
row_homogeneous = true,
column_spacing = 10,
row_spacing = 10,
halign = Gtk.Align.START,
valign = Gtk.Align.START
})
--[[ GtkScrolledWindow:
A container for scrollable content
]]
local Scroll = Gtk.ScrolledWindow({
visible = true,
-- Removes a shadow that is added by default
shadow_type = Gtk.ShadowType.NONE,
-- "Expands" the child width, and makes the child use the real allocated width
propagate_natural_width = true,
-- Same, but for height
propagate_natural_height = true,
Grid
})
for top = 1, 100 do
for left = 1, 100 do
Grid:attach(
Gtk.Label({ visible = true, label = "Top: "..top..". Left: "..left }),
left - 1,
top - 1,
1, 1
)
end
end
self.active_window:add(Scroll)
self.active_window:present()
end
return App:run(arg)