elm_code: support setting custom fonts
For EDI create the config that would allow this to be altered. Actual setting widget to follow...
This commit is contained in:
parent
fcce45fc82
commit
642bb0ba85
|
@ -71,7 +71,7 @@ _elm_code_test_welcome_setup(Evas_Object *parent)
|
|||
widget = eo_add(ELM_CODE_WIDGET_CLASS, parent,
|
||||
elm_code_widget_code_set(code));
|
||||
eo_do(widget,
|
||||
elm_code_widget_font_size_set(12),
|
||||
elm_code_widget_font_set(NULL, 12),
|
||||
eo_event_callback_add(&ELM_CODE_EVENT_LINE_LOAD_DONE, _elm_code_test_line_done_cb, NULL);
|
||||
eo_event_callback_add(ELM_CODE_WIDGET_EVENT_LINE_CLICKED, _elm_code_test_line_clicked_cb, code));
|
||||
|
||||
|
@ -101,7 +101,7 @@ _elm_code_test_editor_setup(Evas_Object *parent)
|
|||
widget = eo_add(ELM_CODE_WIDGET_CLASS, parent,
|
||||
elm_code_widget_code_set(code));
|
||||
eo_do(widget,
|
||||
elm_code_widget_font_size_set(14),
|
||||
elm_code_widget_font_set(NULL, 14),
|
||||
elm_code_widget_editable_set(EINA_TRUE),
|
||||
elm_code_widget_show_whitespace_set(EINA_TRUE),
|
||||
elm_code_widget_line_numbers_set(EINA_TRUE));
|
||||
|
@ -123,14 +123,14 @@ _elm_code_test_editor_setup(Evas_Object *parent)
|
|||
}
|
||||
|
||||
static Evas_Object *
|
||||
_elm_code_test_mirror_setup(Elm_Code *code, Evas_Object *parent)
|
||||
_elm_code_test_mirror_setup(Elm_Code *code, char *font_name, Evas_Object *parent)
|
||||
{
|
||||
Elm_Code_Widget *widget;
|
||||
|
||||
widget = eo_add(ELM_CODE_WIDGET_CLASS, parent,
|
||||
elm_code_widget_code_set(code));
|
||||
eo_do(widget,
|
||||
elm_code_widget_font_size_set(11),
|
||||
elm_code_widget_font_set(font_name, 11),
|
||||
elm_code_widget_line_numbers_set(EINA_TRUE));
|
||||
|
||||
evas_object_size_hint_weight_set(widget, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
|
@ -212,8 +212,8 @@ _elm_code_test_welcome_mirror_cb(void *data, Evas_Object *obj EINA_UNUSED, void
|
|||
code = elm_code_widget_code_get());
|
||||
elm_box_pack_end(screen, widget);
|
||||
|
||||
elm_box_pack_end(screen, _elm_code_test_mirror_setup(code, screen));
|
||||
elm_box_pack_end(screen, _elm_code_test_mirror_setup(code, screen));
|
||||
elm_box_pack_end(screen, _elm_code_test_mirror_setup(code, "Mono:style=Oblique", screen));
|
||||
elm_box_pack_end(screen, _elm_code_test_mirror_setup(code, "Nimbus Mono", screen));
|
||||
|
||||
evas_object_show(screen);
|
||||
elm_naviframe_item_push(naviframe, "Mirrored editor",
|
||||
|
|
|
@ -121,13 +121,13 @@ elm_code_diff_widget_add(Evas_Object *parent, Elm_Code *code)
|
|||
}
|
||||
|
||||
EAPI void
|
||||
elm_code_diff_widget_font_size_set(Evas_Object *widget, int size)
|
||||
elm_code_diff_widget_font_set(Evas_Object *widget, char *name, int size)
|
||||
{
|
||||
Elm_Code_Widget *child;
|
||||
|
||||
child = (Elm_Code_Widget *) evas_object_data_get(widget, _ELM_CODE_DIFF_WIDGET_LEFT);
|
||||
eo_do(child, elm_code_widget_font_size_set(size));
|
||||
eo_do(child, elm_code_widget_font_set(name, size));
|
||||
child = (Elm_Code_Widget *) evas_object_data_get(widget, _ELM_CODE_DIFF_WIDGET_RIGHT);
|
||||
eo_do(child, elm_code_widget_font_size_set(size));
|
||||
eo_do(child, elm_code_widget_font_set(name, size));
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ extern "C" {
|
|||
|
||||
EAPI Evas_Object *elm_code_diff_widget_add(Evas_Object *parent, Elm_Code *code);
|
||||
|
||||
EAPI void elm_code_diff_widget_font_size_set(Evas_Object *widget, int size);
|
||||
EAPI void elm_code_diff_widget_font_set(Evas_Object *widget, char *name, int size);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
@ -1277,16 +1277,28 @@ _elm_code_widget_lines_visible_get(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd
|
|||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_code_widget_font_size_set(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd, Evas_Font_Size font_size)
|
||||
_elm_code_widget_font_set(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd, char *name,
|
||||
Evas_Font_Size size)
|
||||
{
|
||||
evas_object_textgrid_font_set(pd->grid, "Mono", font_size * elm_config_scale_get());
|
||||
pd->font_size = font_size;
|
||||
char *face = name;
|
||||
if (!face)
|
||||
face = "Mono";
|
||||
|
||||
evas_object_textgrid_font_set(pd->grid, face, size * elm_config_scale_get());
|
||||
if (pd->font_name)
|
||||
free((char *)pd->font_name);
|
||||
pd->font_name = strdup(face);
|
||||
pd->font_size = size;
|
||||
}
|
||||
|
||||
EOLIAN static Evas_Font_Size
|
||||
_elm_code_widget_font_size_get(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd)
|
||||
EOLIAN static void
|
||||
_elm_code_widget_font_get(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd, char **name,
|
||||
Evas_Font_Size *size)
|
||||
{
|
||||
return pd->font_size;
|
||||
if (name)
|
||||
*name = strdup((const char *)pd->font_name);
|
||||
if (size)
|
||||
*size = pd->font_size;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
|
@ -1517,7 +1529,7 @@ _elm_code_widget_evas_object_smart_add(Eo *obj, Elm_Code_Widget_Data *pd)
|
|||
eo_event_callback_add(ELM_CODE_WIDGET_EVENT_SELECTION_CHANGED, _elm_code_widget_selection_cb, obj),
|
||||
eo_event_callback_add(ELM_CODE_WIDGET_EVENT_SELECTION_CLEARED, _elm_code_widget_selection_cb, obj));
|
||||
|
||||
_elm_code_widget_font_size_set(obj, pd, 10);
|
||||
_elm_code_widget_font_set(obj, pd, NULL, 10);
|
||||
}
|
||||
|
||||
#include "elm_code_widget_text.c"
|
||||
|
|
|
@ -21,21 +21,24 @@ class Elm_Code_Widget (Elm.Layout, Elm_Interface_Atspi_Text)
|
|||
code: Elm_Code *; /*@ Our underlying Elm_Code object */
|
||||
}
|
||||
}
|
||||
@property font_size {
|
||||
@property font {
|
||||
set {
|
||||
/*@
|
||||
Set the font size that this widget uses, the font will always be a system monospaced font
|
||||
Set the font that this widget uses, the font should be a monospaced scalable font.
|
||||
Passing NULL will load the default system monospaced font.
|
||||
|
||||
@ingroup Style */
|
||||
}
|
||||
get {
|
||||
/*@
|
||||
Get the font size currently in use
|
||||
Get the font currently in use.
|
||||
The font name is a copy ad should be freed once it is no longer needed
|
||||
|
||||
@ingroup Style */
|
||||
}
|
||||
values {
|
||||
font_size: Evas_Font_Size; /*@ The font size of the widgget */
|
||||
name: char *; /*@ The name of the font to load */
|
||||
size: Evas_Font_Size; /*@ The font size for the widget */
|
||||
}
|
||||
}
|
||||
@property gravity {
|
||||
|
|
|
@ -15,6 +15,7 @@ typedef struct
|
|||
Elm_Code *code;
|
||||
Evas_Object *grid, *scroller;
|
||||
|
||||
const char *font_name;
|
||||
Evas_Font_Size font_size;
|
||||
double gravity_x, gravity_y;
|
||||
|
||||
|
|
Loading…
Reference in New Issue