Created
March 30, 2016 18:33
-
-
Save rmacqueen/dcf3ea7a4cb2412d2b42aa50c5755aaf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Gtk = imports.gi.Gtk; | |
Gtk.init(null); | |
let frame = new Gtk.Frame({ | |
// expand: false, | |
margin: 30 | |
}); | |
frame.set_size_request(200, 100) | |
frame.get_style_context().add_class('shadow') | |
frame.connect_after('size-allocate', function (widget, clip) { | |
clip.x -= 30; clip.y -= 30; | |
clip.width += 60; clip.height += 60; | |
frame.set_clip(clip) | |
}) | |
let css = ".shadow {background-color:red; border: 2px solid blue; box-shadow: 0px 10px 20px 10px red;}" | |
let provider = new Gtk.CssProvider(); | |
provider.load_from_data(css); | |
let context = frame.get_style_context(); | |
context.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); | |
let overlay = new Gtk.Overlay(); | |
let grid = new Gtk.Grid({ | |
expand: true, | |
halign: Gtk.Align.FILL, | |
valign: Gtk.Align.FILL, | |
}); | |
grid.set_size_request(200, 100) | |
overlay.add(grid); | |
let mwindow = new Gtk.Window({ | |
default_width: 800, | |
default_height: 600 | |
}); | |
overlay.add_overlay(frame) | |
mwindow.add(overlay); | |
mwindow.show_all(); | |
mwindow.connect('destroy', function() { Gtk.main_quit() }); | |
Gtk.main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment