I kinda hacked one in using standard Gnoga items. I don't know how good it
is from a production
perspective, but it works out ok for my at home stuff. There's still lots
of work to make it fully Gnoga
ready, but here is a basic Modal Dialog.
It can definitely be expanded upon and I haven't gotten into what it needs
to add Remove/Attach type functions correctly, so it currently doesn't
support that kind of stuff. It's basically designed to be added to a
window and not removed until the window is destroyed. Other functions will
need to be added if
you want to modify the modal background other than color, but this leaves a
blueprint on how to do it.
gnoga-gui-view-modal_dialog.ads
************************************************
with Gnoga.Gui.Window;
with Gnoga.Gui.Base;
with Gnoga.Types.Colors;
package Gnoga.Gui.View.Modal_Dialog is
type Dialog_Type is new View_Type with private;
type Dialog_Access is access all Dialog_Type;
type Pointer_To_Dialog_Class is access all Dialog_Type'Class;
procedure Create
(View : in out Dialog_Type;
Parent : in out Gnoga.Gui.Window.Window_Type'Class;
ID : in String := "");
procedure Show
(View : in out Dialog_Type;
Show : Boolean := True);
procedure Center(View : in out Dialog_Type);
procedure Modal_Background_Color
(View : in out Dialog_Type;
Color : String);
procedure Modal_Background_Color
(View : in out Dialog_Type;
Color : Gnoga.Types.Colors.Color_Enumeration);
private
overriding
procedure Create
(View : in out Dialog_Type;
Parent : in out Gnoga.Gui.Base.Base_Type'Class;
ID : in String := "") is null;
type Dialog_Type is new View_Type with record
Modal_Background : View_Type;
end record;
end Gnoga.Gui.View.Modal_Dialog;
************************************************
gnoga-gui-view-modal_dialog.adb
************************************************
with Gnoga.Gui.Element;
package body Gnoga.Gui.View.Modal_Dialog is
procedure Create
(View : in out Dialog_Type;
Parent : in out Gnoga.Gui.Window.Window_Type'Class;
ID : in String := "")
is
-- Copy of Parent's Main View
Old_View : Gnoga.Gui.Base.Pointer_To_Base_Class := Parent.Get_View;
begin
-- Create view
View.Modal_Background.Create(Parent);
-- Creating a view using a window as a parent sets the view as the
-- window's main view. This line sets it back to the original.
Parent.Set_View(Old_View.all);
-- Configure the Modal Background
View.Modal_Background.Fill_Parent;
View.Modal_Background.Background_Color(Value => "Grey");
-- Set the default show/hide state
View.Show(False);
-- Create the Dialog
View_Type(View).Create
(Parent => View.Modal_Background,
ID => ID);
-- Configure the dialog
View.Background_Color(Value => "White");
View.Width(Value => 400);
View.Height(Value => 300);
View.Position(Value => Gnoga.Gui.Element.Fixed);
View.Center;
end Create;
procedure Show
(View : in out Dialog_Type;
Show : Boolean := True)
is
begin
if Show then
View.Modal_Background.Z_Index(Integer'Last);
View.Modal_Background.Opacity(1.0);
View.Modal_Background.Hidden(False);
else
View.Modal_Background.Hidden;
View.Modal_Background.Opacity(0.0);
View.Modal_Background.Z_Index(Integer'First);
end if;
end Show;
procedure Center(View : in out Dialog_Type) is
Frame : View_Type renames View.Modal_Background;
begin
View.Top (Value => Frame.Position_Top + Frame.Height/2 -
View.Height/2);
View.Left(Value => Frame.Position_Left + Frame.Width/2 -
View.Width/2);
end Center;
procedure Modal_Background_Color
(View : in out Dialog_Type;
Color : String)
is
begin
View.Modal_Background.Background_Color(Color);
end Modal_Background_Color;
procedure Modal_Background_Color
(View : in out Dialog_Type;
Color : Gnoga.Types.Colors.Color_Enumeration)
is
begin
View.Modal_Background.Background_Color(Color);
end Modal_Background_Color;
end Gnoga.Gui.View.Modal_Dialog;
************************************************
Example Setup Code:
************************************************
type App_Data(Main_Window : access Gnoga.Gui.Window.Window_Type'Class) is
new Gnoga.Types.Connection_Data_Type
with
record
Top_Level_View : Gnoga.Gui.View.View_Type;
Modal : Gnoga.Gui.View.Modal_Dialog.Dialog_Type;
Show_Dlg_Bttn : Gnoga.Gui.Element.Common.Button_Type;
Hide_Dlg_Bttn : Gnoga.Gui.Element.Common.Button_Type;
-- Add other controls here
end record;
type App_Access is access all App_Data;
procedure On_Show_Dlg_Click
(Object : in out Gnoga.Gui.Base.Base_Type'Class)
is
App : App_Access := App_Access(Object.Connection_Data);
begin
App.Modal.Show;
end On_Show_Dlg_Click;
procedure On_Hide_Dlg_Click
(Object : in out Gnoga.Gui.Base.Base_Type'Class)
is
App : App_Access := App_Access(Object.Connection_Data);
begin
App.Modal.Show(False);
end On_Hide_Dlg_Click;
-- This procedure is called each time a connection is made.
procedure On_Connect
(Main_Window : in out Gnoga.Gui.Window.Window_Type'Class;
Connection : access
Gnoga.Application.Multi_Connect.Connection_Holder_Type)
is
-- This is deallocated when the connection closes
App : App_Access := new App_Data(Main_Window'Unchecked_Access);
begin
-- Associate App with this connection
App.Main_Window.Connection_Data (App);
-- Initialize Application Layout
App.Top_Level_View.Create(Main_Window);
App.Top_Level_View.Hidden; -- Hide initially until done
App.Top_Level_View.Put_Line("Hello World");
App.Show_Dlg_Bttn.Create(App.Top_Level_View,"Show Dialog");
App.Show_Dlg_Bttn.On_Click_Handler(On_Show_Dlg_Click'Access);
-- Configure your Modal Dialog here
App.Modal.Create(App.Main_Window.all);
App.Modal.Put_Line("Modal Dialog");
App.Hide_Dlg_Bttn.Create(App.Modal,"Hide Dialog");
App.Hide_Dlg_Bttn.On_Click_Handler(On_Hide_Dlg_Click'Access);
-- Show Page
App.Top_Level_View.Hidden(False);
-- Do something
end On_Connect;
************************************************
On Wed, May 10, 2017 at 7:17 AM, Gautier de Montmollin <gdem...@hotmail.com>
wrote:
> Hello,
> Is there somewhere a GNOGA modal dialog example with a string input field,
> a bit like this:
> https://jqueryui.com/dialog/#modal-form
> ?
> The rest of the GNOGA app would not be erased, but be temporarily
> ineffective - hence my request for a modal dialog, not switching to a new
> page.
> I guess we would best use the JQuery plugin, and perhaps an example is
> hidden in the various GNOGA examples.
> TIA
> Gautier
>
>
> ------------------------------------------------------------
> ------------------
> 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
>
>
------------------------------------------------------------------------------
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