Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
Merge pull request #8302 from mono/proppy-native
Browse files Browse the repository at this point in the history
Enables by default propperty panel
  • Loading branch information
sevoku authored Oct 11, 2019
2 parents 6db2d57 + 0c656ac commit 62e5edc
Show file tree
Hide file tree
Showing 18 changed files with 601 additions and 565 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class PropertyPadStyle
public NSColor Checkerboard0 { get; internal set; }
public NSColor Checkerboard1 { get; internal set; }
public NSColor ValueBlockBackgroundColor { get; internal set; }
public NSColor FrameBoxButtonBackgroundColor { get; internal set; }
public NSColor TabBorderColor { get; internal set; }
public NSColor PanelTabBackground { get; internal set; }
}
Expand All @@ -48,14 +49,16 @@ public static void LoadStyles ()
ToolbarBackgroundColor = NSColor.White;
CellBackgroundSelectedColor = NSColor.FromRgb (0.36f, 0.54f, 0.90f);


PropertyPad = new PropertyPadStyle {
Checkerboard0 = NSColor.FromRgb (255, 255, 255),
Checkerboard1 = NSColor.FromRgb (217, 217, 217),
PanelTabBackground = NSColor.FromRgb (248, 247, 248),
TabBorderColor = NSColor.FromRgba (0, 0, 0, 25),
ValueBlockBackgroundColor = NSColor.FromRgba (0, 0, 0, 20)
};
} else {
ValueBlockBackgroundColor = NSColor.FromRgba (0, 0, 0, 20),
FrameBoxButtonBackgroundColor = NSColor.FromRgb (0.36f, 0.54f, 0.90f)
};
} else {
CellBackgroundSelectedColor = NSColor.FromRgb (0.38f, 0.55f, 0.91f);
HeaderBackgroundColor = NSColor.FromRgb (0.29f, 0.29f, 0.29f);
HeaderBorderBackgroundColor = NSColor.FromRgb (0.29f, 0.29f, 0.29f);
Expand All @@ -67,8 +70,9 @@ public static void LoadStyles ()
Checkerboard1 = NSColor.FromRgb (0, 0, 0),
PanelTabBackground = NSColor.FromRgb (85, 85, 85),
TabBorderColor = NSColor.FromRgba (255, 255, 255, 0),
ValueBlockBackgroundColor = NSColor.FromRgba (255, 255, 255, 25)
};
ValueBlockBackgroundColor = NSColor.FromRgba (255, 255, 255, 25),
FrameBoxButtonBackgroundColor = NSColor.FromRgb (0.38f, 0.55f, 0.91f)
};
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,17 @@
<Compile Include="MonoDevelop.DesignerSupport.Toolbox\Styles.cs" />
<Compile Include="MonoDevelop.DesignerSupport.Toolbox\Toolbox.cs" />
<Compile Include="MonoDevelop.DesignerSupport\MacPropertyGrid.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditors\PropertyPadObjectEditor.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditors\PropertyPadEditorProvider.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditors\PropertyProviderTypeInfo.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditors\PropertyDescriptorEventInfo.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditors\PropertyInfo\DescriptorPropertyInfo.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditors\PropertyInfo\EnumDescriptorPropertyInfo.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditors\PropertyInfo\StringStandardValuesPropertyInfo.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditors\PropertyInfo\FilePathPropertyInfo.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditors\PropertyInfo\DirectoryPathPropertyInfo.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditor\ComponentModelObjectEditor.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditor\ComponentModelEditorProvider.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditor\PropertyDescriptorEventInfo.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditor\PropertyInfo\DescriptorPropertyInfo.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditor\PropertyInfo\EnumDescriptorPropertyInfo.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditor\PropertyInfo\StringStandardValuesPropertyInfo.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditor\PropertyInfo\FilePathPropertyInfo.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditor\PropertyInfo\DirectoryPathPropertyInfo.cs" />
<Compile Include="MonoDevelop.DesignerSupport\IPropertyPad.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditors\PropertyInfo\FlagDescriptorPropertyInfo.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditors\PropertyPadItem.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditor\PropertyInfo\FlagDescriptorPropertyInfo.cs" />
<Compile Include="MonoDevelop.DesignerSupport\NativePropertyEditor\ComponentModelTarget.cs" />
<Compile Include="MonoDevelop.DesignerSupport\MonoDevelopHostResourceProvider.cs" />
<Compile Include="MonoDevelop.DesignerSupport.Toolbox\IDragDataToolboxNode.cs" />
<Compile Include="MonoDevelop.DesignerSupport.Projects\ProjectFileDescriptor.BuildActionStringsConverter.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,20 @@

#if MAC

using MonoDevelop.Ide.Gui;
using MonoDevelop.Components.Commands;
using System;
using MonoDevelop.Components;
using Xamarin.PropertyEditing;
using Xamarin.PropertyEditing.Mac;
using MonoDevelop.Components.Mac;
using MonoDevelop.Ide;
using MonoDevelop.Ide.Commands;
using MonoDevelop.Components.Theming;
using AppKit;
using CoreGraphics;
using Foundation;

namespace MonoDevelop.DesignerSupport
{
class MacPropertyGrid : NSStackView, IPropertyGrid
class MacPropertyGrid : NSView, IPropertyGrid
{
MacPropertyEditorPanel propertyEditorPanel;

PropertyPadEditorProvider editorProvider;

NSScrollView scrollView;
readonly MacPropertyEditorPanel propertyEditorPanel;
ComponentModelEditorProvider editorProvider;
ComponentModelTarget currentSelectedObject;

public event EventHandler Focused;

Expand All @@ -62,66 +53,39 @@ class MacPropertyGrid : NSStackView, IPropertyGrid

public MacPropertyGrid ()
{
Orientation = NSUserInterfaceLayoutOrientation.Vertical;
Alignment = NSLayoutAttribute.Leading;
Spacing = 10;
Distribution = NSStackViewDistribution.Fill;

propertyEditorPanel = new MacPropertyEditorPanel (new MonoDevelopHostResourceProvider ());

scrollView = new NSScrollView () {
HasVerticalScroller = true,
HasHorizontalScroller = false,
propertyEditorPanel = new MacPropertyEditorPanel (new MonoDevelopHostResourceProvider ()) {
ShowHeader = false
};
scrollView.WantsLayer = true;
scrollView.BackgroundColor = Styles.HeaderBackgroundColor;
scrollView.DocumentView = propertyEditorPanel;
AddSubview (propertyEditorPanel);

AddArrangedSubview (scrollView);

propertyEditorPanel.Focused += PropertyEditorPanel_Focused;
editorProvider = new ComponentModelEditorProvider ();
editorProvider.PropertyChanged += EditorProvider_PropertyChanged;

//propertyEditorPanel.PropertiesChanged += PropertyEditorPanel_PropertiesChanged;
}

void Widget_Focused (object o, Gtk.FocusedArgs args)
{
propertyEditorPanel.Window.MakeFirstResponder (propertyEditorPanel);
propertyEditorPanel.TargetPlatform = new TargetPlatform (editorProvider) {
AutoExpandAll = true
};
propertyEditorPanel.ArrangeMode = PropertyArrangeMode.Category;
}

void PropertyEditorPanel_Focused (object sender, EventArgs e) => Focused?.Invoke (this, EventArgs.Empty);
private void EditorProvider_PropertyChanged (object sender, EventArgs e) =>
PropertyGridChanged?.Invoke (this, EventArgs.Empty);

public override void SetFrameSize (CGSize newSize)
{
scrollView.SetFrameSize (newSize);
base.SetFrameSize (newSize);
propertyEditorPanel.SetFrameSize (newSize);
}

void PropertyEditorPanel_PropertiesChanged (object sender, EventArgs e) => PropertyGridChanged?.Invoke (this, e);

public void BlankPad ()
{
propertyEditorPanel.SelectedItems.Clear ();
currentSelectedObject = null;
}

public void OnPadContentShown ()
{
if (editorProvider == null) {
editorProvider = new PropertyPadEditorProvider ();
propertyEditorPanel.TargetPlatform = new TargetPlatform (editorProvider) {
AutoExpandGroups = new string [] { "Build", "Misc", "NuGet", "Reference" }
};
propertyEditorPanel.ArrangeMode = PropertyArrangeMode.Category;
}
}

PropertyPadItem currentSelectedObject;

public void SetCurrentObject (object lastComponent, object [] propertyProviders)
{
if (lastComponent != null) {
var selection = new PropertyPadItem (lastComponent, propertyProviders);
var selection = new ComponentModelTarget (lastComponent, propertyProviders);
if (currentSelectedObject != selection) {
propertyEditorPanel.SelectedItems.Clear ();
propertyEditorPanel.SelectedItems.Add (selection);
Expand All @@ -130,23 +94,32 @@ public void SetCurrentObject (object lastComponent, object [] propertyProviders)
}
}

protected override void Dispose (bool disposing)
public void Populate (bool saveEditSession)
{
if (propertyEditorPanel != null) {
propertyEditorPanel.Focused -= PropertyEditorPanel_Focused;
}
base.Dispose (disposing);
//not implemented
}

public void Populate (bool saveEditSession)
public void SetToolbarProvider (Components.PropertyGrid.PropertyGrid.IToolbarProvider toolbarProvider)
{
//not implemented
}

public void SetToolbarProvider (Components.PropertyGrid.PropertyGrid.IToolbarProvider toolbarProvider)
public void OnPadContentShown ()
{
//not implemented
}

protected override void Dispose (bool disposing)
{
if (disposing) {
if (editorProvider != null) {
editorProvider.PropertyChanged -= EditorProvider_PropertyChanged;
editorProvider.Dispose ();
editorProvider = null;
}
}
base.Dispose (disposing);
}
}

class MacPropertyEditorPanel : PropertyEditorPanel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ public override NSColor GetNamedColor (string name)
return Styles.PropertyPad.TabBorderColor;
case ValueBlockBackgroundColor:
return Styles.PropertyPad.ValueBlockBackgroundColor;
case FrameBoxButtonBackgroundColor:
return Styles.PropertyPad.FrameBoxButtonBackgroundColor;
}
return base.GetNamedColor (name);
return NSColor.FromName (name);
}
}
}
Expand Down
Loading

0 comments on commit 62e5edc

Please sign in to comment.