editor: Add a tooltip popup if you hover over a line with a warning attached
This commit is contained in:
parent
ce2545db25
commit
a8e45be3a1
|
@ -36,6 +36,7 @@ elm_code_text.c \
|
||||||
elm_code_file.c \
|
elm_code_file.c \
|
||||||
elm_code_parse.c \
|
elm_code_parse.c \
|
||||||
elm_code_widget_text.c \
|
elm_code_widget_text.c \
|
||||||
|
elm_code_widget_tooltip.c \
|
||||||
elm_code_widget_selection.c \
|
elm_code_widget_selection.c \
|
||||||
elm_code_widget.c \
|
elm_code_widget.c \
|
||||||
elm_code_diff_widget.c \
|
elm_code_diff_widget.c \
|
||||||
|
|
|
@ -50,6 +50,7 @@ typedef struct
|
||||||
Eina_Bool show_whitespace;
|
Eina_Bool show_whitespace;
|
||||||
|
|
||||||
Elm_Code_Widget_Selection_Data *selection;
|
Elm_Code_Widget_Selection_Data *selection;
|
||||||
|
Evas_Object *tooltip;
|
||||||
} Elm_Code_Widget_Data;
|
} Elm_Code_Widget_Data;
|
||||||
|
|
||||||
/* Private parser callbacks */
|
/* 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_line(Elm_Code *code, Elm_Code_Line *line);
|
||||||
|
|
||||||
void _elm_code_parse_file(Elm_Code *code, Elm_Code_File *file);
|
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);
|
||||||
|
|
|
@ -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 *widget;
|
||||||
Elm_Code_Widget_Data *pd;
|
Elm_Code_Widget_Data *pd;
|
||||||
|
Elm_Code_Line *line;
|
||||||
Evas_Event_Mouse_Move *event;
|
Evas_Event_Mouse_Move *event;
|
||||||
unsigned int row;
|
unsigned int row;
|
||||||
int col;
|
int col;
|
||||||
|
Eina_Bool hasline;
|
||||||
|
|
||||||
widget = (Elm_Code_Widget *)data;
|
widget = (Elm_Code_Widget *)data;
|
||||||
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
|
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
|
||||||
event = (Evas_Event_Mouse_Move *)event_info;
|
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)
|
if (!pd->editable || !pd->selection || !event->buttons)
|
||||||
return;
|
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);
|
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_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
evas_object_show(grid);
|
evas_object_show(grid);
|
||||||
|
_elm_code_widget_tooltip_add(obj);
|
||||||
elm_object_content_set(scroller, grid);
|
elm_object_content_set(scroller, grid);
|
||||||
pd->grid = grid;
|
pd->grid = grid;
|
||||||
_elm_code_widget_setup_palette(grid);
|
_elm_code_widget_setup_palette(grid);
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue