[DEV] better interaction and display

This commit is contained in:
Edouard DUPIN 2017-04-18 21:44:32 +02:00
parent b6af117397
commit 2f45546540
20 changed files with 396 additions and 48 deletions

View File

@ -55,6 +55,11 @@ namespace appl {
while (m_threadRunning == true) {
// READ section data:
enet::Tcp data = std::move(m_interface.waitNext());
if (data.getConnectionStatus() != enet::Tcp::status::link) {
APPL_CRITICAL("New TCP connection (DEAD ....) ==> gateway is dead ...");
// TODO: Check interaface: if (m_interface.
std::this_thread::sleep_for(std::chrono::milliseconds(300));
}
APPL_VERBOSE("New connection");
m_gateway->newDirectInterface(std::move(data));
}

View File

@ -97,6 +97,8 @@ void appl::ClientProperty::connect() {
void appl::ClientProperty::setLogin(std::string _login) {
fromUser = "";
toUser = "";
address = "";
port = 0;
// separate loggin and IP adress ...
std::string login;
std::vector<std::string> listElem = etk::split(_login, '~');

View File

@ -19,6 +19,7 @@
#include <appl/widget/Player.hpp>
#include <appl/widget/ProgressBar.hpp>
#include <appl/widget/VolumeBar.hpp>
#include <appl/widget/UpBar.hpp>
#include <zeus/zeus.hpp>
namespace appl {
@ -76,6 +77,7 @@ namespace appl {
appl::widget::Player::createManagerWidget(_context.getWidgetManager());
appl::widget::ProgressBar::createManagerWidget(_context.getWidgetManager());
appl::widget::VolumeBar::createManagerWidget(_context.getWidgetManager());
appl::widget::UpBar::createManagerWidget(_context.getWidgetManager());
// Create the windows
ememory::SharedPtr<appl::Windows> basicWindows = appl::Windows::create();
// configure the ewol context to use the new windows

View File

@ -81,7 +81,9 @@ void appl::Windows::init() {
drawWidgetTree();
m_listViewer = ememory::dynamicPointerCast<appl::widget::ListViewer>(m_composer->getSubObjectNamed("ws-name-list-viewer"));
if (m_listViewer != nullptr) {
m_listViewer->signalSelect.connect(sharedFromThis(), &appl::Windows::onCallbackSelectMedia);
}
subBind(ewol::widget::Button, "bt-film-picture", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSelectFilms);
@ -115,6 +117,12 @@ void appl::Windows::init() {
}
}
}
m_player = ememory::dynamicPointerCast<appl::widget::Player>(m_composer->getSubObjectNamed("ws-name-player"));
if (m_player != nullptr) {
m_player->signalPrevious.connect(sharedFromThis(), &appl::Windows::onCallbackPlayerPrevious);
m_player->signalNext.connect(sharedFromThis(), &appl::Windows::onCallbackPlayerNext);
m_player->signalFinished.connect(sharedFromThis(), &appl::Windows::onCallbackPlayerFinished);
}
}
@ -125,6 +133,9 @@ void appl::Windows::onCallbackShortCut(const std::string& _value) {
void appl::Windows::onCallbackMenuEvent(const std::string& _value) {
APPL_WARNING("Event from Menu : " << _value);
if (m_player != nullptr) {
m_player->stop();
}
if (_value == "menu:connect") {
appl::widget::ConnectionShared tmpWidget = appl::widget::Connection::create();
if (tmpWidget == nullptr) {
@ -169,8 +180,6 @@ void appl::Windows::onCallbackMenuEvent(const std::string& _value) {
} else if (_value == "menu:courses") {
ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer");
m_listViewer->searchElements("courses");
} else if (_value == "menu:TV-child") {
ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer");
m_listViewer->searchElements("");
@ -300,9 +309,37 @@ void appl::Windows::onCallbackSelectSourses() {
void appl::Windows::onCallbackSelectMedia(const uint32_t& _value) {
ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-player");
ememory::SharedPtr<appl::widget::Player> tmpPlayer = ememory::dynamicPointerCast<appl::widget::Player>(getSubObjectNamed("ws-name-player"));
if (tmpPlayer != nullptr) {
tmpPlayer->playStream(m_clientProp, _value);
if (m_player != nullptr) {
m_player->playStream(m_clientProp, _value);
}
}
void appl::Windows::onCallbackPlayerPrevious() {
if (m_player != nullptr) {
m_player->stop();
}
if (m_listViewer != nullptr) {
if (m_listViewer->previous() == false) {
ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer");
}
}
}
void appl::Windows::onCallbackPlayerNext() {
if (m_player != nullptr) {
m_player->stop();
}
if (m_listViewer != nullptr) {
if (m_listViewer->next() == false) {
ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer");
}
}
}
void appl::Windows::onCallbackPlayerFinished() {
if (m_player != nullptr) {
m_player->stop();
}
ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer");
}

View File

@ -8,6 +8,8 @@
#include <ewol/widget/Windows.hpp>
#include <ewol/widget/Composer.hpp>
#include <appl/widget/ListViewer.hpp>
#include <appl/widget/Player.hpp>
namespace appl {
class Windows;
@ -20,6 +22,7 @@ namespace appl {
ewol::widget::ComposerShared m_composer;
ememory::SharedPtr<ClientProperty> m_clientProp;
appl::widget::ListViewerShared m_listViewer;
appl::widget::PlayerShared m_player;
std::vector<std::string> m_list;
int32_t m_id;
public:
@ -55,6 +58,8 @@ namespace appl {
void onCallbackSelectHome() {
onCallbackMenuEvent("menu:home");
}
void onCallbackPlayerPrevious();
void onCallbackPlayerNext();
void onCallbackPlayerFinished();
};
}

View File

@ -494,7 +494,7 @@ void appl::ElementDisplayed::generateDisplay(vec2 _startPos, vec2 _size) {
} else if (etk::start_with(m_property->m_mineType, "audio") == true) {
m_image.setSource("DATA:MusicNote.svg", 128);
} else {
APPL_INFO("Set image: Unknow type '" << m_property->m_mineType << "'");
APPL_DEBUG("Set image: Unknow type '" << m_property->m_mineType << "'");
m_image.setSource("DATA:Home.svg", 128);
}
} else {
@ -549,6 +549,7 @@ bool appl::widget::ListViewer::onEventInput(const ewol::event::Input& _event) {
}
fullTitle += prop->m_title;
APPL_DEBUG("info element : " << prop->m_id << " title: " << fullTitle);
m_currentPayed = prop->m_id;
signalSelect.emit(prop->m_id);
} else if (m_listDisplay[findId]->m_propertyGroup != nullptr) {
ememory::SharedPtr<appl::ElementPropertyGroup> prop = m_listDisplay[findId]->m_propertyGroup;
@ -568,3 +569,49 @@ bool appl::widget::ListViewer::onEventInput(const ewol::event::Input& _event) {
}
return false;
}
bool appl::widget::ListViewer::previous() {
for (int64_t iii=0; iii<int64_t(m_listElement.size()); ++iii) {
if (m_listElement[iii] == nullptr) {
continue;
}
if (m_listElement[iii]->m_id == m_currentPayed) {
// Start search ...
--iii;
while(iii>=0) {
if (m_listElement[iii] == nullptr) {
--iii;
continue;
}
m_currentPayed = m_listElement[iii]->m_id;
signalSelect.emit(m_currentPayed);
return true;
}
return false;
}
}
return false;
}
bool appl::widget::ListViewer::next() {
for (size_t iii=0; iii<m_listElement.size(); ++iii) {
if (m_listElement[iii] == nullptr) {
continue;
}
if (m_listElement[iii]->m_id == m_currentPayed) {
// Start search ...
++iii;
while(iii<m_listElement.size()) {
if (m_listElement[iii] == nullptr) {
++iii;
continue;
}
m_currentPayed = m_listElement[iii]->m_id;
signalSelect.emit(m_currentPayed);
return true;
}
return false;
}
}
return false;
}

View File

@ -86,6 +86,7 @@ namespace appl {
std::string m_currentFilter;
std::string m_currentGroup;
std::vector<ememory::SharedPtr<ElementDisplayed>> m_listDisplay; //!< list of element in the current local display
uint64_t m_currentPayed;
protected:
//! @brief constructor
ListViewer();
@ -104,6 +105,19 @@ namespace appl {
void searchElements(std::string _filter="");
void searchElementsInternal(const std::string& _filter, const std::string& _group="");
bool onEventInput(const ewol::event::Input& _event) override;
public:
/**
* @brief Generate the event with the previous file property
* @return true We find an element
* @return false We find nothing
*/
bool previous();
/**
* @brief Generate the event with the next file property
* @return true We find an element
* @return false We find nothing
*/
bool next();
};
}
}

View File

@ -6,6 +6,7 @@
#include <appl/widget/Player.hpp>
#include <appl/widget/UpBar.hpp>
#include <ewol/widget/Sizer.hpp>
#include <ewol/widget/List.hpp>
#include <ewol/widget/Button.hpp>
@ -42,10 +43,12 @@ void appl::widget::Player::init() {
subBind(appl::widget::VideoDisplay, "[" + etk::to_string(getId()) + "]appl-player-display", signalPosition, sharedFromThis(), &appl::widget::Player::onCallbackPosition);
subBind(appl::widget::VideoDisplay, "[" + etk::to_string(getId()) + "]appl-player-display", signalDuration, sharedFromThis(), &appl::widget::Player::onCallbackDuration);
subBind(appl::widget::VideoDisplay, "[" + etk::to_string(getId()) + "]appl-player-display", signalFinish, sharedFromThis(), &appl::widget::Player::onCallbackFinished);
subBind(appl::widget::VideoDisplay, "[" + etk::to_string(getId()) + "]appl-player-display", signalFps, sharedFromThis(), &appl::widget::Player::onCallbackFPS);
subBind(appl::widget::ProgressBar, "[" + etk::to_string(getId()) + "]appl-player-progress-bar", signalChange, sharedFromThis(), &appl::widget::Player::onCallbackSeekRequest);
subBind(appl::widget::VolumeBar, "[" + etk::to_string(getId()) + "]appl-player-volume", signalChange, sharedFromThis(), &appl::widget::Player::onCallbackVolumeRequest);
subBind(appl::widget::UpBar, "[" + etk::to_string(getId()) + "]appl-player-volume", signalChange, sharedFromThis(), &appl::widget::Player::onCallbackVolumeRequest);
subBind(appl::widget::UpBar, "[" + etk::to_string(getId()) + "]appl-player-light", signalChange, sharedFromThis(), &appl::widget::Player::onCallbackLightRequest);
m_display = ememory::dynamicPointerCast<appl::widget::VideoDisplay>(getSubObjectNamed("[" + etk::to_string(getId()) + "]appl-player-display"));
m_progress = ememory::dynamicPointerCast<appl::widget::ProgressBar>(getSubObjectNamed("[" + etk::to_string(getId()) + "]appl-player-progress-bar"));
@ -107,6 +110,19 @@ static std::string timeToStaticString(const echrono::Duration& _time) {
return out;
}
void appl::widget::Player::onCallbackFinished() {
if (m_progress != nullptr) {
std::vector<std::pair<float,float>> tmp;
m_progress->setRangeAvaillable(tmp);
m_progress->propertyValue.set(0);
m_progress->propertyMaximum.set(0);
}
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-time", "value", "<font color='black'>--:--</font>");
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-duration", "value", "<font color='black'>--:--</font>");
signalFinished.emit();
}
void appl::widget::Player::onCallbackDuration(const echrono::Duration& _time) {
//APPL_ERROR("duration = " << _time);
if (m_progress != nullptr) {
@ -146,17 +162,34 @@ void appl::widget::Player::onCallbackVolumeRequest(const float& _value) {
if (m_display != nullptr) {
m_display->changeVolume(_value);
}
std::string display = etk::to_string(int32_t(_value)) + "." + etk::to_string(std::abs(int32_t(_value*10.0f)-int32_t(_value)*10));
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-volume", "value", display + " dB");
}
void appl::widget::Player::onCallbackLightRequest(const float& _value) {
APPL_DEBUG("===========================================================================");
APPL_DEBUG("volume change value=" << _value << " %");
APPL_DEBUG("===========================================================================");
if (m_display != nullptr) {
m_display->changeLight(_value);
}
}
void appl::widget::Player::onCallbackFPS(const int32_t& _fps) {
APPL_DEBUG("FPS = " << _fps);
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-fps", "value", "FPS=<font color='orangered'>" + etk::to_string(_fps) + "</font>");
}
void appl::widget::Player::stop() {
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-bt-play", "value", "false");
if (m_display == nullptr) {
return;
}
m_display->stop();
}
void appl::widget::Player::suspend() {
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-bt-play", "value", "false");
if (m_display == nullptr) {

View File

@ -37,6 +37,7 @@ namespace appl {
ememory::SharedPtr<appl::widget::ProgressBar> m_progress; //!< Display widget
public:
void playStream(ememory::SharedPtr<appl::ClientProperty> _property, uint32_t _mediaId);
void stop();
void suspend();
public:
void onGetFocus() override;
@ -49,7 +50,9 @@ namespace appl {
void onCallbackDuration(const echrono::Duration& _value);
void onCallbackSeekRequest(const float& _value);
void onCallbackVolumeRequest(const float& _value);
void onCallbackLightRequest(const float& _value);
void onCallbackFPS(const int32_t& _fps);
void onCallbackFinished();
};
};
};

View File

@ -0,0 +1,106 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <appl/widget/UpBar.hpp>
#include <ewol/widget/Sizer.hpp>
#include <ewol/widget/List.hpp>
#include <ewol/widget/Button.hpp>
#include <ewol/widget/CheckBox.hpp>
#include <ewol/widget/ListFileSystem.hpp>
#include <ewol/widget/Entry.hpp>
#include <ewol/widget/Spacer.hpp>
#include <ewol/widget/Slider.hpp>
#include <ewol/widget/Image.hpp>
#include <ewol/widget/Composer.hpp>
#include <ewol/widget/Manager.hpp>
#include <vector>
#include <etk/tool.hpp>
#include <appl/debug.hpp>
#include <ewol/ewol.hpp>
#include <etk/stdTools.hpp>
#include <ewol/tools/message.hpp>
appl::widget::UpBar::UpBar() :
propertyType(this, "bar-type",
"sound",
"type of the element",
&appl::widget::UpBar::onChangePropertyType),
propertyValue(this, "value",
0,
"value of the bar",
&appl::widget::UpBar::onChangePropertyValue),
signalChange(this, "value", "Value of the upbar") {
addObjectType("appl::widget::UpBar");
}
void appl::widget::UpBar::init() {
ewol::widget::Composer::init();
if (*propertySubFile == "") {
if (*propertyType == "volume") {
propertySubFile.set("DATA:gui-volume.xml");
} else if (*propertyType == "light") {
propertySubFile.set("DATA:gui-light.xml");
} else {
APPL_ERROR("can not set the mode of upBar");
}
}
if (*propertyType == "volume") {
subBind(appl::widget::VolumeBar, "[" + etk::to_string(getId()) + "]appl-upbar-range", signalChange, sharedFromThis(), &appl::widget::UpBar::onCallbackVolumeRequest);
} else {
subBind(appl::widget::VolumeBar, "[" + etk::to_string(getId()) + "]appl-upbar-range", signalChange, sharedFromThis(), &appl::widget::UpBar::onCallbackLightRequest);
}
subBind(appl::widget::VolumeBar, "[" + etk::to_string(getId()) + "]appl-upbar-range", signalHide, sharedFromThis(), &appl::widget::UpBar::onCallbackHide);
markToRedraw();
}
appl::widget::UpBar::~UpBar() {
}
void appl::widget::UpBar::onCallbackVolumeRequest(const float& _value) {
APPL_DEBUG("===========================================================================");
APPL_DEBUG("volume change value=" << _value << " dB");
APPL_DEBUG("===========================================================================");
signalChange.emit(_value);
std::string display = etk::to_string(int32_t(_value)) + "." + etk::to_string(std::abs(int32_t(_value*10.0f)-int32_t(_value)*10));
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-label", "value", display + " dB");
}
void appl::widget::UpBar::onCallbackLightRequest(const float& _value) {
APPL_DEBUG("===========================================================================");
APPL_DEBUG("Light change value=" << _value << " %");
APPL_DEBUG("===========================================================================");
signalChange.emit(float(int32_t(_value))*0.01f);
std::string display = etk::to_string(int32_t(_value));
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-label", "value", display + " %");
}
void appl::widget::UpBar::onCallbackHide(const float& _value) {
if (_value == 0.0f) {
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-label", "hide", etk::to_string(true));
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-image", "hide", etk::to_string(true));
} else {
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-label", "hide", etk::to_string(false));
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-image", "hide", etk::to_string(false));
}
}
void appl::widget::UpBar::onChangePropertyType() {
}
void appl::widget::UpBar::onChangePropertyValue() {
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-range", "value", etk::to_string(*propertyValue));
if (*propertyType == "volume") {
onCallbackVolumeRequest(*propertyValue);
} else {
onCallbackLightRequest(*propertyValue);
}
return;
}

View File

@ -0,0 +1,42 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
#include <ewol/debug.hpp>
#include <ewol/widget/Composer.hpp>
#include <esignal/Signal.hpp>
#include <appl/widget/ProgressBar.hpp>
#include <appl/widget/VolumeBar.hpp>
#include <appl/ClientProperty.hpp>
namespace appl {
namespace widget {
class UpBar;
using UpBarShared = ememory::SharedPtr<appl::widget::UpBar>;
using UpBarWeak = ememory::WeakPtr<appl::widget::UpBar>;
class UpBar : public ewol::widget::Composer {
public: // properties
eproperty::Value<std::string> propertyType; //!< Type of the bar
eproperty::Value<float> propertyValue; //!< value of the bar ...
public: // signals
esignal::Signal<float> signalChange; //!< Value of the bar
protected:
UpBar();
void init() override;
public:
DECLARE_WIDGET_FACTORY(UpBar, "appl_UpBar");
virtual ~UpBar();
private:
// callback functions:
void onCallbackLightRequest(const float& _value);
void onCallbackVolumeRequest(const float& _value);
void onCallbackHide(const float& _value);
void onChangePropertyType();
void onChangePropertyValue();
};
};
};

View File

@ -20,7 +20,8 @@ const int32_t appl::widget::VideoDisplay::m_vboIdCoordTex(1);
const int32_t appl::widget::VideoDisplay::m_vboIdColor(2);
#define NB_VBO (3)
appl::widget::VideoDisplay::VideoDisplay() {
appl::widget::VideoDisplay::VideoDisplay() :
m_light(1.0f) {
addObjectType("appl::widget::VideoDisplay");
m_color = etk::color::white;
m_nbFramePushed = 0;
@ -126,22 +127,6 @@ void appl::widget::VideoDisplay::play() {
APPL_DEBUG("Already started");
return;
}
/*
APPL_ERROR("==========================================================");
APPL_ERROR("== Presence of Audio: " << m_decoder->haveAudio() << " ==");
APPL_ERROR("==========================================================");
if (m_decoder->haveAudio() == true) {
m_audioInterface = m_audioManager->createOutput(m_decoder->audioGetSampleRate(),
m_decoder->audioGetChannelMap(),
m_decoder->audioGetFormat(),
"speaker");
if(m_audioInterface == nullptr) {
APPL_ERROR("Can not create Audio interface");
}
m_audioInterface->setReadwrite();
m_audioInterface->start();
}
*/
// Start decoder, this is maybe not the good point, but if we configure a decoder, it is to use it ...
m_decoder->start();
//TODO: Set an option to river to auto-generate dot: m_audioManager->generateDotAll("out/local_player_flow.dot");
@ -152,6 +137,13 @@ void appl::widget::VideoDisplay::changeVolume(const float& _value) {
m_audioManager->setVolume("MASTER", _value);
}
}
void appl::widget::VideoDisplay::changeLight(const float& _value) {
m_light = _value;
m_color.setR(m_light);
m_color.setG(m_light);
m_color.setB(m_light);
m_color.setA(1.0);
}
void appl::widget::VideoDisplay::pause() {
m_isPalying = false;
@ -313,7 +305,7 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event)
int32_t idSlot = m_decoder->audioGetOlderSlot();
if ( idSlot != -1
&& m_currentTime > m_decoder->m_audioPool[idSlot].m_time) {
APPL_WARNING("Get Slot AUDIO " << m_currentTime << " > " << m_decoder->m_audioPool[idSlot].m_time);
APPL_VERBOSE("Get Slot AUDIO " << m_currentTime << " > " << m_decoder->m_audioPool[idSlot].m_time);
if (m_audioInterface == nullptr) {
// start audio interface the first time we need it
APPL_ERROR("==========================================================");
@ -345,7 +337,7 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event)
// check the slot is valid and check display time of the element:
if ( idSlot != -1
&& m_currentTime > m_decoder->m_videoPool[idSlot].m_time) {
APPL_WARNING("Get Slot VIDEO " << m_currentTime << " > " << m_decoder->m_audioPool[idSlot].m_time);
APPL_VERBOSE("Get Slot VIDEO " << m_currentTime << " > " << m_decoder->m_audioPool[idSlot].m_time);
m_resource->get().swap(m_decoder->m_videoPool[idSlot].m_image);
m_imageSize = m_resource->get().getSize();
ivec2 tmpSize = m_decoder->m_videoPool[idSlot].m_imagerealSize;
@ -375,9 +367,10 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event)
}
// TODO : Chek if this is needed, the display configuration not change too much ...
markToRedraw();
// TODO: understand why this take 4 seconds to detect end ... maybe check end with the end read of the file ...
if ( m_haveDuration == true
&& m_decoder->getDuration() > echrono::milliseconds(10)) {
if (m_currentTime >= m_decoder->getDuration() + echrono::milliseconds(200)) {
if (m_currentTime >= m_decoder->getDuration() /*- echrono::milliseconds(1000)*/) {
APPL_WARNING("Finish playing");
signalFinish.emit();
stop();

View File

@ -97,6 +97,10 @@ namespace appl {
return m_decoder->getDownloadPart();
}
void changeVolume(const float& _value);
private:
float m_light;
public:
void changeLight(const float& _value);
};
}
}

View File

@ -7,9 +7,11 @@
#include <appl/widget/VolumeBar.hpp>
#include <ewol/widget/Manager.hpp>
#include <ewol/object/Manager.hpp>
appl::widget::VolumeBar::VolumeBar() :
signalChange(this, "change", ""),
signalHide(this, "hide", ""),
propertyValue(this, "value",
0.0f,
"Value of the VolumeBar",
@ -24,7 +26,12 @@ appl::widget::VolumeBar::VolumeBar() :
propertyMaximum(this, "max",
5.0f,
"Maximum value",
&appl::widget::VolumeBar::onChangePropertyMaximum) {
&appl::widget::VolumeBar::onChangePropertyMaximum),
propertyDanger(this, "danger",
4.0f,
"Danger value"),
m_isHidden(false),
m_lastEventTime(echrono::Time::now()) {
addObjectType("appl::widget::VolumeBar");
m_textColorFg = etk::color::orange;
@ -35,10 +42,25 @@ appl::widget::VolumeBar::VolumeBar() :
m_textColorBg.setA(0x3F);
propertyCanFocus.setDirectCheck(true);
m_PCH = getObjectManager().periodicCall.connect(this, &appl::widget::VolumeBar::periodicCall);
// Limit event at 1:
setMouseLimit(1);
}
void appl::widget::VolumeBar::periodicCall(const ewol::event::Time& _event) {
if (echrono::Time::now() - m_lastEventTime > echrono::seconds(3)) {
m_isHidden = true;
signalHide.emit(0.0f);
}
if (m_isHidden == true) {
m_PCH.disconnect();
}
markToRedraw();
}
appl::widget::VolumeBar::~VolumeBar() {
}
@ -51,6 +73,9 @@ void appl::widget::VolumeBar::calculateMinMaxSize() {
}
void appl::widget::VolumeBar::onDraw() {
if (m_isHidden == true) {
return;
}
m_draw.draw();
}
@ -75,7 +100,7 @@ void appl::widget::VolumeBar::onRegenerateDisplay() {
m_draw.lineRel(vec2(0.0f, -m_size.y()));
#endif
// chaneg color whe soud became louder ...
if (*propertyValue > 0.5f) {
if (*propertyValue > *propertyDanger) {
m_draw.setColor(m_textColorLoaded);
} else {
m_draw.setColor(m_textColorDone);
@ -88,6 +113,12 @@ void appl::widget::VolumeBar::onRegenerateDisplay() {
}
bool appl::widget::VolumeBar::onEventInput(const ewol::event::Input& _event) {
m_lastEventTime = echrono::Time::now();
if (m_isHidden == true) {
m_isHidden = false;
signalHide.emit(1.0f);
m_PCH = getObjectManager().periodicCall.connect(this, &appl::widget::VolumeBar::periodicCall);
}
vec2 relativePos = relativePosition(_event.getPos());
//EWOL_DEBUG("Event on VolumeBar ..." << _event);
if (_event.getId() == 1) {

View File

@ -10,6 +10,8 @@
#include <appl/debug.hpp>
#include <ewol/widget/Widget.hpp>
#include <ewol/compositing/Drawing.hpp>
#include <echrono/Time.hpp>
#include <echrono/Duration.hpp>
#include <esignal/Signal.hpp>
namespace appl {
@ -23,12 +25,23 @@ namespace appl {
class VolumeBar : public ewol::Widget {
public: // signals
esignal::Signal<float> signalChange;
esignal::Signal<float> signalHide; //!< Hide value [0..1] ==> 0 is hidden
public:
//eproperty::Value<std::string> propertyShape; //!< name of the shape used
eproperty::Value<float> propertyValue; //!< current value of the VolumeBar
eproperty::Value<float> propertyStep; //!< Up and down step value
eproperty::Value<float> propertyMinimum; //!< minimum value of the VolumeBar
eproperty::Value<float> propertyMaximum; //!< maximum value of the VolumeBar
eproperty::Value<float> propertyDanger; //!< change color value
private:
bool m_isHidden;
echrono::Time m_lastEventTime;
esignal::Connection m_PCH; //!< Periodic Call Handle to remove it when needed
/**
* @brief Periodic call to update grapgic display
* @param[in] _event Time generic event
*/
void periodicCall(const ewol::event::Time& _event);
protected:
VolumeBar();
public:

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="64" height="64">
<path style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:4px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 15,2 H 27 V 62 H 15 Z"/>
<path style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:4px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 37,2 H 49 V 62 H 37 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 467 B

View File

@ -0,0 +1,5 @@
<sizer mode="vert" fill="true" expand="false,true" gravity="left">
<image name="[{ID}]appl-upbar-image" src="DATA:Light.svg" size="8,8mm"/>
<appl_VolumeBar name="[{ID}]appl-upbar-range" expand="false,true" fill="true" step="5" min="0" max="200" danger="101" value="100" mode="vert"/>
<label name="[{ID}]appl-upbar-label">100%</label>
</sizer>

View File

@ -12,7 +12,8 @@
<button name="[{ID}]appl-player-bt-play" toggle="true" shape="">
<!--<label>_T{Play}</label>-->
<image src="DATA:Play.svg" size="8,8mm"/>
<label>_T{Pause}</label>
<!--<label>_T{Pause}</label>-->
<image src="DATA:Suspend.svg" size="8,8mm"/>
</button>
<spacer expand="true,false" fill="true"/>
<button name="[{ID}]appl-player-bt-next" shape="">
@ -30,20 +31,12 @@
<label name="[{ID}]appl-player-label-duration"/>
</sizer>
<sizer mode="hori" fill="true" expand="true,false">
<sizer mode="vert" fill="true" expand="false,true">
<image src="DATA:Light.svg" size="8,8mm" />
<appl_VolumeBar name="[{ID}]appl-player-light" expand="false,true" fill="true" step="5" value="100" min="0" max="100" mode="vert"/>
<label name="[{ID}]appl-player-label-light">100%</label>
</sizer>
<appl_UpBar name="[{ID}]appl-player-light" bar-type="light" fill="true" expand="false,true" min-size="17,0%"/>
<sizer mode="vert" fill="true" expand="true">
<spacer expand="true" fill="true"/>
<label name="[{ID}]appl-player-label-fps"/>
</sizer>
<sizer mode="vert" fill="true" expand="false,true">
<image src="DATA:Volume.svg" size="8,8mm" />
<appl_VolumeBar name="[{ID}]appl-player-volume" expand="false,true" fill="true" step="0.3" value="0" min="-40" max="6" mode="vert"/>
<label name="[{ID}]appl-player-label-volume">0dB</label>
</sizer>
<appl_UpBar name="[{ID}]appl-player-volume" bar-type="volume" fill="true" expand="false,true" min-size="17,0%"/>
</sizer>
</sizer>

View File

@ -0,0 +1,5 @@
<sizer mode="vert" fill="true" expand="false,true" gravity="right">
<image name="[{ID}]appl-upbar-image" src="DATA:Volume.svg" size="8,8mm"/>
<appl_VolumeBar name="[{ID}]appl-upbar-range" expand="false,true" fill="true" step="0.3" value="0" min="-40" danger="0.2" max="6" mode="vert"/>
<label name="[{ID}]appl-upbar-label">0dB</label>
</sizer>

View File

@ -40,6 +40,7 @@ def configure(target, my_module):
'appl/widget/Player.cpp',
'appl/widget/ProgressBar.cpp',
'appl/widget/VolumeBar.cpp',
'appl/widget/UpBar.cpp',
])
my_module.add_depend([
'ffmpeg-libs',
@ -51,7 +52,7 @@ def configure(target, my_module):
])
my_module.add_flag('c++', [
"-DPROJECT_NAME=\"\\\""+ my_module.get_name()+"\\\"\"",
"-DAPPL_VERSION=\"\\\"" + tools.version_to_string(get_version()) + "\\\"\"",
"-DAPPL_VERSION=\"\\\"" + tools.version_to_string(my_module.get_version()) + "\\\"\"",
"-Wno-deprecated-declarations"
])
my_module.copy_path('data/*')