/// <summary> /// UI Element Browser Bar /// </summary> void BrowserBar(VisualElement root) { #region Browser Bar //Browser Bar Toolbar toolbar = new Toolbar(); toolbar.style.justifyContent = Justify.SpaceBetween; root.Add(toolbar); // Back Button backButton = AddToolbarButton(EditorGUIUtility.isProSkin ? GetTexture("Back") : GetTexture("Back_Alt"), Back, 5); backButton.tooltip = "Back"; backButton.SetEnabled(false); toolbar.Add(backButton); // Forward Button forwardButton = AddToolbarButton(EditorGUIUtility.isProSkin ? GetTexture("Forward") : GetTexture("Forward_Alt"), Forward, 0); forwardButton.tooltip = "Forward"; forwardButton.SetEnabled(false); toolbar.Add(forwardButton); homeButton = AddToolbarButton(EditorGUIUtility.isProSkin ? GetTexture("Home") : GetTexture("Home_Alt"), Home, 2); homeButton.tooltip = "Home"; toolbar.Add(homeButton); ToolbarButton AddToolbarButton(Texture texture, Action action, float marginLeft) { ToolbarButton toolbarButton = new ToolbarButton(action) { style = { marginLeft = marginLeft, width = 20, borderLeftWidth = marginLeft == 0 ? 0 : 1, borderColor = new Color(0.57f, 0.57f, 0.57f), borderTopLeftRadius = 2, alignItems = Align.Center, paddingBottom = 0, paddingLeft = 0, paddingRight = 0, } }; toolbarButton.Add(new Image { image = texture, style = { marginTop = 4, height = 10, width = 10 } }); return(toolbarButton); } // Search Bar ToolbarSearchField toolbarSearchField = new ToolbarSearchField(); toolbarSearchField.SetValueWithoutNotify(searchString); //ToolbarSearchField's buttons have broken hover and action pseudo-states so we have to fix that StyleSheet fixSheet = LoadAssetOfType <StyleSheet>("InbuiltFixStyles", SearchFilter.Packages); toolbarSearchField.styleSheets.Add(fixSheet); toolbarSearchField.style.flexGrow = 1; toolbarSearchField.RegisterCallback <ChangeEvent <string> >(evt => { searchString = evt.newValue; DoSearch(); }); TextField textField = toolbarSearchField.Q <TextField>(); textField.RegisterCallback <FocusEvent>(evt => { if (searchRoot.visible || string.IsNullOrEmpty(searchString)) { return; } //If there's a search string and we're in the search box we should enable the search container. searchRoot.visible = true; //If there isn't any search (ie. the previously cached search was never built, perform the search) if (searchStringsCache.Count == 0) { DoSearch(); } }); //The internal text field has a fixed width so we have to remove that StyleLength width = textField.style.width; width.keyword = StyleKeyword.Auto; textField.style.width = width; //The cancel button is improperly aligned so we have to fix that Button cancelButton = toolbarSearchField.Q <Button>("unity-cancel"); cancelButton.style.width = 15; //The search button doesn't expand automatically, so we have to fix that Button searchButton = toolbarSearchField.Q <Button>("unity-search"); searchButton.style.flexGrow = 1; //Set the Search Field to be 1/2 width toolbar.RegisterCallback <GeometryChangedEvent>(evt => toolbarSearchField.style.marginLeft = evt.newRect.width / 2f - 70); toolbar.Add(toolbarSearchField); #endregion }
public void OnEnable() { #region UXML and USS set-up // Each editor window contains a root VisualElement object VisualElement root = rootVisualElement; // Import UXML and USS StyleSheet acToolsStyles = AssetDatabase.LoadAssetAtPath <StyleSheet>(ACToolsEditorUI.UniversalStyleSheet); VisualTreeAsset visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/_ACTools/_Data Manager/Editor/Window/DataManagerWindow.uxml"); StyleSheet styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/_ACTools/_Data Manager/Editor/Window/DataManagerWindow.uss"); // Adds style sheets to root. root.styleSheets.Add(acToolsStyles); root.styleSheets.Add(styleSheet); // Clones the visual tree and adds it to the root. VisualElement tree = visualTree.CloneTree(); tree.AddToClassList("ACTools_template-container"); root.Add(tree); #endregion #region Toolbar // Sets up the add fields, buttons, and events. #region Create Menu createMenu = tree.Q <ToolbarMenu>("CreateMenu"); createMenu.Q <TextElement>("").AddToClassList("ACTools_toolbar-icon_cross"); CreateDataType += CreateNewDataType.CreateDataType; CreateDataType += CreateDataTypeFromCVSWindow.ShowWindow; createMenu.menu.InsertAction(0, NewDataTypeButtonName, CreateDataType); createMenu.menu.InsertAction(1, CVSDataTypeButtonName, CreateDataType); #endregion #region Search Field searchField = tree.Q <ToolbarSearchField>("SearchTypes"); searchField.Q <Button>("unity-search").clickable.clicked += SearchDataManagerWindow; #endregion #region Refresh Button refreshButton = tree.Q <ToolbarButton>("RefreshButton"); refreshButton.clickable.clicked += RefreshDataManagerAction; VisualElement refreshIcon = new VisualElement(); refreshIcon.AddToClassList("ACTools_toolbar-icon_refresh"); refreshButton.Add(refreshIcon); #endregion #endregion #region Main Row // Sets selected values to null; DataTypeSelected = false; ItemSelected = false; #region Left Column // Gets the left column. leftColumnItems = tree.Q <VisualElement>("LC_Items"); DrawLeftColumnItems(); #endregion #region Right Column // Gets the middle column. rightColumnItems = tree.Q <VisualElement>("RC_Items"); DrawRightColumnItems(); #endregion #endregion }
public PhotoView (IBrowsableCollection query) : base () { this.query = query; description_delay = new FSpot.Delay (1000, new GLib.IdleHandler (CommitPendingChanges)); this.Destroyed += HandleDestroy; Name = "ImageContainer"; Box vbox = new VBox (false, 6); Add (vbox); background = new EventBox (); Frame frame = new Frame (); background.Add (frame); frame.ShadowType = ShadowType.In; vbox.PackStart (background, true, true, 0); Box inner_vbox = new VBox (false , 2); frame.Add (inner_vbox); photo_view = new FSpot.PhotoImageView (query); photo_view.PhotoChanged += HandlePhotoChanged; photo_view.SelectionChanged += HandleSelectionChanged; photo_view_scrolled = new ScrolledWindow (null, null); photo_view_scrolled.SetPolicy (PolicyType.Automatic, PolicyType.Automatic); photo_view_scrolled.ShadowType = ShadowType.None; photo_view_scrolled.Add (photo_view); photo_view_scrolled.ButtonPressEvent += HandleButtonPressEvent; photo_view.AddEvents ((int) EventMask.KeyPressMask); inner_vbox.PackStart (photo_view_scrolled, true, true, 0); HBox inner_hbox = new HBox (false, 2); //inner_hbox.BorderWidth = 6; tag_view = new TagView (); inner_hbox.PackStart (tag_view, false, true, 0); SetColors (); Label comment = new Label (Catalog.GetString ("Comment:")); inner_hbox.PackStart (comment, false, false, 0); description_entry = new Entry (); inner_hbox.PackStart (description_entry, true, true, 0); description_entry.Changed += HandleDescriptionChanged; inner_vbox.PackStart (inner_hbox, false, true, 0); Box toolbar_hbox = new HBox (false, 6); vbox.PackStart (toolbar_hbox, false, true, 0); toolbar_hbox.PackStart (CreateConstraintsOptionMenu (), false, false, 0); crop_button = new ToolbarButton (); crop_button.Add (new Gtk.Image ("f-spot-crop", IconSize.Button)); toolbar_hbox.PackStart (crop_button, false, true, 0); crop_button.Clicked += new EventHandler (HandleCropButtonClicked); redeye_button = new ToolbarButton (); redeye_button.Add (new Gtk.Image ("f-spot-red-eye", IconSize.Button)); toolbar_hbox.PackStart (redeye_button, false, true, 0); redeye_button.Clicked += new EventHandler (HandleRedEyeButtonClicked); color_button = new ToolbarButton (); color_button.Add (new Gtk.Image ("f-spot-adjust-colors", IconSize.Button)); toolbar_hbox.PackStart (color_button, false, true, 0); color_button.Clicked += new EventHandler (HandleColorButtonClicked); desaturate_button = new ToolbarButton (); desaturate_button.Add (new Gtk.Image ("f-spot-desaturate", IconSize.Button)); toolbar_hbox.PackStart (desaturate_button, false, true, 0); desaturate_button.Clicked += HandleDesaturateButtonClicked; sepia_button = new ToolbarButton (); sepia_button.Add (new Gtk.Image ("f-spot-sepia", IconSize.Button)); toolbar_hbox.PackStart (sepia_button, false, true, 0); sepia_button.Clicked += HandleSepiaButtonClicked; ItemAction straighten = new TiltEditorAction (photo_view); toolbar_hbox.PackStart (straighten.GetToolButton (false), false, true, 0); ItemAction softfocus = new SoftFocusEditorAction (photo_view); toolbar_hbox.PackStart (softfocus.GetToolButton (false), false, true, 0); ItemAction autocolor = new AutoColor (photo_view.Item); toolbar_hbox.PackStart (autocolor.GetToolButton (false), false, true, 0); /* Face detection ! */ face_widget = new FaceBox (toolbar_hbox, photo_view); vbox.PackStart ( face_widget, false, true, 0); /* Spacer Label */ toolbar_hbox.PackStart (new Label (String.Empty), true, true, 0); count_label = new Label (String.Empty); toolbar_hbox.PackStart (count_label, false, true, 0); display_previous_button = new ToolbarButton (); Gtk.Image display_previous_image = new Gtk.Image (Stock.GoBack, IconSize.Button); display_previous_button.Add (display_previous_image); display_previous_button.Clicked += new EventHandler (HandleDisplayPreviousButtonClicked); toolbar_hbox.PackStart (display_previous_button, false, true, 0); display_next_button = new ToolbarButton (); Gtk.Image display_next_image = new Gtk.Image (Stock.GoForward, IconSize.Button); display_next_button.Add (display_next_image); display_next_button.Clicked += new EventHandler (HandleDisplayNextButtonClicked); toolbar_hbox.PackStart (display_next_button, false, true, 0); tips.Enable (); UpdateButtonSensitivity (); vbox.ShowAll (); tips.SetTip (color_button, Catalog.GetString ("Adjust the photo colors"), String.Empty); tips.SetTip (constraints_option_menu, Catalog.GetString ("Constrain the aspect ratio of the selection"), String.Empty); tips.SetTip (display_next_button, Catalog.GetString ("Next photo"), String.Empty); tips.SetTip (display_previous_button, Catalog.GetString ("Previous photo"), String.Empty); tips.SetTip (desaturate_button, Catalog.GetString ("Convert the photo to black and white"), String.Empty); tips.SetTip (sepia_button, Catalog.GetString ("Convert the photo to sepia tones"), String.Empty); Realized += delegate (object o, EventArgs e) {SetColors ();}; }
private void InitializeControls() { /* * var commandBinding = new CommandBinding( * ApplicationCommands.Open, * OpenCmdExecuted, * OpenCmdCanExecute); * * CommandBindings.Add(commandBinding); * * //button.Command = commandBinding;*/ //var commandBack = new RoutedCommand("Back", GetType()); CommandBindingBack = new RelayCommand( (obj) => CommandBackCanExecute(obj), (obj) => TabViewer.SeekBackward()); CommandBindingForward = new RelayCommand( (obj) => CommandForwardCanExecute(obj), (obj) => TabViewer.SeekForward()); //project.navigator.CanSeekBackwardOb //CommandBinder. //CommandBindings.Add(commandBindingBack); //var gesture2 = new KeyGesture { Key = Key.B, Modifiers = InputModifiers.Control }; //HotKeyManager.SetHotKey(button, gesture1); // gray color 3289C7 ButtonBack = AddButton("Back (Alt+Left)", Icons.Streams.Back, CommandBindingBack); ButtonForward = AddButton("Forward (Alt+Right)", Icons.Streams.Forward, CommandBindingForward); AddSeparator(); ButtonRefresh = AddButton("Refresh (Ctrl+R)", Icons.Streams.Refresh); //buttonRefresh.Add(); ButtonRefresh.Add(Refresh); AddSeparator(); ButtonLink = AddButton("Link - Copy to Clipboard", Icons.Streams.Link); ButtonImport = AddButton("Import Link from Clipboard", Icons.Streams.Import); // Handle in BaseWindow //var refreshGesture = new KeyGesture { Key = Key.F5 }; //HotKeyManager.SetHotKey(buttonRefresh, refreshGesture); /* * var buttonBack = new ToolbarButton2() * { * Content = "<-", * //ToolTip = "Back", * //Content = imageBack, * //Command = commandBindingBack, * };*/ // Requires ReactiveUI import, can we get a version that imports? //var commandBack = ReactiveCommand.Create(() => ButtonBack_Click(null, null)); //buttonBack.Bind(Class1.DoubleValueProperty, new Binding("[0]", BindingMode.TwoWay) { Source = source }); //buttonBack.Click += ButtonBack_Click; /*var buttonForward = new Button() * { * Content = "->", * //ToolTip = "Forward", * //Content = imageForward, * //Command = commandBindingForward.Command, * //Command = commandBack, * };*/ //buttonForward.Click += ButtonForward_Click; }
public PhotoView(IBrowsableCollection query) : base() { this.query = query; description_delay = new FSpot.Delay(1000, new GLib.IdleHandler(CommitPendingChanges)); this.Destroyed += HandleDestroy; Name = "ImageContainer"; Box vbox = new VBox(false, 6); Add(vbox); background = new EventBox(); Frame frame = new Frame(); background.Add(frame); frame.ShadowType = ShadowType.In; vbox.PackStart(background, true, true, 0); Box inner_vbox = new VBox(false, 2); frame.Add(inner_vbox); photo_view = new FSpot.PhotoImageView(query); photo_view.PhotoChanged += HandlePhotoChanged; photo_view.SelectionChanged += HandleSelectionChanged; photo_view_scrolled = new ScrolledWindow(null, null); photo_view_scrolled.SetPolicy(PolicyType.Automatic, PolicyType.Automatic); photo_view_scrolled.ShadowType = ShadowType.None; photo_view_scrolled.Add(photo_view); photo_view_scrolled.ButtonPressEvent += HandleButtonPressEvent; photo_view.AddEvents((int)EventMask.KeyPressMask); inner_vbox.PackStart(photo_view_scrolled, true, true, 0); HBox inner_hbox = new HBox(false, 2); //inner_hbox.BorderWidth = 6; tag_view = new TagView(); inner_hbox.PackStart(tag_view, false, true, 0); SetColors(); Label comment = new Label(Catalog.GetString("Comment:")); inner_hbox.PackStart(comment, false, false, 0); description_entry = new Entry(); inner_hbox.PackStart(description_entry, true, true, 0); description_entry.Changed += HandleDescriptionChanged; inner_vbox.PackStart(inner_hbox, false, true, 0); Box toolbar_hbox = new HBox(false, 6); vbox.PackStart(toolbar_hbox, false, true, 0); toolbar_hbox.PackStart(CreateConstraintsOptionMenu(), false, false, 0); crop_button = new ToolbarButton(); crop_button.Add(new Gtk.Image("f-spot-crop", IconSize.Button)); toolbar_hbox.PackStart(crop_button, false, true, 0); crop_button.Clicked += new EventHandler(HandleCropButtonClicked); redeye_button = new ToolbarButton(); redeye_button.Add(new Gtk.Image("f-spot-red-eye", IconSize.Button)); toolbar_hbox.PackStart(redeye_button, false, true, 0); redeye_button.Clicked += new EventHandler(HandleRedEyeButtonClicked); color_button = new ToolbarButton(); color_button.Add(new Gtk.Image("f-spot-adjust-colors", IconSize.Button)); toolbar_hbox.PackStart(color_button, false, true, 0); color_button.Clicked += new EventHandler(HandleColorButtonClicked); desaturate_button = new ToolbarButton(); desaturate_button.Add(new Gtk.Image("f-spot-desaturate", IconSize.Button)); toolbar_hbox.PackStart(desaturate_button, false, true, 0); desaturate_button.Clicked += HandleDesaturateButtonClicked; sepia_button = new ToolbarButton(); sepia_button.Add(new Gtk.Image("f-spot-sepia", IconSize.Button)); toolbar_hbox.PackStart(sepia_button, false, true, 0); sepia_button.Clicked += HandleSepiaButtonClicked; ItemAction straighten = new TiltEditorAction(photo_view); toolbar_hbox.PackStart(straighten.GetToolButton(false), false, true, 0); ItemAction softfocus = new SoftFocusEditorAction(photo_view); toolbar_hbox.PackStart(softfocus.GetToolButton(false), false, true, 0); ItemAction autocolor = new AutoColor(photo_view.Item); toolbar_hbox.PackStart(autocolor.GetToolButton(false), false, true, 0); /* Face detection ! */ face_widget = new FaceBox(toolbar_hbox, photo_view); vbox.PackStart(face_widget, false, true, 0); /* Spacer Label */ toolbar_hbox.PackStart(new Label(String.Empty), true, true, 0); count_label = new Label(String.Empty); toolbar_hbox.PackStart(count_label, false, true, 0); display_previous_button = new ToolbarButton(); Gtk.Image display_previous_image = new Gtk.Image(Stock.GoBack, IconSize.Button); display_previous_button.Add(display_previous_image); display_previous_button.Clicked += new EventHandler(HandleDisplayPreviousButtonClicked); toolbar_hbox.PackStart(display_previous_button, false, true, 0); display_next_button = new ToolbarButton(); Gtk.Image display_next_image = new Gtk.Image(Stock.GoForward, IconSize.Button); display_next_button.Add(display_next_image); display_next_button.Clicked += new EventHandler(HandleDisplayNextButtonClicked); toolbar_hbox.PackStart(display_next_button, false, true, 0); tips.Enable(); UpdateButtonSensitivity(); vbox.ShowAll(); tips.SetTip(color_button, Catalog.GetString("Adjust the photo colors"), String.Empty); tips.SetTip(constraints_option_menu, Catalog.GetString("Constrain the aspect ratio of the selection"), String.Empty); tips.SetTip(display_next_button, Catalog.GetString("Next photo"), String.Empty); tips.SetTip(display_previous_button, Catalog.GetString("Previous photo"), String.Empty); tips.SetTip(desaturate_button, Catalog.GetString("Convert the photo to black and white"), String.Empty); tips.SetTip(sepia_button, Catalog.GetString("Convert the photo to sepia tones"), String.Empty); Realized += delegate(object o, EventArgs e) { SetColors(); }; }