Skip to content

Commit

Permalink
Add Irr_gui.cursor#rel_pos.
Browse files Browse the repository at this point in the history
  • Loading branch information
antegallya committed Aug 30, 2011
1 parent bfe2b14 commit 83452ed
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions irr_core_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ value copy_pos2d_s32(position2d<s32> pos) {
return v;
}

position2d<f32> Pos2d_f32_val(value v) {
return position2d<f32>(Double_val(Field(v, 0)), Double_val(Field(v, 1)));
}

value copy_pos2d_f32(position2d<f32> pos) {
CAMLparam0();
CAMLlocal2(v, v_double);
v = caml_alloc(2, 0);
v_double = caml_copy_double(pos.X);
Store_field(v, 0, v_double);
v_double = caml_copy_double(pos.Y);
Store_field(v, 1, v_double);
CAMLreturn(v);
}

vector3df Vector3df_val(value v) {
return vector3df(Double_val(Field(v, 0)), Double_val(Field(v, 1)),
Double_val(Field(v, 2)));
Expand Down
3 changes: 3 additions & 0 deletions irr_core_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ value copy_dimension2d_f32(dimension2d<f32>);
position2d<s32> Pos2d_s32_val(value);
value copy_pos2d_s32(position2d<s32>);

position2d<f32> Pos2d_f32_val(value);
value copy_pos2d_f32(position2d<f32>);

vector3df Vector3df_val(value);
value copy_vector3df(vector3df);

Expand Down
4 changes: 4 additions & 0 deletions irr_gui.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ type obj = Irr_base.obj
external cursor_get_position : obj -> int Irr_core.pos_2d =
"ml_ICursorControl_getPosition"

external cursor_get_relative_position : obj -> float Irr_core.pos_2d =
"ml_ICursorControl_getRelativePosition"

external cursor_set_visible : obj -> bool -> unit =
"ml_ICursorControl_setVisible"

class cursor obj = object(self)
inherit Irr_base.reference_counted obj
method pos = cursor_get_position self#obj
method rel_pos = cursor_get_relative_position self#obj
method set_visible b = cursor_set_visible self#obj b
end

Expand Down
1 change: 1 addition & 0 deletions irr_gui.mli
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type obj = Irr_base.obj
class cursor : obj -> object
inherit Irr_base.reference_counted
method pos : int Irr_core.pos_2d
method rel_pos : float Irr_core.pos_2d
method set_visible : bool -> unit
end

Expand Down
6 changes: 6 additions & 0 deletions irr_gui_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ extern "C" CAMLprim value ml_ICursorControl_getPosition(value v_cursor) {
return copy_pos2d_s32(((ICursorControl*) v_cursor)->getPosition());
}

extern "C" CAMLprim
value ml_ICursorControl_getRelativePosition(value v_cursor) {
return copy_pos2d_f32(((ICursorControl*) v_cursor)->
getRelativePosition());
}

extern "C" CAMLprim value ml_ICursorControl_setVisible(
value v_cursor, value v_b)
{
Expand Down

0 comments on commit 83452ed

Please sign in to comment.