demo_view_slider.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "demo_view.h"
  2. #include <rtgui/rtgui_system.h>
  3. #include <rtgui/widgets/label.h>
  4. #include <rtgui/widgets/slider.h>
  5. rtgui_view_t *demo_view_slider(rtgui_workbench_t* workbench)
  6. {
  7. rtgui_view_t *view;
  8. rtgui_rect_t rect;
  9. rtgui_label_t *label;
  10. rtgui_slider_t *slider;
  11. /* create a demo view */
  12. view = demo_view(workbench, "Slider View");
  13. /* get demo view rect */
  14. demo_view_get_rect(view, &rect);
  15. label = rtgui_label_create("horizontal slider:");
  16. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
  17. rect.x1 += 5; rect.x2 -= 5;
  18. rect.y1 += 5; rect.y2 = rect.y1 + 18;
  19. rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
  20. rect.y1 += 20; rect.y2 = rect.y1 + 18;
  21. slider = rtgui_slider_create(0, 100, RTGUI_HORIZONTAL);
  22. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(slider));
  23. rtgui_widget_set_rect(RTGUI_WIDGET(slider), &rect);
  24. /* get demo view rect */
  25. demo_view_get_rect(view, &rect);
  26. label = rtgui_label_create("vertical slider:");
  27. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
  28. rect.x1 += 5; rect.x2 -= 5;
  29. rect.y1 += 50; rect.y2 = rect.y1 + 18;
  30. rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
  31. rect.x1 += 110; rect.x2 = rect.x1 + 20;
  32. rect.y1 += 18 + 5; rect.y2 = rect.y1 + 150;
  33. slider = rtgui_slider_create(0, 100, RTGUI_VERTICAL);
  34. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(slider));
  35. rtgui_widget_set_rect(RTGUI_WIDGET(slider), &rect);
  36. return view;
  37. }