Make pressing the preview work again

This commit is contained in:
Benjamin Schaaf 2021-04-26 19:07:59 +10:00
parent 1bd975698c
commit d03d4b99e3
4 changed files with 93 additions and 77 deletions

View File

@ -4,9 +4,10 @@
} }
.controlbox { .controlbox {
background: rgba(0,0,0,0.2); background: rgba(0, 0, 0, 0.2);
} }
.button-overlay { .button-overlay {
opacity: 0.9; opacity: 0.9;
background-color: rgba(0, 0, 0, 0.2);
} }

View File

@ -25,19 +25,19 @@
<child type="overlay"> <child type="overlay">
<object class="GtkBox"> <object class="GtkBox">
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="vexpand">1</property> <property name="halign">fill</property>
<property name="hexpand">1</property> <property name="valign">start</property>
<property name="spacing">5</property> <property name="spacing">5</property>
<property name="can-focus">0</property> <property name="can-focus">0</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-bottom">5</property>
<property name="margin-top">5</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="orientation">horizontal</property> <property name="orientation">horizontal</property>
<property name="hexpand">1</property> <property name="hexpand">1</property>
<property name="valign">start</property> <property name="valign">start</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="can-focus">0</property> <property name="can-focus">0</property>
<property name="spacing">5</property> <property name="spacing">5</property>
<child> <child>
@ -64,6 +64,10 @@
<object class="GtkButton"> <object class="GtkButton">
<property name="visible">0</property> <property name="visible">0</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="orientation">horizontal</property> <property name="orientation">horizontal</property>
@ -85,87 +89,94 @@
</style> </style>
</object> </object>
</child> </child>
<style>
<class name="button-overlay"/>
</style>
</object>
</child>
<child type="overlay">
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="halign">fill</property>
<property name="valign">end</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="orientation">horizontal</property> <property name="orientation">horizontal</property>
<property name="hexpand">1</property> <property name="hexpand">1</property>
<property name="vexpand">1</property>
<property name="valign">end</property> <property name="valign">end</property>
<property name="can-focus">0</property> <property name="margin-start">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="spacing">5</property>
<child> <child>
<object class="GtkBox"> <object class="GtkButton">
<property name="orientation">horizontal</property> <property name="action-name">app.open-settings</property>
<property name="hexpand">1</property> <property name="icon-name">settings-symbolic</property>
<property name="valign">end</property> </object>
</child>
<child>
<object class="GtkButton">
<property name="action-name">app.switch-camera</property>
<property name="icon-name">switch-camera-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="action-name">app.capture</property>
<child>
<object class="GtkImage">
<property name="pixel-size">60</property>
<property name="can-focus">0</property> <property name="can-focus">0</property>
<property name="spacing">5</property> <property name="icon-name">shutter-button-symbolic</property>
</object>
</child>
<style>
<class name="circular"/>
</style>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="hexpand">1</property>
<property name="halign">end</property>
<property name="valign">end</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="spacing">5</property>
<child>
<object class="GtkButton">
<property name="action-name">app.open-last</property>
<child> <child>
<object class="GtkButton"> <object class="GtkStack" id="open_last_stack">
<property name="action-name">app.open-settings</property> <property name="can-focus">0</property>
<property name="icon-name">settings-symbolic</property> <child>
</object> <object class="GtkImage" id="thumb_last">
</child> <property name="width-request">24</property>
<child> <property name="height-request">24</property>
<object class="GtkButton"> <property name="can-focus">0</property>
<property name="action-name">app.switch-camera</property> </object>
<property name="icon-name">switch-camera-symbolic</property> </child>
<child>
<object class="GtkSpinner" id="process_spinner">
<property name="width-request">24</property>
<property name="height-request">24</property>
<property name="can-focus">0</property>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkButton"> <object class="GtkButton">
<property name="action-name">app.capture</property> <property name="action-name">app.open-photos</property>
<child> <property name="icon-name">folder-symbolic</property>
<object class="GtkImage">
<property name="pixel-size">60</property>
<property name="can-focus">0</property>
<property name="icon-name">shutter-button-symbolic</property>
</object>
</child>
<style>
<class name="circular"/>
</style>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="hexpand">1</property>
<property name="halign">end</property>
<property name="valign">end</property>
<property name="can-focus">0</property>
<property name="spacing">5</property>
<child>
<object class="GtkButton">
<property name="action-name">app.open-last</property>
<child>
<object class="GtkStack" id="open_last_stack">
<property name="can-focus">0</property>
<child>
<object class="GtkImage" id="thumb_last">
<property name="width-request">24</property>
<property name="height-request">24</property>
<property name="can-focus">0</property>
</object>
</child>
<child>
<object class="GtkSpinner" id="process_spinner">
<property name="width-request">24</property>
<property name="height-request">24</property>
<property name="can-focus">0</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="action-name">app.open-photos</property>
<property name="icon-name">folder-symbolic</property>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>

View File

@ -545,6 +545,7 @@ static void
preview_pressed(GtkGestureClick *gesture, int n_press, double x, double y) preview_pressed(GtkGestureClick *gesture, int n_press, double x, double y)
{ {
GtkWidget *widget = gtk_event_controller_get_widget(GTK_EVENT_CONTROLLER(gesture)); GtkWidget *widget = gtk_event_controller_get_widget(GTK_EVENT_CONTROLLER(gesture));
int scale_factor = gtk_widget_get_scale_factor(widget);
// Tapped zbar result // Tapped zbar result
if (zbar_result) { if (zbar_result) {
@ -552,9 +553,8 @@ preview_pressed(GtkGestureClick *gesture, int n_press, double x, double y)
float offset_x, offset_y, size_x, size_y; float offset_x, offset_y, size_x, size_y;
position_preview(&offset_x, &offset_y, &size_x, &size_y); position_preview(&offset_x, &offset_y, &size_x, &size_y);
double scale = preview_buffer_height / size_y; int zbar_x = (x - offset_x) * scale_factor / size_x * preview_buffer_width;
int zbar_x = (x - offset_x) * scale; int zbar_y = (y - offset_y) * scale_factor / size_y * preview_buffer_height;
int zbar_y = (y - offset_y) * scale;
for (uint8_t i = 0; i < zbar_result->size; ++i) { for (uint8_t i = 0; i < zbar_result->size; ++i) {
MPZBarCode *code = &zbar_result->codes[i]; MPZBarCode *code = &zbar_result->codes[i];

View File

@ -255,7 +255,9 @@ mp_process_pipeline_init_gl(GdkSurface *surface)
static cairo_surface_t * static cairo_surface_t *
process_image_for_preview(const uint8_t *image) process_image_for_preview(const uint8_t *image)
{ {
#ifdef PROFILE_DEBAYER
clock_t t1 = clock(); clock_t t1 = clock();
#endif
// Pick an available buffer // Pick an available buffer
MPProcessPipelineBuffer *output_buffer = NULL; MPProcessPipelineBuffer *output_buffer = NULL;
@ -293,8 +295,10 @@ process_image_for_preview(const uint8_t *image)
glDeleteTextures(1, &input_texture); glDeleteTextures(1, &input_texture);
#ifdef PROFILE_DEBAYER
clock_t t2 = clock(); clock_t t2 = clock();
printf("%fms\n", (float)(t2 - t1) / CLOCKS_PER_SEC * 1000); printf("%fms\n", (float)(t2 - t1) / CLOCKS_PER_SEC * 1000);
#endif
// { // {
// glBindTexture(GL_TEXTURE_2D, textures[1]); // glBindTexture(GL_TEXTURE_2D, textures[1]);