Skip to content

Commit

Permalink
add anchor support (oops)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlasky committed Feb 5, 2021
1 parent b921fc9 commit ac7db95
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/gotk3-layershell
.idea/
12 changes: 10 additions & 2 deletions example.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ func main() {
log.Fatal("Unable to create window:", err)
}
layershell.InitForWindow(win)
layershell.SetLayer(win, layershell.LAYER_SHELL_LAYER_OVERLAY)

layershell.SetAnchor(win, layershell.LAYER_SHELL_EDGE_LEFT,true);
layershell.SetAnchor(win, layershell.LAYER_SHELL_EDGE_TOP, true);
layershell.SetAnchor(win, layershell.LAYER_SHELL_EDGE_RIGHT,true);

layershell.SetLayer(win, layershell.LAYER_SHELL_LAYER_BOTTOM)
layershell.SetMargin(win, layershell.LAYER_SHELL_EDGE_TOP, 0)
layershell.SetMargin(win, layershell.LAYER_SHELL_EDGE_LEFT, 0)
layershell.SetMargin(win, layershell.LAYER_SHELL_EDGE_RIGHT,0)


win.SetTitle("Simple Example")
win.Connect("destroy", func() {
Expand All @@ -35,7 +43,7 @@ func main() {
win.Add(l)

// Set the default window size.
//win.SetDefaultSize(800, 600)
win.SetDefaultSize(800, 30)

// Recursively show all widgets contained in this window.
win.ShowAll()
Expand Down
10 changes: 10 additions & 0 deletions layershell/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ func native(window *gtk.Window) *C.GtkWindow {
return wp;
}

func boolConv(b bool) C.int {
if (b) { return C.int(1)}
return C.int(0)
}

func InitForWindow(window *gtk.Window) {
w := native(window);
C.gtk_layer_init_for_window(w)
Expand All @@ -48,6 +53,11 @@ func AutoExclusiveZoneEnable(window *gtk.Window) {
C.gtk_layer_auto_exclusive_zone_enable(w)
}

func SetAnchor(window *gtk.Window, side LayerShellEdgeFlags, pinned bool) {
w := native(window)
C.gtk_layer_set_anchor(w, C.GtkLayerShellEdge(side), boolConv(pinned))
}

func SetMargin(window *gtk.Window, side LayerShellEdgeFlags, margin int) {
w := native(window)
C.gtk_layer_set_margin(w, C.GtkLayerShellEdge(side), C.int(margin))
Expand Down

0 comments on commit ac7db95

Please sign in to comment.