* Fixed some VS warnings 4.x-dev

Sat, 06 Nov 2021 07:00:26 +0200

author
cemkalyoncu
date
Sat, 06 Nov 2021 07:00:26 +0200
branch
4.x-dev
changeset 1761
590f2c163684
parent 1760
33598e9edccd
child 1762
c4c7fae673b8

* Fixed some VS warnings

Source/Gorgon/CGI/Polygon.h file | annotate | diff | comparison | revisions
Source/Gorgon/Containers/Image.h file | annotate | diff | comparison | revisions
Source/Gorgon/Geometry/Point.h file | annotate | diff | comparison | revisions
Source/Gorgon/Geometry/Scripting.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/ImageProcessing/Filters.h file | annotate | diff | comparison | revisions
Source/Gorgon/OS/Win32.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/UI/Dimension.h file | annotate | diff | comparison | revisions
Source/Gorgon/UI/Organizers/Flow.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/UI/ScrollingWidget.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/UI/TooltipManager.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/ColorPlane.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Generator.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Listbox.h file | annotate | diff | comparison | revisions
--- a/Source/Gorgon/CGI/Polygon.h	Fri Nov 05 16:14:49 2021 +0200
+++ b/Source/Gorgon/CGI/Polygon.h	Sat Nov 06 07:00:26 2021 +0200
@@ -210,7 +210,7 @@
             }
             
             //fill
-            fn((Float)y, drawlist);
+            fn(y, drawlist);
             drawlist.clear();
         }
     }
--- a/Source/Gorgon/Containers/Image.h	Fri Nov 05 16:14:49 2021 +0200
+++ b/Source/Gorgon/Containers/Image.h	Sat Nov 06 07:00:26 2021 +0200
@@ -940,7 +940,7 @@
 
                         for(int x=0; x<newsize.Width; x++) {
                             for(unsigned c=0; c<cpp; c++) {
-                                float xn = x + b.Left;
+                                float xn = float(x + b.Left);
 
                                 target(x, y, c) = Get((int)std::round(xn - yn * perpixel), y, c);
                             }
@@ -952,7 +952,7 @@
                         float yn = y - origin.Y + b.Top;
 
                         for(int x=0; x<newsize.Width; x++) {
-                            float xn = x + b.Left;
+                            float xn = float(x + b.Left);
 
                             float xx = xn - yn * perpixel;
 
@@ -978,7 +978,7 @@
                         float yn = y - origin.Y + b.Top;
 
                         for(int x=0; x<newsize.Width; x++) {
-                            float xn = x + b.Left;
+                            float xn = float(x + b.Left);
 
                             float xx = xn - yn * perpixel;
 
@@ -1039,7 +1039,7 @@
 
                         for(int y=0; y<newsize.Height; y++) {
                             for(unsigned c=0; c<cpp; c++) {
-                                float yn = y + b.Top;
+                                float yn = float(y + b.Top);
 
                                 target(x, y, c) = Get(x, (int)std::round(yn - xn * perpixel), c);
                             }
@@ -1051,7 +1051,7 @@
                         float xn = x - origin.X + b.Left;
 
                         for(int y=0; y<newsize.Height; y++) {
-                            float yn = y + b.Top;
+                            float yn = float(y + b.Top);
 
                             float yy = yn - xn * perpixel;
 
@@ -1077,7 +1077,7 @@
                         float xn = x - origin.X + b.Left;
 
                         for(int y=0; y<newsize.Height; y++) {
-                            float yn = y + b.Top;
+                            float yn = float(y + b.Top);
 
                             float yy = yn - xn * perpixel;
 
@@ -1120,7 +1120,7 @@
                 int yy = size.Height - 1;
                 for(int y=0; y<size.Height; y++) {
                     for(int x=0; x<size.Width; x++) {
-                        for(int c=0; c<cpp; c++) {
+                        for(unsigned c=0; c<cpp; c++) {
                             target(x, y, c) = operator()(x, yy, c);
                         }
                     }
@@ -1137,7 +1137,7 @@
                 int xx = size.Width- 1;
                 for(int x=0; x<size.Width; x++) {
                     for(int y=0; y<size.Height; y++) {
-                        for(int c=0; c<cpp; c++) {
+                        for(unsigned c=0; c<cpp; c++) {
                             target(x, y, c) = operator()(xx, y, c);
                         }
                     }
--- a/Source/Gorgon/Geometry/Point.h	Fri Nov 05 16:14:49 2021 +0200
+++ b/Source/Gorgon/Geometry/Point.h	Sat Nov 06 07:00:26 2021 +0200
@@ -284,6 +284,7 @@
 				Float ydif = (Float)(target.Y - Y);
 				return (xdif * xdif) + (ydif * ydif);
 			}
+
 			/// Calculates Euclidean distance from this point to origin
 			Float Distance() const {
 				return std::sqrt( Float(X*X) + Float(Y*Y) );
@@ -293,14 +294,15 @@
 			Float EuclideanSquare() const {
 				return Float(X * X) + Float(Y * Y);
 			}
+
 			/// Calculates Manhattan distance from this point to the given target
-			Float ManhattanDistance(const basic_Point &target) const {
-				return (Float)(std::abs(X-target.X) + std::abs(Y-target.Y));
+			T_ ManhattanDistance(const basic_Point &target) const {
+				return (std::abs(X-target.X) + std::abs(Y-target.Y));
 			}
 
 			/// Calculates Manhattan distance from this point to origin
-			Float ManhattanDistance() const {
-				return (Float)(std::abs(X) + std::abs(Y));
+			T_ ManhattanDistance() const {
+				return (std::abs(X) + std::abs(Y));
 			}
 			
 			/// Normalizes the point as a unit vector
--- a/Source/Gorgon/Geometry/Scripting.cpp	Fri Nov 05 16:14:49 2021 +0200
+++ b/Source/Gorgon/Geometry/Scripting.cpp	Sat Nov 06 07:00:26 2021 +0200
@@ -204,7 +204,7 @@
                     Scripting::MapFunction(
                         [](Point owner, Point other){
                             return owner.ManhattanDistance(other);
-                        },Scripting::Types::Float(),
+                        },Scripting::Types::Int(),
                         {
                             Scripting::Parameter("Point","Another point to calculate the Manhattan Distance from",point)
                         },
@@ -213,7 +213,7 @@
                     Scripting::MapFunction(
                         [](Point owner){
                             return owner.ManhattanDistance();
-                        },Scripting::Types::Float(),
+                        },Scripting::Types::Int(),
                         { },
                         Scripting::ConstTag
                     )
--- a/Source/Gorgon/ImageProcessing/Filters.h	Fri Nov 05 16:14:49 2021 +0200
+++ b/Source/Gorgon/ImageProcessing/Filters.h	Sat Nov 06 07:00:26 2021 +0200
@@ -170,7 +170,7 @@
                         default:
                             for(int c=0; c<C; c++) {
                                 if(!noalpha || c != A)
-                                    output(x, y, c) = values[c] / weightsum;
+                                    output(x, y, c) = Byte(values[c] / weightsum);
                             }
                             break;
                         }
@@ -178,7 +178,7 @@
                     else {
                         for(int c=0; c<C; c++) {
                             if(!noalpha || c != A)
-                                output(x, y, c) = values[c] / weightsum;
+                                output(x, y, c) = Byte(values[c] / weightsum);
                         }
                     }
                 }
@@ -279,7 +279,7 @@
                         default:
                             for(int c=0; c<C; c++) {
                                 if(!noalpha || c != A)
-                                    output(x, y, c) = values[c];
+                                    output(x, y, c) = Byte(values[c]);
                             }
                             break;
                         }
@@ -287,7 +287,7 @@
                     else {
                         for(int c=0; c<C; c++) {
                             if(!noalpha || c != A)
-                                output(x, y, c) = values[c];
+                                output(x, y, c) = Byte(values[c]);
                         }
                     }
                 }
--- a/Source/Gorgon/OS/Win32.cpp	Fri Nov 05 16:14:49 2021 +0200
+++ b/Source/Gorgon/OS/Win32.cpp	Sat Nov 06 07:00:26 2021 +0200
@@ -440,7 +440,7 @@
 
 		std::vector<std::string> filenames;
 
-		for(int i = 0; i<fontcount; i++) {
+		for(int i = 0; i<(int)fontcount; i++) {
 			DWORD type, size = maxsize, nl = maxnamelen;
 
 			result = RegEnumValue(fontskey, i,
--- a/Source/Gorgon/UI/Dimension.h	Fri Nov 05 16:14:49 2021 +0200
+++ b/Source/Gorgon/UI/Dimension.h	Sat Nov 06 07:00:26 2021 +0200
@@ -158,8 +158,8 @@
                         return (float)value * emwidth / 100.f;
                     case UnitSize:
                         if(!issize || (value >= -1 && value <= 1))
-                            return value * unitsize;
-                        return value * unitsize + (value - 1) * spacing;
+                            return float(value * unitsize);
+                        return float(value * unitsize + (value - 1) * spacing);
                     case MilliUnitSize:
                         if(!issize || (value >= -1000 && value <= 1000))
                             return (float)value * unitsize / 1000;
@@ -184,7 +184,7 @@
                     case EM:
                         return (float)value * emwidth / 100.f;
                     case UnitSize:
-                        return value * (unitsize + spacing);
+                        return float(value * (unitsize + spacing));
                     case MilliUnitSize:
                         return (float)value * (unitsize + spacing) / 1000;
                     case Spaces:
--- a/Source/Gorgon/UI/Organizers/Flow.cpp	Fri Nov 05 16:14:49 2021 +0200
+++ b/Source/Gorgon/UI/Organizers/Flow.cpp	Sat Nov 06 07:00:26 2021 +0200
@@ -59,10 +59,10 @@
                 float off = 0;
                 
                 if(align == Graphics::TextAlignment::Center) {
-                    off = (width - w) / 2;
+                    off = (width - w) / 2.f;
                 }
                 else if(align == Graphics::TextAlignment::Right) {
-                    off = width - w;
+                    off = float(width - w);
                 }
                 
                 float perfraction = 0;
--- a/Source/Gorgon/UI/ScrollingWidget.cpp	Fri Nov 05 16:14:49 2021 +0200
+++ b/Source/Gorgon/UI/ScrollingWidget.cpp	Sat Nov 06 07:00:26 2021 +0200
@@ -139,11 +139,11 @@
                 
             auto vscroller = dynamic_cast<Widgets::VScroller<float>*>(stack.GetWidget(UI::ComponentTemplate::VScrollTag));
             if(vscroller)
-                vscroller->SetSmoothChangeSpeed(scrollspeedpx);
+                vscroller->SetSmoothChangeSpeed(float(scrollspeedpx));
             
             auto hscroller = dynamic_cast<Widgets::HScroller<float>*>(stack.GetWidget(UI::ComponentTemplate::HScrollTag));
             if(hscroller)
-                hscroller->SetSmoothChangeSpeed(scrollspeedpx);
+                hscroller->SetSmoothChangeSpeed(float(scrollspeedpx));
                     
             scrollleftover = 0;
         }
--- a/Source/Gorgon/UI/TooltipManager.cpp	Fri Nov 05 16:14:49 2021 +0200
+++ b/Source/Gorgon/UI/TooltipManager.cpp	Sat Nov 06 07:00:26 2021 +0200
@@ -153,7 +153,7 @@
         
         if(delayleft != -1) {
             if(toplevel) {
-                int movement = (toplevel->GetMouseLocation()-lastlocation).ManhattanDistance();
+                int movement = (int)(toplevel->GetMouseLocation()-lastlocation).ManhattanDistance();
                 if(toleranceleft < movement) {
                     lastlocation = toplevel->GetMouseLocation();
                     delayleft = delay + Time::DeltaTime();
@@ -163,7 +163,7 @@
                 }
             }
             
-            if(delayleft <= Time::DeltaTime()) {
+            if(delayleft <= (long)Time::DeltaTime()) {
                 if(current) {
                     Show(current->GetTooltip());
                     place();
@@ -177,7 +177,7 @@
         }
         
         if(lingerleft != -1) {
-            if(lingerleft <= Time::DeltaTime()) {
+            if(lingerleft <= (long)Time::DeltaTime()) {
                 Hide();
                 
                 lingerleft = -1;
--- a/Source/Gorgon/Widgets/ColorPlane.cpp	Fri Nov 05 16:14:49 2021 +0200
+++ b/Source/Gorgon/Widgets/ColorPlane.cpp	Sat Nov 06 07:00:26 2021 +0200
@@ -61,7 +61,7 @@
                 if(l.Y == 0) {
                     if(l.X >= huetable.size() / 2) {
                         halftablerow = 1;
-                        l.X -= huetable.size() / 2;
+                        l.X -= (int)huetable.size() / 2;
                     }
                     else if(l.X < huetable.size()){
                         halftablerow = 0;
@@ -70,7 +70,7 @@
                 if(l.Y == 1) {
                     if(l.X >= huetable.size() / 2) {
                         halftablerow = 3;
-                        l.X -= huetable.size() / 2;
+                        l.X -= (int)huetable.size() / 2;
                     }
                     else if(l.X < huetable.size()){
                         halftablerow = 2;
@@ -80,7 +80,7 @@
             else if(l.Y == 0) {
                 if(l.X >= huetable.size() / 2) {
                     halftablerow = 3;
-                    l.X -= huetable.size() / 2;
+                    l.X -= (int)huetable.size() / 2;
                 }
                 else if(l.X < huetable.size()){
                     halftablerow = 2;
@@ -90,16 +90,16 @@
             found = true;
             switch(halftablerow) {
             case 0:
-                color = Graphics::LChAf(20, 10, huetable[l.X * 2]);
+                color = Graphics::LChAf(20, 10, float(huetable[l.X * 2]));
                 break;
             case 1:
-                color = Graphics::LChAf(80, 15, huetable[l.X * 2]);
+                color = Graphics::LChAf(80, 15, float(huetable[l.X * 2]));
                 break;
             case 2:
-                color = Graphics::LChAf(8, 25, huetable[l.X * 2]);
+                color = Graphics::LChAf(8, 25, float(huetable[l.X * 2]));
                 break;
             case 3:
-                color = Graphics::LChAf(5, 75, huetable[l.X * 2]);
+                color = Graphics::LChAf(5, 75, float(huetable[l.X * 2]));
                 break;
                 
             default:
@@ -115,7 +115,7 @@
             
             if(l.Y < lctable.size() && l.X < huetable.size()) {
                 found = true;
-                color = Graphics::LChAf(lctable[l.Y].first, lctable[l.Y].second, huetable[l.X]);
+                color = Graphics::LChAf(float(lctable[l.Y].first), float(lctable[l.Y].second), float(huetable[l.X]));
             }
             
             if(alpha) 
@@ -177,8 +177,8 @@
         display.Resize(sz);
         display.ForAllValues([](auto &c) { c = 255; });
         
-        sz.Width  -= huetable.size()*2 + 2;
-        sz.Height -= lctable.size()*2  + 8 + (lctable.size()>8)*2 + alpha*4; //extra space between grayscale and other colors
+        sz.Width  -= int(huetable.size()*2 + 2);
+        sz.Height -= int(lctable.size()*2  + 8 + (lctable.size()>8)*2 + alpha*4); //extra space between grayscale and other colors
         
         float w = (float)sz.Width / huetable.size();
         float h = (float)sz.Height/ (lctable.size() + 2 + (lctable.size()>8) + alpha);
@@ -191,7 +191,7 @@
         basecolor.A = 1.f;
         
         if(alpha) {
-            int sw = (h+4)/4+1;
+            int sw = int(std::round((h+4)/4+1));
             bool state = false;
             bool sstate = false;
             int toth = display.GetData().GetHeight();
@@ -239,7 +239,7 @@
         for(auto p : lctable) {
             x = 2;
             for(auto hue : huetable) {
-                drawrect(Graphics::LChAf(p.first, p.second, hue));
+                drawrect(Graphics::LChAf(float(p.first), float(p.second), float(hue)));
             }
             
             y += h + 2;
@@ -250,10 +250,10 @@
         //additional low constrast colors
         if(lctable.size() > 8) {
             for(int hue=0; hue<huetable.size()/2; hue++) {
-                drawrect(Graphics::LChAf(20, 10, huetable[hue*2]));
+                drawrect(Graphics::LChAf(20, 10, float(huetable[hue*2])));
             }
             for(int hue=0; hue<huetable.size()/2; hue++) {
-                drawrect(Graphics::LChAf(80, 15, huetable[hue*2]));
+                drawrect(Graphics::LChAf(80, 15, float(huetable[hue*2])));
             }
             y += h + 2;
         }
@@ -261,10 +261,10 @@
         //compress very dark colors
         x = 2;
         for(int hue=0; hue<huetable.size()/2; hue++) {
-            drawrect(Graphics::LChAf(8, 25, huetable[hue*2]));
+            drawrect(Graphics::LChAf(8.f, 25.f, float(huetable[hue*2])));
         }
         for(int hue=0; hue<huetable.size()/2; hue++) {
-            drawrect(Graphics::LChAf(5, 75, huetable[hue*2]));
+            drawrect(Graphics::LChAf(5.f, 75.f, float(huetable[hue*2])));
         }
         y += h + 2;
         
--- a/Source/Gorgon/Widgets/Generator.cpp	Fri Nov 05 16:14:49 2021 +0200
+++ b/Source/Gorgon/Widgets/Generator.cpp	Sat Nov 06 07:00:26 2021 +0200
@@ -96,8 +96,8 @@
             FcObjectSetDestroy(os);
         }
 
+    nofc:
 #endif
-    nofc:
         static const std::string regularlist[] = {"dejavu sans", "freesans", "liberation sans", "arial","times new roman"};
         static const std::string monolist[] = {"dejavu sans mono", "free mono", "liberation mono", "consolas", "courier new"};
         
@@ -431,7 +431,7 @@
             }
         }
         else {
-            border.Width = bordersize;
+            border.Width = (int)std::round(bordersize);
             border.Shape = bordersize / 2.f + objectheight/18.f;
         }
         
@@ -500,28 +500,28 @@
         
         switch(id.Type) {
         case AssetID::Rectangle:
-            prov = makeborder(bd, bg, id.Border, bw, br);
+            prov = makeborder(bd, bg, id.Border, (int)std::round(bw), (int)std::round(br));
             break;
         case AssetID::Background:
-            prov = makeborder(0x0, bg, id.Border, bw, br);
+            prov = makeborder(0x0, bg, id.Border, (int)std::round(bw), (int)std::round(br));
             break;
         case AssetID::Frame:
-            prov = makeborder(bd, 0x0, id.Border, bw, br);
+            prov = makeborder(bd, 0x0, id.Border, (int)std::round(bw), (int)std::round(br));
             break;
         case AssetID::White:
-            prov = makeborder(0x0, Graphics::Color::White, id.Border, bw, br);
+            prov = makeborder(0x0, Graphics::Color::White, id.Border, (int)std::round(bw), (int)std::round(br));
             break;
         case AssetID::Focus:
             prov = makefocusborder();
             break;
         case AssetID::Edit:
-            prov = makeborder(bd, Colors[Graphics::Color::Edit].Backcolor, id.Border, bw, br);
+            prov = makeborder(bd, Colors[Graphics::Color::Edit].Backcolor, id.Border, (int)std::round(bw), (int)std::round(br));
             break;
         case AssetID::FgFilled:
-            prov = makeborder(bd, fg, id.Border, bw, br);
+            prov = makeborder(bd, fg, id.Border, (int)std::round(bw), (int)std::round(br));
             break;
         case AssetID::BorderFilled:
-            prov = makeborder(bd, bd, id.Border, bw, br);
+            prov = makeborder(bd, bd, id.Border, (int)std::round(bw), (int)std::round(br));
             break;
         case AssetID::DownArrow:
             prov = arrow(fg, shapesize, Gorgon::PI);
@@ -1213,7 +1213,7 @@
         
         auto &defbord = temp.AddGraphics(9, UI::ComponentCondition::Default);
         
-        float r = Border.Radius - Focus.Spacing;
+        float r = float(Border.Radius - Focus.Spacing);
         r = std::max(0.f, r);
         
         defbord.Content.SetAnimation(A(Frame, Focus, AllExceptTop, r, (float)Focus.Width));
@@ -2509,8 +2509,8 @@
             bg.SetTag(UI::ComponentTemplate::ResizeTag);            
         };
         
-        addborder(UI::ComponentCondition::Always, A(Rectangle, PassiveContiner, All, expandedradius(spacing)));
-        addborder(UI::ComponentCondition::Focused, A(Rectangle, ActiveContainer, All, expandedradius(spacing)));
+        addborder(UI::ComponentCondition::Always, A(Rectangle, PassiveContiner, All, expandedradius(float(spacing))));
+        addborder(UI::ComponentCondition::Focused, A(Rectangle, ActiveContainer, All, expandedradius(float(spacing))));
         
         auto &titlebar = tmp.AddContainer(5, UI::ComponentCondition::Always)
             .AddIndex(7) //icon
--- a/Source/Gorgon/Widgets/Listbox.h	Fri Nov 05 16:14:49 2021 +0200
+++ b/Source/Gorgon/Widgets/Listbox.h	Sat Nov 06 07:00:26 2021 +0200
@@ -1175,7 +1175,7 @@
                 if(it == storage.end())
                     return -1;
                 else
-                    return it-storage.begin();
+                    return long(it-storage.begin());
             }
             
             /// Allocates memory for the given amount of items
@@ -2059,7 +2059,7 @@
             vscroller->Range        = 1;
             *vscroller              = scrolloffset;
             vscroller->SmallChange  = float(scrolldist);
-            vscroller->SetSmoothChangeSpeed(scrollspeed);
+            vscroller->SetSmoothChangeSpeed(float(scrollspeed));
             vscroller->ValueChanged.Register(*this, &ListboxWidgetBase::ScrollTo);
             
             return vscroller;
@@ -2075,11 +2075,11 @@
             if(1000*abs(target-cur)/scrollspeed > maxscrolltime) {
                 //due to integer division, this value would be scrollspeed at some points, which will reset smooth speed
                 //if not, when scrolling is finished it will be reset
-                curspeed = 1000*abs(target-cur) / maxscrolltime;
+                curspeed = int(1000*abs(target-cur) / maxscrolltime);
             
                 auto scroller = dynamic_cast<VScroller<float>*>(stack.GetWidget(UI::ComponentTemplate::VScrollTag));
                 if(scroller)
-                    scroller->SetSmoothChangeSpeed(curspeed);
+                    scroller->SetSmoothChangeSpeed(float(curspeed));
             }
             
             float dist = (float)curspeed/1000 * Time::DeltaTime();
@@ -2115,7 +2115,7 @@
                 
                 auto scroller = dynamic_cast<VScroller<float>*>(stack.GetWidget(UI::ComponentTemplate::VScrollTag));
                 if(scroller)
-                    scroller->SetSmoothChangeSpeed(scrollspeed); //just in case
+                    scroller->SetSmoothChangeSpeed(float(scrollspeed)); //just in case
                     
                 stack.RemoveFrameEvent();
             }

mercurial