forked from enlightenment/efl
elm_code: Add focus support for the elm_code widget.
Hook into the internal elementary API to be part of the focus chain
This commit is contained in:
parent
29d31ad9f1
commit
3c9e554b7b
|
@ -92,8 +92,7 @@ _elm_code_test_diff_setup(Evas_Object *parent)
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
elm_code_test_win_setup(void)
|
elm_code_test_win_setup(void)
|
||||||
{
|
{
|
||||||
Evas_Object *win;
|
Evas_Object *win,*vbox;
|
||||||
Evas_Object *vbox;
|
|
||||||
|
|
||||||
win = elm_win_util_standard_add("main", "Elm_Code Test");
|
win = elm_win_util_standard_add("main", "Elm_Code Test");
|
||||||
if (!win) return NULL;
|
if (!win) return NULL;
|
||||||
|
@ -104,15 +103,11 @@ elm_code_test_win_setup(void)
|
||||||
elm_box_homogeneous_set(vbox, EINA_TRUE);
|
elm_box_homogeneous_set(vbox, EINA_TRUE);
|
||||||
evas_object_show(vbox);
|
evas_object_show(vbox);
|
||||||
|
|
||||||
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
|
|
||||||
evas_object_smart_callback_add(win, "delete,request", _elm_code_test_win_del, NULL);
|
|
||||||
|
|
||||||
elm_box_pack_end(vbox, _elm_code_test_welcome_setup(vbox));
|
elm_box_pack_end(vbox, _elm_code_test_welcome_setup(vbox));
|
||||||
|
|
||||||
elm_box_pack_end(vbox, _elm_code_test_diff_setup(vbox));
|
elm_box_pack_end(vbox, _elm_code_test_diff_setup(vbox));
|
||||||
|
|
||||||
elm_win_resize_object_add(win, vbox);
|
elm_win_resize_object_add(win, vbox);
|
||||||
|
|
||||||
|
evas_object_smart_callback_add(win, "delete,request", _elm_code_test_win_del, NULL);
|
||||||
evas_object_resize(win, 380 * elm_config_scale_get(), 240 * elm_config_scale_get());
|
evas_object_resize(win, 380 * elm_config_scale_get(), 240 * elm_config_scale_get());
|
||||||
evas_object_show(win);
|
evas_object_show(win);
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
#include <Eo.h>
|
#include <Eo.h>
|
||||||
#include <Evas.h>
|
#include <Evas.h>
|
||||||
#include <Elementary.h>
|
#include <Elementary.h>
|
||||||
|
#define ELM_INTERNAL_API_ARGESFSDFEFC
|
||||||
|
#include <elm_widget.h>
|
||||||
|
|
||||||
#include <Elm_Code.h>
|
#include <Elm_Code.h>
|
||||||
#include "elm_code_widget2.eo.h"
|
#include "elm_code_widget2.eo.h"
|
||||||
|
|
||||||
|
@ -15,7 +18,7 @@ typedef struct
|
||||||
|
|
||||||
Evas_Font_Size font_size;
|
Evas_Font_Size font_size;
|
||||||
unsigned int cursor_line, cursor_col;
|
unsigned int cursor_line, cursor_col;
|
||||||
Eina_Bool editable;
|
Eina_Bool editable, focussed;
|
||||||
} Elm_Code_Widget2_Data;
|
} Elm_Code_Widget2_Data;
|
||||||
|
|
||||||
Eina_Unicode status_icons2[] = {
|
Eina_Unicode status_icons2[] = {
|
||||||
|
@ -133,7 +136,7 @@ _elm_code_widget_fill_line(Elm_Code_Widget2_Data *pd, Evas_Textgrid_Cell *cells,
|
||||||
}
|
}
|
||||||
|
|
||||||
_elm_code_widget_fill_line_tokens(cells, w, line);
|
_elm_code_widget_fill_line_tokens(cells, w, line);
|
||||||
if (pd->editable && pd->cursor_line == line->number)
|
if (pd->editable && pd->focussed && pd->cursor_line == line->number)
|
||||||
{
|
{
|
||||||
if (pd->cursor_col < (unsigned int) w)
|
if (pd->cursor_col < (unsigned int) w)
|
||||||
cells[pd->cursor_col].bg = ELM_CODE_TOKEN_TYPE_CURSOR;
|
cells[pd->cursor_col].bg = ELM_CODE_TOKEN_TYPE_CURSOR;
|
||||||
|
@ -225,6 +228,10 @@ _elm_code_widget2_clicked_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj E
|
||||||
|
|
||||||
widget = (Elm_Code_Widget2 *)data;
|
widget = (Elm_Code_Widget2 *)data;
|
||||||
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET2_CLASS);
|
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET2_CLASS);
|
||||||
|
|
||||||
|
if (pd->editable && !pd->focussed)
|
||||||
|
return;
|
||||||
|
|
||||||
event = (Evas_Event_Mouse_Up *)event_info;
|
event = (Evas_Event_Mouse_Up *)event_info;
|
||||||
y = event->canvas.y;
|
y = event->canvas.y;
|
||||||
|
|
||||||
|
@ -236,6 +243,19 @@ _elm_code_widget2_clicked_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj E
|
||||||
eo_do(widget, eo_event_callback_call(ELM_CODE_WIDGET2_EVENT_LINE_CLICKED, line));
|
eo_do(widget, eo_event_callback_call(ELM_CODE_WIDGET2_EVENT_LINE_CLICKED, line));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EOLIAN static Eina_Bool
|
||||||
|
_elm_code_widget2_elm_widget_on_focus(Eo *obj, Elm_Code_Widget2_Data *pd)
|
||||||
|
{
|
||||||
|
Eina_Bool int_ret = EINA_FALSE;
|
||||||
|
eo_do_super(obj, ELM_CODE_WIDGET2_CLASS, int_ret = elm_obj_widget_on_focus());
|
||||||
|
if (!int_ret) return EINA_TRUE;
|
||||||
|
|
||||||
|
pd->focussed = elm_widget_focus_get(obj);
|
||||||
|
|
||||||
|
_elm_code_widget_fill(pd);
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
_elm_code_widget2_elm_interface_scrollable_content_pos_set(Eo *obj EINA_UNUSED,
|
_elm_code_widget2_elm_interface_scrollable_content_pos_set(Eo *obj EINA_UNUSED,
|
||||||
Elm_Code_Widget2_Data *pd EINA_UNUSED,
|
Elm_Code_Widget2_Data *pd EINA_UNUSED,
|
||||||
|
@ -329,7 +349,7 @@ _elm_code_widget2_evas_object_smart_add(Eo *obj, Elm_Code_Widget2_Data *pd)
|
||||||
Evas_Object *grid;
|
Evas_Object *grid;
|
||||||
|
|
||||||
eo_do_super(obj, ELM_CODE_WIDGET2_CLASS, evas_obj_smart_add());
|
eo_do_super(obj, ELM_CODE_WIDGET2_CLASS, evas_obj_smart_add());
|
||||||
// elm_widget_can_focus_set(obj, EINA_TRUE);
|
elm_widget_can_focus_set(obj, EINA_TRUE);
|
||||||
|
|
||||||
grid = evas_object_textgrid_add(obj);
|
grid = evas_object_textgrid_add(obj);
|
||||||
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);
|
||||||
|
|
|
@ -37,6 +37,7 @@ class Elm_Code_Widget2 (Elm_Box, Elm_Interface_Scrollable,
|
||||||
class.constructor;
|
class.constructor;
|
||||||
Eo.Base.constructor;
|
Eo.Base.constructor;
|
||||||
Evas.Object_Smart.add;
|
Evas.Object_Smart.add;
|
||||||
|
Elm_Widget.on_focus;
|
||||||
Elm_Interface_Scrollable.content_pos_set;
|
Elm_Interface_Scrollable.content_pos_set;
|
||||||
}
|
}
|
||||||
events {
|
events {
|
||||||
|
|
|
@ -31,12 +31,16 @@ void _elm_code_widget2_eo_base_constructor(Eo *obj, Elm_Code_Widget2_Data *pd);
|
||||||
void _elm_code_widget2_evas_object_smart_add(Eo *obj, Elm_Code_Widget2_Data *pd);
|
void _elm_code_widget2_evas_object_smart_add(Eo *obj, Elm_Code_Widget2_Data *pd);
|
||||||
|
|
||||||
|
|
||||||
|
Eina_Bool _elm_code_widget2_elm_widget_on_focus(Eo *obj, Elm_Code_Widget2_Data *pd);
|
||||||
|
|
||||||
|
|
||||||
void _elm_code_widget2_elm_interface_scrollable_content_pos_set(Eo *obj, Elm_Code_Widget2_Data *pd, Evas_Coord x, Evas_Coord y, Eina_Bool sig);
|
void _elm_code_widget2_elm_interface_scrollable_content_pos_set(Eo *obj, Elm_Code_Widget2_Data *pd, Evas_Coord x, Evas_Coord y, Eina_Bool sig);
|
||||||
|
|
||||||
|
|
||||||
static Eo_Op_Description _elm_code_widget2_op_desc[] = {
|
static Eo_Op_Description _elm_code_widget2_op_desc[] = {
|
||||||
EO_OP_FUNC_OVERRIDE(eo_constructor, _elm_code_widget2_eo_base_constructor),
|
EO_OP_FUNC_OVERRIDE(eo_constructor, _elm_code_widget2_eo_base_constructor),
|
||||||
EO_OP_FUNC_OVERRIDE(evas_obj_smart_add, _elm_code_widget2_evas_object_smart_add),
|
EO_OP_FUNC_OVERRIDE(evas_obj_smart_add, _elm_code_widget2_evas_object_smart_add),
|
||||||
|
EO_OP_FUNC_OVERRIDE(elm_obj_widget_on_focus, _elm_code_widget2_elm_widget_on_focus),
|
||||||
EO_OP_FUNC_OVERRIDE(elm_interface_scrollable_content_pos_set, _elm_code_widget2_elm_interface_scrollable_content_pos_set),
|
EO_OP_FUNC_OVERRIDE(elm_interface_scrollable_content_pos_set, _elm_code_widget2_elm_interface_scrollable_content_pos_set),
|
||||||
EO_OP_FUNC(elm_code_widget2_code_set, _elm_code_widget2_code_set, ""),
|
EO_OP_FUNC(elm_code_widget2_code_set, _elm_code_widget2_code_set, ""),
|
||||||
EO_OP_FUNC(elm_code_widget2_code_get, _elm_code_widget2_code_get, ""),
|
EO_OP_FUNC(elm_code_widget2_code_get, _elm_code_widget2_code_get, ""),
|
||||||
|
|
Loading…
Reference in New Issue