//internal delegate void DrawTextCallback(SclFontInfo fontinfo, SclColor color, IntPtr str, int x, int y, int w, int h, int label_alignment, int padding_x, int padding_y, int inner_width, int inner_height, IntPtr userData);
internal delegate void DrawTextCallback(IntPtr font_name, short font_size, bool is_italic, bool is_bold, int r, int g, int b, int a,
IntPtr str, int pos_x, int pos_y, int w, int h,
- int align, int padding_x, int padding_y, int inner_width, int inner_height, IntPtr user_data);
+ int align, int padding_x, int padding_y, int inner_width, int inner_height, int type, IntPtr user_data);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void DrawImageCallback(IntPtr image_path, int dest_x, int dest_y, int dest_weight, int dest_height,
- int src_x, int src_y, int src_width, int src_height, IntPtr user_data);
+ int src_x, int src_y, int src_width, int src_height, int type, IntPtr user_data);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void DrawRectangleCallback(int pos_x, int pos_y, int width, int height,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate int DragStateChangedCallback(IntPtr eventDesc);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void UpdateWindowPositionCallback(int type, int x, int y, int rotationX, int rotationY, IntPtr user_data);
+
[DllImport(Libraries.SclNui, EntryPoint = "scl_nui_init")]
internal static extern int SclNuiInit(string entry_filepath);
[DllImport(Libraries.SclNui, EntryPoint = "scl_nui_set_drag_state_changed_cb")]
internal static extern int SclNuiDragStateChangedCb(DragStateChangedCallback callbackFunction);
+ [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_set_update_window_position_cb")]
+ internal static extern int SclNuiUpdateWindowPositionCb(UpdateWindowPositionCallback callbackFunction, IntPtr userData);
+
+ [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_enable_magnifier")]
+ internal static extern int SclNuiEnableMagnifier(bool enabled);
+
[DllImport(Libraries.SclNui, EntryPoint = "scl_dbus_init")]
internal static extern int SclDbusInit();
--- /dev/null
+using System.Collections.Generic;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen;
+
+namespace ISEDefaultNUI
+{
+ public class MagnifierPosition
+ {
+ public int X;
+ public int Y;
+ public int rotationX;
+ public int rotationY;
+
+ public MagnifierPosition(int X, int Y, int rotationX, int rotationY)
+ {
+ this.X = X;
+ this.Y = Y;
+ this.rotationX = rotationX;
+ this.rotationY = rotationY;
+ }
+ }
+
+ public class MagnifierWindow
+ {
+ private static MagnifierWindow instance;
+ private Timer timer;
+ private List<ImageView> imageList;
+ private List<TextLabel> labelList;
+ private MagnifierPosition position;
+
+ private MagnifierWindow()
+ {
+ timer = new Timer(ResourceManager.MagnifierShowDuration);
+ timer.Tick += TimerTick;
+ imageList = new List<ImageView>();
+ labelList = new List<TextLabel>();
+ }
+
+ private bool TimerTick(object source, Timer.TickEventArgs e)
+ {
+ if (IsExists())
+ Hide();
+
+ return true;
+ }
+
+ public static MagnifierWindow Instance
+ {
+ get
+ {
+ if (instance == null)
+ instance = new MagnifierWindow();
+
+ return instance;
+ }
+ }
+
+ public void Show(View parent)
+ {
+ imageList.ForEach(image => parent.Add(image));
+ labelList.ForEach(label => parent.Add(label));
+ timer.Start();
+ }
+
+ public void Hide()
+ {
+ timer.Stop();
+
+ labelList.ForEach(label =>
+ {
+ label.Unparent();
+ label.Dispose();
+ });
+
+ imageList.ForEach(image =>
+ {
+ image.Unparent();
+ image.Dispose();
+ });
+
+ labelList.Clear();
+ imageList.Clear();
+ }
+
+ public void SetPosition(MagnifierPosition newPosition)
+ {
+ position = newPosition;
+ }
+
+ public MagnifierPosition GetPosition()
+ {
+ return position;
+ }
+
+ public void AddImage(ImageView imageView)
+ {
+ imageList.Add(imageView);
+ }
+
+ public void AddLabel(TextLabel textLabel)
+ {
+ labelList.Add(textLabel);
+ }
+
+ public bool IsExists()
+ {
+ if (imageList.Count != 0 || labelList.Count != 0)
+ return true;
+
+ return false;
+ }
+
+ public bool IsRunning()
+ {
+ return timer.IsRunning();
+ }
+ }
+}
private UpdateWindowCallback _update_window_cb = null;
private KeyClickEventCallback _onKeyClickEvent = null;
private DragStateChangedCallback _onDragStateChangedEvent = null;
+ private UpdateWindowPositionCallback _updateWindowPositionChangedEvent = null;
private List<ImageView> image_list;
private List<TextLabel> label_list;
private int beforePositionX = 0;
private int afterPositionX = 0;
+ private MagnifierWindow magnifier = MagnifierWindow.Instance;
+
enum LabelAlignment
{
LABEL_ALIGN_LEFT_TOP = 0,
MAX_LABEL_ALIGNMENT
}
+ enum WindowType
+ {
+ Keypad = 0,
+ Magnifier,
+ Dim,
+ Popup,
+ }
+
struct SclPoint
{
public int x, y;
//_draw_text_cb = (SclFontInfo fontinfo, SclColor color, IntPtr str, int x, int y, int w, int h, int label_alignment, int padding_x, int padding_y, int inner_width, int inner_height, IntPtr userData) =>
_draw_text_cb = (IntPtr font_name, short font_size, bool is_italic, bool is_bold, int r, int g, int b, int a,
IntPtr str, int pos_x, int pos_y, int width, int height,
- int label_align, int padding_x, int padding_y, int inner_width, int inner_height, IntPtr user_data) =>
+ int label_align, int padding_x, int padding_y, int inner_width, int inner_height, int type, IntPtr user_data) =>
{
Log.Info("NUIIME", "### start draw text");
string FontName = Marshal.PtrToStringAnsi(font_name);
LabelAlignment align = (LabelAlignment)label_align;
string keystr = Marshal.PtrToStringAnsi(str);
+ WindowType windowType = (WindowType)type;
- keyText = draw_text(FontName, font_size, is_italic, is_bold, r, g, b, a,
+ if (windowType == WindowType.Magnifier)
+ {
+ MagnifierPosition magnifierPosition = magnifier.GetPosition();
+ TextLabel magnifierText = draw_text(FontName, font_size, is_italic, is_bold, r, g, b, a,
+ keystr, magnifierPosition.X, magnifierPosition.Y, width, height,
+ align, padding_x, padding_y, inner_width, inner_height);
+ magnifier.AddLabel(magnifierText);
+ }
+ else
+ {
+ keyText = draw_text(FontName, font_size, is_italic, is_bold, r, g, b, a,
keystr, pos_x, pos_y, width, height,
align, padding_x, padding_y, inner_width, inner_height);
- Add(keyText);
- label_list.Add(keyText);
-
+ Add(keyText);
+ label_list.Add(keyText);
+ }
};
SclNuiSetDrawTextCb(_draw_text_cb, (IntPtr)null);
/* Draw image */
- _draw_image_cb = (IntPtr image_path, int dest_x, int dest_y, int dest_weight, int dest_height, int src_x, int src_y, int src_width, int src_height, IntPtr user_data) =>
+ _draw_image_cb = (IntPtr image_path, int dest_x, int dest_y, int dest_weight, int dest_height, int src_x, int src_y, int src_width, int src_height, int type, IntPtr user_data) =>
{
string image_path_str = Marshal.PtrToStringAnsi(image_path);
+ WindowType windowType = (WindowType)type;
Log.Info("NUIIME", "image: " + image_path_str + ", x: " + dest_x + ", y: " + dest_y);
if (image_path_str.EndsWith("/"))
return;
- imageView = draw_image(image_path_str, dest_x, dest_y, dest_weight, dest_height, src_x, src_y, src_width, src_height);
- Add(imageView);
- image_list.Add(imageView);
+ if (windowType == WindowType.Magnifier)
+ {
+ MagnifierPosition magnifierPosition = magnifier.GetPosition();
+ ImageView magnifierImageView = draw_image(image_path_str, magnifierPosition.X, magnifierPosition.Y, dest_weight, dest_height, src_x, src_y, src_width, src_height);
+ magnifier.AddImage(magnifierImageView);
+ }
+ else
+ {
+ imageView = draw_image(image_path_str, dest_x, dest_y, dest_weight, dest_height, src_x, src_y, src_width, src_height);
+ Add(imageView);
+ image_list.Add(imageView);
+ }
};
SclNuiSetDrawImageCb(_draw_image_cb, (IntPtr)null);
{
Log.Info("NUIIME", "update_window");
- UpdateArea(x, y, width, height);
+ UpdateArea(x, y, width, height);
+
+ if (magnifier.IsExists() && !magnifier.IsRunning())
+ magnifier.Show(this);
};
SclNuiUpdateWindowCb(_update_window_cb, (IntPtr)null);
{
NUIApplication.Current.Exit();
};
+
+ Preference.EventContext context = null;
+ Preference.GetEventContext(ResourceManager.IseConfigPreviewOn).TryGetTarget(out context);
+ if (context != null)
+ {
+ context.Changed += PreviewModeChanged;
+ }
+
+ _updateWindowPositionChangedEvent = (int type, int x, int y, int rotationX, int rotationY, IntPtr user_data) =>
+ {
+ WindowType windowType = (WindowType)type;
+ if (windowType == WindowType.Magnifier)
+ {
+ magnifier.SetPosition(new MagnifierPosition(x, y, rotationX, rotationY));
+ }
+ };
+ SclNuiUpdateWindowPositionCb(_updateWindowPositionChangedEvent, (IntPtr)null);
+ }
+
+ private void PreviewModeChanged(object sender, PreferenceChangedEventArgs e)
+ {
+ IseConfig.Instance.ReadIsePreviewOn();
+ this.EnableMagnifier(IseConfig.Instance.PreviewOn);
}
~SCLNUI()
Log.Info("NUIIME", "### end draw text");
- return key_text;
+ return key_text;
}
View draw_rectangle(int pos_x, int pos_y, int width, int height, bool fill, int fill_color_r, int fill_color_g, int fill_color_b, int fill_color_a)
ImageView draw_image(string image_path_str, int dest_x, int dest_y, int dest_weight, int dest_height, int src_x, int src_y, int src_width, int src_height)
{
Log.Info("NUIIME", "### start draw image");
-
+
ImageView imageView = new ImageView(image_path_str);
imageView.Position = new Position(dest_x, dest_y);
Log.Info("NUIIME", "### end draw image");
- return imageView;
+ return imageView;
}
void dispose_all_objects()
- {
+ {
Log.Info("NUIIME", "Clear all objects");
int i = 0;
{
i++;
label_element.Unparent();
- label_element.Dispose();
+ label_element.Dispose();
}
Log.Info("NUIIME", "Dispose labels (" + i + ")");
label_list.Clear();
// - Set the mTouchedInButton to false
case PointStateType.Down:
{
+ if (magnifier.IsExists())
+ magnifier.Hide();
+
Log.Info("NUIIME", "[MOUSE DOWN] x=" + e.Touch.GetScreenPosition(0).X + ", y=" + e.Touch.GetScreenPosition(0).Y);
SclControllerMousePress((int)e.Touch.GetScreenPosition(0).X, (int)e.Touch.GetScreenPosition(0).Y);
beforePositionX = (int)e.Touch.GetScreenPosition(0).X;
{
return SclNuiSetStringSubstitution(original, substitute);
}
+
+ public int EnableMagnifier(bool enabled)
+ {
+ return SclNuiEnableMagnifier(enabled);
+ }
}
}