public void initialize( Table table, Skin skin ) { table.getRowDefaults().setPadTop( 10 ); table.add( name.Replace( "PostProcessor", string.Empty ) ).getElement<Label>().setFontScale( 1f ).setFontColor( new Color( 241, 156, 0 ) ); // if we have a component, stick a bool for enabled here if( target != null ) { _enabledCheckbox = new CheckBox( string.Empty, skin ); _enabledCheckbox.programmaticChangeEvents = false; if( target is Component ) _enabledCheckbox.isChecked = ( (Component)target ).enabled; else if( target is PostProcessor ) _enabledCheckbox.isChecked = ((PostProcessor)target ).enabled; _enabledCheckbox.onChanged += newValue => { if( target is Component ) ((Component)target).enabled = newValue; else if( target is PostProcessor ) ( (PostProcessor)target ).enabled = newValue; }; table.add( _enabledCheckbox ).right(); } table.row(); foreach( var i in _inspectors ) { i.initialize( table, skin ); table.row(); } }
public override void initialize( Table table, Skin skin ) { var button = new TextButton( _name, skin ); button.onClicked += onButtonClicked; // we could have zero or 1 param var parameters = ( _memberInfo as MethodInfo ).GetParameters(); if( parameters.Length == 0 ) { table.add( button ); return; } var parameter = parameters[0]; _parameterType = parameter.ParameterType; _textField = new TextField( _parameterType.GetTypeInfo().IsValueType ? Activator.CreateInstance( _parameterType ).ToString() : "", skin ); _textField.shouldIgnoreTextUpdatesWhileFocused = false; // add a filter for float/int if( _parameterType == typeof( float ) ) _textField.setTextFieldFilter( new FloatFilter() ); if( _parameterType == typeof( int ) ) _textField.setTextFieldFilter( new DigitsOnlyFilter() ); if( _parameterType == typeof( bool ) ) _textField.setTextFieldFilter( new BoolFilter() ); table.add( button ); table.add( _textField ).setMaxWidth( 70 ); }
public override void initialize( Table table, Skin skin ) { // if we have a RangeAttribute we need to make a slider var rangeAttr = getFieldOrPropertyAttribute<RangeAttribute>(); if( rangeAttr != null ) setupSlider( table, skin, rangeAttr.minValue, rangeAttr.maxValue, rangeAttr.stepSize ); else setupTextField( table, skin ); }
private void initialize() { defaults().space( 16 ); add( contentTable = new Table() ).expand().fill(); row(); add( buttonTable = new Table() ); contentTable.defaults().space( 16 ); buttonTable.defaults().space( 16 ); }
public override void initialize( Table table, Skin skin ) { var label = createNameLabel( table, skin ); _textField = new TextField( getValue<string>(), skin ); _textField.setTextFieldFilter( new FloatFilter() ); _textField.onTextChanged += ( field, str ) => { setValue( str ); }; table.add( label ); table.add( _textField ).setMaxWidth( 70 ); }
void setupSlider( Table table, Skin skin, float minValue, float maxValue, float stepSize ) { var label = createNameLabel( table, skin ); _slider = new Slider( skin, null, minValue, maxValue ); _slider.setStepSize( stepSize ); _slider.setValue( getValue<float>() ); _slider.onChanged += newValue => { _setter.Invoke( newValue ); }; table.add( label ); table.add( _slider ); }
public override void initialize( Table table, Skin skin ) { var label = createNameLabel( table, skin ); _checkbox = new CheckBox( string.Empty, skin ); _checkbox.programmaticChangeEvents = false; _checkbox.isChecked = getValue<bool>(); _checkbox.onChanged += newValue => { setValue( newValue ); }; table.add( label ); table.add( _checkbox ); }
void setupTextField( Table table, Skin skin ) { var label = createNameLabel( table, skin ); _textField = new TextField( getValue<float>().ToString(), skin ); _textField.setTextFieldFilter( new FloatFilter() ); _textField.onTextChanged += ( field, str ) => { float newValue; if( float.TryParse( str, out newValue ) ) setValue( newValue ); }; table.add( label ); table.add( _textField ).setMaxWidth( 70 ); }
public Window( string title, WindowStyle style ) { Assert.isNotNull( title, "title cannot be null" ); touchable = Touchable.Enabled; clip = true; titleLabel = new Label( title, new LabelStyle( style.titleFont, style.titleFontColor ) ); titleLabel.setEllipsis( true ); titleTable = new Table(); titleTable.add( titleLabel ).setExpandX().setFillX().setMinWidth( 0 ); addElement( titleTable ); setStyle( style ); width = 150; height = 150; }
public override void initialize( Table table, Skin skin ) { // add a header var label = table.add( createNameLabel( table, skin ) ).setColspan( 2 ).getElement<Label>(); label.setStyle( label.getStyle().clone() ).setFontColor( new Color( 228, 228, 76 ) ); table.row().setPadLeft( 15 ); // figure out which fiedls and properties are useful to add to the inspector var fields = ReflectionUtils.getFields( _valueType ); foreach( var field in fields ) { if( !field.IsPublic && IEnumerableExt.count( field.GetCustomAttributes<InspectableAttribute>() ) == 0 ) continue; var inspector = getInspectorForType( field.FieldType, _target, field ); if( inspector != null ) { inspector.setStructTarget( _target, this, field ); inspector.initialize( table, skin ); _inspectors.Add( inspector ); table.row().setPadLeft( 15 ); } } var properties = ReflectionUtils.getProperties( _valueType ); foreach( var prop in properties ) { if( !prop.CanRead || !prop.CanWrite ) continue; if( ( !prop.GetMethod.IsPublic || !prop.SetMethod.IsPublic ) && IEnumerableExt.count( prop.GetCustomAttributes<InspectableAttribute>() ) == 0 ) continue; var inspector = getInspectorForType( prop.PropertyType, _target, prop ); if( inspector != null ) { inspector.setStructTarget( _target, this, prop ); inspector.initialize( table, skin ); _inspectors.Add( inspector ); table.row().setPadLeft( 15 ); } } }
public override void initialize( Table table, Skin skin ) { var value = getValue<Vector2>(); var label = createNameLabel( table, skin ); var labelX = new Label( "x", skin ); _textFieldX = new TextField( value.X.ToString(), skin ); _textFieldX.setTextFieldFilter( new FloatFilter() ).setPreferredWidth( 50 ); _textFieldX.onTextChanged += ( field, str ) => { float newX; if( float.TryParse( str, out newX ) ) { var newValue = getValue<Vector2>(); newValue.X = newX; setValue( newValue ); } }; var labelY = new Label( "y", skin ); _textFieldY = new TextField( value.Y.ToString(), skin ); _textFieldY.setTextFieldFilter( new FloatFilter() ).setPreferredWidth( 50 ); _textFieldY.onTextChanged += ( field, str ) => { float newY; if( float.TryParse( str, out newY ) ) { var newValue = getValue<Vector2>(); newValue.Y = newY; setValue( newValue ); } }; var hBox = new HorizontalGroup( 5 ); hBox.addElement( labelX ); hBox.addElement( _textFieldX ); hBox.addElement( labelY ); hBox.addElement( _textFieldY ); table.add( label ); table.add( hBox ); }
public override void initialize( Table table, Skin skin ) { var label = createNameLabel( table, skin ); // gotta get ugly here _selectBox = new SelectBox<string>( skin ); var enumValues = Enum.GetValues( _valueType ); var enumStringValues = new List<string>(); foreach( var e in enumValues ) enumStringValues.Add( e.ToString() ); _selectBox.setItems( enumStringValues ); _selectBox.onChanged += selectedItem => { setValue( Enum.Parse( _valueType, selectedItem ) ); }; table.add( label ); table.add( _selectBox ).setFillX(); }
public override void initialize( Table table, Skin skin ) { // we either have a getter that gets a Material or an Effedt var effect = _valueType == typeof( Material ) ? getValue<Material>().effect : getValue<Effect>(); if( effect == null ) return; // add a header and indent our cells table.add( effect.GetType().Name ).setColspan( 2 ).getElement<Label>().setFontColor( new Color( 228, 228, 76 ) ); table.row().setPadLeft( 15 ); // figure out which properties are useful to add to the inspector var effectProps = ReflectionUtils.getProperties( effect.GetType() ); foreach( var prop in effectProps ) { if( prop.DeclaringType == typeof( Effect ) ) continue; if( !prop.CanRead || !prop.CanWrite || prop.Name == "Name" ) continue; if( ( !prop.GetMethod.IsPublic || !prop.SetMethod.IsPublic ) && IEnumerableExt.count( prop.GetCustomAttributes<InspectableAttribute>() ) == 0 ) continue; var inspector = getInspectorForType( prop.PropertyType, effect, prop ); if( inspector != null ) { inspector.setTarget( effect, prop ); inspector.initialize( table, skin ); _inspectors.Add( inspector ); table.row().setPadLeft( 15 ); } } table.row(); }
void prepCanvas() { _skin = Skin.createDefaultSkin(); // modify some of the default styles to better suit our needs var tfs = _skin.get<TextFieldStyle>(); tfs.background.leftWidth = tfs.background.rightWidth = 4; tfs.background.bottomHeight = 0; tfs.background.topHeight = 3; var checkbox = _skin.get<CheckBoxStyle>(); checkbox.checkboxOn.minWidth = checkbox.checkboxOn.minHeight = 15; checkbox.checkboxOff.minWidth = checkbox.checkboxOff.minHeight = 15; checkbox.checkboxOver.minWidth = checkbox.checkboxOver.minHeight = 15; // since we arent using this as a Component on an Entity we'll fake it here ui = new UICanvas(); ui.onAddedToEntity(); ui.stage.isFullScreen = true; _table = new Table(); _table.top().left(); _table.defaults().setPadTop( 4 ).setPadLeft( 4 ).setPadRight( 0 ).setAlign( Align.left ); _table.setBackground( new PrimitiveDrawable( new Color( 40, 40, 40 ) ) ); // wrap up the table in a ScrollPane _scrollPane = ui.stage.addElement( new ScrollPane( _table, _skin ) ); // force a validate which will layout the ScrollPane and populate the proper scrollBarWidth _scrollPane.validate(); _scrollPane.setSize( 295 + _scrollPane.getScrollBarWidth(), Screen.height ); }
public override void initialize( Table table, Skin skin ) { var value = getValue<Color>(); var label = createNameLabel( table, skin ); var labelR = new Label( "r", skin ); _textFieldR = new TextField( value.R.ToString(), skin ); _textFieldR.setMaxLength( 3 ); _textFieldR.setTextFieldFilter( new DigitsOnlyFilter() ).setPreferredWidth( 28 ); _textFieldR.onTextChanged += ( field, str ) => { int newR; if( int.TryParse( str, out newR ) ) { var newValue = getValue<Color>(); newValue.R = (byte)newR; setValue( newValue ); } }; var labelG = new Label( "g", skin ); _textFieldG = new TextField( value.G.ToString(), skin ); _textFieldG.setMaxLength( 3 ); _textFieldG.setTextFieldFilter( new DigitsOnlyFilter() ).setPreferredWidth( 28 ); _textFieldG.onTextChanged += ( field, str ) => { int newG; if( int.TryParse( str, out newG ) ) { var newValue = getValue<Color>(); newValue.G = (byte)newG; setValue( newValue ); } }; var labelB = new Label( "b", skin ); _textFieldB = new TextField( value.B.ToString(), skin ); _textFieldB.setMaxLength( 3 ); _textFieldB.setTextFieldFilter( new DigitsOnlyFilter() ).setPreferredWidth( 28 ); _textFieldB.onTextChanged += ( field, str ) => { int newB; if( int.TryParse( str, out newB ) ) { var newValue = getValue<Color>(); newValue.B = (byte)newB; setValue( newValue ); } }; var labelA = new Label( "a", skin ); _textFieldA = new TextField( value.A.ToString(), skin ); _textFieldA.setMaxLength( 3 ); _textFieldA.setTextFieldFilter( new DigitsOnlyFilter() ).setPreferredWidth( 28 ); _textFieldA.onTextChanged += ( field, str ) => { int newA; if( int.TryParse( str, out newA ) ) { var newValue = getValue<Color>(); newValue.A = (byte)newA; setValue( newValue ); } }; var hBox = new HorizontalGroup( 2 ); hBox.addElement( labelR ); hBox.addElement( _textFieldR ); hBox.addElement( labelG ); hBox.addElement( _textFieldG ); hBox.addElement( labelB ); hBox.addElement( _textFieldB ); hBox.addElement( labelA ); hBox.addElement( _textFieldA ); table.add( label ); table.add( hBox ); }
internal void SetLayout(Table table) { this.table = table; }