aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-12-23 13:34:20 -0200
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-12-23 15:05:26 -0200
commit4ee19584c0cf1048d5cc813ec82f9be249411d3f (patch)
tree50f9cbc08cdb8d5f87a733e5671b77a0dcd8d0fd
parent8956d6f5df867e911203e06db97313f30f57a98b (diff)
Add zoom control
The icon was imported from gnome icon set (https://github.com/GNOME/gnome-icon-theme) before changeset e4fc9dade2d6411173bb84c0f1064eeac0b6a5fb, to ensure that it matches the license of camorama project (GPL 2). Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
-rw-r--r--data/Makefile.am1
-rw-r--r--data/Makefile.in1
-rw-r--r--data/camorama-gtk2.ui80
-rw-r--r--data/camorama-gtk3.ui60
-rw-r--r--data/camorama-gtk4.ui60
-rw-r--r--data/pixmaps/zoom.pngbin0 -> 958 bytes
-rw-r--r--src/callbacks.c7
-rw-r--r--src/callbacks.h1
-rw-r--r--src/camorama-window.c13
-rw-r--r--src/v4l.c8
-rw-r--r--src/v4l.h2
11 files changed, 195 insertions, 38 deletions
diff --git a/data/Makefile.am b/data/Makefile.am
index 3abd732..59fa479 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -3,6 +3,7 @@ stuff_DATA = \
pixmaps/snap-icon.xpm \
pixmaps/snap-icon-small.xpm \
pixmaps/contrast.png \
+ pixmaps/zoom.png \
pixmaps/colourness.png \
pixmaps/brightness.png \
pixmaps/whiteness.png \
diff --git a/data/Makefile.in b/data/Makefile.in
index 31aa497..52c27a8 100644
--- a/data/Makefile.in
+++ b/data/Makefile.in
@@ -280,6 +280,7 @@ stuff_DATA = \
pixmaps/snap-icon.xpm \
pixmaps/snap-icon-small.xpm \
pixmaps/contrast.png \
+ pixmaps/zoom.png \
pixmaps/colourness.png \
pixmaps/brightness.png \
pixmaps/whiteness.png \
diff --git a/data/camorama-gtk2.ui b/data/camorama-gtk2.ui
index 41da30f..6fa189c 100644
--- a/data/camorama-gtk2.ui
+++ b/data/camorama-gtk2.ui
@@ -30,6 +30,10 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
+ <object class="GtkAdjustment" id="adjustment7">
+ <property name="upper">255</property>
+ <property name="step_increment">1</property>
+ </object>
<object class="GtkDialog" id="prefswindow">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Preferences</property>
@@ -1564,7 +1568,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">12</property>
- <property name="n_rows">5</property>
+ <property name="n_rows">6</property>
<property name="n_columns">3</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
@@ -1613,8 +1617,8 @@
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@@ -1631,8 +1635,8 @@
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@@ -1649,8 +1653,8 @@
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@@ -1695,8 +1699,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
@@ -1711,8 +1715,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
@@ -1727,8 +1731,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
@@ -1753,8 +1757,8 @@
<property name="pixbuf">colourness.png</property>
</object>
<packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@@ -1766,8 +1770,8 @@
<property name="pixbuf">stock-tool-hue-saturation-16.png</property>
</object>
<packing>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@@ -1779,8 +1783,8 @@
<property name="pixbuf">whiteness.png</property>
</object>
<packing>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@@ -1796,6 +1800,44 @@
<property name="y_options">GTK_FILL</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="zoom_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Zoom:</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="zoom_icon">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixbuf">zoom.png</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHScale" id="zoom_slider">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="adjustment">adjustment7</property>
+ <property name="round_digits">0</property>
+ <property name="digits">0</property>
+ <property name="value_pos">left</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/data/camorama-gtk3.ui b/data/camorama-gtk3.ui
index 927ad1e..c0f7593 100644
--- a/data/camorama-gtk3.ui
+++ b/data/camorama-gtk3.ui
@@ -30,6 +30,10 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
+ <object class="GtkAdjustment" id="adjustment7">
+ <property name="upper">255</property>
+ <property name="step_increment">1</property>
+ </object>
<object class="GtkImage" id="image21">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -433,7 +437,7 @@
</object>
<packing>
<property name="left_attach">2</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
</packing>
</child>
<child>
@@ -448,7 +452,7 @@
</object>
<packing>
<property name="left_attach">2</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
</packing>
</child>
<child>
@@ -463,7 +467,7 @@
</object>
<packing>
<property name="left_attach">2</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
</packing>
</child>
<child>
@@ -499,7 +503,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
</packing>
</child>
<child>
@@ -511,7 +515,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
</packing>
</child>
<child>
@@ -523,7 +527,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
</packing>
</child>
<child>
@@ -556,7 +560,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
</packing>
</child>
<child>
@@ -567,7 +571,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
</packing>
</child>
<child>
@@ -578,7 +582,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
</packing>
</child>
<child>
@@ -596,6 +600,44 @@
<property name="top_attach">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="zoom_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Zoom:</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="zoom_icon">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixbuf">zoom.png</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScale" id="zoom_slider">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="adjustment">adjustment7</property>
+ <property name="round_digits">0</property>
+ <property name="digits">0</property>
+ <property name="value_pos">left</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/data/camorama-gtk4.ui b/data/camorama-gtk4.ui
index 79b4b7c..3397bb4 100644
--- a/data/camorama-gtk4.ui
+++ b/data/camorama-gtk4.ui
@@ -23,6 +23,10 @@
<property name="upper">255</property>
<property name="step_increment">1</property>
</object>
+ <object class="GtkAdjustment" id="adjustment7">
+ <property name="upper">255</property>
+ <property name="step_increment">1</property>
+ </object>
<object class="GtkWindow" id="main_window">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Camorama-libglade</property>
@@ -359,7 +363,7 @@
</object>
<packing>
<property name="left_attach">2</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
</packing>
</child>
<child>
@@ -374,7 +378,7 @@
</object>
<packing>
<property name="left_attach">2</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
</packing>
</child>
<child>
@@ -389,7 +393,7 @@
</object>
<packing>
<property name="left_attach">2</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
</packing>
</child>
<child>
@@ -425,7 +429,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
</packing>
</child>
<child>
@@ -437,7 +441,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
</packing>
</child>
<child>
@@ -449,7 +453,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
</packing>
</child>
<child>
@@ -482,7 +486,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
</packing>
</child>
<child>
@@ -493,7 +497,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
</packing>
</child>
<child>
@@ -504,7 +508,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
</packing>
</child>
<child>
@@ -522,6 +526,44 @@
<property name="top_attach">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="zoom_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Zoom:</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="zoom_icon">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixbuf">zoom.png</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScale" id="zoom_slider">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="adjustment">adjustment7</property>
+ <property name="round_digits">0</property>
+ <property name="digits">0</property>
+ <property name="value_pos">left</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">4</property>
diff --git a/data/pixmaps/zoom.png b/data/pixmaps/zoom.png
new file mode 100644
index 0000000..9700f79
--- /dev/null
+++ b/data/pixmaps/zoom.png
Binary files differ
diff --git a/src/callbacks.c b/src/callbacks.c
index d2c9036..732b79c 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -762,6 +762,13 @@ void brightness_change(GtkScale *sc1, cam_t *cam)
v4l2_set_control(cam->dev, V4L2_CID_BRIGHTNESS, cam->brightness);
}
+void zoom_change(GtkScale *sc1, cam_t *cam)
+{
+
+ cam->zoom = 256 * (int)gtk_range_get_value((GtkRange *) sc1);
+ v4l2_set_control(cam->dev, V4L2_CID_ZOOM_ABSOLUTE, cam->zoom);
+}
+
void colour_change(GtkScale *sc1, cam_t *cam)
{
diff --git a/src/callbacks.h b/src/callbacks.h
index 273743c..6d1eb2f 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -65,6 +65,7 @@ void on_scale1_drag_data_received(GtkScale *, cam_t *);
void on_status_show(GtkWidget *, cam_t *);
void contrast_change(GtkScale *, cam_t *);
void brightness_change(GtkScale *, cam_t *);
+void zoom_change(GtkScale *, cam_t *);
void colour_change(GtkScale *, cam_t *);
void hue_change(GtkScale *, cam_t *);
void wb_change(GtkScale *, cam_t *);
diff --git a/src/camorama-window.c b/src/camorama-window.c
index 298e56d..8bebbde 100644
--- a/src/camorama-window.c
+++ b/src/camorama-window.c
@@ -313,6 +313,19 @@ void load_interface(cam_t *cam)
gtk_range_set_value((GtkRange *)GTK_WIDGET(gtk_builder_get_object(cam->xml, "color_slider")),
(int)(cam->colour / 256));
}
+ if (cam->zoom < 0) {
+ gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object(cam->xml,
+ "zoom_icon")));
+ gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object(cam->xml,
+ "zoom_label")));
+ gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object(cam->xml,
+ "zoom_slider")));
+ } else {
+ g_signal_connect(gtk_builder_get_object(cam->xml, "zoom_slider"),
+ "value-changed", G_CALLBACK(zoom_change), cam);
+ gtk_range_set_value((GtkRange *)GTK_WIDGET(gtk_builder_get_object(cam->xml, "zoom_slider")),
+ (int)(cam->zoom / 256));
+ }
if (cam->hue < 0) {
gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object(cam->xml,
"hue_icon")));
diff --git a/src/v4l.c b/src/v4l.c
index c5aa797..10c4494 100644
--- a/src/v4l.c
+++ b/src/v4l.c
@@ -297,6 +297,14 @@ void get_pic_info(cam_t *cam)
} else {
cam->colour = -1;
}
+ i = v4l2_get_control(cam->dev, V4L2_CID_ZOOM_ABSOLUTE);
+ if (i >= 0) {
+ cam->zoom = i;
+ if (cam->debug == TRUE)
+ printf("zoom = %d\n", cam->zoom);
+ } else {
+ cam->zoom = -1;
+ }
i = v4l2_get_control(cam->dev, V4L2_CID_CONTRAST);
if (i >= 0) {
cam->contrast = i;
diff --git a/src/v4l.h b/src/v4l.h
index 69df548..323f3db 100644
--- a/src/v4l.h
+++ b/src/v4l.h
@@ -55,7 +55,7 @@ typedef struct camera {
float scale;
CamoImageSize size;
char name[32];
- int contrast, brightness, whiteness, colour, hue, bytesperline;
+ int contrast, brightness, whiteness, colour, hue, zoom, bytesperline;
unsigned int pixformat;
int frame_number;

Privacy Policy