]> git.lizzy.rs Git - nothing.git/commitdiff
(#931) Implement labels for sliders
authorrexim <reximkut@gmail.com>
Sat, 6 Jul 2019 18:31:18 +0000 (01:31 +0700)
committerrexim <reximkut@gmail.com>
Sat, 6 Jul 2019 18:31:18 +0000 (01:31 +0700)
src/game/level/level_editor/color_picker.c

index 488e40669b0ecb60864fa4463da7306b09f53c3f..a02f6d93a7bb036f4b0e8d34aad54ed37ed6635a 100644 (file)
 #define COLOR_SLIDER_HEIGHT 50.0f
 #define COLOR_SLIDER_WIDTH 300.0f
 
+const char *slider_labels[COLOR_SLIDER_N] = {
+    "Hue",
+    "Saturation",
+    "Lightness"
+};
+
 LayerPtr color_picker_as_layer(ColorPicker *color_picker)
 {
     LayerPtr layer = {
@@ -61,11 +67,24 @@ int color_picker_render(const ColorPicker *color_picker,
 
     /* TODO(#931): Color Picker sliders don't have any labels */
     for (ColorPickerSlider index = 0; index < COLOR_SLIDER_N; ++index) {
+        const Rect slider_rect =
+            rect(0.0f, COLOR_SLIDER_HEIGHT * (float) (index + 1),
+                 COLOR_SLIDER_WIDTH, COLOR_SLIDER_HEIGHT);
+
         if (slider_render(
                 &color_picker->sliders[index],
                 camera,
-                rect(0.0f, COLOR_SLIDER_HEIGHT * (float) (index + 1),
-                     COLOR_SLIDER_WIDTH, COLOR_SLIDER_HEIGHT)) < 0) {
+                slider_rect) < 0) {
+            return -1;
+        }
+
+        if (camera_render_text_screen(
+                camera,
+                slider_labels[index],
+                vec(2.5f, 2.5f),
+                COLOR_BLACK,
+                vec(slider_rect.x + COLOR_SLIDER_WIDTH,
+                    slider_rect.y + COLOR_SLIDER_HEIGHT * 0.5f - 2.5f * (float) FONT_CHAR_HEIGHT * 0.5f)) < 0) {
             return -1;
         }
     }