[help] Stub out a right-click-help UI

Not looking anything up yet but we're getting started
This commit is contained in:
Andy Williams 2016-04-07 17:44:12 +01:00
parent 29d70a22fd
commit 1971583e5e
3 changed files with 42 additions and 9 deletions

View File

@ -603,11 +603,12 @@ _elm_code_widget_cursor_move(Elm_Code_Widget *widget, Elm_Code_Widget_Data *pd,
_elm_code_widget_fill_line(widget, elm_code_file_line_get(pd->code->file, pd->cursor_line));
}
static Eina_Bool
_elm_code_widget_position_at_coordinates_get(Elm_Code_Widget *widget, Elm_Code_Widget_Data *pd,
EOLIAN static Eina_Bool
_elm_code_widget_position_at_coordinates_get(Eo *obj, Elm_Code_Widget_Data *pd,
Evas_Coord x, Evas_Coord y,
unsigned int *row, int *col)
{
Elm_Code_Widget *widget;
Eina_List *item;
Elm_Code_Line *line;
Evas_Coord ox, oy, sx, sy, rowy;
@ -615,6 +616,7 @@ _elm_code_widget_position_at_coordinates_get(Elm_Code_Widget *widget, Elm_Code_W
int cw, ch, gutter;
unsigned int guess, number;
widget = (Elm_Code_Widget *)obj;
evas_object_geometry_get(widget, &ox, &oy, NULL, NULL);
elm_scroller_region_get(pd->scroller, &sx, &sy, NULL, NULL);
x = x + sx - ox;

View File

@ -177,6 +177,16 @@ class Elm.Code_Widget (Elm.Layout, Elm.Interface_Atspi_Text)
lines_visible_get {
return: uint; [[the number of lines currently visible in the widget.]]
}
position_at_coordinates_get {
[[get the row, col position for a given coordinate on the widget.]]
params {
x: Evas_Coord; [[the x coordinate in the widget]]
y: Evas_Coord; [[the y coordinate in the widget]]
row: uint *; [[the row for the coordinates]]
col: int *; [[the column for the coordinates]]
}
return: bool; [[true if a line exists at these coordinates]]
}
//text functions
text_left_gutter_width_get {

View File

@ -466,15 +466,36 @@ _unfocused_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UN
}
static void
_gutter_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info)
_mouse_up_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED,
Evas_Object *obj EINA_UNUSED, void *event_info)
{
Elm_Code_Line *line;
Elm_Code_Widget *widget;
Evas_Object *popup;
Evas_Event_Mouse_Up *event;
unsigned int row;
int col;
const char *word;
line = (Elm_Code_Line *)event_info;
widget = (Elm_Code_Widget *)data;
event = (Evas_Event_Mouse_Up *)event_info;
if (line->status_text)
printf("CLANG %s\n", line->status_text);
if (event->button != 3)
return;
elm_code_widget_position_at_coordinates_get(widget, event->canvas.x, event->canvas.y, &row, &col);
elm_code_widget_selection_select_word(widget, row, col);
word = elm_code_widget_selection_text_get(widget);
if (!word || !strlen(word))
return;
popup = elm_popup_add(widget);
elm_popup_timeout_set(popup,1.5);
elm_object_style_set(popup, "transparent");
elm_object_part_text_set(popup, "title,text", word);
elm_object_text_set(popup, "No help available for this term");
evas_object_show(popup);
}
static void
@ -557,7 +578,7 @@ edi_editor_add(Evas_Object *parent, Edi_Mainview_Item *item)
evas_object_event_callback_add(widget, EVAS_CALLBACK_KEY_DOWN,
_smart_cb_key_down, editor);
evas_object_smart_callback_add(widget, "changed,user", _changed_cb, editor);
evas_object_smart_callback_add(widget, "line,gutter,clicked", _gutter_clicked_cb, editor);
evas_object_event_callback_add(widget, EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb, widget);
evas_object_smart_callback_add(widget, "unfocused", _unfocused_cb, editor);
elm_code_parser_standard_add(code, ELM_CODE_PARSER_STANDARD_TODO);