Skip to content

Commit

Permalink
LT-20853: Fix FocusBox word bundle elements' order (#31)
Browse files Browse the repository at this point in the history
* Dispose and recreate the FocusBoxController if the writing system has changed
  • Loading branch information
JakeOliver28 authored Apr 26, 2024
1 parent 3e09448 commit 3fdca2b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions Src/LexText/Interlinear/InterlinDocForAnalysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public virtual void TriggerAnalysisSelected(AnalysisOccurrence target, bool fSav
MoveFocusBoxIntoPlace();
// Now it is the right size and place we can show it.
TryShowFocusBox();
// All this CAN hapen because we're editing in another window...for example,
// All this CAN happen because we're editing in another window...for example,
// if we edit something that deletes the current wordform in a concordance view.
// In that case we don't want to steal the focus.
if (ParentForm == Form.ActiveForm)
Expand Down Expand Up @@ -1828,16 +1828,19 @@ internal override void UpdateForNewLineChoices(InterlinLineChoices newChoices)
}
}

private bool previousRightToLeft;
private bool hasRightToLeftChanged => previousRightToLeft != Vc.RightToLeft;
/// <summary>
/// returns the focus box for the interlinDoc if it exists or can be created.
/// </summary>
internal FocusBoxController FocusBox
{
get
{
if (ExistingFocusBox == null && ForEditing)
if ((ExistingFocusBox == null && ForEditing) || hasRightToLeftChanged)
{
CreateFocusBox();
previousRightToLeft = Vc.RightToLeft;
}
return ExistingFocusBox;
}
Expand All @@ -1849,6 +1852,11 @@ internal FocusBoxController FocusBox

internal override void CreateFocusBox()
{
if (ExistingFocusBox != null)
{
ExistingFocusBox.Dispose();
}

ExistingFocusBox = CreateFocusBoxInternal();
}

Expand Down
4 changes: 2 additions & 2 deletions Src/LexText/Interlinear/SandboxBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3873,10 +3873,10 @@ public override void MakeRoot()

m_dxdLayoutWidth = kForceLayout; // Don't try to draw until we get OnSize and do layout.
// For some reason, we don't always initialize our control size to be the same as our rootbox.
this.Margin = new Padding(3, 0, 3, 1);
Margin = new Padding(3, 0, 3, 1);
SyncControlSizeToRootBoxSize();
if (RightToLeftWritingSystem)
this.Anchor = AnchorStyles.Right | AnchorStyles.Top;
Anchor = AnchorStyles.Right | AnchorStyles.Top;

//TODO:
//ptmw->RegisterRootBox(qrootb);
Expand Down

0 comments on commit 3fdca2b

Please sign in to comment.