This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ardera's profile picture

Bedrock Object Alignments not working

Started by ardera, 27 July 2015 - 08:42 AM
ardera #1
Posted 27 July 2015 - 10:42 AM
Hey,
my problem is that the Alignment Properties I set in the Bedrock View file are not being paid attention from the Objects.
For example:
I set the Alignment of a Label Object to "Center", but it still is drawn on the very left of the screen.


BootupLabel, BootupButtonSettings, BootupButtonExit and BootupCopyright are drawn on the left of the screen although I set their Alignments to "Center".

This is my complete main.view file:
Spoiler

{
BackgroundColour="white",
Children = {
  {
   Name="realmain",
   Type="View",
   Width=51,
   Height=3,
   BackgroundColour="lightGray",
   Children = {
	{
	 X=1,
	 Y=1,
	 Name="ButtonLBCS",
	 Type="Button",
	 Text="LBCS",
	 BackgroundColour="gray",
	 TextColour="white"
	},
	{
	 X=8,
	 y=1,
	 Name="ButtonProject",
	 Type="Button",
	 Text="Project",
	 BackgroundColour="gray",
	 TextColour="white"
	},
	{
	 X=18,
	 Y=1,
	 Name="ButtonBuild",
	 Type="Button",
	 Text="Build",
	 BackgroundColour="gray",
	 TextColour="white"
	},
	{
	 X=26,
	 Y=1,
	 Name="ButtonDebug",
	 Type="Button",
	 Text="Debug",
	 BackgroundColour="gray",
	 TextColour="white"
	},
	{
	 X=34,
	 Y=1,
	 Name="ButtonHelp",
	 Type="Button",
	 Text="Help",
	 BackgroundColour="gray",
	 TextColour="white"
	}
   }
  },
  {
   Name="editor",
   Type="ScrollView",
   Width=51,
   Height=16,
   Y=4,
   BackgroundColour="white",
   Children = {
	{
	 Name="editorpane",
	 Type="LBCSeditor",
	 Width=50,
	 Height=16,
	 Y=1,
	 BackgroundColour="white"
	},
	{
	 Name="bootup",
	 Type="View",
	 Width=50,
	 Height=16,
	 Y=1,
	 BackgroundColour="white",
	 Children = {
	  {
	   Name = "BootupLabel",
	   Type = "Label",
	   Text = "Welcome!",
	   Y = 2,
	   Align = "Center",
	   TextColour = "black",
	  },
	  {
	   Name = "BootupButtonNewProject",
	   Type = "Button",
	   Text = "New Project",
	   Width = 24,
	   X = 2,
	   Y = 3,
	   TextColour = "gray"
	  },
	  {
	   Name = "BootupButtonLastProject",
	   Type = "Button",
	   Text = "Last Project",
	   TextColour = "gray",
	   Width = 24,
	   X = 27,
	   Y = 3
	  },
	  {
	   Name = "BootupButtonLoadProject",
	   Type = "Button",
	   Text = "Load Project",
	   Width = 24,
	   X = 2,
	   Y = 5,
	   TextColour = "gray",
	  },
	  {
	   Name = "BootupButtonDocs",
	   Type = "Button",
	   Text = "Docs & Tutorials",
	   Width = 24,
	   X = 27,
	   Y = 5,
	   TextColour = "gray"
	  },
	  {
	   Name = "BootupButtonSettings",
	   Type = "Button",
	   Text = "Settings",
	   Width = 16,
	   Align = "Center",
	   Y = 7,
	   TextColour = "gray"
	  },
	  {
	   Name = "BootupButtonExit",
	   Type = "Button",
	   Text = "Exit",
	   Width = 14,
	   Align = "Center",
	   Y = 14,
	   TextColour = "gray"
	  },
	  {
	   Name = "BootupCopyright",
	   Type = "Label",
	   Text = "(C) 2015 Hannes Winkler",
	   Align = "Center",
	   Y = 16,
	   TextColour = "lightGray"
	  }
	 }
	}
   }
  },
  {
   Name="MenuLBCS",
   Type="Menu",
   X=1,
   Y=2,
   BackgroundColor="lightGray",
   Visible=false,
   Prepared=true,
   Children={
	{
	 Name = "MenuButtonSettings",
	 Text = "Settings",
	 Type = "Button"
	},
	{
	 Name = "MenuButtonExit",
	 Text = "Exit",
	 Type = "Button"
	}
   }
  },
  {
   Name="MenuProject",
   Type="Menu",
   X=8,
   Y=2,
   BackgroundColor="lightGray",
   Visible=false,
   Prepared=true,
   Children={
	{
	 Name="MenuButtonNewProject",
	 Text="New Project",
	 Type="Button"
	}
   }
  },
  {
   Name="MenuDebug",
   Type="Menu",
   X=26,
   Y=2,
   BackgroundColor="lightGray",
   Visible=false,
   Prepared=true,
   Children={
	{
	 Name="MenuButtonShell",
	 Text="Open Shell",
	 Type="Button"
	}
   }
  },
  {
   Name="MenuBuild",
   Type="Menu",
   X=18,
   Y=2,
   BackgroundColor="lightGray",
   Visible=false,
   Prepared=true,
   Children={
	{
	 Name="MenuButtonBuild",
	 Text="Build",
	 Type="Button"
	}
   }
  },
  {
   Name="MenuHelp",
   Type="Menu",
   X=34,
   Y=2,
   BackgroundColor="lightGray",
   Visible=false,
   Prepared=true,
   Children={
	{
	 Name="MenuButtonDocs",
	 Text="Open Docs",
	 Type="Button"
	}
   }
  }
}
}

And this is the part where the problematic objects are defined:
Spoiler

{
Name="editor",
Type="ScrollView",
Width=51,
Height=16,
Y=4,
BackgroundColour="white",
Children = {
  {
   Name="editorpane",
   Type="LBCSeditor",
   Width=50,
   Height=16,
   Y=1,
   BackgroundColour="white"
  },
  {
   Name="bootup",
   Type="View",
   Width=50,
   Height=16,
   Y=1,
   BackgroundColour="white",
   Children = {
	{
	 Name = "BootupLabel",
	 Type = "Label",
	 Text = "Welcome!",
	 Y = 2,
	 Align = "Center",
	 TextColour = "black",
	},
	{
	 Name = "BootupButtonNewProject",
	 Type = "Button",
	 Text = "New Project",
	 Width = 24,
	 X = 2,
	 Y = 3,
	 TextColour = "gray"
	},
	{
	 Name = "BootupButtonLastProject",
	 Type = "Button",
	 Text = "Last Project",
	 TextColour = "gray",
	 Width = 24,
	 X = 27,
	 Y = 3
	},
	{
	 Name = "BootupButtonLoadProject",
	 Type = "Button",
	 Text = "Load Project",
	 Width = 24,
	 X = 2,
	 Y = 5,
	 TextColour = "gray",
	},
	{
	 Name = "BootupButtonDocs",
	 Type = "Button",
	 Text = "Docs & Tutorials",
	 Width = 24,
	 X = 27,
	 Y = 5,
	 TextColour = "gray"
	},
	{
	 Name = "BootupButtonSettings",
	 Type = "Button",
	 Text = "Settings",
	 Width = 16,
	 Align = "Center",
	 Y = 7,
	 TextColour = "gray"
	},
	{
	 Name = "BootupButtonExit",
	 Type = "Button",
	 Text = "Exit",
	 Width = 14,
	 Align = "Center",
	 Y = 14,
	 TextColour = "gray"
	},
	{
	 Name = "BootupCopyright",
	 Type = "Label",
	 Text = "(C) 2015 Hannes Winkler",
	 Align = "Center",
	 Y = 16,
	 TextColour = "lightGray"
	}
   }
  }
}
Edited on 27 July 2015 - 08:47 AM
MKlegoman357 #2
Posted 27 July 2015 - 10:46 AM
Alignment is the alignment of the text of labels and buttons, not the position of them on the screen. The only way I can think of to align objects to the center is make their position '50%, -half of the object's width'.

EDIT: you'll probably also want to make the width or height of certain objects "100%", rather than 51.
Edited on 27 July 2015 - 08:48 AM
ardera #3
Posted 27 July 2015 - 11:06 AM
Ah okay, thanks