A checkbox is a button that contains an image indicating the checked or unchecked state and a label
Inheritance: TextButton
示例#1
0
		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();
			}
		}
示例#2
0
		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 );
		}
        public TrackMixerEntity(Scene scene, Vector2 TracksPos, UICanvas canvas, bool[] trackbtn)
        {
            //
            // ONLY piano key entities come here
            //
            MainGameScene = scene as MainScene;              //hand entity belongs to MainScene
            //
            // Background for mixer
            //
            StartX = TracksPos.X;
            StartY = TracksPos.Y;
            //Background = scene.CreateEntity("background", new Vector2(StartX, StartY));
            //Background.Tag = 90;
            //Background.AddComponent(new SpriteRenderer(scene.Content.Load<Texture2D>("Slider/BackgroundMetal")).SetOrigin(new Vector2(0, 0)).SetRenderLayer(99));


            StartX = TracksPos.X + 10;
            StartY = TracksPos.Y + 10;
            //
            // bitmap font for checkbox
            //
            Nez.BitmapFonts.BitmapFont bf = scene.Content.Load <BitmapFont>("fonts/futura");
            slidertick = new SpriteDrawable((scene.Content.Load <Texture2D>("Slider/SliderMetalSmall")));
            sliderknob = new SpriteDrawable((scene.Content.Load <Texture2D>("Slider/SliderKnobBlk")));

            selecton  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/SelOn")));
            selectoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/SelOff")));

            soloon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/SoloOn")));
            solooff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/SoloOff")));

            muteon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/MuteOn")));
            muteoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/MuteOff")));
            //
            // Add all the buttons for each track used (I assume 16 maximum)
            //

            int trackNo = 0;

            foreach (bool trkOnOff in trackbtn)
            {
                //
                // track is being used (check mark) button is disabled
                //
                sel = canvas.Stage.AddElement(new Nez.UI.CheckBox("", new CheckBoxStyle(selectoff, selecton, bf, Color.Black)));
                sel.SetPosition(StartX, StartY);
                sel.OnClicked += MainGameScene.Track_Selection;
                sel.IsChecked  = trkOnOff;                          //on or off button?
                sel.SetDisabled(!trkOnOff);                         //if !trkOnOff = true then track not in use
                sel.Tag = trackNo;
                //
                // volume slider
                //
                slider = canvas.Stage.AddElement(new Slider(0, 100, 5, true, new SliderStyle(slidertick, sliderknob)));
                slider.SetPosition(StartX, StartY + 30);
                slider.SetHeight(150);

                slider.OnChanged += MainGameScene.Vol_Changed;
                slider.SetValue(100);
                //slider.Tag = trackNo;
                //
                // track SOLO
                //
                solo = canvas.Stage.AddElement(new Nez.UI.CheckBox("", new CheckBoxStyle(solooff, soloon, bf, Color.Black)));
                solo.SetPosition(StartX, StartY + 180);
                solo.OnClicked += MainGameScene.SoloBtn_OnClicked;
                solo.IsChecked  = false;
                solo.Tag        = trackNo;
                MainGameScene.SoloBtnGroup[trackNo] = solo;         //add solo button to the group
                //
                // track MUTE
                //
                mute = canvas.Stage.AddElement(new Nez.UI.CheckBox("", new CheckBoxStyle(muteoff, muteon, bf, Color.Black)));
                mute.SetPosition(StartX, StartY + 210);
                mute.OnClicked += MainGameScene.Track_Selection;
                mute.IsChecked  = false;
                mute.Tag        = trackNo;
                //
                // On/Off button to give track instrument/channel number
                //
                switch (trackNo)
                {
                case 0:
                    trkon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk00On")));
                    trkoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk00Off")));
                    break;

                case 1:
                    trkon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk01On")));
                    trkoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk01Off")));
                    break;

                case 2:
                    trkon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk02On")));
                    trkoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk02Off")));
                    break;

                case 3:
                    trkon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk03On")));
                    trkoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk03Off")));
                    break;

                case 4:
                    trkon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk04On")));
                    trkoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk04Off")));
                    break;

                case 5:
                    trkon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk05On")));
                    trkoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk05Off")));
                    break;

                case 6:
                    trkon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk06On")));
                    trkoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk06Off")));
                    break;

                case 7:
                    trkon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk07On")));
                    trkoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk07Off")));
                    break;

                case 8:
                    trkon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk08On")));
                    trkoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk08Off")));
                    break;

                case 9:
                    trkon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk09On")));
                    trkoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk09Off")));
                    break;

                case 10:
                    trkon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk10On")));
                    trkoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk10Off")));
                    break;

                case 11:
                    trkon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk11On")));
                    trkoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk11Off")));
                    break;

                case 12:
                    trkon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk12On")));
                    trkoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk12Off")));
                    break;

                case 13:
                    trkon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk13On")));
                    trkoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk13Off")));
                    break;

                case 14:
                    trkon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk14On")));
                    trkoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk14Off")));
                    break;

                case 15:
                    trkon  = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk15On")));
                    trkoff = new SpriteDrawable((scene.Content.Load <Texture2D>("slider/Trk15Off")));
                    break;
                }
                trk = canvas.Stage.AddElement(new Nez.UI.CheckBox("", new CheckBoxStyle(trkoff, trkoff, bf, Color.Black)));

                trk.SetPosition(StartX, StartY + 240);
                trk.OnClicked += MainGameScene.TrackBtn_OnClicked;
                trk.Tag        = trackNo;
                trk.IsChecked  = false;
                trk.SetDisabled(!trkOnOff);                      //if !trkOnOff = true then track not in use

                StartX  += 36.5f;
                trackNo += 1;
            }
        }
示例#4
0
        public void SoloBtn_OnClicked(Nez.UI.Button btn)
        {
            SoloPushedOn = btn.IsChecked;           //toggle on/off
            //
            // Solo comes here for each track
            //
            if (TrackChanl[btn.Tag] < 0)
            {
                return;
            }
            if (SoloPushedOn)
            {
                //
                // all tracks are turned off except this one
                //
                for (int i = 0; i < 16; i++)
                {
                    if (TracksInMidi[i])            //valid track
                    {
                        //
                        // turn off all tracks
                        //
                        if (TrackChanl[i] >= 0)
                        {
                            TracksPlaying[i] = false;
                            ChannelsPlaying[TrackChanl[i]] = false;
                        }
                        Nez.UI.CheckBox tmpCB = SoloBtnGroup[i];
                        tmpCB.IsChecked = false;
                    }
                }
                //
                // turn on this track (btn)
                //
                btn.IsChecked = true;
            }
            else
            {
                //
                // all tracks are back on
                //
                for (int i = 0; i < 16; i++)
                {
                    if (TracksInMidi[i])            //valid track
                    {
                        //
                        // turn on all tracks
                        //
                        if (TrackChanl[i] >= 0)
                        {
                            TracksPlaying[i] = true;
                            ChannelsPlaying[TrackChanl[i]] = true;
                        }
                    }
                }
                //
                // turn off this track (btn)
                //
                btn.IsChecked = false;
            }
            TracksPlaying[btn.Tag] = true;
            ChannelsPlaying[TrackChanl[btn.Tag]] = true;
            //
            // give info about the track
            //
            TrackBtn_OnClicked(btn);

            AllChannels = 0;
            sequencer1.Stop();
            sequencer1.Continue();
        }