Exemple #1
0
 public TutorialDialog()
 {
     Init();
     WidthRequest = GtkUtils.ScaleGtkWidget(756);
     TransientFor = FamiStudioForm.Instance;
     SetPosition(WindowPosition.CenterOnParent);
 }
Exemple #2
0
        public CairoImage(Pixbuf pb)
        {
            pixbuf = pb;

            WidthRequest  = GtkUtils.ScaleGtkWidget((int)(pb.Width / DpiScaling.Dialog));
            HeightRequest = GtkUtils.ScaleGtkWidget((int)(pb.Height / DpiScaling.Dialog));
        }
Exemple #3
0
        public FlatButton(Pixbuf pb, string text = null)
        {
            pixbuf     = pb;
            buttonText = text;

            Events |= Gdk.EventMask.ButtonPressMask | EventMask.EnterNotifyMask | EventMask.LeaveNotifyMask | EventMask.ButtonReleaseMask;

            if (text == null)
            {
                WidthRequest  = GtkUtils.ScaleGtkWidget(40);
                HeightRequest = GtkUtils.ScaleGtkWidget(40);
            }

#if FAMISTUDIO_LINUX
            if (context == null)
            {
                context = CreatePangoContext();
            }

            var fontSize = Pango.Units.ToPixels(Style.FontDesc.Size);

            layoutNormal           = new Pango.Layout(context);
            layoutNormal.Alignment = Pango.Alignment.Left;
            layoutNormal.SetText(text);
            layoutNormal.FontDescription = Pango.FontDescription.FromString($"Quicksand {fontSize}");

            layoutBold           = new Pango.Layout(context);
            layoutBold.Alignment = Pango.Alignment.Left;
            layoutBold.SetText(text);
            layoutBold.FontDescription = Pango.FontDescription.FromString($"Quicksand Bold {fontSize}");
#endif
        }
Exemple #4
0
        private void Init()
        {
            var hbox      = new HBox(false, 0);
            var hboxYesNo = new HBox(false, 0);

            var suffix = GLTheme.DialogScaling >= 2.0f ? "@2x" : "";

            buttonYes      = new FlatButton(Gdk.Pixbuf.LoadFromResource($"FamiStudio.Resources.Yes{suffix}.png"));
            buttonNo       = new FlatButton(Gdk.Pixbuf.LoadFromResource($"FamiStudio.Resources.No{suffix}.png"));
            buttonAdvanced = new FlatButton(Gdk.Pixbuf.LoadFromResource($"FamiStudio.Resources.PlusSmall{suffix}.png"));

            buttonYes.Show();
            buttonYes.ButtonPressEvent += ButtonYes_ButtonPressEvent;
            buttonNo.Show();
            buttonNo.ButtonPressEvent       += ButtonNo_ButtonPressEvent;
            buttonAdvanced.ButtonPressEvent += ButtonAdvanced_ButtonPressEvent;

            buttonYes.TooltipText      = "Accept";
            buttonNo.TooltipText       = "Cancel";
            buttonAdvanced.TooltipText = "Toggle Advanced Options";

            hboxYesNo.PackStart(buttonYes, false, false, 0);
            hboxYesNo.PackStart(buttonNo, false, false, 0);
            hboxYesNo.Show();

            var alignLeft = new Alignment(0.0f, 0.5f, 0.0f, 0.0f);

            alignLeft.TopPadding = 5;
            alignLeft.Add(buttonAdvanced);
            alignLeft.Show();

            var alignRight = new Alignment(1.0f, 0.5f, 0.0f, 0.0f);

            alignRight.TopPadding = 5;
            alignRight.Add(hboxYesNo);
            alignRight.Show();

            hbox.Add(alignLeft);
            hbox.Add(alignRight);
            hbox.Show();

            var vbox = new VBox();

            vbox.PackStart(propertyPage, false, false, 0);
            vbox.PackStart(hbox, false, false, 0);
            vbox.Show();

            Add(vbox);

            propertyPage.PropertyWantsClose += propertyPage_PropertyWantsClose;
            propertyPage.Show();

            BorderWidth     = (uint)GtkUtils.ScaleGtkWidget(5);
            Resizable       = false;
            Decorated       = false;
            Modal           = true;
            SkipTaskbarHint = true;
            TransientFor    = FamiStudioForm.Instance;
        }
Exemple #5
0
        private Entry CreateColoredTextBox(string txt, System.Drawing.Color backColor)
        {
            var textBox = new Entry();

            textBox.Text = txt;
            textBox.ModifyBase(StateType.Normal, ToGdkColor(backColor));
            textBox.WidthRequest = GtkUtils.ScaleGtkWidget(50);
            textBox.Changed     += TextBox_Changed;

            return(textBox);
        }
        private FlatButton AddButton(string text, Gdk.Pixbuf image)
        {
            var btn = new FlatButton(image, text);

            btn.Show();
            btn.HeightRequest     = GtkUtils.ScaleGtkWidget(32);
            btn.Bold              = tabs.Count == 0;
            btn.ButtonPressEvent += Btn_ButtonPressEvent;
            buttonsVBox.PackStart(btn, false, false, 0);

            return(btn);
        }
Exemple #7
0
        private Entry CreateTextBox(string txt, int maxLength, string tooltip = null)
        {
            var textBox = new Entry();

            textBox.Text         = txt;
            textBox.MaxLength    = maxLength;
            textBox.WidthRequest = GtkUtils.ScaleGtkWidget(50);
            textBox.TooltipText  = tooltip;
            textBox.Changed     += TextBox_Changed;

            return(textBox);
        }
Exemple #8
0
        public PropertyDialog(System.Drawing.Point pt, int width, bool leftAlign = false, bool topAlign = false) : base(WindowType.Toplevel)
        {
            Init();
            WidthRequest = GtkUtils.ScaleGtkWidget(width);

            initialLocation.X = GtkUtils.UnscaleWindowCoord(pt.X);
            initialLocation.Y = GtkUtils.UnscaleWindowCoord(pt.Y);

            this.leftAlign = leftAlign;
            this.topAlign  = topAlign;

            Move(pt.X, pt.Y);
        }
Exemple #9
0
        void RadioLabel_SizeAllocated(object o, SizeAllocatedArgs args)
        {
            var radio = o as RadioButton;
            var idx   = GetPropertyIndex(radio);
            var prop  = properties[idx];

            if (prop.multilineLabelText != null)
            {
                var lbl = radio.Child as Label;
                lbl.Text                = prop.multilineLabelText;
                lbl.WidthRequest        = args.Allocation.Width - GtkUtils.ScaleGtkWidget(32);
                prop.multilineLabelText = null;
            }
        }
Exemple #10
0
        public CheckBoxList(string[] values, bool[] selected)
        {
            vbox = new VBox();
            vbox.Show();

            CreateCheckboxes(values, selected);

            var scroll = new ScrolledWindow();

            scroll.SetPolicy(PolicyType.Never, PolicyType.Automatic);
            scroll.AddWithViewport(vbox);
            scroll.Show();
            scroll.Child.HeightRequest = GtkUtils.ScaleGtkWidget(200);

            Add(scroll);
        }
Exemple #11
0
        public PropertyDialog(int width, bool canAccept = true, bool canCancel = true, Window parent = null) : base(WindowType.Toplevel)
        {
            Init();
            WidthRequest = GtkUtils.ScaleGtkWidget(width);

            if (!canAccept)
            {
                buttonYes.Hide();
            }
            if (!canCancel)
            {
                buttonNo.Hide();
            }

            TransientFor = parent != null ? parent : FamiStudioForm.Instance;
            SetPosition(WindowPosition.CenterOnParent);
        }
Exemple #12
0
        private ComboBox CreateDropDownList(string[] values, string value, string tooltip = null)
        {
            var cb = ComboBox.NewText();

            for (int i = 0; i < values.Length; i++)
            {
                cb.AppendText(values[i]);
                if (values[i] == value)
                {
                    cb.Active = i;
                }
            }

            cb.Sensitive    = values.Length > 0;
            cb.TooltipText  = tooltip;
            cb.WidthRequest = GtkUtils.ScaleGtkWidget(125);
            cb.Changed     += Cb_Changed;

            return(cb);
        }
Exemple #13
0
        private ScrolledWindow CreateMultilineTextBox(string txt)
        {
            var textView = new TextView();

            textView.Buffer.Text   = txt;
            textView.Editable      = false;
            textView.CursorVisible = false;
            textView.ModifyFont(FontDescription.FromString(PlatformUtils.IsMacOS ? "Quicksand 10" : "Quicksand 8"));
            textView.WrapMode = Gtk.WrapMode.WordChar;
            textView.Show();

            var scroll = new ScrolledWindow(null, null);

            scroll.HscrollbarPolicy = PolicyType.Never;
            scroll.VscrollbarPolicy = PolicyType.Automatic;
            scroll.HeightRequest    = GtkUtils.ScaleGtkWidget(400);
            scroll.ShadowType       = ShadowType.EtchedIn;
            scroll.Show();
            scroll.Add(textView);

            return(scroll);
        }
Exemple #14
0
        public void Build(bool advanced = false)
        {
            var propertyCount = advanced || advancedPropertyStart < 0 ? properties.Count : advancedPropertyStart;

            Resize((uint)propertyCount, showWarnings ? 3u : 2u);

            ColumnSpacing = (uint)GtkUtils.ScaleGtkWidget(5);
            RowSpacing    = (uint)GtkUtils.ScaleGtkWidget(5);

            for (int i = 0; i < propertyCount; i++)
            {
                var prop = properties[i];

                if (!prop.visible)
                {
                    continue;
                }

                if (prop.label != null)
                {
                    Attach(prop.label, 0, 1, (uint)i, (uint)(i + 1), AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, 0, 0);
                    Attach(prop.control, 1, 2, (uint)i, (uint)(i + 1));

                    prop.label.Show();
                    prop.control.Show();
                }
                else
                {
                    var attachOption = AttachOptions.Expand | AttachOptions.Fill;

                    // HACK: Cant be bothered to deal with GTK+2 aspect ratios.
                    if (prop.control is ColorSelector img)
                    {
                        img.DesiredWidth = Toplevel.WidthRequest - GtkUtils.ScaleGtkWidget(10); // (10 = Border * 2)
                    }
                    else if (prop.control is Label lbl && lbl.Wrap)
                    {
                        attachOption = AttachOptions.Shrink | AttachOptions.Fill;
                    }

                    Attach(prop.control, 0, NColumns, (uint)i, (uint)(i + 1), attachOption, AttachOptions.Expand | AttachOptions.Fill, (uint)prop.leftMargin, 0);
                    prop.control.Show();
                }

                if (prop.warningIcon != null)
                {
                    Attach(prop.warningIcon, 2, 3, (uint)i, (uint)(i + 1), AttachOptions.Shrink, AttachOptions.Expand | AttachOptions.Fill, 0, 0);
                }
            }

            for (int i = propertyCount; i < properties.Count; i++)
            {
                var prop = properties[i];

                if (prop.label != null)
                {
                    Remove(prop.label);
                }
                Remove(prop.control);
                if (prop.warningIcon != null)
                {
                    Remove(prop.warningIcon);
                }
            }
        }
        public MultiPropertyDialog(string title, int width, int height, int tabWidth = 160)
        {
            var buttonsHBox = new HBox(false, 0);

            var suffix    = DpiScaling.Dialog >= 2.0f ? "@2x" : "";
            var buttonYes = new FlatButton(Gdk.Pixbuf.LoadFromResource($"FamiStudio.Resources.Yes{suffix}.png"));
            var buttonNo  = new FlatButton(Gdk.Pixbuf.LoadFromResource($"FamiStudio.Resources.No{suffix}.png"));

            buttonYes.Show();
            buttonYes.ButtonPressEvent += ButtonYes_ButtonPressEvent;
            buttonNo.Show();
            buttonNo.ButtonPressEvent += ButtonNo_ButtonPressEvent;

            buttonYes.TooltipText = "Accept";
            buttonNo.TooltipText  = "Cancel";

            buttonsHBox.PackStart(buttonYes, false, false, 0);
            buttonsHBox.PackStart(buttonNo, false, false, 0);
            buttonsHBox.HeightRequest = GtkUtils.ScaleGtkWidget(40);
            buttonsHBox.Show();

            var buttonsAlign = new Alignment(1.0f, 0.5f, 0.0f, 0.0f);

            buttonsAlign.TopPadding = (uint)GtkUtils.ScaleGtkWidget(5);
            buttonsAlign.Show();
            buttonsAlign.Add(buttonsHBox);

            buttonsVBox = new VBox();
            buttonsVBox.Show();
            buttonsVBox.WidthRequest = GtkUtils.ScaleGtkWidget(tabWidth);

            var buttonsVBoxPadding = new Alignment(0.0f, 0.0f, 0.0f, 0.0f);

            buttonsVBoxPadding.RightPadding = (uint)GtkUtils.ScaleGtkWidget(5);
            buttonsVBoxPadding.Show();
            buttonsVBoxPadding.Add(buttonsVBox);

            propsVBox = new VBox();
            propsVBox.Show();
            propsVBox.HeightRequest = GtkUtils.ScaleGtkWidget(210);

            mainHbox = new HBox();
            mainHbox.Show();
            mainHbox.PackStart(buttonsVBoxPadding, false, false, 0);
            mainHbox.PackStart(propsVBox, true, true, 0);

            var vbox = VBox;

            vbox.Show();
            vbox.PackStart(mainHbox);
            vbox.PackStart(buttonsAlign, false, false, 0);

            WidthRequest  = GtkUtils.ScaleGtkWidget(width);
            HeightRequest = GtkUtils.ScaleGtkWidget(height);

            BorderWidth     = (uint)GtkUtils.ScaleGtkWidget(5);
            Resizable       = false;
            Decorated       = false;
            Modal           = true;
            SkipTaskbarHint = true;
            SetPosition(WindowPosition.CenterOnParent);
            TransientFor = FamiStudioForm.Instance;
        }
Exemple #16
0
        private void Init()
        {
            var suffix = GLTheme.DialogScaling >= 2.0f ? "@2x" : "";

            buttonLeft  = new FlatButton(Gdk.Pixbuf.LoadFromResource($"FamiStudio.Resources.ArrowLeft{suffix}.png"));
            buttonRight = new FlatButton(Gdk.Pixbuf.LoadFromResource($"FamiStudio.Resources.ArrowRight{suffix}.png"));

            checkBoxDontShow          = new CheckButton();
            checkBoxDontShow.CanFocus = false;
            checkBoxDontShow.Show();

            var checkLabel = new Label();

            checkLabel.Text = "Do not show again";
            checkLabel.Show();

            buttonLeft.Show();
            buttonLeft.ButtonPressEvent += ButtonLeft_ButtonPressEvent;
            buttonRight.Show();
            buttonRight.ButtonPressEvent += ButtonRight_ButtonPressEvent;

            buttonLeft.TooltipText  = "Previous";
            buttonRight.TooltipText = "Next";

            var buttonsHbox = new HBox(false, 0);

            buttonsHbox.PackStart(buttonLeft, false, false, 0);
            buttonsHbox.PackStart(buttonRight, false, false, 0);
            buttonsHbox.Show();

            var buttonsAlign = new Alignment(1.0f, 0.5f, 0.0f, 0.0f);

            buttonsAlign.TopPadding = (uint)GtkUtils.ScaleGtkWidget(5);
            buttonsAlign.Show();
            buttonsAlign.Add(buttonsHbox);

            var checkBoxHBox = new HBox(false, 0);

            checkBoxHBox.PackStart(checkBoxDontShow, false, false, 0);
            checkBoxHBox.PackStart(checkLabel, false, false, 0);
            checkBoxHBox.Show();

            var checkBoxAlign = new Alignment(0.0f, 0.5f, 0.0f, 0.0f);

            checkBoxAlign.TopPadding = (uint)GtkUtils.ScaleGtkWidget(5);
            checkBoxAlign.Show();
            checkBoxAlign.Add(checkBoxHBox);

            var hbox = new HBox(true, 0);

            hbox.PackStart(checkBoxAlign);
            hbox.PackStart(buttonsAlign);
            hbox.Show();

            label = new Label();
            label.WidthRequest  = GtkUtils.ScaleGtkWidget(736);
            label.HeightRequest = GtkUtils.ScaleGtkWidget(64);
            label.SetAlignment(0.0f, 0.0f);
            label.Wrap = true;
            label.Show();

            image = new Image();
            image.WidthRequest  = GtkUtils.ScaleGtkWidget(736);
            image.HeightRequest = GtkUtils.ScaleGtkWidget(414);
            image.Show();

            var vbox = VBox;

            vbox.PackStart(label, false, false, 0);
            vbox.PackStart(image, false, false, 0);
            vbox.PackStart(hbox, false, false, 0);
            vbox.Show();

            BorderWidth     = (uint)GtkUtils.ScaleGtkWidget(10);
            Resizable       = false;
            Decorated       = false;
            Modal           = true;
            SkipTaskbarHint = true;

            SetPage(0);
        }
Exemple #17
0
        private void SetPage(int idx)
        {
            pageIndex          = Utils.Clamp(idx, 0, TutorialMessages.Messages.Length - 1);
            image.Pixbuf       = Gdk.Pixbuf.LoadFromResource($"FamiStudio.Resources.{TutorialMessages.Images[pageIndex]}").ScaleSimple(GtkUtils.ScaleGtkWidget(736), GtkUtils.ScaleGtkWidget(414), Gdk.InterpType.Bilinear);
            label.Text         = TutorialMessages.Messages[pageIndex];
            buttonLeft.Visible = pageIndex != 0;

            var suffix = GLTheme.DialogScaling >= 2.0f ? "@2x" : "";

            buttonRight.Pixbuf = pageIndex == TutorialMessages.Messages.Length - 1 ?
                                 Gdk.Pixbuf.LoadFromResource($"FamiStudio.Resources.Yes{suffix}.png") :
                                 Gdk.Pixbuf.LoadFromResource($"FamiStudio.Resources.ArrowRight{suffix}.png");
        }
Exemple #18
0
        private ScrolledWindow CreateTreeView(ColumnDesc[] columnDescs, object[,] data, int height)
        {
            var treeView = new TreeView();

            for (int i = 0; i < columnDescs.Length; i++)
            {
                var desc     = columnDescs[i];
                var renderer = (CellRenderer)null;
                var attr     = "text";

                switch (desc.Type)
                {
                case ColumnType.Label:
                {
                    var textRenderer = new CellRendererText();
                    renderer = textRenderer;
                    break;
                }

                case ColumnType.CheckBox:
                {
                    var toggleRenderer = new CellRendererToggle();
                    toggleRenderer.Toggled += ToggleRenderer_Toggled;
                    renderer = toggleRenderer;
                    attr     = "active";
                    break;
                }

                case ColumnType.DropDown:
                {
                    var comboRenderer = new CellRendererCombo();
                    var listStore     = new ListStore(typeof(string));
                    for (int j = 0; j < desc.DropDownValues.Length; j++)
                    {
                        listStore.AppendValues(desc.DropDownValues[j]);
                    }
                    comboRenderer.Editable   = true;
                    comboRenderer.HasEntry   = false;
                    comboRenderer.Model      = listStore;
                    comboRenderer.Edited    += ComboRenderer_Edited;
                    comboRenderer.TextColumn = 0;
                    renderer = comboRenderer;
                    break;
                }

                case ColumnType.Slider:
                {
                    // TODO : Right now, we dont apply the formatting. To support
                    // this we will need to add an extra string column to our model,
                    // update it with the formatting and tell the renderer to use
                    // that volum as the "text" attribute. Or create our own cell
                    // renderer that supports formatting.
                    var sliderRenderer = new CellRendererProgress();
                    attr     = "value";
                    renderer = sliderRenderer;
                    break;
                }

                case ColumnType.Button:
                {
                    var buttonRenderer = new CellRendererButton();
                    renderer = buttonRenderer;
                    break;
                }
                }

                renderer.Data[0] = treeView;

                var column = new TreeViewColumn(columnDescs[i].Name, renderer, attr, i);
                column.SortColumnId = -1; // Disable sorting
                treeView.AppendColumn(column);
            }

            if (data == null)
            {
                data = new string[0, 0];
            }

            treeView.Model               = CreateListStoreFromData(columnDescs, data);
            treeView.EnableGridLines     = TreeViewGridLines.Both;
            treeView.ButtonPressEvent   += TreeView_ButtonPressEvent;
            treeView.ButtonReleaseEvent += TreeView_ButtonReleaseEvent;
            treeView.Selection.Mode      = SelectionMode.Single;
            treeView.Realized           += TreeView_Realized;
            treeView.SizeAllocated      += TreeView_SizeAllocated;
            treeView.Show();

            treeView.Events            |= EventMask.PointerMotionMask;
            treeView.MotionNotifyEvent += TreeView_MotionNotifyEvent;

            var scroll = new ScrolledWindow(null, null);

            scroll.HscrollbarPolicy = PolicyType.Never;
            scroll.VscrollbarPolicy = PolicyType.Automatic;
            scroll.HeightRequest    = GtkUtils.ScaleGtkWidget(height);
            scroll.ShadowType       = ShadowType.EtchedIn;
            scroll.Add(treeView);

            return(scroll);
        }