Skip to content

Commit 97cd341

Browse files
committed
[Add] - Image / Buttons Spacing
Images are now being displayed in the middle according to the main box it sits at and all of its contents comes from that. The buttons are using a margin to sit in the bottom.
1 parent a43ff4b commit 97cd341

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

src/gtk_gui.c

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -147,40 +147,60 @@ static void activate(GtkApplication *app, gpointer user_data)
147147
// create new vertical box container
148148
box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
149149
gtk_widget_set_halign(box, GTK_ALIGN_CENTER);
150-
gtk_widget_set_valign(box, GTK_ALIGN_END);
150+
gtk_widget_set_valign(box, GTK_ALIGN_CENTER);
151151
// include box container in window
152152
gtk_window_set_child(GTK_WINDOW(window), box);
153153

154-
// create new horizontal box container for both user and filtered images
154+
// Create a horizontal box container for the images
155155
GtkWidget *image_container = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
156156
gtk_widget_set_halign(image_container, GTK_ALIGN_CENTER);
157-
gtk_widget_set_valign(image_container, GTK_ALIGN_CENTER);
158-
gtk_widget_set_margin_bottom(image_container, 20);
159-
// append image container to vertical box
157+
gtk_widget_set_valign(image_container, GTK_ALIGN_CENTER); // Center vertically
158+
// Append the image container to the main vertical box
160159
gtk_box_append(GTK_BOX(box), image_container);
161160

162-
// create image widget for user image
161+
// Create a vertical box container for the user image
162+
user_image_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
163+
gtk_widget_set_halign(user_image_box, GTK_ALIGN_CENTER);
164+
gtk_widget_set_valign(user_image_box, GTK_ALIGN_CENTER); // Center vertically
165+
// Append the user image container to the horizontal image container
166+
gtk_box_append(GTK_BOX(image_container), user_image_box);
167+
168+
// Create image widget for user image
163169
image = gtk_image_new_from_file("assets/images/test_image.bmp");
164170
gtk_image_set_pixel_size(GTK_IMAGE(image), 250);
165-
// Set horizontal alignment to center
171+
// Set horizontal alignment to center for the image
166172
gtk_widget_set_halign(image, GTK_ALIGN_CENTER);
167-
// append user image widget to image container
168-
gtk_box_append(GTK_BOX(image_container), image);
173+
// Append the user image widget to the user image container
174+
gtk_box_append(GTK_BOX(user_image_box), image);
175+
176+
// Set a top margin for the user image to raise it within the layout
177+
gtk_widget_set_margin_top(image, 50); // Adjust the margin as needed
169178

170-
// create image widget for filtered image
179+
// Create a vertical box container for the filtered image
180+
filtered_image_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
181+
gtk_widget_set_halign(filtered_image_box, GTK_ALIGN_CENTER);
182+
gtk_widget_set_valign(filtered_image_box, GTK_ALIGN_CENTER); // Center vertically
183+
// Append the filtered image container to the horizontal image container
184+
gtk_box_append(GTK_BOX(image_container), filtered_image_box);
185+
186+
// Create image widget for filtered image
171187
image = gtk_image_new_from_file("assets/images/test_image.bmp");
172188
gtk_image_set_pixel_size(GTK_IMAGE(image), 250);
173-
// Set horizontal alignment to center
189+
// Set horizontal alignment to center for the image
174190
gtk_widget_set_halign(image, GTK_ALIGN_CENTER);
175-
// append filtered image widget to image container
176-
gtk_box_append(GTK_BOX(image_container), image);
191+
// Append the filtered image widget to the filtered image container
192+
gtk_box_append(GTK_BOX(filtered_image_box), image);
193+
194+
// Set a top margin for the filtered image to raise it within the layout
195+
gtk_widget_set_margin_top(image, 50);
177196

178197
// create new horizontal box container for buttons
179198
button_box0 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
180199
gtk_widget_set_halign(button_box0, GTK_ALIGN_CENTER);
181200
gtk_widget_set_valign(button_box0, GTK_ALIGN_CENTER);
182201
// append button box to vertical box
183202
gtk_box_append(GTK_BOX(box), button_box0);
203+
gtk_widget_set_margin_top(button_box0, 100); // temp
184204

185205
// create new horizontal box container for buttons
186206
button_box1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);

0 commit comments

Comments
 (0)