editor: Add a tooltip popup if you hover over a line with a warning attached

This commit is contained in:
Andy Williams 2015-04-04 17:51:39 +01:00
parent 151956ea93
commit f50bff8e99
4 changed files with 64 additions and 2 deletions

View File

@ -36,6 +36,7 @@ elm_code_text.c \
elm_code_file.c \
elm_code_parse.c \
elm_code_widget_text.c \
elm_code_widget_tooltip.c \
elm_code_widget_selection.c \
elm_code_widget.c \
elm_code_diff_widget.c \

View File

@ -50,6 +50,7 @@ typedef struct
Eina_Bool show_whitespace;
Elm_Code_Widget_Selection_Data *selection;
Evas_Object *tooltip;
} Elm_Code_Widget_Data;
/* Private parser callbacks */
@ -59,3 +60,9 @@ void _elm_code_parse_setup();
void _elm_code_parse_line(Elm_Code *code, Elm_Code_Line *line);
void _elm_code_parse_file(Elm_Code *code, Elm_Code_File *file);
/* Private widget methods */
void _elm_code_widget_tooltip_text_set(Evas_Object *widget, const char *text);
void _elm_code_widget_tooltip_add(Evas_Object *widget);

View File

@ -672,19 +672,28 @@ _elm_code_widget_mouse_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj
{
Elm_Code_Widget *widget;
Elm_Code_Widget_Data *pd;
Elm_Code_Line *line;
Evas_Event_Mouse_Move *event;
unsigned int row;
int col;
Eina_Bool hasline;
widget = (Elm_Code_Widget *)data;
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
event = (Evas_Event_Mouse_Move *)event_info;
hasline = _elm_code_widget_position_at_coordinates_get(widget, pd, event->cur.canvas.x, event->cur.canvas.y, &row, &col);
if (!hasline)
_elm_code_widget_tooltip_text_set(widget, NULL);
else
{
line = elm_code_file_line_get(pd->code->file, row);
_elm_code_widget_tooltip_text_set(widget, line->status_text);
}
if (!pd->editable || !pd->selection || !event->buttons)
return;
_elm_code_widget_position_at_coordinates_get(widget, pd, event->cur.canvas.x, event->cur.canvas.y, &row, &col);
elm_code_widget_selection_end(widget, row, col);
}
@ -1360,6 +1369,7 @@ _elm_code_widget_evas_object_smart_add(Eo *obj, Elm_Code_Widget_Data *pd)
evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(grid);
_elm_code_widget_tooltip_add(obj);
elm_object_content_set(scroller, grid);
pd->grid = grid;
_elm_code_widget_setup_palette(grid);

View File

@ -0,0 +1,44 @@
#ifdef HAVE_CONFIG
# include "config.h"
#endif
#include "Elm_Code.h"
#include "elm_code_private.h"
void
_elm_code_widget_tooltip_text_set(Evas_Object *widget, const char *text)
{
Elm_Code_Widget_Data *pd;
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
if (!text)
elm_object_tooltip_hide(widget);
else
elm_object_tooltip_show(widget);
if (pd->tooltip) // will have been created by the callback below...
elm_object_text_set(pd->tooltip, text);
}
static Evas_Object *
_elm_code_widget_tooltip_cb(void *data EINA_UNUSED, Evas_Object *obj, Evas_Object *tooltip)
{
Elm_Code_Widget_Data *pd;
Evas_Object *label;
pd = eo_data_scope_get(obj, ELM_CODE_WIDGET_CLASS);
label = elm_label_add(tooltip);
pd->tooltip = label;
return label;
}
void
_elm_code_widget_tooltip_add(Evas_Object *widget)
{
elm_object_tooltip_content_cb_set(widget, _elm_code_widget_tooltip_cb, NULL, NULL);
}