Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with GPack.layout adjustments #116

Closed
vrotaru opened this issue Aug 25, 2020 · 1 comment
Closed

Problem with GPack.layout adjustments #116

vrotaru opened this issue Aug 25, 2020 · 1 comment

Comments

@vrotaru
Copy link

vrotaru commented Aug 25, 2020

Here is the layout definition from gPack.ml

let layout ?hadjustment ?vadjustment ?layout_width ?layout_height =
  Layout.make_params []
    ?hadjustment:(may_map GData.as_adjustment hadjustment)
    ?vadjustment:(may_map GData.as_adjustment hadjustment)
    ?width:layout_width ?height:layout_height ~cont:(
  pack_container ~create:(fun p -> new layout (Layout.create p)))

It looks wrong because the vadjustment parameter is never used, but hadjustment is used twice. I've tried to create a simple example to see what happens and something is wrong even if not exactly what I was expecting.

let main () = 
  let _local = GMain.init () in
  let window = GWindow.window ~title: "Layout Demo" ~width: 450 ~height: 450 () in
  ignore@@ window#misc#connect#destroy ~callback: GMain.quit;

  let sw = GBin.scrolled_window ~packing: window#add () in
  let layout = GPack.layout 
      ~hadjustment: sw#hadjustment ~vadjustment: sw#vadjustment 
      ~layout_width: 600 ~layout_height: 600 
      ~packing: sw#add () in

  let a = GMisc.label ~text: "A" () in
  layout#put a#coerce ~x: 20 ~y: 20;

  let b = GMisc.label ~text: "B" () in
  layout#put b#coerce ~x: 500 ~y: 500;

  window#show ();
  GMain.main ()

let _ = main ()

What happens when I compile and run this code is that the vertical scrolling works and horizontal scrolling doesn't.
However if I scroll horizontally and then vertically then it jumps to to the correct position.

Hope this helps

@garrigue
Copy link
Owner

Fixed in lablgtk3 (034d4fb) and master (c5a4b68)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants