Skip to content

Commit c4bb3ff

Browse files
committed
Make showing the navigation button on DocumentControl configurable
1 parent 3611c74 commit c4bb3ff

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

src/Eto/Forms/Controls/DocumentControl.cs

+17
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,17 @@ public bool AllowReordering
217217
set { Handler.AllowReordering = value; }
218218
}
219219

220+
221+
/// <summary>
222+
/// Gets or sets a value indicating the tabs can be navigated by next and previous buttons.
223+
/// </summary>
224+
/// <value><c>true</c> to allow navigating; otherwise, <c>false</c>.</value>
225+
public bool AllowNavigating
226+
{
227+
get { return Handler.AllowNavigating; }
228+
set { Handler.AllowNavigating = value; }
229+
}
230+
220231
/// <summary>
221232
/// Gets or sets the disabled foreground color.
222233
/// </summary>
@@ -565,6 +576,12 @@ public void OnSelectedIndexChanged(DocumentControl widget, EventArgs e)
565576
/// <value><c>true</c> to allow reordering; otherwise, <c>false</c>.</value>
566577
bool AllowReordering { get; set; }
567578

579+
/// <summary>
580+
/// Gets or sets a value indicating the tabs can be navigated by next and previous buttons.
581+
/// </summary>
582+
/// <value><c>true</c> to allow navigating; otherwise, <c>false</c>.</value>
583+
bool AllowNavigating { get; set; }
584+
568585
/// <summary>
569586
/// Gets or sets the disabled foreground color.
570587
/// </summary>

src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs

+22-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class ThemedDocumentControlHandler : ThemedContainerHandler<TableLayout,
88
List<DocumentPage> pages = new List<DocumentPage>();
99
ThemedDocumentPageHandler tabPrev, tabNext;
1010

11+
bool allowNavigating;
1112
PointF mousePos;
1213
int selectedIndex;
1314
float nextPrevWidth;
@@ -42,6 +43,20 @@ public Padding TabPadding
4243
set => Widget.Properties.Set(TabPadding_Key, value, DefaultTabPadding);
4344
}
4445

46+
/// <summary>
47+
/// Gets or sets a value indicating indicating the tabs can be navigated by next and previous buttons.
48+
/// </summary>
49+
/// <value><c>true</c> if navigatable; otherwise, <c>false</c>.</value>
50+
public bool AllowNavigating
51+
{
52+
get { return allowNavigating; }
53+
set
54+
{
55+
allowNavigating = value;
56+
Calculate();
57+
}
58+
}
59+
4560
/// <summary>
4661
/// Gets or sets the font for the tab text.
4762
/// </summary>
@@ -189,6 +204,7 @@ public ThemedDocumentControlHandler()
189204
{
190205
mousePos = new PointF(-1, -1);
191206
selectedIndex = -1;
207+
allowNavigating = true;
192208
nextPrevWidth = 0;
193209
startx = 0;
194210
font = SystemFonts.Default();
@@ -531,7 +547,7 @@ void CalculateTabs(bool force = false)
531547
if (!force && !Widget.Loaded)
532548
return;
533549
var posx = 0f;
534-
if (nextPrevWidth == 0f)
550+
if (allowNavigating && nextPrevWidth == 0f)
535551
{
536552
CalculateTab(tabPrev, -1, ref posx);
537553
CalculateTab(tabNext, -1, ref posx);
@@ -568,8 +584,11 @@ void Drawable_Paint(object sender, PaintEventArgs e)
568584

569585
posx = 0;
570586

571-
DrawTab(g, tabPrev, -1);
572-
DrawTab(g, tabNext, -1);
587+
if (allowNavigating)
588+
{
589+
DrawTab(g, tabPrev, -1);
590+
DrawTab(g, tabNext, -1);
591+
}
573592
}
574593

575594
void CalculateTab(ThemedDocumentPageHandler tab, int i, ref float posx)

0 commit comments

Comments
 (0)