I'm running into something that I wanted to understand the "why" on. I
already have a workaround, but I want to see what is causing the issue.
I've been playing around with a custom dialog type made from Gnoga
elements. What I am finding is if the supplied user view to my Dialog_Type
functions has Fill_Parent set, then one of my internal views loses its
width/height info. I whittled it down to a smaller example. For
reference, the Fill_View is the view that will block other content while
the Frame_View is the containing view to whatever other view is supplied.
To compile and run this file, just pick any multiconnect example and attach
Test_Width.On_Connect to it. If I comment out the line:
App.User_View.Fill_Parent;
Then everything works correct. I am wondering how calling Fill_Parent on
User_View changes the Width and Height on Frame_View
Test_Width.ads
**********************************************************************************
with Gnoga.Types;
with Gnoga.Gui.Window;
with Gnoga.Gui.View;
with Gnoga.Application.Multi_Connect;
package Test_Width is
procedure On_Connect
(Main_Window : in out Gnoga.Gui.Window.Window_Type'Class;
Connection : access
Gnoga.Application.Multi_Connect.Connection_Holder_Type);
end Test_Width;
Test_Width.adb
**********************************************************************************
with ada.Text_IO;
with Gnoga.Gui.Element;
with Gnoga.Gui.View.Grid;
with Gnoga.Gui.Element.Common;
package body Test_Width is
type App_Data
(Window : not null access Gnoga.Gui.Window.Window_Type'Class)
is new Gnoga.Types.Connection_Data_Type with record
Main_View : Gnoga.Gui.View.View_Type;
Fill_View : Gnoga.Gui.View.View_Type;
Frame_View : Gnoga.Gui.View.View_Type;
User_View : Gnoga.Gui.View.View_Type;
Grid : Gnoga.Gui.View.Grid.Grid_View_Type;
Button : Gnoga.Gui.Element.Common.Button_Type;
end record;
type App_Access is access all App_Data;
-- Centers Child_View inside of Parent_View
procedure Center
(Parent_View : in out Gnoga.Gui.View.View_Type;
Child_View : in out Gnoga.Gui.View.View_Type)
is
Top_Offset : Integer
:= (Parent_View.Height/2
- Child_View.Height/2);
Left_Offset : Integer
:= (Parent_View.Width/2
- Child_View.Width/2);
use type String;
begin
-- Bound to top left corner
if Top_Offset < 0 then
Top_Offset := 0;
end if;
if Left_Offset < 0 then
Left_Offset := 0;
end if;
Child_View.Top
(Parent_View.Offset_From_Top + Top_Offset);
Child_View.Left
(Parent_View.Offset_From_Left + Left_Offset);
end Center;
-- Shows Parent_Viewe, Child_View, and other children
-- Centers it if desired
procedure Show
(Parent_View : in out Gnoga.Gui.View.View_Type;
Child_View : in out Gnoga.Gui.View.View_Type;
Show : Boolean := True;
Center : Boolean := True)
is
begin
if Show then
Parent_View.Hidden(False);
if Center then
Test_Width.Center(Parent_View,Child_View);
end if;
Parent_View.Visible;
else
Parent_View.Visible(False);
Parent_View.Hidden;
end if;
end Show;
procedure Init(App : in out App_Data) is
use Gnoga.Gui.View.Grid;
begin
App.Main_View.Create(App.Window.all);
-- Configure the Filling View (Grey background)
App.Fill_View.Create(App.Main_View);
App.Fill_View.Place_Inside_Top_Of(App.Main_View);
App.Fill_View.Fill_Parent;
App.Fill_View.Background_Color("Grey");
-- Configure the Frame View (holds the user view
-- and provides centering capability).
App.Frame_View.Create(App.Fill_View);
App.Frame_View.Position(Gnoga.Gui.Element.Fixed);
App.Frame_View.Background_Color("White");
-- Hide everything for now
Show
(Parent_View => App.Fill_View,
Child_View => App.Frame_View,
Show => False,
Center => False);
-- Configure the user view
App.User_View.Create(App.Frame_View);
-- This line causes Frame_View to lose width/height info
App.User_View.Fill_Parent;
App.Button.Create(App.User_View,"Test");
App.User_View.Height(200);
App.User_View.Width(300);
-- Show the Fill_View and its children
Show
(Parent_View => App.Fill_View,
Child_View => App.Frame_View,
Show => True,
Center => True);
end Init;
procedure Print(App : App_Data) is
begin
Ada.Text_IO.Put_Line
("Main_View: "
& Integer'Image(App.Main_View.Height)
& ","
& Integer'Image(App.Main_View.Width));
Ada.Text_IO.Put_Line
("Fill_View: "
& Integer'Image(App.Fill_View.Height)
& ","
& Integer'Image(App.Fill_View.Width));
Ada.Text_IO.Put_Line
("Frame_View: "
& Integer'Image(App.Frame_View.Height)
& ","
& Integer'Image(App.Frame_View.Width));
Ada.Text_IO.Put_Line
("User_View: "
& Integer'Image(App.User_View.Height)
& ","
& Integer'Image(App.User_View.Width));
end Print;
procedure On_Connect
(Main_Window : in out Gnoga.Gui.Window.Window_Type'Class;
Connection : access
Gnoga.Application.Multi_Connect.Connection_Holder_Type)
is
App : App_Access := new App_Data(Main_Window'Unchecked_Access);
begin
App.Window.Connection_Data(App);
Init(App.all);
Print(App.all);
end On_Connect;
end Test_Width;
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gnoga-list mailing list
Gnoga-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnoga-list