Skip to content
Browse files

* code_graph: main view and toolbar

  • Loading branch information...
1 parent e3c5d8a commit b173329f3df557bb5870b8c118ad2f8007908e01 Yoann Padioleau committed May 18, 2012
View
37 code_graph/view3.ml
@@ -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
@@ -25,6 +24,7 @@ module CairoH = Cairo_helpers3
module Model = Model3
module Controller = Controller3
open Model3
+module View_overlays = View_overlays3
(*****************************************************************************)
(* Prelude *)
@@ -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
@@ -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 *)
(*-------------------------------------------------------------------*)
View
13 code_graph/view_matrix.ml
@@ -23,8 +23,21 @@ module CairoH = Cairo_helpers3
(*****************************************************************************)
(*****************************************************************************)
+(* Scaling *)
+(*****************************************************************************)
+
+(*****************************************************************************)
(* Painting *)
(*****************************************************************************)
let paint w =
+ pr2 "View_matrix.paint Todo";
+ ()
+
+(*****************************************************************************)
+(* Events *)
+(*****************************************************************************)
+
+let button_action da w ev =
raise Todo
+
View
4 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
View
40 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
+
View
4 code_graph/view_overlays3.mli
@@ -0,0 +1,4 @@
+
+val motion_notify:
+ < as_widget : [> `widget ] Gtk.obj; .. > ->
+ Model3.world -> GdkEvent.Motion.t -> bool
View
8 visual/view2.ml
@@ -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;
View
2 visual/view_overlays.ml
@@ -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

0 comments on commit b173329

Please sign in to comment.
Something went wrong with that request. Please try again.