Skip to content

Commit 3156641

Browse files
committed
Make sixel 'opt in' in images scenario and apply a hack to fix TabView not refreshing properly
1 parent a6f03e4 commit 3156641

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

UICatalog/Scenarios/Images.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,27 @@ public override void Main ()
100100
{
101101
X = Pos.Right (lblDriverName) + 2,
102102
Y = 1,
103-
CheckedState = _sixelSupportResult.IsSupported
104-
? CheckState.Checked
105-
: CheckState.UnChecked,
103+
CheckedState = CheckState.UnChecked,
106104
Text = "Supports Sixel"
107105
};
108106

107+
var lblSupportsSixel = new Label ()
108+
{
109+
110+
X = Pos.Right (lblDriverName) + 2,
111+
Y = Pos.Bottom (cbSupportsSixel),
112+
Text = "(Check if your terminal supports Sixel)"
113+
};
114+
115+
116+
/* CheckedState = _sixelSupportResult.IsSupported
117+
? CheckState.Checked
118+
: CheckState.UnChecked;*/
109119
cbSupportsSixel.CheckedStateChanging += (s, e) =>
110120
{
111121
_sixelSupportResult.IsSupported = e.NewValue == CheckState.Checked;
112122
SetupSixelSupported (e.NewValue == CheckState.Checked);
123+
ApplyShowTabViewHack ();
113124
};
114125

115126
_win.Add (cbSupportsSixel);
@@ -130,7 +141,7 @@ public override void Main ()
130141

131142
_tabView = new ()
132143
{
133-
Y = Pos.Bottom (btnOpenImage), Width = Dim.Fill (), Height = Dim.Fill ()
144+
Y = Pos.Bottom (lblSupportsSixel), Width = Dim.Fill (), Height = Dim.Fill ()
134145
};
135146

136147
_tabView.AddTab (tabBasic, true);
@@ -143,6 +154,7 @@ public override void Main ()
143154

144155
btnOpenImage.Accepting += OpenImage;
145156

157+
_win.Add (lblSupportsSixel);
146158
_win.Add (_tabView);
147159
Application.Run (_win);
148160
_win.Dispose ();
@@ -275,9 +287,19 @@ private void OpenImage (object sender, CommandEventArgs e)
275287
}
276288

277289
_imageView.SetImage (img);
290+
ApplyShowTabViewHack ();
278291
Application.Refresh ();
279292
}
280293

294+
private void ApplyShowTabViewHack ()
295+
{
296+
// TODO HACK: This hack seems to be required to make tabview actually refresh itself
297+
_tabView.SetNeedsDisplay();
298+
var orig = _tabView.SelectedTab;
299+
_tabView.SelectedTab = _tabView.Tabs.Except (new []{orig}).ElementAt (0);
300+
_tabView.SelectedTab = orig;
301+
}
302+
281303
private void BuildBasicTab (Tab tabBasic)
282304
{
283305
_imageView = new ()

0 commit comments

Comments
 (0)