Skip to content
This repository has been archived by the owner on Jun 4, 2019. It is now read-only.

Commit

Permalink
* code_graph: main view and toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoann Padioleau authored and Yoann Padioleau committed May 18, 2012
1 parent e3c5d8a commit b173329
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 8 deletions.
37 changes: 35 additions & 2 deletions code_graph/view3.ml
Expand Up @@ -12,7 +12,6 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file
* license.txt for more details.
*)

open Common
(* floats are the norm in graphics *)
open Common.ArithFloatInfix
Expand All @@ -25,6 +24,7 @@ module CairoH = Cairo_helpers3
module Model = Model3
module Controller = Controller3
open Model3
module View_overlays = View_overlays3

(*****************************************************************************)
(* Prelude *)
Expand Down Expand Up @@ -63,7 +63,7 @@ let expose da w ev =
let gwin = da#misc#window in
let cr = Cairo_lablgtk.create gwin in
assemble_layers cr w;
()
true

let configure da w ev =
let width = GdkEvent.Configure.width ev in
Expand Down Expand Up @@ -178,11 +178,44 @@ let mk_gui w =
(*-------------------------------------------------------------------*)
(* toolbar *)
(*-------------------------------------------------------------------*)
vbox#pack (G.mk (GButton.toolbar) (fun tb ->

tb#insert_widget (G.mk (GButton.button ~stock:`GO_BACK) (fun b ->
b#connect#clicked ~callback:(fun () ->
raise Todo
(* !Controller._go_back dw;*)
)
));
));

(*-------------------------------------------------------------------*)
(* main view *)
(*-------------------------------------------------------------------*)

let vpane = GPack.paned `VERTICAL
~packing:(vbox#pack ~expand:true ~fill:true) () in

let da = GMisc.drawing_area () in
da#misc#set_double_buffered false;

vpane#add1 da#coerce;

da#misc#set_can_focus true ;
da#event#add [ `KEY_PRESS;
`BUTTON_MOTION; `POINTER_MOTION;
`BUTTON_PRESS; `BUTTON_RELEASE ];

da#event#connect#expose ~callback:(expose da w) +> ignore;
da#event#connect#configure ~callback:(configure da w) +> ignore;

da#event#connect#button_press
(View_matrix.button_action da w) +> ignore;
da#event#connect#button_release
(View_matrix.button_action da w) +> ignore;

da#event#connect#motion_notify
(View_overlays.motion_notify da w) +> ignore;

(*-------------------------------------------------------------------*)
(* status bar *)
(*-------------------------------------------------------------------*)
Expand Down
13 changes: 13 additions & 0 deletions code_graph/view_matrix.ml
Expand Up @@ -22,9 +22,22 @@ module CairoH = Cairo_helpers3
(* Prelude *)
(*****************************************************************************)

(*****************************************************************************)
(* Scaling *)
(*****************************************************************************)

(*****************************************************************************)
(* Painting *)
(*****************************************************************************)

let paint w =
pr2 "View_matrix.paint Todo";
()

(*****************************************************************************)
(* Events *)
(*****************************************************************************)

let button_action da w ev =
raise Todo

4 changes: 4 additions & 0 deletions code_graph/view_matrix.mli
@@ -1,2 +1,6 @@

val paint: Model3.world -> unit

val button_action:
< as_widget : [> `widget ] Gtk.obj; .. > ->
Model3.world -> GdkEvent.Button.t -> bool
40 changes: 40 additions & 0 deletions code_graph/view_overlays3.ml
@@ -0,0 +1,40 @@
(* Yoann Padioleau
*
* Copyright (C) 2012 Facebook
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation, with the
* special exception on linking described in file license.txt.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file
* license.txt for more details.
*)
open Common
(* floats are the norm in graphics *)
open Common.ArithFloatInfix

(*****************************************************************************)
(* Prelude *)
(*****************************************************************************)

(* This module mainly modifies the w.overlay cairo surface. It also
* triggers the refresh_da which triggers itself the expose event
* which triggers the View.assemble_layers composition of w.pm with
* w.overlay
*)

(*****************************************************************************)
(* The overlays *)
(*****************************************************************************)

(*****************************************************************************)
(* Assembling overlays *)
(*****************************************************************************)

let motion_notify da w ev =
pr2 "View_overlay: motion_notify Todo";
true

4 changes: 4 additions & 0 deletions code_graph/view_overlays3.mli
@@ -0,0 +1,4 @@

val motion_notify:
< as_widget : [> `widget ] Gtk.obj; .. > ->
Model3.world -> GdkEvent.Motion.t -> bool
8 changes: 4 additions & 4 deletions visual/view2.ml
Expand Up @@ -544,17 +544,17 @@ let mk_gui ~screen_size ~legend test_mode (root, model, dw, dbfile_opt) =

da#misc#set_can_focus true ;
da#event#add [ `KEY_PRESS;
`BUTTON_MOTION; `POINTER_MOTION;
`BUTTON_PRESS; `BUTTON_RELEASE ];
`BUTTON_MOTION; `POINTER_MOTION;
`BUTTON_PRESS; `BUTTON_RELEASE ];

da2#misc#set_can_focus true ;
da2#event#add [ `KEY_PRESS;
(* weird, but because even if didn't say
* POINTER_MOTION here, the minimap still
* gets an event for mouse over :(
*)
`BUTTON_MOTION; `POINTER_MOTION;
`BUTTON_PRESS; `BUTTON_RELEASE ];
`BUTTON_MOTION; `POINTER_MOTION;
`BUTTON_PRESS; `BUTTON_RELEASE ];


da#event#connect#expose ~callback:(expose da dw) +> ignore;
Expand Down
2 changes: 0 additions & 2 deletions visual/view_overlays.ml
Expand Up @@ -15,12 +15,10 @@
* license.txt for more details.
*)
(*e: Facebook copyright *)

open Common
(* floats are the norm in graphics *)
open Common.ArithFloatInfix


module F = Figures
module T = Treemap
module CairoH = Cairo_helpers
Expand Down

0 comments on commit b173329

Please sign in to comment.