Mon, 28 Jun 2021 10:10:07 +0300
* Icon label bg & spacing fix
* Bitmap export const fix
--- a/Source/Gorgon/Graphics/Bitmap.cpp Mon Jun 28 10:08:45 2021 +0300 +++ b/Source/Gorgon/Graphics/Bitmap.cpp Mon Jun 28 10:10:07 2021 +0300 @@ -147,7 +147,7 @@ return data->ImportBMP(file); } - bool Bitmap::Export(const std::string &filename) { + bool Bitmap::Export(const std::string &filename) const { auto dotpos = filename.find_last_of('.'); if(dotpos!=-1) { auto ext = filename.substr(dotpos+1); @@ -166,7 +166,7 @@ return false; } - bool Bitmap::ExportPNG(const std::string &filename) { + bool Bitmap::ExportPNG(const std::string &filename) const { ASSERT(data, "Image data does not exists"); if(GetMode()!=Graphics::ColorMode::RGB && @@ -188,7 +188,7 @@ return true; } - bool Bitmap::ExportPNG(std::ostream &out) { + bool Bitmap::ExportPNG(std::ostream &out) const { ASSERT(data, "Image data does not exists"); if(data->GetSize().Cells() == 0) @@ -206,7 +206,7 @@ return true; } - bool Bitmap::ExportBMP(const std::string &filename) { + bool Bitmap::ExportBMP(const std::string &filename) const { ASSERT(data, "Image data does not exists"); if(data->GetSize().Cells() == 0) @@ -215,7 +215,7 @@ return data->ExportBMP(filename); } - bool Bitmap::ExportBMP(std::ostream &out) { + bool Bitmap::ExportBMP(std::ostream &out) const { ASSERT(data, "Image data does not exists"); if(data->GetSize().Cells() == 0) @@ -224,7 +224,7 @@ return data->ExportBMP(out); } - bool Bitmap::ExportJPEG(const std::string &filename, int quality) { + bool Bitmap::ExportJPEG(const std::string &filename, int quality) const { ASSERT(data, "Image data does not exists"); if(GetMode()!=Graphics::ColorMode::RGB && @@ -246,7 +246,7 @@ return true; } - bool Bitmap::ExportJPG(std::ostream &out, int quality) { + bool Bitmap::ExportJPG(std::ostream &out, int quality) const { ASSERT(data, "Image data does not exists"); if(GetMode()!=Graphics::ColorMode::RGB &&
--- a/Source/Gorgon/Graphics/Bitmap.h Mon Jun 28 10:08:45 2021 +0300 +++ b/Source/Gorgon/Graphics/Bitmap.h Mon Jun 28 10:10:07 2021 +0300 @@ -460,41 +460,41 @@ /// If image data is already discarded, there is no way to retrieve it. May throw if color mode is not supported /// by PNG encoding. PNG encoding allows: RGB, RGBA, Grayscale, Grayscale alpha. Additionally, Alpha only /// images are saved as grayscale alpha. - bool Export(const std::string &filename); + bool Export(const std::string &filename) const; /// Exports the data of the image resource to a PNG file. This function requires image data to be present. /// If image data is already discarded, there is no way to retrieve it. May throw if color mode is not supported /// by PNG encoding. PNG encoding allows: RGB, RGBA, Grayscale, Grayscale alpha. Additionally, Alpha only /// images are saved as grayscale alpha. - bool ExportPNG(const std::string &filename); + bool ExportPNG(const std::string &filename) const; /// Exports the data of the image resource to a PNG file. This function requires image data to be present. /// If image data is already discarded, there is no way to retrieve it. May throw if color mode is not supported /// by PNG encoding. PNG encoding allows: RGB, RGBA, Grayscale, Grayscale alpha. Additionally, Alpha only /// images are saved as grayscale alpha. - bool ExportPNG(std::ostream &out); + bool ExportPNG(std::ostream &out) const; /// Exports the data of the image resource to a bitmap file. This function requires image data to be present. /// If image data is already discarded, there is no way to retrieve it. All color modes are supported in BMP, /// however, saving and loading the file may change the color mode. Regardless of this change when drawn, /// bitmap will appear the same on the screen. - bool ExportBMP(const std::string &filename); + bool ExportBMP(const std::string &filename) const; /// Exports the data of the image resource to a bitmap file. This function requires image data to be present. /// If image data is already discarded, there is no way to retrieve it. All color modes are supported in BMP, /// however, saving and loading the file may change the color mode. Regardless of this change when drawn, /// bitmap will appear the same on the screen. - bool ExportBMP(std::ostream &out); + bool ExportBMP(std::ostream &out) const; /// Exports the data of the image resource to a JPG file. This function requires image data to be present. /// If image data is already discarded, there is no way to retrieve it. May throw if color mode is not supported /// by PNG encoding. JPG encoding allows: RGB and Grayscale. Quality is between 0 and 100. - bool ExportJPEG(const std::string &filename, int quality = 90); + bool ExportJPEG(const std::string &filename, int quality = 90) const; /// Exports the data of the image resource to a JPG file. This function requires image data to be present. /// If image data is already discarded, there is no way to retrieve it. May throw if color mode is not supported /// by PNG encoding. JPG encoding allows: RGB and Grayscale. Quality is between 0 and 100. - bool ExportJPG(std::ostream &out, int quality = 90); + bool ExportJPG(std::ostream &out, int quality = 90) const; /// Creates the blurred version of this image as a new separate image. This function creates another image since /// it is not possible to apply blur in place. You may use move assignment to modify the original `img = img.Blur(1.2);`
--- a/Source/Gorgon/Widgets/Generator.cpp Mon Jun 28 10:08:45 2021 +0300 +++ b/Source/Gorgon/Widgets/Generator.cpp Mon Jun 28 10:10:07 2021 +0300 @@ -1761,48 +1761,41 @@ } UI::Template SimpleGenerator::IconLabel() { - Geometry::Size defsize = {GetUnitSize(1), unitsize}; + Geometry::Size defsize = {GetUnitSize(1), GetUnitSize(1)}; UI::Template temp = maketemplate(); temp.SetSpacing(spacing); temp.SetSize(defsize); temp.AddContainer(0, UI::ComponentCondition::Always) - .AddIndex(3) //Border - .AddIndex(4) //Content + .AddIndex(2) //Content ; - auto &bg = temp.AddContainer(3, UI::ComponentCondition::Always); - bg.Background.SetAnimation(A(Rectangle, Info)); - bg.SetPositioning(UI::ComponentTemplate::Absolute); - - - auto &cont = temp.AddContainer(4, UI::ComponentCondition::Always, UI::ComponentCondition::Disabled) + + auto &cont = temp.AddContainer(2, UI::ComponentCondition::Always, UI::ComponentCondition::Disabled) .AddIndex(1) //icon - .AddIndex(2) //text ; cont.SetValueModification(UI::ComponentTemplate::ModifyAlpha, UI::ComponentTemplate::UseTransition); cont.SetValueRange(0, 1, 0.5); cont.SetReversible(true); - cont.SetClip(true); - cont.SetPadding(spacing); - cont.SetBorderSize(Border.Width + Border.Radius/2); + //cont.SetClip(true); + //cont.Background.SetAnimation(A(Background, Regular)); cont.SetPositioning(UI::ComponentTemplate::Absolute); auto &txt = temp.AddTextholder(1, UI::ComponentCondition::Always); - txt.SetRenderer(infoprinter); + txt.SetRenderer(printer); txt.SetColor(Graphics::Color::White); txt.SetAnchor(UI::Anchor::MiddleRight, UI::Anchor::MiddleLeft, UI::Anchor::MiddleLeft); txt.SetDataEffect(UI::ComponentTemplate::Text); txt.SetSize(100, 100, UI::Dimension::Percent); txt.SetSizing(UI::ComponentTemplate::ShrinkOnly); - auto &icon = temp.AddPlaceholder(1, UI::ComponentCondition::Icon1IsSet); + auto &icon = temp.AddGraphics(1, UI::ComponentCondition::Icon1IsSet); icon.SetDataEffect(UI::ComponentTemplate::Icon); - icon.SetAnchor(UI::Anchor::MiddleRight, UI::Anchor::MiddleLeft, UI::Anchor::MiddleLeft); + icon.SetAnchor(UI::Anchor::MiddleRight, UI::Anchor::MiddleCenter, UI::Anchor::MiddleCenter); icon.SetSize(100, 100, UI::Dimension::Percent); + icon.SetFillArea(false); icon.SetSizing(UI::ComponentTemplate::ShrinkOnly); - icon.SetMargin(0, 0, 0, 0); return temp;
--- a/Source/Gorgon/Widgets/Generator.h Mon Jun 28 10:08:45 2021 +0300 +++ b/Source/Gorgon/Widgets/Generator.h Mon Jun 28 10:10:07 2021 +0300 @@ -124,7 +124,7 @@ case Label_Info: return *new UI::Template(InfoLabel()); case Label_Icon: - return *new UI::Template(InfoLabel()); + return *new UI::Template(IconLabel()); case Checkbox_Regular: return *new UI::Template(Checkbox()); case Checkbox_Button: