Example: Resize Runtime

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • willfreer
    Forum Member
    • Aug 2004
    • 47

    #76
    full screen

    For some reason this works good on the background, but the buttons, art and video art still their original size, in the top left of the project, any suggestions?

    Comment

    • mindstitchdr
      Indigo Rose Customer
      • Dec 2004
      • 239

      #77
      Try this:

      Make sure you project is set to Resizable then,

      Global Functions:
      Code:
      ---------------------------------------------------------------------------
      --Function Resize_OnSize;
      --This function is in place to reduce the amount of code that must go on
      --each pages "On Size" event
      ---------------------------------------------------------------------------
      function Resize_OnSize (PageWidth,PageHeight)
      	if bFirstRun then
      		setOriginalPageSize(PageWidth,PageHeight);
      		bFirstRun = false;
      	end
      	SetSize(PageWidth,PageHeight);
      end
      
      ---------------------------------------------------------------------------
      --Function Resize_OnPreLoad();
      --This function is in place to reduce the amount of code that must go on
      --each pages "On Preload" event
      ---------------------------------------------------------------------------
      function Resize_OnPreLoad()
      	getOriginalPositions();
      	Size = Page.GetSize();
      	if not bFirstRun then
      		SetSize(Size.Width,Size.Height);
      	end
      end
      
      
      -- This is a global variable that is used to determine the first time that 
      -- This page has been Accessed
      bFirstRun = true;
      
      ---------------------------------------------------------------------------
      --Function setOriginalPageSize
      --This function is used to set a global table with the original page
      --size of your project
      ---------------------------------------------------------------------------
      function setOriginalPageSize(WidthO,HeightO)
      	-- Store these values in a global table. This action is only
      	-- performed once.
      	tblOriginalSize = {Width=WidthO,Height=HeightO};
      end
      
      ---------------------------------------------------------------------------
      --Function RevertSize
      --This function puts all objects back to their original position and size
      --This makes the page look proper if the project is resized on a different
      --page.
      ---------------------------------------------------------------------------
      function Resize_OnClose ()
      	
      	-- Stop the page from redrawing temporarily. If this was not in place
      	-- you would see a flash of the original objects before it is resized
      	-- when you jump pages.
      	Application.SetRedraw(false);
      	
      	-- The loop will go through all of the entries in the global table tblOriginalPos
      	-- and set all of the objects back to their original state.
      	for i = 1, Table.Count(tblOriginalPos) do
      		-- Get the table that is stored in the global table on every itteration of
      		-- the loop
      		tblPos = tblOriginalPos[i];
      		
      		-- The next if -> elseif block determines which type of object
      		-- is currently in the table tblPos
      		if tblPos.ObType == OBJECT_BUTTON then
      			-- If it is a Button then set it back to its original size
      			Button.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
      			-- If it is a Button then set it back to its original Position
      			Button.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
      		elseif tblPos.ObType == OBJECT_LABEL then
      			Label.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
      			Label.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
      		elseif tblPos.ObType == OBJECT_PARAGRAPH then
      			Paragraph.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
      			Paragraph.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
      		elseif tblPos.ObType == OBJECT_IMAGE then
      			Image.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
      			Image.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
      		elseif tblPos.ObType == OBJECT_FLASH then
      			Flash.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
      			Flash.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
      		elseif tblPos.ObType == OBJECT_VIDEO then
      			Video.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
      			Video.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
      		elseif tblPos.ObType == OBJECT_WEB then
      			Web.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
      			Web.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
      		elseif tblPos.ObType == OBJECT_INPUT then
      			Input.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
      			Input.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
      		elseif tblPos.ObType == OBJECT_HOTSPOT then
      			Hotspot.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
      			Hotspot.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
      		elseif tblPos.ObType == OBJECT_LISTBOX then
      			ListBox.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
      			ListBox.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
      		elseif tblPos.ObType == OBJECT_COMBOBOX then
      			ComboBox.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
      			ComboBox.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
      		elseif tblPos.ObType == OBJECT_PROGRESS then
      			Progress.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
      			Progress.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
      		elseif tblPos.ObType == OBJECT_TREE then
      			Tree.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
      			Tree.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
      		elseif tblPos.ObType == OBJECT_PLUGIN then
      			Plugin.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
      			Plugin.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);	
      
      		end		
      	end
      end
      
      ---------------------------------------------------------------------------
      --Function getOriginalPositions
      --This function enumerates all objects on the current page. It then stores
      --information about the objects in a global table to be used for a 
      --reference point to perform the position and size adjustments
      --The following information is stored about each object:
      -- Object Name
      -- Object Type
      -- Width
      -- Height
      -- Position X
      -- Position Y
      ---------------------------------------------------------------------------
      function getOriginalPositions ()
      	-- The master table that contains information about each object on the page
      	tblOriginalPos = {};
      	-- The table that will be stored in the above master table. Each objects 
      	-- information will be stored in the below table
      	Pos = {};
      	-- Get all of the objects on a page
      	Objects = Page.EnumerateObjects();
      	-- Loop through each object on the page
      	for i = 1, Table.Count(Objects) do
      		-- Find out what TYPE of object it is.
      		Type = Page.GetObjectType(Objects[i]);
      		-- If it is a Button then
      		if Type == OBJECT_BUTTON then
      			-- Get the size
      			Size = Button.GetSize(Objects[i]);
      			-- Get the Position
      			Position = Button.GetPos(Objects[i]);
      			-- Set the table up to store this information
      			Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Position.Y,ObName=Objects[i],ObType=OBJECT_BUTTON};
      			-- Store the 'Pos' table in the master table tblOriginalPos
      			tblOriginalPos[i] = Pos;	
      		elseif Type == OBJECT_LABEL then
      			Size = Label.GetSize(Objects[i]);
      			Position = Label.GetPos(Objects[i]);	
      			Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Position.Y,ObName=Objects[i],ObType=OBJECT_LABEL};
      			tblOriginalPos[i] = Pos; 
      		elseif Type == OBJECT_PARAGRAPH then
      			Size = Paragraph.GetSize(Objects[i]);
      			Position = Paragraph.GetPos(Objects[i]);
      			Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Position.Y,ObName=Objects[i],ObType=OBJECT_PARAGRAPH};
      			tblOriginalPos[i] = Pos;
      		elseif Type == OBJECT_IMAGE then
      			Size = Image.GetSize(Objects[i]);
      			Position = Image.GetPos(Objects[i]);	
      			Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Position.Y,ObName=Objects[i],ObType=OBJECT_IMAGE};
      			tblOriginalPos[i] = Pos;
      		elseif Type == OBJECT_FLASH then
      			Size = Flash.GetSize(Objects[i]);
      			Position = Flash.GetPos(Objects[i]);
      			Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Position.Y,ObName=Objects[i],ObType=OBJECT_FLASH};
      			tblOriginalPos[i] = Pos;
      		elseif Type == OBJECT_VIDEO then
      			Size = Video.GetSize(Objects[i]);
      			Position = Video.GetPos(Objects[i]);	
      			Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Position.Y,ObName=Objects[i],ObType=OBJECT_VIDEO};
      			tblOriginalPos[i] = Pos;
      		elseif Type == OBJECT_WEB then
      			Size = Web.GetSize(Objects[i]);
      			Position = Web.GetPos(Objects[i]);
      			Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Position.Y,ObName=Objects[i],ObType=OBJECT_WEB};
      			tblOriginalPos[i] = Pos;
      		elseif Type == OBJECT_INPUT then
      			Size = Input.GetSize(Objects[i]);
      			Position = Input.GetPos(Objects[i]);
      			Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Position.Y,ObName=Objects[i],ObType=OBJECT_INPUT};
      			tblOriginalPos[i] = Pos;
      		elseif Type == OBJECT_HOTSPOT then
      			Size = Hotspot.GetSize(Objects[i]);
      			Position = Hotspot.GetPos(Objects[i]);	
      			Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Position.Y,ObName=Objects[i],ObType=OBJECT_HOTSPOT};
      			tblOriginalPos[i] = Pos;
      		elseif Type == OBJECT_LISTBOX then
      			Size = ListBox.GetSize(Objects[i]);
      			Position = ListBox.GetPos(Objects[i]);
      			Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Position.Y,ObName=Objects[i],ObType=OBJECT_LISTBOX};
      			tblOriginalPos[i] = Pos;
      		elseif Type == OBJECT_COMBOBOX then
      			Size = ComboBox.GetSize(Objects[i]);
      			Position = ComboBox.GetPos(Objects[i]);	
      			Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Position.Y,ObName=Objects[i],ObType=OBJECT_COMBOBOX};
      			tblOriginalPos[i] = Pos;
      		elseif Type == OBJECT_PROGRESS then
      			Size = Progress.GetSize(Objects[i]);
      			Position = Progress.GetPos(Objects[i]);
      			Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Position.Y,ObName=Objects[i],ObType=OBJECT_PROGRESS};
      			tblOriginalPos[i] = Pos;
      		elseif Type == OBJECT_TREE then
      			Size = Tree.GetSize(Objects[i]);			
      			Position = Tree.GetPos(Objects[i]);
      			Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Position.Y,ObName=Objects[i],ObType=OBJECT_TREE};
      			tblOriginalPos[i] = Pos;
      		elseif Type == OBJECT_PLUGIN then
      			Size = Plugin.GetSize(Objects[i]);			
      			Position = Plugin.GetPos(Objects[i]);
      			Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Position.Y,ObName=Objects[i],ObType=OBJECT_PLUGIN};
      			tblOriginalPos[i] = Pos;	
      		end	
      	end
      end
      
      ---------------------------------------------------------------------------
      --Function SetSize
      --This function is where the calculations for resizing and repositioning
      --takes place. It accepts a page Width and Height as parameters. It then
      --finds the ration between the original paage size and the current page size.
      --Every object on the page is then repositioned and resized by the ration
      --of the difference in size.
      ---------------------------------------------------------------------------
      function SetSize (Width,Height)
      	-- Get the original size of the page/project
      	OriginalWidth = tblOriginalSize.Width;
      	OriginalHeight = tblOriginalSize.Height;
      
      	-- Calculate the difference between the original page size and the current
      	RatioW = Width / OriginalWidth;
      	RatioH = Height  / OriginalHeight;
      	
      	-- Turn off the redraw
      	Application.SetRedraw(false);
      	
      	-- Now loop through the table that stores information about each object
      	--and reposition and resize them according to the above ratio
      	for i=1, Table.Count(tblOriginalPos) do
      		-- Each item in tblOriginalPos is a table that holds specific informtion about 
      		-- that object
      		tblProps = tblOriginalPos[i];
      		-- If the item is a Button
      		if tblProps.ObType == OBJECT_BUTTON then
      			-- Set the position of the object
      			Button.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
      			-- Set the size of the object
      			Button.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
      		elseif tblProps.ObType == OBJECT_LABEL then
      			Label.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
      			Label.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
      		elseif tblProps.ObType == OBJECT_PARAGRAPH then
      			Paragraph.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
      			Paragraph.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
      		elseif tblProps.ObType == OBJECT_IMAGE then
      			Image.SetPos(tblProps.ObName, tblProps.X * RatioW, tblProps.Y * RatioH);
      			Image.SetSize(tblProps.ObName, tblProps.W * RatioW, tblProps.H * RatioH);
      		elseif tblProps.ObType == OBJECT_FLASH then
      			Flash.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
      			Flash.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
      		elseif tblProps.ObType == OBJECT_VIDEO then
      			Video.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
      			Video.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
      		elseif tblProps.ObType == OBJECT_WEB then
      			Web.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
      			Web.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
      		elseif tblProps.ObType == OBJECT_INPUT then
      			Input.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
      			Input.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
      		elseif tblProps.ObType == OBJECT_HOTSPOT then
      			Hotspot.SetPos(tblProps.ObName, tblProps.X * RatioW, tblProps.Y * RatioH);
      			Hotspot.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
      		elseif tblProps.ObType == OBJECT_LISTBOX then
      			ListBox.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
      			ListBox.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
      		elseif tblProps.ObType == OBJECT_COMBOBOX then
      			ComboBox.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
      			ComboBox.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
      		elseif tblProps.ObType == OBJECT_PROGRESS then
      			Progress.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
      			Progress.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
      		elseif tblProps.ObType == OBJECT_TREE then
      			Tree.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
      			Tree.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
      		elseif tblProps.ObType == OBJECT_PLUGIN then
      			Plugin.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
      			Plugin.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
      		end
      	end
      
      	-- Allow the page to redraw once all objects have been adjusted
      	Application.SetRedraw(true);
      
      end
      Page's On Preload:

      Code:
      Resize_OnPreLoad();
      Page's On Close:

      Code:
      Resize_OnClose();
      Page's On Size:

      Code:
      Resize_OnSize(e_PageWidth,e_PageHeight);

      Comment

      • Solmos
        New Member
        • Aug 2006
        • 355

        #78
        Hi mindstitchdr

        in that code it is possible to redimensionar the size of the columns of datagrid? fixing to us to the size of an image by column?

        I have proven with this code but not work

        Global functions:

        Code:
        elseif tblProps.ObType == OBJECT_IMAGE then
        			Image.SetPos(tblProps.ObName, tblProps.X * RatioW, tblProps.Y * RatioH);
        			Image.SetSize(tblProps.ObName, tblProps.W * RatioW, tblProps.H * RatioH);
        			
        			if tblProps.ObName == "Image10" then
        			DataGrid.SetColumnWidth("Plugin1", 0, tblProps.W * RatioW, true);
        			elseif tblProps.ObName == "Image9" then
        			DataGrid.SetColumnWidth("Plugin1", 1, tblProps.W * RatioW, true);
        			elseif tblProps.ObName == "Image1" then
        			DataGrid.SetColumnWidth("Plugin1", 2, tblProps.W * RatioW, true);
        			end

        Comment

        • Solmos
          New Member
          • Aug 2006
          • 355

          #79
          another question

          since it could do so that redimensione the application from 630x405 and not less of that size of page?

          thx

          Comment

          • mindstitchdr
            Indigo Rose Customer
            • Dec 2004
            • 239

            #80
            Sorry it took so long to reply, put this in your projects OnStartup actions:

            Code:
            function g_OnGetMinMaxInfo()
            tbReturn = {};
            tbReturn.MinX = 630;
            tbReturn.MinY = 405;
            
            
            return tbReturn;
            end
            That should prevent the page from going smaller than 630x405. As far as the datagrid plugin resizing I'm not sure.

            Comment

            • meshmeh
              Forum Member
              • Sep 2007
              • 10

              #81
              Dear friends
              I tried this program it is ok in all object except for mediaplayer !!!!!
              why that happened

              Comment

              • andunok
                Forum Member
                • Oct 2007
                • 2

                #82
                yes:yes:yes
                You are the BEST of the BEST-mindstitchdr
                Thanks for all...You resolved the FULLSCREEN mode for my project.

                FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN
                BRAVISSIMO,,,,,,,,

                Comment

                • rhosk
                  Indigo Rose Customer
                  • Aug 2003
                  • 1698

                  #83
                  I do believe that he's a little excited...
                  Regards,

                  -Ron

                  Music | Video | Pictures

                  Comment

                  • FoxLeader
                    Forum Member
                    • Nov 2006
                    • 432

                    #84
                    Really? I don't :lol

                    Anyway, good job and thanks for sharing!

                    Comment

                    • Adam
                      Indigo Rose Staff Member
                      • May 2000
                      • 2148

                      #85
                      thats funny. It's good to see people get excited over lua actions.

                      AJK

                      Comment

                      • andunok
                        Forum Member
                        • Oct 2007
                        • 2

                        #86
                        Hi, mindstitchdr
                        I want if you can or if it's possible to make in my project 3 buttons:

                        1. maximize (minimize)
                        2. restore
                        3. exit
                        My project is Resizable and Standard

                        I wish to make Resizable and Bordered with 3 buttons: maximize (minimize), restore and exit seem like windows.
                        It's possible?
                        Thanks....
                        By the way......good job for your script (Fullscreen mode)

                        Comment

                        • mindstitchdr
                          Indigo Rose Customer
                          • Dec 2004
                          • 239

                          #87
                          Well it looks like you have to leave the app at "Standard" for this to work. Take a look at my example. When you minimize the app then restore, none of the buttons redraw. I'm not really sure how to fix it, if it is possible.
                          Attached Files

                          Comment

                          • usernameCasper
                            Forum Member
                            • Nov 2006
                            • 306

                            #88
                            Hey mindstitchdr,

                            I looked at your project and it seems you got alot of code that is redundant.
                            E.g.: Your global functions, and statements in the syntax like:
                            currentapp = Application.GetWndHandle();
                            Window.Minimize(Application.GetWndHandle(currentap p));

                            It won't redraw cause allot of the code is redundant.
                            Try to add the following code into button3:
                            Code:
                            Window.Minimize(Application.GetWndHandle());
                            And try to optimize the code, remove redundant code.

                            Hope this helps (keep it simple and it works).

                            Kind regards,
                            Casper

                            Comment

                            • mindstitchdr
                              Indigo Rose Customer
                              • Dec 2004
                              • 239

                              #89
                              Well keep in mind this resize function is not "My code". Its the code from the example posted by Adam on the first page. (willfreer didn't look in the Global Functions) I know the button 3 code was redundant, I was just trying things to try to get it to work and could not.

                              Comment

                              • usernameCasper
                                Forum Member
                                • Nov 2006
                                • 306

                                #90
                                Ahh, yes, but the global function contains alot more redundant code than the code in the button.
                                I haven't analysed it yet, just a quick look, I maybe will look to it tomorrow,
                                I got to take a nap now (almost 0:00 am ).
                                But for minimizing and maximizing you don't need the resize function, I made
                                the similiar function a while ago and it worked fine.
                                I'll post tomorrow further.

                                Good night,
                                Casper

                                Comment

                                Working...
                                X