mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-10-02 05:06:35 -05:00
add focus box when switching tabs
to help the user see which part of the screen they should focus on
This commit is contained in:
@@ -240,7 +240,10 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
||||
|
||||
args = new TabChangeRequestedEventArgs(this);
|
||||
RequestTabChange?.Invoke(mapper, args);
|
||||
if (args.RequestAccepted) selection.SetJumpBackTab(mapper);
|
||||
if (args.RequestAccepted) {
|
||||
selection.SetJumpBackTab(mapper);
|
||||
FocusToolPanel.Raise(this);
|
||||
}
|
||||
});
|
||||
}, TaskContinuationOptions.ExecuteSynchronously);
|
||||
}
|
||||
@@ -919,6 +922,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
||||
public event EventHandler<TabChangeRequestedEventArgs> RequestTabChange;
|
||||
public event EventHandler<Action> RequestDelayedWork;
|
||||
public event EventHandler RequestMenuClose;
|
||||
public event EventHandler FocusToolPanel;
|
||||
#pragma warning restore 0067
|
||||
|
||||
public Shortcuts Shortcuts { get; }
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace HavenSoft.HexManiac.WPF.Controls {
|
||||
private MapEditorViewModel ViewModel => (MapEditorViewModel)DataContext;
|
||||
private new ToolTip ToolTip => (ToolTip)base.ToolTip;
|
||||
|
||||
public event EventHandler FocusElement;
|
||||
|
||||
public MapTab() {
|
||||
InitializeComponent();
|
||||
DataContextChanged += UpdateDataContext;
|
||||
@@ -158,6 +160,7 @@ namespace HavenSoft.HexManiac.WPF.Controls {
|
||||
|
||||
private void ButtonLeave(object sender, MouseEventArgs e) {
|
||||
UpdateTooltipContent(NoTooltip);
|
||||
if (ViewModel == null) return;
|
||||
ViewModel.ShowHighlightCursor = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- Left Panel -->
|
||||
<Grid DataContext="{Binding Tools}" HorizontalAlignment="Stretch">
|
||||
<Grid Name="ToolPanel" DataContext="{Binding Tools}" HorizontalAlignment="Stretch">
|
||||
<Grid.Style>
|
||||
<Style TargetType="Grid">
|
||||
<Style.Triggers>
|
||||
@@ -900,7 +900,7 @@
|
||||
<TextBlock Foreground="{DynamicResource Error}" DockPanel.Dock="Bottom" TextWrapping="Wrap"
|
||||
Text="{Binding ErrorText}" Visibility="{Binding ShowErrorText, Converter={StaticResource BoolToVisibility}}" />
|
||||
<ScrollViewer Name="CodeToolMultiTextBox" PreviewMouseWheel="ScrollCodeContent">
|
||||
<ItemsControl ItemsSource="{Binding Contents}">
|
||||
<ItemsControl ItemsSource="{Binding Contents}" Name="CodeToolMultiTextBoxItems" VerticalAlignment="Top">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
|
||||
@@ -21,6 +21,7 @@ using System.Windows.Threading;
|
||||
|
||||
namespace HavenSoft.HexManiac.WPF.Controls {
|
||||
public partial class TabView {
|
||||
public event EventHandler FocusElement;
|
||||
|
||||
#region ZoomLevel
|
||||
|
||||
@@ -69,6 +70,7 @@ namespace HavenSoft.HexManiac.WPF.Controls {
|
||||
}
|
||||
if (e.OldValue is ViewPort viewPortOld) {
|
||||
viewPortOld.Tools.StringTool.PropertyChanged -= HandleStringToolPropertyChanged;
|
||||
viewPortOld.FocusToolPanel -= FocusToolPanel;
|
||||
}
|
||||
if (e.NewValue is IViewPort viewPortNew1) {
|
||||
viewPortNew1.PropertyChanged += HandleViewPortScrollChanged;
|
||||
@@ -77,6 +79,7 @@ namespace HavenSoft.HexManiac.WPF.Controls {
|
||||
}
|
||||
if (e.NewValue is ViewPort viewPortNew) {
|
||||
viewPortNew.Tools.StringTool.PropertyChanged += HandleStringToolPropertyChanged;
|
||||
viewPortNew.FocusToolPanel += FocusToolPanel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,6 +511,18 @@ namespace HavenSoft.HexManiac.WPF.Controls {
|
||||
|
||||
private void ScrollCodeContent(object sender, MouseWheelEventArgs e) => CodeContentsPopup.IsOpen = false;
|
||||
|
||||
private void FocusToolPanel(object sender, EventArgs e) {
|
||||
if (DataContext is IViewPort viewPort) {
|
||||
if (viewPort.Tools.SelectedTool is CodeTool code) {
|
||||
if (code.Mode.IsAny(CodeMode.Script, CodeMode.BattleScript, CodeMode.TrainerAiScript, CodeMode.AnimationScript)) {
|
||||
FocusElement.Raise(CodeToolMultiTextBoxItems);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
FocusElement.Raise(ToolPanel);
|
||||
}
|
||||
|
||||
private void ComboBoxArrayElementViewTextInput(object sender, TextCompositionEventArgs e) {
|
||||
var element = (FrameworkElement)sender;
|
||||
var viewModel = (ComboBoxArrayElementViewModel)element.DataContext;
|
||||
|
||||
@@ -574,6 +574,7 @@
|
||||
<ContentControl.Resources>
|
||||
<DataTemplate DataType="{x:Type hshmcvm:ViewPort}">
|
||||
<hsg3hv:TabView
|
||||
FocusElement="FocusTabElement"
|
||||
AnimateScroll="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.AnimateScroll}"
|
||||
ZoomLevel="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.ZoomLevel}"/>
|
||||
</DataTemplate>
|
||||
@@ -594,7 +595,7 @@
|
||||
<hsg3hv:ImageEditorView />
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type mapvm:MapEditorViewModel}">
|
||||
<hsg3hv:MapTab />
|
||||
<hsg3hv:MapTab FocusElement="FocusTabElement" />
|
||||
</DataTemplate>
|
||||
</ContentControl.Resources>
|
||||
</ContentControl>
|
||||
|
||||
@@ -274,6 +274,11 @@ namespace HavenSoft.HexManiac.WPF.Windows {
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void FocusTabElement(object sender, EventArgs e) {
|
||||
var panel = (FrameworkElement)sender;
|
||||
NavigationCommands.NavigateJournal.Execute(panel, this);
|
||||
}
|
||||
|
||||
protected override void OnDragEnter(DragEventArgs e) {
|
||||
base.OnDragEnter(e);
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
|
||||
|
||||
Reference in New Issue
Block a user