/*
 * DWN - Desktop Window Manager
 * retoor <retoor@molodetz.nl>
 * Generic slider widget for panel controls
 */

#ifndef DWN_SLIDER_H
#define DWN_SLIDER_H

#include "dwn.h"
#include <stdbool.h>

#define SLIDER_WIDTH 30
#define SLIDER_HEIGHT 120
#define SLIDER_PADDING 8
#define SLIDER_KNOB_HEIGHT 8

/* Forward declaration */
typedef struct GenericSlider GenericSlider;

/* Callback type for value changes */
typedef void (*SliderValueChangedCallback)(GenericSlider *slider, int value);

/* Generic slider structure */
struct GenericSlider {
    Window window;
    int x, y;
    int width, height;
    bool visible;
    bool dragging;
    
    /* Value (always 0-100 internally) */
    int value;
    
    /* Display */
    const char *label_prefix;
    bool show_percentage;
    
    /* Callback */
    SliderValueChangedCallback on_value_changed;
    void *user_data;
};

/* Lifecycle */
GenericSlider *slider_create(int x, int y, 
                              const char *label_prefix,
                              bool show_percentage,
                              SliderValueChangedCallback callback,
                              void *user_data);
void slider_destroy(GenericSlider *slider);

/* Visibility */
void slider_show(GenericSlider *slider, int x, int y);
void slider_hide(GenericSlider *slider);
bool slider_is_visible(const GenericSlider *slider);

/* Rendering */
void slider_render(GenericSlider *slider);

/* Event handling */
void slider_handle_click(GenericSlider *slider, int x, int y);
void slider_handle_motion(GenericSlider *slider, int x, int y);
void slider_handle_release(GenericSlider *slider);

/* Value */
void slider_set_value(GenericSlider *slider, int value);
int slider_get_value(const GenericSlider *slider);

/* Hit testing */
bool slider_hit_test(const GenericSlider *slider, int x, int y);

#endif
