Skip to content

Commit 5fe47e7

Browse files
settonCode Review
authored andcommitted
Expose API to Float/Put a child at a given position
For OC21-020 Change-Id: Id0cfed1e109358f09aeec8da5289830df3e3422a
1 parent 0f8849a commit 5fe47e7

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

features

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ An ISO date (YYYY-MM-DD) appears in parentheses after the
99
description line. This date shows the implementation date
1010
of the feature.
1111

12+
New features in GtkAda 17
13+
-------------------------
14+
15+
OC21-020 additions to Gtkada.MDI.Float_Child and Gtkada.MDI.Put
16+
17+
New parameters allow controlling the position of the child as it is
18+
being put in the MDI or when it is being floated.
19+
1220
New features in GtkAda 3.14.1
1321
-----------------------------
1422

src/gtkada-mdi.adb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2899,7 +2899,9 @@ package body Gtkada.MDI is
28992899
procedure Put
29002900
(MDI : access MDI_Window_Record;
29012901
Child : access MDI_Child_Record'Class;
2902-
Initial_Position : Child_Position := Position_Automatic)
2902+
Initial_Position : Child_Position := Position_Automatic;
2903+
Position_At_Mouse : Boolean := True;
2904+
X, Y : Gint := 0)
29032905
is
29042906
Float : constant Boolean :=
29052907
MDI.All_Floating_Mode
@@ -2922,7 +2924,7 @@ package body Gtkada.MDI is
29222924

29232925
Set_State (Child, Normal);
29242926

2925-
Float_Child (Child, Float);
2927+
Float_Child (Child, Float, Position_At_Mouse, X, Y);
29262928

29272929
if not Float then
29282930
Put_In_Notebook (MDI, Child, Initial_Position => Initial_Position);
@@ -3717,10 +3719,12 @@ package body Gtkada.MDI is
37173719

37183720
procedure Float_Child
37193721
(Child : access MDI_Child_Record'Class;
3720-
Float : Boolean) is
3722+
Float : Boolean;
3723+
Position_At_Mouse : Boolean := True;
3724+
X, Y : Gint := 0) is
37213725
begin
37223726
Internal_Float_Child
3723-
(Child, Float, Position_At_Mouse => True, X => 0, Y => 0);
3727+
(Child, Float, Position_At_Mouse => Position_At_Mouse, X => X, Y => Y);
37243728
end Float_Child;
37253729

37263730
-----------------------------------

src/gtkada-mdi.ads

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,17 @@ package Gtkada.MDI is
294294
-- - Else the window is put on top of the currently selected window
295295

296296
procedure Put
297-
(MDI : access MDI_Window_Record;
298-
Child : access MDI_Child_Record'Class;
299-
Initial_Position : Child_Position := Position_Automatic);
297+
(MDI : access MDI_Window_Record;
298+
Child : access MDI_Child_Record'Class;
299+
Initial_Position : Child_Position := Position_Automatic;
300+
Position_At_Mouse : Boolean := True;
301+
X, Y : Gint := 0);
300302
-- Add a new child to the MDI window, and return its embedding widget.
301303
-- Calling Put does not give the focus to the newly inserted widget.
302304
-- To do that, you should call Set_Focus_Child.
305+
-- If Initial_Position is Position_Float, then position the floating window
306+
-- under the mouse cursor, unless Position_At_Mouse is False, in which
307+
-- case position the window at X, Y.
303308

304309
function Save_Desktop
305310
(Self : not null access MDI_Child_Record) return Glib.Xml_Int.Node_Ptr;
@@ -620,8 +625,15 @@ package Gtkada.MDI is
620625
-----------------------
621626

622627
procedure Float_Child
623-
(Child : access MDI_Child_Record'Class; Float : Boolean);
624-
-- Change the floating state of a child
628+
(Child : access MDI_Child_Record'Class;
629+
Float : Boolean;
630+
Position_At_Mouse : Boolean := True;
631+
X, Y : Gint := 0);
632+
-- Change the floating state of a child.
633+
-- If Float is True:
634+
-- - if Position_At_Mouse is True, position the window
635+
-- under the mouse pointer.
636+
-- - if Position_At_Mouse is False, use position the window at X, Y.
625637

626638
function Is_Floating
627639
(Child : access MDI_Child_Record'Class) return Boolean;

0 commit comments

Comments
 (0)