OSDN Git Service

レタリングのコードに無駄な部分があった
authorgdkhd812 <test@yahoo.co.jp>
Sat, 1 Apr 2017 13:57:47 +0000 (22:57 +0900)
committergdkhd812 <test@yahoo.co.jp>
Sat, 1 Apr 2017 13:57:47 +0000 (22:57 +0900)
Core/Direct2D/InlineChar.cs
Core/EditView.cs

index ab2b720..e48d5e7 100644 (file)
@@ -51,30 +51,40 @@ namespace FooEditEngine
             breakConditionBefore = DW.BreakCondition.CanBreak;
         }
 
+        DW.InlineObjectMetrics? _Metrics;
         public DW.InlineObjectMetrics Metrics
         {
             get
             {
-                DW.InlineObjectMetrics value = new DW.InlineObjectMetrics();
-                value.Height = this.Layout.Metrics.Height;
-                value.Width = this.Layout.Metrics.Width;
-                DW.LineMetrics[] lines = this.Layout.GetLineMetrics();
-                value.Baseline = lines[0].Baseline;
-                return value;
+                if(_Metrics == null)
+                {
+                    DW.InlineObjectMetrics value = new DW.InlineObjectMetrics();
+                    value.Height = this.Layout.Metrics.Height;
+                    value.Width = this.Layout.Metrics.Width;
+                    DW.LineMetrics[] lines = this.Layout.GetLineMetrics();
+                    value.Baseline = lines[0].Baseline;
+                    _Metrics = value;
+                }
+                return _Metrics.Value;
             }
         }
 
+        public DW.OverhangMetrics? _OverhangMetrics;
         public DW.OverhangMetrics OverhangMetrics
         {
             get
             {
-                DW.OverhangMetrics value = new DW.OverhangMetrics();
-                DW.TextMetrics metrics = this.Layout.Metrics;
-                value.Left = metrics.Left;
-                value.Right = metrics.Left + metrics.Width;
-                value.Top = metrics.Top;
-                value.Bottom = metrics.Top + metrics.Height;
-                return value;
+                if(_OverhangMetrics == null)
+                {
+                    DW.OverhangMetrics value = new DW.OverhangMetrics();
+                    DW.TextMetrics metrics = this.Layout.Metrics;
+                    value.Left = metrics.Left;
+                    value.Right = metrics.Left + metrics.Width;
+                    value.Top = metrics.Top;
+                    value.Bottom = metrics.Top + metrics.Height;
+                    _OverhangMetrics = value;
+                }
+                return _OverhangMetrics.Value;
             }
         }
 
@@ -103,29 +113,39 @@ namespace FooEditEngine
             this.Brush = brush;
         }
 
+        DW.InlineObjectMetrics? _Metrics;
         public DW.InlineObjectMetrics Metrics
         {
             get
             {
-                DW.InlineObjectMetrics value = new DW.InlineObjectMetrics();
-                value.Width = (float)this._TabWidth;
-                value.Height = (float)LineHeight;
-                value.Baseline = (float)(value.Height * 0.8);    //デフォルトでは8割らしい
-                value.SupportsSideways = false;
-                return value;
+                if(_Metrics == null)
+                {
+                    DW.InlineObjectMetrics value = new DW.InlineObjectMetrics();
+                    value.Width = (float)this._TabWidth;
+                    value.Height = (float)LineHeight;
+                    value.Baseline = (float)(value.Height * 0.8);    //デフォルトでは8割らしい
+                    value.SupportsSideways = false;
+                    _Metrics = value;
+                }
+                return _Metrics.Value;
             }
         }
+        public DW.OverhangMetrics? _OverhangMetrics;
         public DW.OverhangMetrics OverhangMetrics
         {
             get
             {
-                DW.OverhangMetrics value = new DW.OverhangMetrics();
-                DW.InlineObjectMetrics metrics = this.Metrics;
-                value.Left = 0;
-                value.Right = metrics.Width;
-                value.Top = 0;
-                value.Bottom =  metrics.Height;
-                return value;
+                if (_OverhangMetrics == null)
+                {
+                    DW.OverhangMetrics value = new DW.OverhangMetrics();
+                    DW.InlineObjectMetrics metrics = this.Metrics;
+                    value.Left = 0;
+                    value.Right = metrics.Width;
+                    value.Top = 0;
+                    value.Bottom = metrics.Height;
+                    _OverhangMetrics = value;
+                }
+                return _OverhangMetrics.Value;
             }
         }
 
index 5676016..6a266f0 100644 (file)
@@ -288,7 +288,7 @@ namespace FooEditEngine
 
                     DrawUpdateArea(i, pos.Y);
 
-                    pos.Y += this.LayoutLines.GetLayout(i).Height;
+                    pos.Y += layout.Height;
                     //pos.Y += this.render.emSize.Height;
                 }
 
@@ -320,7 +320,7 @@ namespace FooEditEngine
 
                     this.render.DrawOneLine(this.Document, this.LayoutLines, i, pos.X, pos.Y);
 
-                    pos.Y += this.LayoutLines.GetLayout(i).Height;
+                    pos.Y += layout.Height;
                     //pos.Y += this.render.emSize.Height;
                 }
 
@@ -444,8 +444,9 @@ namespace FooEditEngine
             IEditorRender render = (IEditorRender)base.render;
 
             int row = this.Document.CaretPostion.row;
-            double lineHeight = this.LayoutLines.GetLayout(row).Height;
-            double charWidth = this.LayoutLines.GetLayout(row).GetWidthFromIndex(this.Document.CaretPostion.col);
+            ITextLayout layout = this.LayoutLines.GetLayout(row);
+            double lineHeight = layout.Height;
+            double charWidth = layout.GetWidthFromIndex(this.Document.CaretPostion.col);
 
             if (this.InsertMode || charWidth == 0)
             {