options_behavior: add ui to change "hide cursor" setting

terminology-1.5
Boris Faure 3 years ago
parent 96218a733c
commit 38404d93ff
  1. 1
      src/bin/main.h
  2. 78
      src/bin/options_behavior.c
  3. 6
      src/bin/win.c
  4. 3
      src/bin/win.h

@ -11,7 +11,6 @@ void main_split_v(Evas_Object *win, Evas_Object *term, const char *cmd);
void term_close(Evas_Object *win, Evas_Object *term,
Eina_Bool hold_if_requested);
void main_trans_update(const Config *config);
void main_media_update(const Config *config);
void main_media_mute_update(const Config *config);
void main_media_visualize_update(const Config *config);

@ -1,5 +1,6 @@
#include "private.h"
#include <math.h>
#include <Elementary.h>
#include <assert.h>
#include "config.h"
@ -14,6 +15,7 @@ typedef struct _Behavior_Ctx {
Evas_Object *op_h;
Evas_Object *op_wh_current;
Evas_Object *term;
Evas_Object *sld_hide_cursor;
Config *config;
} Behavior_Ctx;
@ -204,6 +206,46 @@ _cursors_changed_cb(void *data, Evas_Object *obj,
config_save(config, NULL);
}
static void
_cb_op_hide_cursor_changed(void *data,
Evas_Object *obj,
void *_event EINA_UNUSED)
{
Behavior_Ctx *ctx = data;
Config *config = ctx->config;
if (elm_check_state_get(obj))
{
config->hide_cursor = elm_slider_value_get(ctx->sld_hide_cursor);
elm_object_disabled_set(ctx->sld_hide_cursor, EINA_FALSE);
}
else
{
config->hide_cursor = INFINITY;
elm_object_disabled_set(ctx->sld_hide_cursor, EINA_TRUE);
}
main_hide_cursor_update(config);
config_save(config, NULL);
}
static void
_cb_hide_cursor_slider_chg(void *data,
Evas_Object *obj,
void *_event EINA_UNUSED)
{
Behavior_Ctx *ctx = data;
Config *config = ctx->config;
double value = elm_slider_value_get(obj);
if (config->hide_cursor == value)
return;
config->hide_cursor = value;
main_hide_cursor_update(config);
config_save(config, NULL);
}
static void
_add_cursors_option(Evas_Object *bx,
Behavior_Ctx *ctx)
@ -551,6 +593,8 @@ options_behavior(Evas_Object *opbox, Evas_Object *term)
evas_object_smart_callback_add(o, "delay,changed",
_cb_op_behavior_sback_chg, ctx);
SEPARATOR;
o = elm_label_add(bx);
evas_object_size_hint_weight_set(o, 0.0, 0.0);
evas_object_size_hint_align_set(o, 0.0, 0.5);
@ -564,7 +608,6 @@ options_behavior(Evas_Object *opbox, Evas_Object *term)
evas_object_show(o);
o = elm_slider_add(bx);
elm_object_tooltip_text_set(o, tooltip);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
elm_slider_span_size_set(o, 40);
@ -580,5 +623,38 @@ options_behavior(Evas_Object *opbox, Evas_Object *term)
evas_object_size_hint_weight_set(opbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(opbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(o);
SEPARATOR;
o = elm_check_add(opbox);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
elm_object_text_set(o, _("Translucent"));
elm_object_text_set(o, _("Auto hide the mouse cursor when idle:"));
elm_check_state_set(o, !isnan(config->hide_cursor));
elm_box_pack_end(bx, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "changed",
_cb_op_hide_cursor_changed, ctx);
o = elm_slider_add(bx);
ctx->sld_hide_cursor = o;
elm_object_tooltip_text_set(o, tooltip);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
elm_slider_span_size_set(o, 40);
elm_slider_unit_format_set(o, _("%1.1f s"));
elm_slider_indicator_format_set(o, _("%1.1f s"));
elm_slider_min_max_set(o, 0.0, 60.0);
elm_slider_value_set(o, config->hide_cursor);
elm_box_pack_end(bx, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "delay,changed",
_cb_hide_cursor_slider_chg, ctx);
evas_object_size_hint_weight_set(opbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(opbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(o);
#undef SEPARATOR
}

@ -679,6 +679,12 @@ _win_trans(Win *wn, Term *term, Eina_Bool trans)
}
}
void
main_hide_cursor_update(const Config *config)
{
/* TODO */
}
void
main_trans_update(const Config *config)
{

@ -89,4 +89,7 @@ void
term_apply_shine(Term *term, int shine);
void background_set_shine(Config *config, Evas_Object *bg);
void main_trans_update(const Config *config);
void main_hide_cursor_update(const Config *config);
#endif

Loading…
Cancel
Save