Created
March 14, 2017 20:34
-
-
Save rmacqueen/6e4ed04ef5f4c3ccaf11f352cd7d28d3 to your computer and use it in GitHub Desktop.
emeus breaks when using wrap on gtk label
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; | |
const Emeus = imports.gi.Emeus; | |
const Pango = imports.gi.Pango; | |
Gtk.init(null) | |
let layout1 = new Emeus.ConstraintLayout(); | |
let layout2 = new Emeus.ConstraintLayout(); | |
let grid = new Gtk.Frame(); | |
layout1.add(grid); | |
grid.add(layout2) | |
let label2 = new Gtk.Label({ | |
label: "Label 2 Label 2 Label 2 Label 2 Label 2 Label 2 Label 2 Label 2 Label 2 Label 2 Label 2 Label 2 Label 2 Label 2 ", | |
// wrap: true, | |
// wrap_mode: Pango.WrapMode.WORD_CHAR, | |
}) | |
let label3 = new Gtk.Label({ | |
label: "Label 3 Label 3 Label 3 Label 3 Label 3 Label 3 Label 3 Label 3 Label 3 Label 3 Label 3 Label 3 Label 3 Label 3 Label 3", | |
// wrap: true, | |
// wrap_mode: Pango.WrapMode.WORD_CHAR, | |
}) | |
layout2.add(label3); | |
layout2.add(label2); | |
function _add_constraint (props, layout) { | |
props.constant = props.constant || 0; | |
props.multiplier = props.multiplier || 1; | |
props.relation = props.relation || Emeus.ConstraintRelation.EQ; | |
props.source_object = props.source_object || null; | |
props.strength = props.strength || Emeus.ConstraintStrength.REQUIRED; | |
let c = new Emeus.Constraint(props); | |
layout.add_constraint(c); | |
} | |
let constraints1 = [ | |
{ | |
target_object: grid, | |
target_attribute: Emeus.ConstraintAttribute.RIGHT, | |
source_attribute: Emeus.ConstraintAttribute.RIGHT, | |
}, | |
{ | |
target_object: grid, | |
target_attribute: Emeus.ConstraintAttribute.BOTTOM, | |
source_attribute: Emeus.ConstraintAttribute.BOTTOM, | |
}, | |
{ | |
target_object: grid, | |
target_attribute: Emeus.ConstraintAttribute.HEIGHT, | |
source_attribute: Emeus.ConstraintAttribute.HEIGHT, | |
}, | |
{ | |
target_object: grid, | |
target_attribute: Emeus.ConstraintAttribute.WIDTH, | |
source_attribute: Emeus.ConstraintAttribute.WIDTH, | |
multiplier: 0.5, | |
}, | |
] | |
let constraints2 = [ | |
{ | |
target_object: label2, | |
target_attribute: Emeus.ConstraintAttribute.LEFT, | |
source_attribute: Emeus.ConstraintAttribute.LEFT, | |
source_object: null, // Changing layout2 to null here alters the final layout, even though documentation says that setting source_object to null should be equivalent to setting it to parent layout | |
}, | |
{ | |
target_object: label2, | |
target_attribute: Emeus.ConstraintAttribute.BOTTOM, | |
source_attribute: Emeus.ConstraintAttribute.BOTTOM, | |
source_object: null, // Changing layout2 to null here alters the final layout, even though documentation says that setting source_object to null should be equivalent to setting it to parent layout | |
}, | |
// { | |
// target_object: label2, | |
// target_attribute: Emeus.ConstraintAttribute.HEIGHT, | |
// source_attribute: Emeus.ConstraintAttribute.HEIGHT, | |
// source_object: null, // Changing layout2 to null here alters the final layout, even though documentation says that setting source_object to null should be equivalent to setting it to parent layout | |
// multiplier: 0.5, | |
// }, | |
{ | |
target_object: label2, | |
target_attribute: Emeus.ConstraintAttribute.WIDTH, | |
source_attribute: Emeus.ConstraintAttribute.WIDTH, | |
source_object: null, // Changing layout2 to null here alters the final layout, even though documentation says that setting source_object to null should be equivalent to setting it to parent layout | |
}, | |
{ | |
target_object: label3, | |
target_attribute: Emeus.ConstraintAttribute.LEFT, | |
source_attribute: Emeus.ConstraintAttribute.LEFT, | |
}, | |
{ | |
target_object: label3, | |
target_attribute: Emeus.ConstraintAttribute.BOTTOM, | |
source_attribute: Emeus.ConstraintAttribute.TOP, | |
source_object: label2 | |
}, | |
// { | |
// target_object: label3, | |
// target_attribute: Emeus.ConstraintAttribute.HEIGHT, | |
// source_attribute: Emeus.ConstraintAttribute.HEIGHT, | |
// multiplier: 0.5, | |
// }, | |
{ | |
target_object: label3, | |
target_attribute: Emeus.ConstraintAttribute.WIDTH, | |
source_attribute: Emeus.ConstraintAttribute.WIDTH, | |
}, | |
] | |
constraints1.forEach((props) => _add_constraint(props, layout1)) | |
constraints2.forEach((props) => _add_constraint(props, layout2)) | |
let mwindow = new Gtk.Window({ | |
default_width: 800, | |
default_height: 600 | |
}); | |
mwindow.add(layout1); | |
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