infobar.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
  3. * For license, see COPYING.
  4. */
  5. #ifndef INFOBAR_H
  6. #define INFOBAR_H
  7. #include "wmfs.h"
  8. #include "util.h"
  9. #include "draw.h"
  10. #include "tag.h"
  11. enum { ElemTag = 0, ElemLayout, ElemSelbar, ElemStatus, ElemCustom, ElemLast };
  12. struct infobar *infobar_new(struct screen *s, struct theme *theme, Barpos pos, const char *elem);
  13. void infobar_elem_update(struct infobar *i);
  14. void infobar_refresh(struct infobar *i);
  15. void infobar_remove(struct infobar *i);
  16. void infobar_free(struct screen *s);
  17. /* Basic placement of elements */
  18. static inline void
  19. infobar_elem_placement(struct element *e)
  20. {
  21. struct element *p = TAILQ_PREV(e, esub, next);
  22. e->geo.y = e->geo.w = 0;
  23. e->geo.h = e->infobar->geo.h;
  24. e->geo.x = (p ? p->geo.x + p->geo.w + PAD : 0);
  25. }
  26. /* Bars placement management and usable space management */
  27. static inline bool
  28. infobar_placement(struct infobar *i, Barpos p)
  29. {
  30. i->pos = p;
  31. i->geo = i->screen->ugeo;
  32. i->geo.h = i->theme->bars_width;
  33. switch(p)
  34. {
  35. case BarTop:
  36. i->screen->ugeo.y += i->geo.h;
  37. i->screen->ugeo.h -= i->geo.h;
  38. break;
  39. case BarBottom:
  40. i->geo.y = (i->screen->ugeo.y + i->screen->ugeo.h) - i->geo.h;
  41. i->screen->ugeo.h -= i->geo.h;
  42. break;
  43. default:
  44. case BarHide:
  45. return false;
  46. }
  47. tag_update_frame_geo(i->screen);
  48. return true;
  49. }
  50. static inline void
  51. infobar_elem_screen_update(struct screen *s, int addf)
  52. {
  53. struct infobar *i;
  54. s->elemupdate |= FLAGINT(addf);
  55. SLIST_FOREACH(i, &s->infobars, next)
  56. infobar_elem_update(i);
  57. s->elemupdate &= ~FLAGINT(ElemTag);
  58. }
  59. #endif /* INFOBAR_H */