You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
start implementing Drawable using underlying GdkPaintable
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class android_graphics_drawable_Drawable */
|
||||
|
||||
#ifndef _Included_android_graphics_drawable_Drawable
|
||||
#define _Included_android_graphics_drawable_Drawable
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: android_graphics_drawable_Drawable
|
||||
* Method: native_paintable_from_path
|
||||
* Signature: (Ljava/lang/String;)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_android_graphics_drawable_Drawable_native_1paintable_1from_1path
|
||||
(JNIEnv *, jclass, jstring);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -279,6 +279,14 @@ JNIEXPORT void JNICALL Java_android_view_View_native_1layout
|
||||
JNIEXPORT void JNICALL Java_android_view_View_native_1requestLayout
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: android_view_View
|
||||
* Method: native_setBackgroundDrawable
|
||||
* Signature: (JJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_view_View_native_1setBackgroundDrawable
|
||||
(JNIEnv *, jobject, jlong, jlong);
|
||||
|
||||
/*
|
||||
* Class: android_view_View
|
||||
* Method: nativeInvalidate
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
#include "../defines.h"
|
||||
#include "../generated_headers/android_graphics_drawable_Drawable.h"
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_android_graphics_drawable_Drawable_native_1paintable_1from_1path(JNIEnv *env, jclass class, jstring pathStr) {
|
||||
const char *path = (*env)->GetStringUTFChars(env, pathStr, NULL);
|
||||
|
||||
GdkPaintable *paintable = GDK_PAINTABLE(gdk_texture_new_from_filename(path, NULL));
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, pathStr, path);
|
||||
return _INTPTR(paintable);
|
||||
}
|
||||
@@ -405,3 +405,9 @@ JNIEXPORT void JNICALL Java_android_view_View_setBackgroundColor(JNIEnv *env, jo
|
||||
|
||||
gtk_style_context_add_provider(gtk_widget_get_style_context(gtk_widget_get_parent(widget)), GTK_STYLE_PROVIDER(css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_view_View_native_1setBackgroundDrawable(JNIEnv *env, jobject this, jlong widget_ptr, jlong paintable_ptr) {
|
||||
GtkWidget *widget = GTK_WIDGET(_PTR(widget_ptr));
|
||||
GdkPaintable *paintable = GDK_PAINTABLE(_PTR(paintable_ptr));
|
||||
wrapper_widget_set_background(WRAPPER_WIDGET(gtk_widget_get_parent(widget)), paintable);
|
||||
}
|
||||
|
||||
@@ -92,6 +92,8 @@ void wrapper_widget_allocate(GtkWidget *widget, int width, int height, int basel
|
||||
gtk_widget_size_allocate(wrapper->child, &allocation, baseline);
|
||||
if (wrapper->sk_area)
|
||||
gtk_widget_size_allocate(wrapper->sk_area, &allocation, baseline);
|
||||
if (wrapper->background)
|
||||
gtk_widget_size_allocate(wrapper->background, &allocation, baseline);
|
||||
}
|
||||
|
||||
static void wrapper_widget_class_init(WrapperWidgetClass *class)
|
||||
@@ -172,3 +174,12 @@ void wrapper_widget_set_layout_params(WrapperWidget *wrapper, int width, int hei
|
||||
wrapper->layout_width = width;
|
||||
wrapper->layout_height = height;
|
||||
}
|
||||
|
||||
void wrapper_widget_set_background(WrapperWidget *wrapper, GdkPaintable *paintable)
|
||||
{
|
||||
if (!wrapper->background) {
|
||||
wrapper->background = gtk_picture_new();
|
||||
gtk_widget_insert_after(wrapper->background, GTK_WIDGET(wrapper), NULL);
|
||||
}
|
||||
gtk_picture_set_paintable(GTK_PICTURE(wrapper->background), paintable);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ struct _WrapperWidget
|
||||
GtkWidget parent_instance;
|
||||
GtkWidget *child;
|
||||
GtkWidget *sk_area;
|
||||
GtkWidget *background;
|
||||
JavaVM *jvm;
|
||||
jobject jobj;
|
||||
jobject canvas;
|
||||
@@ -31,6 +32,7 @@ void wrapper_widget_set_child(WrapperWidget *parent, GtkWidget *child);
|
||||
void wrapper_widget_set_jobject(WrapperWidget *wrapper, JNIEnv *env, jobject jobj);
|
||||
void wrapper_widget_queue_draw(WrapperWidget *wrapper);
|
||||
void wrapper_widget_set_layout_params(WrapperWidget *wrapper, int width, int height);
|
||||
void wrapper_widget_set_background(WrapperWidget *wrapper, GdkPaintable *paintable);
|
||||
|
||||
void _setOnTouchListener(JNIEnv *env, jobject this, GtkWidget *widget, jobject on_touch_listener);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user