Skip to content

Commit 40c71c6

Browse files
committed
DRY
1 parent 870c685 commit 40c71c6

File tree

1 file changed

+10
-71
lines changed

1 file changed

+10
-71
lines changed

lib/include/elements/element/status_bar.hpp

+10-71
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ namespace cycfi::elements
4444
double _value;
4545
};
4646

47-
class basic_progress_bar_base : public status_bar_base
47+
class basic_status_bar_base : public status_bar_base
4848
{
4949
public:
50-
basic_progress_bar_base(double init_value)
50+
basic_status_bar_base(double init_value)
5151
: status_bar_base(init_value)
5252
{}
5353
};
@@ -61,35 +61,25 @@ namespace cycfi::elements
6161
template <
6262
concepts::Element Background
6363
, concepts::Element Foreground
64-
, concepts::StatusBar Base = basic_progress_bar_base
65-
>
66-
class basic_progress_bar : public Base
64+
, concepts::StatusBar Base = basic_status_bar_base>
65+
class basic_status_bar : public Base
6766
{
6867
public:
6968

7069
using background_type = std::decay_t<Background>;
7170
using foreground_type = std::decay_t<Foreground>;
7271

73-
basic_progress_bar(
72+
template <typename... Args>
73+
basic_status_bar(
7474
Background&& bg
7575
, Foreground&& fg
76-
, double init_value
76+
, Args&& ...args
7777
)
78-
: Base(init_value)
78+
: Base(args...)
7979
, _background(std::forward<Foreground>(bg))
8080
, _foreground(std::forward<Background>(fg))
8181
{}
8282

83-
basic_progress_bar(
84-
Background const& bg
85-
, Foreground const& fg
86-
, double init_value
87-
)
88-
: Base(init_value)
89-
, _foreground(fg)
90-
, _background(bg)
91-
{}
92-
9383
element const& background() const override { return _background; }
9484
element& background() override { return _background; }
9585
element const& foreground() const override { return _foreground; }
@@ -102,7 +92,7 @@ namespace cycfi::elements
10292
};
10393

10494
template <concepts::Element Background, concepts::Element Foreground>
105-
basic_progress_bar<Background, Foreground, basic_progress_bar_base>
95+
basic_status_bar<Background, Foreground, basic_status_bar_base>
10696
progress_bar(Background&& bg, Foreground&& fg, double init_value = 0.0)
10797
{
10898
return {
@@ -150,59 +140,8 @@ namespace cycfi::elements
150140
{}
151141
};
152142

153-
namespace concepts
154-
{
155-
template <typename T>
156-
concept BusyBar = std::is_base_of_v<busy_bar_base, std::decay_t<T>>;
157-
}
158-
159-
template <
160-
concepts::Element Background
161-
, concepts::Element Foreground
162-
, concepts::BusyBar Base = basic_busy_bar_base
163-
>
164-
class basic_busy_bar : public Base
165-
{
166-
public:
167-
168-
using background_type = std::decay_t<Background>;
169-
using foreground_type = std::decay_t<Foreground>;
170-
171-
basic_busy_bar(
172-
Background&& bg
173-
, Foreground&& fg
174-
, double init_value
175-
, double start_value
176-
)
177-
: Base(init_value, start_value)
178-
, _background(std::forward<Foreground>(bg))
179-
, _foreground(std::forward<Background>(fg))
180-
{}
181-
182-
basic_busy_bar(
183-
Background const& bg
184-
, Foreground const& fg
185-
, double init_value
186-
, double start_value
187-
)
188-
: Base(init_value, start_value)
189-
, _foreground(fg)
190-
, _background(bg)
191-
{}
192-
193-
element const& background() const override { return _background; }
194-
element& background() override { return _background; }
195-
element const& foreground() const override { return _foreground; }
196-
element& foreground() override { return _foreground; }
197-
198-
private:
199-
200-
background_type _background;
201-
foreground_type _foreground;
202-
};
203-
204143
template <concepts::Element Background, concepts::Element Foreground>
205-
basic_busy_bar<Background, Foreground, basic_busy_bar_base>
144+
inline basic_status_bar<Background, Foreground, basic_busy_bar_base>
206145
busy_bar(
207146
Background&& bg
208147
, Foreground&& fg

0 commit comments

Comments
 (0)