File: context.hpp

package info (click to toggle)
polybar 3.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,108 kB
  • sloc: cpp: 30,424; python: 3,750; sh: 284; makefile: 83
file content (90 lines) | stat: -rw-r--r-- 1,879 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#pragma once

#include "common.hpp"
#include "components/types.hpp"
#include "tags/types.hpp"
#include "utils/color.hpp"

POLYBAR_NS

namespace tags {
  /**
   * Stores all the formatting data which comes from formatting tags needed to
   * render a formatting string.
   */
  class context {
   public:
    context() = delete;
    context(const bar_settings& settings);

    /**
     * Resets to the initial state.
     *
     * The initial state depends on the colors set on the bar itself.
     */
    void reset();

    void apply_bg(color_value c);
    void apply_fg(color_value c);
    void apply_ol(color_value c);
    void apply_ul(color_value c);
    void apply_font(int font);
    void apply_reverse();
    void apply_alignment(alignment align);
    void apply_attr(attr_activation act, attribute attr);
    void apply_reset();
    void store_tray_position(int x_pos);

    rgba get_bg() const;
    rgba get_fg() const;
    rgba get_ol() const;
    rgba get_ul() const;
    int get_font() const;
    bool has_overline() const;
    bool has_underline() const;
    alignment get_alignment() const;

    std::pair<alignment, int> get_relative_tray_position() const;

   protected:
    /**
     * Background color
     */
    rgba m_bg{};
    /**
     * Foreground color
     */
    rgba m_fg{};
    /**
     * Overline color
     */
    rgba m_ol{};
    /**
     * Underline color
     */
    rgba m_ul{};
    /**
     * Font index (1-based)
     */
    int m_font{0};
    /**
     * Is overline enabled?
     */
    bool m_attr_overline{false};
    /**
     * Is underline enabled?
     */
    bool m_attr_underline{false};
    /**
     * Alignment block
     */
    alignment m_align{alignment::NONE};

    std::pair<alignment, int> m_relative_tray_position{alignment::NONE, 0};

  private:
      const bar_settings &m_settings;
  };
} // namespace tags

POLYBAR_NS_END