*Addition and implementation of UI Font 4.x-dev

Wed, 25 Nov 2020 07:27:53 +0200

author
Luca Tonini
date
Wed, 25 Nov 2020 07:27:53 +0200
branch
4.x-dev
changeset 1499
6c10d104a254
parent 1498
e3e79d212403
child 1500
e626149880fd

*Addition and implementation of UI Font

Tools/ResourceManagementUI/CMakeLists.txt file | annotate | diff | comparison | revisions
Tools/ResourceManagementUI/Resource/Font/Goldman-Bold.ttf file | annotate | diff | comparison | revisions
Tools/ResourceManagementUI/Resource/Font/Goldman-Regular.ttf file | annotate | diff | comparison | revisions
Tools/ResourceManagementUI/Resource/Font/OFL.txt file | annotate | diff | comparison | revisions
Tools/ResourceManagementUI/Source/Main.cpp file | annotate | diff | comparison | revisions
Tools/ResourceManagementUI/Source/UI/App.cpp file | annotate | diff | comparison | revisions
Tools/ResourceManagementUI/Source/UI/App.h file | annotate | diff | comparison | revisions
--- a/Tools/ResourceManagementUI/CMakeLists.txt	Mon Nov 23 05:16:58 2020 +0200
+++ b/Tools/ResourceManagementUI/CMakeLists.txt	Wed Nov 25 07:27:53 2020 +0200
@@ -30,4 +30,4 @@
 install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
 
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Resource/Icon.png ${CMAKE_CURRENT_SOURCE_DIR}/Bin/Icon.png COPYONLY)
-
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Resource/Font/Goldman-Regular.ttf ${CMAKE_CURRENT_SOURCE_DIR}/Bin/Goldman-Regular.ttf COPYONLY)
Binary file Tools/ResourceManagementUI/Resource/Font/Goldman-Bold.ttf has changed
Binary file Tools/ResourceManagementUI/Resource/Font/Goldman-Regular.ttf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Tools/ResourceManagementUI/Resource/Font/OFL.txt	Wed Nov 25 07:27:53 2020 +0200
@@ -0,0 +1,93 @@
+Copyright 2018 The Goldman Project Authors (https://github.com/magictype/goldman)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded, 
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
--- a/Tools/ResourceManagementUI/Source/Main.cpp	Mon Nov 23 05:16:58 2020 +0200
+++ b/Tools/ResourceManagementUI/Source/Main.cpp	Wed Nov 25 07:27:53 2020 +0200
@@ -1,19 +1,35 @@
 #include <iostream>
 #include <Gorgon/Main.h>
 #include <Gorgon/String.h>
+#include <Gorgon/OS.h>
+
 #include "UI/App.h"
 
+#ifdef LINUX
+#include <unistd.h>
+#include <wait.h>
+
+namespace Gorgon { namespace OS {
+    bool Start(const std::string &name, std::streambuf *&buf, const std::vector<std::string> &args);
+} }
+#endif
 
 //Main execution function of Resource Management UI
 int main(int argc, char *argv[]){
+    int fs = 12;
+    std::string fontName = "";
     
     Gorgon::Initialize("ResourceManagementUI");
     
-    int fs = 14;
+    //This will set up default fonts on a linux system if the provided font is not available
+    std::streambuf *buf;
+    Gorgon::OS::Start("fc-match", buf, {"-v", "sans"});
+    system("pwd");
     
-    UI::App app({550,350}, fs, "DejaVuSans.ttf", "Gorgon Resource Manager");
+    //Initializes the UI
+    UI::App app({550,350}, fs, "Gorgon Resource Manager");
 
-    
+    //Continues to diplay the UI until it is closed by the user
     while(true){
         
         Gorgon::NextFrame();
--- a/Tools/ResourceManagementUI/Source/UI/App.cpp	Mon Nov 23 05:16:58 2020 +0200
+++ b/Tools/ResourceManagementUI/Source/UI/App.cpp	Wed Nov 25 07:27:53 2020 +0200
@@ -1,12 +1,11 @@
 #include "App.h"
+#include <Gorgon/UI/Organizers/Flow.h>
 
 namespace UI{
 
     //Initialization of constructor class 
-    UI::App::App ( Gorgon::Geometry::Size size, int fontSize, std::string fontname, std::string title ):window(size,title), initFont(fontname,fontSize){
+    UI::App::App ( Gorgon::Geometry::Size size, int fontSize, std::string title ):window(size,title), btnImport("Import"),btnFileFrom("Path From"), btnFileTo("Path To"), pnlSettings(Gorgon::Widgets::Registry::Panel_Left){
         
-        //Set up default window settings
-        Gorgon::Graphics::Initialize();
         
         //Import application icon and apply to window
         //This may fail if the debug path is not set correctly
@@ -21,7 +20,23 @@
         applicationBG.SetColor(0.22f);
         applicationBG.DrawIn(backgroundLayer);
         
-        //Allows the program to be terminated of the window is closed.
+        
+        
+        //Initialization of settings  panel
+        pnlSettings.SetWidth(510);
+        pnlSettings.Move(20, 20);
+        pnlSettings.SetHeight(310);
+        pnlSettings.EnableScroll(false, false);
+        window.Add(pnlSettings);
+        
+        
+        //Organizers to display elements to the panel.
+        auto &org = pnlSettings.CreateOrganizer<Gorgon::UI::Organizers::Flow>();
+        
+        org << std::endl << 2 << "Label" << btnFileFrom << btnFileTo
+         << org.Break << std::endl << 2 << "Label" << btnImport ;
+        
+        //Allows the program to be terminated if the window is closed.
         window.DestroyedEvent.Register([&]() {
             exit(0);
         });
@@ -29,13 +44,7 @@
     }
 
     
-    //construction of UI font, color of text, hover effect, 
-    //background color of texts,ect
-    App::initUIfont::initUIfont ( std::string font, int fs ){
-        Gorgon::Graphics::Initialize();
-        
-        uiGen.Init(fs, font);
-        uiGen.Activate();
-    }
+    
+    
 
 }
--- a/Tools/ResourceManagementUI/Source/UI/App.h	Mon Nov 23 05:16:58 2020 +0200
+++ b/Tools/ResourceManagementUI/Source/UI/App.h	Wed Nov 25 07:27:53 2020 +0200
@@ -6,17 +6,17 @@
 #include <Gorgon/UI/Window.h>
 #include <Gorgon/Geometry/Size.h>
 #include <Gorgon/Widgets/Panel.h>
-
+#include <Gorgon/UI.h>
 #include <Gorgon/Layer.h>
 #include <Gorgon/Graphics/BlankImage.h>
 #include <Gorgon/UI/ComponentStack.h>
 #include <Gorgon/Widgets/Generator.h>
-#include <Gorgon/UI/Window.h>
+
 #include <Gorgon/Widgets/Button.h>
 #include <Gorgon/Widgets/Checkbox.h>
 #include <Gorgon/Widgets/RadioButtons.h>
 #include <Gorgon/Widgets/Label.h>
-#include <Gorgon/Widgets/Panel.h>
+
 #include <Gorgon/UI/RadioControl.h>
 #include <Gorgon/WindowManager.h>
 #include <Gorgon/CGI/Line.h>
@@ -27,20 +27,32 @@
 #include <Gorgon/Widgets/Composer.h>
 #include <typeinfo>
 #include <Gorgon/UI/Template.h>
-#include <Gorgon/CGI/Line.h>
-#include <Gorgon/Widgets/Composer.h>
+#include <Gorgon/Graphics/Color.h>
+#include <Gorgon/Graphics/FreeType.h>
+
 
 namespace UI{
+    
+    class InitUI {
+    public:
+        InitUI() {
+            Gorgon::Graphics::Initialize();
+            Gorgon::UI::Initialize("Goldman-Regular.ttf",7,12);            
+        };
+    };
+    
     class App{
     public:    
         //Declaration function for UI to be called in Main.cpp
-        App (Gorgon::Geometry::Size size, int fontSize, std::string fontname, std::string title );
+        App (Gorgon::Geometry::Size size, int fontSize, std::string title );
         
         
     private:
         //Gorgon Main UI Window
         Gorgon::UI::Window window;
         
+        //This will initialize UI after the window is created.
+        InitUI uninit;
         
         //Gorgon Icon objects for app window
         Gorgon::Graphics::Bitmap ico;
@@ -49,25 +61,18 @@
         //Gorgon Layer objects
         Gorgon::Graphics::Layer backgroundLayer;
         
+        //background of default window
         Gorgon::Graphics::BlankImage applicationBG;
         
         //Gorgon Button Objects
-        //Gorgon::Widgets::Button btnImport;
+        Gorgon::Widgets::Button btnImport, btnFileFrom, btnFileTo;
         
         //Gorgon Checkbox opjects
         //Gorgon::Widgets::Checkbox metadata;
         
         //Gorgon panel objects
-        //Gorgon::Widgets::Panel pnl;
+        Gorgon::Widgets::Panel pnlSettings;
         
-        //Structure for font of UI
-        struct initUIfont{
-            initUIfont(std::string font, int fs);
-            
-            Gorgon::Widgets::SimpleGenerator uiGen;
-        };
         
-        //Initialization of font Structure
-        initUIfont initFont;
     };
 }

mercurial