1// Aseprite
2// Copyright (C) 2017 David Capello
3//
4// This program is distributed under the terms of
5// the End-User License Agreement for Aseprite.
6
7#ifndef APP_UI_SLIDER2_H_INCLUDED
8#define APP_UI_SLIDER2_H_INCLUDED
9#pragma once
10
11#include "ui/box.h"
12#include "ui/entry.h"
13#include "ui/slider.h"
14
15namespace app {
16
17 // TODO merge this with IntEntry?
18 // It looks like there are 3 different modes to input values:
19 //
20 // 1. An entry field (Entry)
21 // 2. An entry field with a popup slider (IntEntry)
22 // 3. A slider + entry field (Slider2, ColorSliders+ColorEntry)
23 //
24 // We might merge all these modes in just on responsive widget, but
25 // I'm not sure.
26 class Slider2 : public ui::HBox {
27 public:
28 Slider2(int min, int max, int value);
29
30 int getValue() const { return m_slider.getValue(); }
31
32 // Signals
33 obs::signal<void()> Change;
34
35 private:
36 virtual void onChange();
37 void onSliderChange();
38 void onEntryChange();
39
40 class Slider2Entry : public ui::Entry {
41 public:
42 Slider2Entry(ui::Slider* slider);
43 private:
44 int minValue() const { return m_slider->getMinValue(); }
45 int maxValue() const { return m_slider->getMaxValue(); }
46 bool onProcessMessage(ui::Message* msg) override;
47 ui::Slider* m_slider;
48 // TODO remove this calling setFocus() in
49 // Widget::onProcessMessage() instead of
50 // Manager::handleWindowZOrder()
51 bool m_recentFocus;
52 };
53 ui::Slider m_slider;
54 Slider2Entry m_entry;
55 };
56
57} // namespace app
58
59#endif
60