浏览代码

Make sixel 'opt in' in images scenario and apply a hack to fix TabView not refreshing properly

tznind 9 月之前
父节点
当前提交
3156641c1e
共有 1 个文件被更改,包括 26 次插入4 次删除
  1. 26 4
      UICatalog/Scenarios/Images.cs

+ 26 - 4
UICatalog/Scenarios/Images.cs

@@ -100,16 +100,27 @@ public class Images : Scenario
         {
         {
             X = Pos.Right (lblDriverName) + 2,
             X = Pos.Right (lblDriverName) + 2,
             Y = 1,
             Y = 1,
-            CheckedState = _sixelSupportResult.IsSupported
-                               ? CheckState.Checked
-                               : CheckState.UnChecked,
+            CheckedState = CheckState.UnChecked,
             Text = "Supports Sixel"
             Text = "Supports Sixel"
         };
         };
 
 
+        var lblSupportsSixel = new Label ()
+        {
+
+            X = Pos.Right (lblDriverName) + 2,
+            Y = Pos.Bottom (cbSupportsSixel),
+            Text = "(Check if your terminal supports Sixel)"
+        };
+
+
+/*        CheckedState = _sixelSupportResult.IsSupported
+                           ? CheckState.Checked
+                           : CheckState.UnChecked;*/
         cbSupportsSixel.CheckedStateChanging += (s, e) =>
         cbSupportsSixel.CheckedStateChanging += (s, e) =>
                                                 {
                                                 {
                                                     _sixelSupportResult.IsSupported = e.NewValue == CheckState.Checked;
                                                     _sixelSupportResult.IsSupported = e.NewValue == CheckState.Checked;
                                                     SetupSixelSupported (e.NewValue == CheckState.Checked);
                                                     SetupSixelSupported (e.NewValue == CheckState.Checked);
+                                                    ApplyShowTabViewHack ();
                                                 };
                                                 };
 
 
         _win.Add (cbSupportsSixel);
         _win.Add (cbSupportsSixel);
@@ -130,7 +141,7 @@ public class Images : Scenario
 
 
         _tabView = new ()
         _tabView = new ()
         {
         {
-            Y = Pos.Bottom (btnOpenImage), Width = Dim.Fill (), Height = Dim.Fill ()
+            Y = Pos.Bottom (lblSupportsSixel), Width = Dim.Fill (), Height = Dim.Fill ()
         };
         };
 
 
         _tabView.AddTab (tabBasic, true);
         _tabView.AddTab (tabBasic, true);
@@ -143,6 +154,7 @@ public class Images : Scenario
 
 
         btnOpenImage.Accepting += OpenImage;
         btnOpenImage.Accepting += OpenImage;
 
 
+        _win.Add (lblSupportsSixel);
         _win.Add (_tabView);
         _win.Add (_tabView);
         Application.Run (_win);
         Application.Run (_win);
         _win.Dispose ();
         _win.Dispose ();
@@ -275,9 +287,19 @@ public class Images : Scenario
         }
         }
 
 
         _imageView.SetImage (img);
         _imageView.SetImage (img);
+        ApplyShowTabViewHack ();
         Application.Refresh ();
         Application.Refresh ();
     }
     }
 
 
+    private void ApplyShowTabViewHack ()
+    {
+        // TODO HACK: This hack seems to be required to make tabview actually refresh itself
+        _tabView.SetNeedsDisplay();
+        var orig = _tabView.SelectedTab;
+        _tabView.SelectedTab = _tabView.Tabs.Except (new []{orig}).ElementAt (0);
+        _tabView.SelectedTab = orig;
+    }
+
     private void BuildBasicTab (Tab tabBasic)
     private void BuildBasicTab (Tab tabBasic)
     {
     {
         _imageView = new ()
         _imageView = new ()