[DEV] add widget composer and corect some other (button, label...)
This commit is contained in:
parent
b75a5b383d
commit
a8003d993b
@ -1,288 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <ewol/widget/Button.hpp>
|
||||
#include <ewol/object/Manager.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::Button);
|
||||
ETK_DECLARE_TYPE(ewol::widget::Button::buttonLock);
|
||||
// DEFINE for the shader display system:
|
||||
static int STATUS_UP(0);
|
||||
static int STATUS_HOVER(2);
|
||||
static int STATUS_PRESSED(1);
|
||||
static int STATUS_DOWN(3);
|
||||
|
||||
ewol::widget::Button::Button() :
|
||||
signalPressed(this, "pressed", "Button is pressed"),
|
||||
signalDown(this, "down", "Button is DOWN"),
|
||||
signalUp(this, "up", "Button is UP"),
|
||||
signalEnter(this, "enter", "The cursor enter inside the button"),
|
||||
signalLeave(this, "leave", "the cursor leave the button"),
|
||||
signalValue(this, "value", "button value change"),
|
||||
propertyShape(this, "shape", etk::Uri("THEME_GUI:///Button.json?lib=ewol"), "The display name for config file", ewol::widget::Button::onChangePropertyShape),
|
||||
propertyValue(this, "value", false, "Value of the Button", ewol::widget::Button::onChangePropertyValue),
|
||||
propertyLock(this, "lock", lockNone, "Lock the button in a special state to permit changing state only by the coder", ewol::widget::Button::onChangePropertyLock),
|
||||
propertyToggleMode(this, "toggle", false, "The Button can toogle", ewol::widget::Button::onChangePropertyToggleMode),
|
||||
propertyEnableSingle(this, "enable-single", false, "If one element set in the Button ==> display only set", ewol::widget::Button::onChangePropertyEnableSingle),
|
||||
this.mouseHover(false),
|
||||
this.buttonPressed(false),
|
||||
this.selectableAreaPos(0,0),
|
||||
this.selectableAreaSize(0,0) {
|
||||
addObjectType("ewol::widget::Button");
|
||||
|
||||
// set property list:
|
||||
propertyLock.add(lockNone, "none");
|
||||
propertyLock.add(lockWhenPressed, "pressed");
|
||||
propertyLock.add(lockWhenReleased, "released");
|
||||
propertyLock.add(lockAccess, "access");
|
||||
|
||||
propertyCanFocus.setDirectCheck(true);
|
||||
|
||||
// shaper satatus update:
|
||||
CheckStatus();
|
||||
// Limit event at 1:
|
||||
setMouseLimit(1);
|
||||
}
|
||||
|
||||
void ewol::widget::Button::init() {
|
||||
ewol::widget::Container2::init();
|
||||
propertyShape.notifyChange();
|
||||
}
|
||||
|
||||
ewol::widget::Button::~Button() {
|
||||
|
||||
}
|
||||
|
||||
void ewol::widget::Button::onChangeSize() {
|
||||
ewol::Padding padding = this.shaper.getPadding();
|
||||
ewol::Padding ret = onChangeSizePadded(padding);
|
||||
//Log.debug(" configuring : origin=" + origin + " size=" + subElementSize + "");
|
||||
this.selectableAreaPos = Vector2f(ret.xLeft(), ret.yButtom());
|
||||
this.selectableAreaSize = this.size - (this.selectableAreaPos + Vector2f(ret.xRight(), ret.yTop()));
|
||||
}
|
||||
|
||||
|
||||
void ewol::widget::Button::calculateMinMaxSize() {
|
||||
ewol::Padding padding = this.shaper.getPadding();
|
||||
calculateMinMaxSizePadded(padding);
|
||||
}
|
||||
|
||||
void ewol::widget::Button::onDraw() {
|
||||
// draw the shaaper (if needed indeed)
|
||||
this.shaper.draw();
|
||||
}
|
||||
|
||||
void ewol::widget::Button::onRegenerateDisplay() {
|
||||
ewol::widget::Container2::onRegenerateDisplay();
|
||||
if (needRedraw() == false) {
|
||||
return;
|
||||
}
|
||||
ewol::Padding padding = this.shaper.getPadding();
|
||||
this.shaper.setShape(Vector2f(0,0),
|
||||
this.size,
|
||||
Vector2fClipInt32(this.selectableAreaPos+Vector2f(padding.xLeft(),padding.yButtom()) ),
|
||||
Vector2fClipInt32(this.selectableAreaSize-Vector2f(padding.x(),padding.y()) ) );
|
||||
//Log.error("pos=" + this.origin + " size=" + this.size);
|
||||
}
|
||||
|
||||
boolean ewol::widget::Button::onEventInput( ewol::event::Input _event) {
|
||||
Log.verbose("Event on BT : " + _event);
|
||||
// disable event in the lock access mode :
|
||||
if(ewol::widget::Button::lockAccess == *propertyLock) {
|
||||
return false;
|
||||
}
|
||||
if( _event.getStatus() == KeyStatus::leave
|
||||
|| _event.getStatus() == KeyStatus::abort) {
|
||||
this.mouseHover = false;
|
||||
this.buttonPressed = false;
|
||||
} else {
|
||||
Vector2f relativePos = relativePosition(_event.getPos());
|
||||
// prevent error from ouside the button
|
||||
if( relativePos.x() < this.selectableAreaPos.x()
|
||||
|| relativePos.y() < this.selectableAreaPos.y()
|
||||
|| relativePos.x() > this.selectableAreaPos.x() + this.selectableAreaSize.x()
|
||||
|| relativePos.y() > this.selectableAreaPos.y() + this.selectableAreaSize.y() ) {
|
||||
this.mouseHover = false;
|
||||
this.buttonPressed = false;
|
||||
} else {
|
||||
this.mouseHover = true;
|
||||
}
|
||||
}
|
||||
Log.verbose("Event on BT ... mouse hover : " + this.mouseHover);
|
||||
if (this.mouseHover == true) {
|
||||
if (_event.getId() == 1) {
|
||||
if(_event.getStatus() == KeyStatus::down) {
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalDown);
|
||||
signalDown.emit();
|
||||
this.buttonPressed = true;
|
||||
markToRedraw();
|
||||
}
|
||||
if(_event.getStatus() == KeyStatus::up) {
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalUp);
|
||||
signalUp.emit();
|
||||
this.buttonPressed = false;
|
||||
markToRedraw();
|
||||
}
|
||||
if(_event.getStatus() == KeyStatus::pressSingle) {
|
||||
if ( ( *propertyValue == true
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *propertyLock == ewol::widget::Button::lockWhenPressed)
|
||||
|| ( *propertyValue == false
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *propertyLock == ewol::widget::Button::lockWhenReleased) ) {
|
||||
// nothing to do : Lock mode ...
|
||||
// user might set himself the new correct value with @ref setValue(xxx)
|
||||
} else {
|
||||
// inverse value :
|
||||
propertyValue.set((*propertyValue)?false:true);
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalPressed);
|
||||
signalPressed.emit();
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalValue + " val=" + *propertyValue );
|
||||
signalValue.emit(*propertyValue);
|
||||
if( *propertyToggleMode == false
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *propertyValue == true) {
|
||||
propertyValue.set(false);
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalValue + " val=" + *propertyValue);
|
||||
signalValue.emit(*propertyValue);
|
||||
}
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
CheckStatus();
|
||||
return this.mouseHover;
|
||||
}
|
||||
|
||||
|
||||
boolean ewol::widget::Button::onEventEntry( ewol::event::Entry _event) {
|
||||
//Log.debug("BT PRESSED : \"" + UTF8_data + "\" size=" + strlen(UTF8_data));
|
||||
if( _event.getType() == KeyKeyboard::character
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::down
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getChar() == '\r') {
|
||||
signalEnter.emit();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ewol::widget::Button::onLostFocus() {
|
||||
this.buttonPressed = false;
|
||||
Log.verbose(propertyName.get() + " : Remove Focus ...");
|
||||
CheckStatus();
|
||||
}
|
||||
|
||||
void ewol::widget::Button::CheckStatus() {
|
||||
if (this.buttonPressed == true) {
|
||||
changeStatusIn(STATUS_PRESSED);
|
||||
return;
|
||||
}
|
||||
if (this.mouseHover == true) {
|
||||
changeStatusIn(STATUS_HOVER);
|
||||
return;
|
||||
}
|
||||
if (*propertyValue == true) {
|
||||
changeStatusIn(STATUS_DOWN);
|
||||
}
|
||||
changeStatusIn(STATUS_UP);
|
||||
}
|
||||
|
||||
void ewol::widget::Button::changeStatusIn(int _newStatusId) {
|
||||
if (this.shaper.changeStatusIn(_newStatusId) == true) {
|
||||
this.PCH = getObjectManager().periodicCall.connect(this, ewol::widget::Button::periodicCall);
|
||||
markToRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ewol::widget::Button::periodicCall( ewol::event::Time _event) {
|
||||
if (this.shaper.periodicCall(_event) == false) {
|
||||
this.PCH.disconnect();
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Button::onChangePropertyShape() {
|
||||
this.shaper.setSource(*propertyShape);
|
||||
markToRedraw();
|
||||
}
|
||||
void ewol::widget::Button::onChangePropertyValue() {
|
||||
if (*propertyToggleMode == true) {
|
||||
if (*propertyValue == false) {
|
||||
this.idWidgetDisplayed = 0;
|
||||
} else {
|
||||
this.idWidgetDisplayed = 1;
|
||||
}
|
||||
}
|
||||
if (*propertyEnableSingle == true) {
|
||||
if ( this.idWidgetDisplayed == 0
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] == null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] != null) {
|
||||
this.idWidgetDisplayed = 1;
|
||||
} else if ( this.idWidgetDisplayed == 1
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] == null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] != null) {
|
||||
this.idWidgetDisplayed = 0;
|
||||
}
|
||||
}
|
||||
CheckStatus();
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Button::onChangePropertyLock() {
|
||||
if(ewol::widget::Button::lockAccess == *propertyLock) {
|
||||
this.buttonPressed = false;
|
||||
this.mouseHover = false;
|
||||
}
|
||||
CheckStatus();
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Button::onChangePropertyToggleMode() {
|
||||
if (*propertyValue == true) {
|
||||
propertyValue.setDirect(false);
|
||||
// TODO : change display and send event ...
|
||||
}
|
||||
if (*propertyToggleMode == false) {
|
||||
this.idWidgetDisplayed = 0;
|
||||
} else {
|
||||
if (*propertyValue == false) {
|
||||
this.idWidgetDisplayed = 0;
|
||||
} else {
|
||||
this.idWidgetDisplayed = 1;
|
||||
}
|
||||
}
|
||||
if (*propertyEnableSingle == true) {
|
||||
if ( this.idWidgetDisplayed == 0
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] == null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] != null) {
|
||||
this.idWidgetDisplayed = 1;
|
||||
} else if ( this.idWidgetDisplayed == 1
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] == null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] != null) {
|
||||
this.idWidgetDisplayed = 0;
|
||||
}
|
||||
}
|
||||
CheckStatus();
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Button::onChangePropertyEnableSingle() {
|
||||
if (*propertyEnableSingle == true) {
|
||||
if ( this.idWidgetDisplayed == 0
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] == null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] != null) {
|
||||
this.idWidgetDisplayed = 1;
|
||||
} else if ( this.idWidgetDisplayed == 1
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] == null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] != null) {
|
||||
this.idWidgetDisplayed = 0;
|
||||
} else if ( this.subWidget[0] == null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] == null) {
|
||||
this.idWidgetDisplayed = 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,216 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/widget/CheckBox.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <ewol/object/Manager.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::CheckBox);
|
||||
|
||||
// DEFINE for the shader display system :
|
||||
#define STATUS_UP (0)
|
||||
#define STATUS_HOVER (2)
|
||||
#define STATUS_PRESSED (1)
|
||||
#define STATUS_SELECTED (2)
|
||||
|
||||
ewol::widget::CheckBox::CheckBox() :
|
||||
signalPressed(this, "pressed", "CheckBox is pressed"),
|
||||
signalDown(this, "down", "CheckBox is DOWN"),
|
||||
signalUp(this, "up", "CheckBox is UP"),
|
||||
signalEnter(this, "enter", "The cursor enter inside the CheckBox"),
|
||||
signalValue(this, "value", "CheckBox value change"),
|
||||
propertyValue(this, "value",
|
||||
false,
|
||||
"Basic value of the widget",
|
||||
ewol::widget::CheckBox::onChangePropertyValue),
|
||||
propertyShape(this, "shape",
|
||||
etk::Uri("THEME_GUI:///CheckBox.json?lib=ewol"),
|
||||
"The display name for config file",
|
||||
ewol::widget::CheckBox::onChangePropertyShape),
|
||||
this.mouseHover(false),
|
||||
this.buttonPressed(false),
|
||||
this.selectableAreaPos(0,0),
|
||||
this.selectableAreaSize(0,0),
|
||||
this.shaperIdSize(-1),
|
||||
this.shaperIdSizeInsize(-1) {
|
||||
addObjectType("ewol::widget::CheckBox");
|
||||
// shaper satatus update:
|
||||
CheckStatus();
|
||||
propertyCanFocus.setDirectCheck(true);
|
||||
// Limit event at 1:
|
||||
setMouseLimit(1);
|
||||
}
|
||||
|
||||
|
||||
void ewol::widget::CheckBox::init() {
|
||||
ewol::widget::Container2::init();
|
||||
propertyShape.notifyChange();
|
||||
}
|
||||
|
||||
ewol::widget::CheckBox::~CheckBox() {
|
||||
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::onChangeSize() {
|
||||
ewol::Padding padding = this.shaper.getPadding();
|
||||
float boxSize = this.shaper.getConfigNumber(this.shaperIdSize);
|
||||
padding.setXLeft(padding.xLeft()*2.0f + boxSize);
|
||||
ewol::Padding ret = onChangeSizePadded(padding);
|
||||
Log.debug(" configuring : padding=" + padding + " boxSize=" + boxSize + "");
|
||||
this.selectableAreaPos = Vector2f(ret.xLeft()/*-boxSize*/, ret.yButtom());
|
||||
this.selectableAreaSize = this.size - (this.selectableAreaPos + Vector2f(ret.xRight(), ret.yTop()));
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::calculateMinMaxSize() {
|
||||
ewol::Padding padding = this.shaper.getPadding();
|
||||
float boxSize = this.shaper.getConfigNumber(this.shaperIdSize);
|
||||
padding.setXLeft(padding.xLeft()*2.0f + boxSize);
|
||||
calculateMinMaxSizePadded(padding);
|
||||
if (this.minSize.y() < padding.y()+boxSize) {
|
||||
this.minSize.setY(padding.y()+boxSize);
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::onDraw() {
|
||||
// draw the shaaper (if needed indeed)
|
||||
this.shaper.draw();
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::onRegenerateDisplay() {
|
||||
ewol::widget::Container2::onRegenerateDisplay();
|
||||
if (needRedraw() == false) {
|
||||
return;
|
||||
}
|
||||
ewol::Padding padding = this.shaper.getPadding();
|
||||
float boxSize = this.shaper.getConfigNumber(this.shaperIdSize);
|
||||
float boxInside = this.shaper.getConfigNumber(this.shaperIdSizeInsize);
|
||||
this.shaper.clear();
|
||||
Log.debug(" configuring : boxSize=" + boxSize + " boxInside=" + boxInside + "");
|
||||
Vector2f origin(this.selectableAreaPos + Vector2f(0, (this.selectableAreaSize.y() - (boxSize+padding.y()))*0.5f));
|
||||
Vector2f size = Vector2f(boxSize+padding.x(), boxSize+padding.y());
|
||||
|
||||
Vector2f origin2 = this.selectableAreaPos + Vector2f((boxSize-boxInside)*0.5f, (this.selectableAreaSize.y() - (boxInside+padding.y()))*0.5f);
|
||||
Vector2f size2 = Vector2f(boxInside+padding.x(), boxInside+padding.y());
|
||||
this.shaper.setShape(Vector2fClipInt32(origin),
|
||||
Vector2fClipInt32(size),
|
||||
Vector2fClipInt32(origin2+Vector2f(padding.xLeft(),padding.yButtom()) ),
|
||||
Vector2fClipInt32(size2-Vector2f(padding.x(),padding.y()) ));
|
||||
}
|
||||
|
||||
boolean ewol::widget::CheckBox::onEventInput( ewol::event::Input _event) {
|
||||
Log.verbose("Event on BT : " + _event);
|
||||
|
||||
boolean previousHoverState = this.mouseHover;
|
||||
if( KeyStatus::leave == _event.getStatus()
|
||||
|| KeyStatus::abort == _event.getStatus()) {
|
||||
this.mouseHover = false;
|
||||
this.buttonPressed = false;
|
||||
} else {
|
||||
Vector2f relativePos = relativePosition(_event.getPos());
|
||||
// prevent error from ouside the button
|
||||
if( relativePos.x() < this.selectableAreaPos.x()
|
||||
|| relativePos.y() < this.selectableAreaPos.y()
|
||||
|| relativePos.x() > this.selectableAreaPos.x() + this.selectableAreaSize.x()
|
||||
|| relativePos.y() > this.selectableAreaPos.y() + this.selectableAreaSize.y() ) {
|
||||
this.mouseHover = false;
|
||||
this.buttonPressed = false;
|
||||
} else {
|
||||
this.mouseHover = true;
|
||||
}
|
||||
}
|
||||
boolean previousPressed = this.buttonPressed;
|
||||
Log.verbose("Event on BT ... mouse hover : " + this.mouseHover);
|
||||
if (this.mouseHover == true) {
|
||||
if (_event.getId() == 1) {
|
||||
if(KeyStatus::down == _event.getStatus()) {
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalDown);
|
||||
signalDown.emit();
|
||||
this.buttonPressed = true;
|
||||
markToRedraw();
|
||||
}
|
||||
if(KeyStatus::up == _event.getStatus()) {
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalUp);
|
||||
signalUp.emit();
|
||||
this.buttonPressed = false;
|
||||
markToRedraw();
|
||||
}
|
||||
if(KeyStatus::pressSingle == _event.getStatus()) {
|
||||
// inverse value :
|
||||
propertyValue.set((*propertyValue)?false:true);
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalPressed);
|
||||
signalPressed.emit();
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalValue + " val=" + propertyValue );
|
||||
signalValue.emit(*propertyValue);
|
||||
markToRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
if( this.mouseHover != previousHoverState
|
||||
|| this.buttonPressed != previousPressed) {
|
||||
CheckStatus();
|
||||
}
|
||||
return this.mouseHover;
|
||||
}
|
||||
|
||||
|
||||
boolean ewol::widget::CheckBox::onEventEntry( ewol::event::Entry _event) {
|
||||
//Log.debug("BT PRESSED : \"" + UTF8_data + "\" size=" + strlen(UTF8_data));
|
||||
if( _event.getType() == KeyKeyboard::character
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::down
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getChar() == '\r') {
|
||||
signalEnter.emit();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::CheckStatus() {
|
||||
if (this.shaper.setState(*propertyValue==true?1:0) == true) {
|
||||
markToRedraw();
|
||||
}
|
||||
if (this.buttonPressed == true) {
|
||||
changeStatusIn(STATUS_PRESSED);
|
||||
return;
|
||||
}
|
||||
if (this.mouseHover == true) {
|
||||
changeStatusIn(STATUS_HOVER);
|
||||
return;
|
||||
}
|
||||
changeStatusIn(STATUS_UP);
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::changeStatusIn(int _newStatusId) {
|
||||
if (this.shaper.changeStatusIn(_newStatusId) == true) {
|
||||
this.PCH = getObjectManager().periodicCall.connect(this, ewol::widget::CheckBox::periodicCall);
|
||||
markToRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ewol::widget::CheckBox::periodicCall( ewol::event::Time _event) {
|
||||
if (this.shaper.periodicCall(_event) == false) {
|
||||
this.PCH.disconnect();
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::onChangePropertyShape() {
|
||||
this.shaper.setSource(*propertyShape);
|
||||
this.shaperIdSize = this.shaper.requestConfig("box-size");
|
||||
this.shaperIdSizeInsize = this.shaper.requestConfig("box-inside");
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::onChangePropertyValue() {
|
||||
if (*propertyValue == false) {
|
||||
this.idWidgetDisplayed = convertId(0);
|
||||
} else {
|
||||
this.idWidgetDisplayed = convertId(1);
|
||||
}
|
||||
CheckStatus();
|
||||
markToRedraw();
|
||||
this.shaper.setActivateState(*propertyValue==true?1:0);
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/** @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/Container.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class Composer;
|
||||
using Composer = ememory::Ptr<ewol::widget::Composer>;
|
||||
using ComposerWeak = ememory::WeakPtr<ewol::widget::Composer>;
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
* the composer widget is a widget that create a link on a string.file to parse the data and generate some widget tree
|
||||
*/
|
||||
class Composer : public ewol::widget::Container {
|
||||
public:
|
||||
eproperty::Value<bool> propertyRemoveIfUnderRemove; //!< Remove the composer if sub element request a remove
|
||||
eproperty::Value<etk::Uri> propertySubFile; //!< If loading a sub-file, we must do it here ==> permit to configure it in the xml and not have wrong display
|
||||
protected:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Composer();
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(Composer, "Composer");
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Composer();
|
||||
/**
|
||||
* load a composition with a file
|
||||
* @param _uri Name of the file
|
||||
* @param _id Unique ID that is used in replacing the balise "{ID}" inside the File (do nothing if == 0)
|
||||
* @return true == > all done OK
|
||||
* @return false == > some error occured
|
||||
*/
|
||||
boolean loadFromFile( etk::Uri _uri, ulong _id=0);
|
||||
/**
|
||||
* load a composition with a file
|
||||
* @param _composerXmlString xml to parse directly
|
||||
* @param _id Unique ID that is used in replacing the balise "{ID}" inside the String (do nothing if == 0)
|
||||
* @return true == > all done OK
|
||||
* @return false == > some error occured
|
||||
*/
|
||||
boolean loadFromString( String _composerXmlString, ulong _id=0);
|
||||
private:
|
||||
void requestDestroyFromChild( EwolObject _child) ;
|
||||
public:
|
||||
boolean loadXML( exml::Element _node) ;
|
||||
protected:
|
||||
void onChangePropertySubFile();
|
||||
};
|
||||
Widget composerGenerateString( String _data = "", ulong _id=0);
|
||||
Widget composerGenerateFile( etk::Uri _uri = "", ulong _id=0);
|
||||
};
|
||||
};
|
@ -1,70 +1,45 @@
|
||||
/** @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 <etk/Color.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/widget/Container.hpp>
|
||||
#include <ewol/compositing/Drawing.hpp>
|
||||
#include <ewol/compositing/Shaper.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class ContextMenu;
|
||||
using ContextMenu = ememory::Ptr<ewol::widget::ContextMenu>;
|
||||
using ContextMenuWeak = ememory::WeakPtr<ewol::widget::ContextMenu>;
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
*/
|
||||
class ContextMenu : public ewol::widget::Container {
|
||||
public:
|
||||
enum markPosition {
|
||||
markTop,
|
||||
markRight,
|
||||
markButtom,
|
||||
markLeft,
|
||||
markNone
|
||||
};
|
||||
public: // properties
|
||||
eproperty::Value<etk::Uri> propertyShape; //!< shape of the widget.
|
||||
eproperty::Value<Vector2f> propertyArrowPos;
|
||||
eproperty::List<enum markPosition> propertyArrawBorder;
|
||||
protected:
|
||||
ContextMenu();
|
||||
void init() ;
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(ContextMenu, "ContextMenu");
|
||||
~ContextMenu();
|
||||
private:
|
||||
ewol::compositing::Shaper this.shaper; //!< Compositing theme.
|
||||
|
||||
// TODO : Use shaper for the arraw ...
|
||||
ewol::compositing::Drawing this.compositing;
|
||||
etk::Color<> this.colorBorder; // use shaper ID
|
||||
|
||||
|
||||
float this.offset;
|
||||
public:
|
||||
void setPositionMarkAuto( Vector2f _origin, Vector2f _size);
|
||||
void setPositionMark(enum markPosition _position, Vector2f _arrowPos);
|
||||
protected:
|
||||
void onDraw() ;
|
||||
public:
|
||||
void onRegenerateDisplay() ;
|
||||
boolean onEventInput( ewol::event::Input _event) ;
|
||||
void onChangeSize() ;
|
||||
void calculateMinMaxSize() ;
|
||||
Widget getWidgetAtPos( Vector2f _pos) ;
|
||||
protected:
|
||||
void onChangePropertyArrowPos();
|
||||
void onChangePropertyArrawBorder();
|
||||
void onChangePropertyShape();
|
||||
class ContextMenu extends Container {
|
||||
public:
|
||||
enum markPosition {
|
||||
markTop,
|
||||
markRight,
|
||||
markButtom,
|
||||
markLeft,
|
||||
markNone
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
public: // properties
|
||||
eproperty::Value<etk::Uri> propertyShape; //!< shape of the widget.
|
||||
eproperty::Value<Vector2f> propertyArrowPos;
|
||||
eproperty::List<enum markPosition> propertyArrawBorder;
|
||||
protected:
|
||||
ContextMenu();
|
||||
void init() ;
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(ContextMenu, "ContextMenu");
|
||||
~ContextMenu();
|
||||
private:
|
||||
ewol::compositing::Shaper this.shaper; //!< Compositing theme.
|
||||
|
||||
// TODO : Use shaper for the arraw ...
|
||||
ewol::compositing::Drawing this.compositing;
|
||||
etk::Color<> this.colorBorder; // use shaper ID
|
||||
|
||||
|
||||
float this.offset;
|
||||
public:
|
||||
void setPositionMarkAuto( Vector2f _origin, Vector2f _size);
|
||||
void setPositionMark(enum markPosition _position, Vector2f _arrowPos);
|
||||
protected:
|
||||
void onDraw() ;
|
||||
public:
|
||||
void onRegenerateDisplay() ;
|
||||
boolean onEventInput( ewol::event::Input _event) ;
|
||||
void onChangeSize() ;
|
||||
void calculateMinMaxSize() ;
|
||||
Widget getWidgetAtPos( Vector2f _pos) ;
|
||||
protected:
|
||||
void onChangePropertyArrowPos();
|
||||
void onChangePropertyArrawBorder();
|
||||
void onChangePropertyShape();
|
||||
};
|
@ -279,7 +279,7 @@ void ewol::widget::Gird::subWidgetUnLink(int _colId, int _rowId) {
|
||||
// try to find it ...
|
||||
for (int iii=0; iii<this.subWidget.size(); iii++) {
|
||||
if( this.subWidget[iii].row == _rowId
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[iii].col == _colId) {
|
||||
&& this.subWidget[iii].col == _colId) {
|
||||
this.subWidget.erase(this.subWidget.begin()+iii);
|
||||
return;
|
||||
}
|
||||
@ -315,8 +315,8 @@ Widget ewol::widget::Gird::getWidgetAtPos( Vector2f _pos) {
|
||||
}
|
||||
Vector2f tmpSize = it.widget.getSize();
|
||||
Vector2f tmpOrigin = it.widget.getOrigin();
|
||||
if( (tmpOrigin.x() <= _pos.x() LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM tmpOrigin.x() + tmpSize.x() >= _pos.x())
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (tmpOrigin.y() <= _pos.y() LOMLOMLOMLOMLOM tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) {
|
||||
if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x())
|
||||
&& (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) {
|
||||
Widget tmpWidget = it.widget.getWidgetAtPos(_pos);
|
||||
if (tmpWidget != null) {
|
||||
return tmpWidget;
|
||||
|
@ -1,43 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/widget/Layer.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::Layer);
|
||||
|
||||
ewol::widget::Layer::Layer() {
|
||||
addObjectType("ewol::widget::Layer");
|
||||
}
|
||||
|
||||
ewol::widget::Layer::~Layer() {
|
||||
Log.debug("[" + getId() + "] Layer : destroy");
|
||||
}
|
||||
|
||||
Widget ewol::widget::Layer::getWidgetAtPos( Vector2f _pos) {
|
||||
if (*propertyHide == true) {
|
||||
return null;
|
||||
}
|
||||
// for all element in the sizer ...
|
||||
for (auto it : this.subWidget) {
|
||||
if (it == null) {
|
||||
continue;
|
||||
}
|
||||
Vector2f tmpSize = it.getSize();
|
||||
Vector2f tmpOrigin = it.getOrigin();
|
||||
if( (tmpOrigin.x() <= _pos.x() LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM tmpOrigin.x() + tmpSize.x() >= _pos.x())
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (tmpOrigin.y() <= _pos.y() LOMLOMLOMLOMLOM tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) {
|
||||
Widget tmpWidget = it.getWidgetAtPos(_pos);
|
||||
if (tmpWidget != null) {
|
||||
return tmpWidget;
|
||||
}
|
||||
// parse the next layer ...
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
@ -1,38 +0,0 @@
|
||||
/** @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/ContainerN.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class Layer;
|
||||
using Layer = ememory::Ptr<ewol::widget::Layer>;
|
||||
using LayerWeak = ememory::WeakPtr<ewol::widget::Layer>;
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
*/
|
||||
class Layer : public ewol::widget::ContainerN {
|
||||
protected:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Layer();
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(Layer, "Layer");
|
||||
/**
|
||||
* Desstructor
|
||||
*/
|
||||
~Layer();
|
||||
public:
|
||||
Widget getWidgetAtPos( Vector2f _pos) ;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -287,13 +287,13 @@ boolean ewol::widget::List::onEventInput( ewol::event::Input _event) {
|
||||
int previous = offsetY;
|
||||
offsetY += this.listSizeY[iii];
|
||||
if ( relativePos.y() < offsetY
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM relativePos.y() >= previous ) {
|
||||
&& relativePos.y() >= previous ) {
|
||||
pos.setY(iii);
|
||||
offsetY = previous;
|
||||
break;
|
||||
}
|
||||
if ( iii == this.listSizeY.size()-2
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM relativePos.y() >= offsetY ) {
|
||||
&& relativePos.y() >= offsetY ) {
|
||||
pos.setY(iii+1);
|
||||
break;
|
||||
}
|
||||
@ -303,13 +303,13 @@ boolean ewol::widget::List::onEventInput( ewol::event::Input _event) {
|
||||
int previous = offsetX;
|
||||
offsetX += this.listSizeX[iii];
|
||||
if ( relativePos.x() < offsetX
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM relativePos.x() >= previous ) {
|
||||
&& relativePos.x() >= previous ) {
|
||||
pos.setX(iii);
|
||||
offsetX = previous;
|
||||
break;
|
||||
}
|
||||
if ( iii == this.listSizeX.size()-2
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM relativePos.x() >= offsetX ) {
|
||||
&& relativePos.x() >= offsetX ) {
|
||||
pos.setX(iii+1);
|
||||
break;
|
||||
}
|
||||
|
@ -1,130 +1,94 @@
|
||||
/** @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 <etk/Color.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/widget/WidgetScrolled.hpp>
|
||||
#include <ewol/compositing/Compositing.hpp>
|
||||
#include <fluorine/Variant.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class List;
|
||||
using List = ememory::Ptr<ewol::widget::List>;
|
||||
using ListWeak = ememory::WeakPtr<ewol::widget::List>;
|
||||
|
||||
enum ListRole {
|
||||
Text = 11234, // string
|
||||
IsSelected, // bool
|
||||
IsExpand, // bool
|
||||
Icon, // string
|
||||
ChildCount, // uint_t
|
||||
HaveChild, // bool
|
||||
ParentId, // uint_t
|
||||
BgColor, // color
|
||||
FgColor, // color
|
||||
DistanceToRoot, // uint_t
|
||||
// Every other role must be set here:
|
||||
EndOfEwolRole
|
||||
};
|
||||
enum ListRole {
|
||||
Text = 11234, // string
|
||||
IsSelected, // bool
|
||||
IsExpand, // bool
|
||||
Icon, // string
|
||||
ChildCount, // uint_t
|
||||
HaveChild, // bool
|
||||
ParentId, // uint_t
|
||||
BgColor, // color
|
||||
FgColor, // color
|
||||
DistanceToRoot, // uint_t
|
||||
// Every other role must be set here:
|
||||
EndOfEwolRole
|
||||
};
|
||||
class List extends WidgetScrolled {
|
||||
public List();
|
||||
public void calculateMinMaxSize() ;
|
||||
// drawing capabilities ....
|
||||
protected List<ememory::Ptr<ewol::Compositing>> listOObject; //!< generic element to display...
|
||||
protected List<Integer> listSizeX; //!< size of every colomns
|
||||
protected List<Integer> listSizeY; //!< size of every rows
|
||||
protected etk::Map<String, ememory::Ptr<ewol::Compositing>> compositingElements;
|
||||
protected void addComposeElemnent( String _name, ememory::Ptr<ewol::Compositing> _element);
|
||||
protected void clearComposeElemnent();
|
||||
protected void removeComposeElemnent();
|
||||
protected ememory::Ptr<ewol::Compositing> getComposeElemnent( String _name);
|
||||
public void clearOObjectList();
|
||||
// list properties ...
|
||||
protected int paddingSizeX;
|
||||
protected int paddingSizeY;
|
||||
protected int displayStartRaw; //!< Current starting diaplayed raw
|
||||
protected int displayCurrentNbLine; //!< Number of line in the display
|
||||
protected int nbVisibleRaw; // set the number of visible raw (calculate don display)
|
||||
// function call to display the list :
|
||||
protected etk::Color<> getBasicBG() {
|
||||
return etk::Color<>(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
* Get the number of colomn and row availlable in the list
|
||||
* @return Number of colomn and row
|
||||
*/
|
||||
class List : public ewol::widget::WidgetScrolled {
|
||||
protected:
|
||||
List();
|
||||
void init() ;
|
||||
public:
|
||||
~List();
|
||||
void calculateMinMaxSize() ;
|
||||
// drawing capabilities ....
|
||||
protected:
|
||||
List<ememory::Ptr<ewol::Compositing>> this.listOObject; //!< generic element to display...
|
||||
List<int> this.listSizeX; //!< size of every colomns
|
||||
List<int> this.listSizeY; //!< size of every rows
|
||||
protected:
|
||||
etk::Map<String, ememory::Ptr<ewol::Compositing>> this.compositingElements;
|
||||
void addComposeElemnent( String _name, ememory::Ptr<ewol::Compositing> _element);
|
||||
void clearComposeElemnent();
|
||||
void removeComposeElemnent();
|
||||
ememory::Ptr<ewol::Compositing> getComposeElemnent( String _name);
|
||||
public:
|
||||
void clearOObjectList();
|
||||
// list properties ...
|
||||
protected:
|
||||
int this.paddingSizeX;
|
||||
int this.paddingSizeY;
|
||||
int this.displayStartRaw; //!< Current starting diaplayed raw
|
||||
int this.displayCurrentNbLine; //!< Number of line in the display
|
||||
int this.nbVisibleRaw; // set the number of visible raw (calculate don display)
|
||||
protected:
|
||||
// function call to display the list :
|
||||
etk::Color<> getBasicBG() {
|
||||
return etk::Color<>(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of colomn and row availlable in the list
|
||||
* @return Number of colomn and row
|
||||
*/
|
||||
Vector2i getMatrixSize() ;
|
||||
|
||||
fluorine::Variant getData(int _role, Vector2i _pos) {
|
||||
switch (_role) {
|
||||
case ListRole::Text:
|
||||
return "";
|
||||
case ListRole::FgColor:
|
||||
return etk::Color<>(0x00, 0x00, 0x00, 0xFF);
|
||||
case ListRole::BgColor:
|
||||
if (_pos.y() % 2 == 0) {
|
||||
return etk::Color<>(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
return etk::Color<>(0x7F, 0x7F, 0x7F, 0xFF);
|
||||
protected Vector2i getMatrixSize() ;
|
||||
|
||||
protected fluorine::Variant getData(int _role, Vector2i _pos) {
|
||||
switch (_role) {
|
||||
case ListRole::Text:
|
||||
return "";
|
||||
case ListRole::FgColor:
|
||||
return etk::Color<>(0x00, 0x00, 0x00, 0xFF);
|
||||
case ListRole::BgColor:
|
||||
if (_pos.y() % 2 == 0) {
|
||||
return etk::Color<>(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
return fluorine::Variant();
|
||||
};
|
||||
/**
|
||||
* Calculate an element size to extimate the render size.
|
||||
* @note Does not generate the with the same size.
|
||||
* @param _pos Position of colomn and Raw of the element.
|
||||
* @return The estimate size of the element.
|
||||
*/
|
||||
Vector2f calculateElementSize( Vector2i _pos);
|
||||
/**
|
||||
* Draw an element in the specific size and position.
|
||||
* @param _pos Position of colomn and Raw of the element.
|
||||
* @param _start Start display position.
|
||||
* @param _size Render raw size
|
||||
* @return The estimate size of the element.
|
||||
*/
|
||||
void drawElement( Vector2i _pos, Vector2f _start, Vector2f _size);
|
||||
/**
|
||||
* Draw the background
|
||||
*/
|
||||
void drawBackground();
|
||||
|
||||
boolean onItemEvent( ewol::event::Input _event, Vector2i _pos, Vector2f _mousePosition) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* set a raw visible in the main display
|
||||
* @param _id Id of the raw that might be visible.
|
||||
*/
|
||||
//void setRawVisible(int _id);
|
||||
protected:
|
||||
void onGetFocus() ;
|
||||
void onLostFocus() ;
|
||||
void onDraw() ;
|
||||
public:
|
||||
void onRegenerateDisplay() ;
|
||||
boolean onEventInput( ewol::event::Input _event) ;
|
||||
return etk::Color<>(0x7F, 0x7F, 0x7F, 0xFF);
|
||||
}
|
||||
return fluorine::Variant();
|
||||
};
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Calculate an element size to extimate the render size.
|
||||
* @note Does not generate the with the same size.
|
||||
* @param _pos Position of colomn and Raw of the element.
|
||||
* @return The estimate size of the element.
|
||||
*/
|
||||
protected Vector2f calculateElementSize( Vector2i _pos);
|
||||
/**
|
||||
* Draw an element in the specific size and position.
|
||||
* @param _pos Position of colomn and Raw of the element.
|
||||
* @param _start Start display position.
|
||||
* @param _size Render raw size
|
||||
* @return The estimate size of the element.
|
||||
*/
|
||||
protected void drawElement( Vector2i _pos, Vector2f _start, Vector2f _size);
|
||||
/**
|
||||
* Draw the background
|
||||
*/
|
||||
protected void drawBackground();
|
||||
|
||||
protected boolean onItemEvent( ewol::event::Input _event, Vector2i _pos, Vector2f _mousePosition) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* set a raw visible in the main display
|
||||
* @param _id Id of the raw that might be visible.
|
||||
*/
|
||||
//void setRawVisible(int _id);
|
||||
protected void onGetFocus() ;
|
||||
protected void onLostFocus() ;
|
||||
protected void onDraw() ;
|
||||
public void onRegenerateDisplay() ;
|
||||
public boolean onEventInput( ewol::event::Input _event) ;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
package sample.atriasoft.ewol.sampleEntry;
|
||||
package org.atriasoft.ewol.widget;
|
||||
|
||||
import org.atriasoft.etk.Dimension3f;
|
||||
import org.atriasoft.etk.Distance;
|
||||
import org.atriasoft.etk.math.Vector3b;
|
||||
import org.atriasoft.etk.math.Vector3f;
|
||||
import org.atriasoft.ewol.widget.Entry;
|
||||
|
||||
import sample.atriasoft.ewol.BasicWindows;
|
||||
|
@ -1,444 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/widget/Scroll.hpp>
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/compositing/Drawing.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::Scroll);
|
||||
|
||||
ewol::widget::Scroll::Scroll() :
|
||||
propertyLimit(this, "limit",
|
||||
Vector2f(0.15,0.5), Vector2f(0.0,0.0), Vector2f(1.0,1.0),
|
||||
"Limit the scroll maximum position [0..1]% represent the free space in the scoll when arrive at the end",
|
||||
ewol::widget::Scroll::onChangePropertyLimit),
|
||||
propertyShapeVert(this, "shape-vert",
|
||||
etk::Uri("THEME_GUI:///WidgetScrolled.json?lib=ewol"),
|
||||
"shape for the vertical display",
|
||||
ewol::widget::Scroll::onChangePropertyShapeVert),
|
||||
propertyShapeHori(this, "shape-hori",
|
||||
etk::Uri("THEME_GUI:///WidgetScrolled.json?lib=ewol"),
|
||||
"shape for the horizonal display",
|
||||
ewol::widget::Scroll::onChangePropertyShapeHori),
|
||||
propertyHover(this, "hover",
|
||||
true,
|
||||
"the display bar are hover the subWidget"),
|
||||
this.pixelScrolling(20),
|
||||
this.highSpeedStartPos(0,0),
|
||||
this.highSpeedMode(speedModeDisable),
|
||||
this.highSpeedButton(-1),
|
||||
this.highSpeedType(KeyType::unknow) {
|
||||
addObjectType("ewol::widget::Scroll");
|
||||
// Remove gravity property: (only keep top/buttom)
|
||||
propertyGravity.remove("center");
|
||||
propertyGravity.remove("top-left");
|
||||
//propertyGravity.remove("top");
|
||||
propertyGravity.remove("top-right");
|
||||
propertyGravity.remove("right");
|
||||
propertyGravity.remove("buttom-right");
|
||||
//propertyGravity.remove("buttom");
|
||||
propertyGravity.remove("buttom-left");
|
||||
propertyGravity.remove("left");
|
||||
}
|
||||
|
||||
void ewol::widget::Scroll::init() {
|
||||
ewol::widget::Container::init();
|
||||
propertyShapeVert.notifyChange();
|
||||
propertyShapeHori.notifyChange();
|
||||
}
|
||||
|
||||
|
||||
ewol::widget::Scroll::~Scroll() {
|
||||
|
||||
}
|
||||
// TODO : create a config for this ...
|
||||
#define SCROLL_BAR_SPACE (15)
|
||||
|
||||
// note: The widget will expand has possible and will control itself the display property
|
||||
void ewol::widget::Scroll::onChangeSize() {
|
||||
// Note: No call of container ==> normal case ...
|
||||
Widget::onChangeSize();
|
||||
if (*propertyHide == true) {
|
||||
return;
|
||||
}
|
||||
if (this.subWidget == null) {
|
||||
return;
|
||||
}
|
||||
// remove the bar if hover
|
||||
Vector2f basicSize = this.size;
|
||||
if (*propertyHover == false) {
|
||||
basicSize -= Vector2f(SCROLL_BAR_SPACE,SCROLL_BAR_SPACE);
|
||||
}
|
||||
|
||||
|
||||
Vector2f origin = this.origin+this.offset;
|
||||
Vector2f minSize = this.subWidget.getCalculateMinSize();
|
||||
Vector2b expand = this.subWidget.propertyExpand.get();
|
||||
//The gravity is not set on the sub element ==> special use of the widget
|
||||
//origin += ewol::gravityGenerateDelta(propertyGravity.get(), minSize - this.size);
|
||||
if ( expand.x() == true
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM minSize.x() < basicSize.x()) {
|
||||
minSize.setX(basicSize.x());
|
||||
}
|
||||
if ( expand.y() == true
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM minSize.y() < basicSize.y()) {
|
||||
minSize.setY(basicSize.y());
|
||||
}
|
||||
this.subWidget.setSize(minSize);
|
||||
if (*propertyGravity == ewol::gravity_top) {
|
||||
origin += Vector2f(0.0f, basicSize.y()-minSize.y());
|
||||
if (*propertyHover == false) {
|
||||
origin += Vector2f(0,SCROLL_BAR_SPACE);
|
||||
}
|
||||
} else if (*propertyGravity == ewol::gravity_buttom) {
|
||||
// nothing to do ... origin +=
|
||||
} else {
|
||||
Log.error(" Not manage other gravity ...");
|
||||
}
|
||||
this.subWidget.setOrigin(origin);
|
||||
this.subWidget.onChangeSize();
|
||||
}
|
||||
|
||||
void ewol::widget::Scroll::calculateMinMaxSize() {
|
||||
// Note: No call of container ==> normal case ...
|
||||
Widget::calculateMinMaxSize();
|
||||
// call sub classes
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.calculateMinMaxSize();
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::Scroll::systemDraw( ewol::DrawProperty _displayProp) {
|
||||
if (*propertyHide == true) {
|
||||
return;
|
||||
}
|
||||
if (this.subWidget != null) {
|
||||
ewol::DrawProperty prop = _displayProp;
|
||||
prop.limit(this.origin, this.size);
|
||||
this.subWidget.systemDraw(prop);
|
||||
}
|
||||
Widget::systemDraw(_displayProp);
|
||||
}
|
||||
|
||||
void ewol::widget::Scroll::onDraw() {
|
||||
this.shaperH.draw();
|
||||
this.shaperV.draw();
|
||||
/*
|
||||
ewol::compositing::Drawing draw;
|
||||
draw.setPos(Vector2f(10,10));
|
||||
draw.setColor(etk::color::orange);
|
||||
draw.rectangleWidth(Vector2f(25,25));
|
||||
draw.setPos(this.size - Vector2f(35,35));
|
||||
draw.setColor(etk::color::green);
|
||||
draw.rectangleWidth(Vector2f(25,25));
|
||||
draw.draw();
|
||||
*/
|
||||
}
|
||||
|
||||
void ewol::widget::Scroll::onRegenerateDisplay() {
|
||||
if (*propertyHide == true) {
|
||||
return;
|
||||
}
|
||||
// call upper class
|
||||
ewol::widget::Container::onRegenerateDisplay();
|
||||
if (needRedraw() == false) {
|
||||
return;
|
||||
}
|
||||
// clear all previous display
|
||||
this.shaperH.clear();
|
||||
this.shaperV.clear();
|
||||
ewol::Padding paddingVert = this.shaperV.getPadding();
|
||||
ewol::Padding paddingHori = this.shaperH.getPadding();
|
||||
Vector2f scrollOffset(0,0);
|
||||
Vector2f scrollSize(0,0);
|
||||
if (this.subWidget != null) {
|
||||
scrollOffset = this.subWidget.getOffset();
|
||||
scrollSize = this.subWidget.getSize();
|
||||
}
|
||||
if( this.size.y() < scrollSize.y()
|
||||
|| scrollOffset.y() != 0) {
|
||||
float lenScrollBar = this.size.y()*this.size.y() / scrollSize.y();
|
||||
lenScrollBar = etk::avg(10.0f, lenScrollBar, this.size.y());
|
||||
float originScrollBar = scrollOffset.y() / (scrollSize.y()-this.size.y()*propertyLimit.y());
|
||||
originScrollBar = etk::avg(0.0f, originScrollBar, 1.0f);
|
||||
originScrollBar *= (this.size.y()-lenScrollBar);
|
||||
this.shaperV.setShape(Vector2f(this.size.x() - paddingVert.x(), 0),
|
||||
Vector2f(paddingVert.x(), this.size.y()),
|
||||
Vector2f(this.size.x() - paddingVert.xRight(), this.size.y() - originScrollBar - lenScrollBar),
|
||||
Vector2f(0, lenScrollBar));
|
||||
}
|
||||
if( this.size.x() < scrollSize.x()
|
||||
|| scrollOffset.x() != 0) {
|
||||
float lenScrollBar = (this.size.x()-paddingHori.xLeft())*(this.size.x()-paddingVert.x()) / scrollSize.x();
|
||||
lenScrollBar = etk::avg(10.0f, lenScrollBar, (this.size.x()-paddingVert.x()));
|
||||
float originScrollBar = scrollOffset.x() / (scrollSize.x()-this.size.x()*propertyLimit.x());
|
||||
originScrollBar = etk::avg(0.0f, originScrollBar, 1.0f);
|
||||
originScrollBar *= (this.size.x()-paddingHori.xRight()-lenScrollBar);
|
||||
this.shaperH.setShape(Vector2f(0, 0),
|
||||
Vector2f(this.size.x()-paddingVert.x(), paddingHori.y()),
|
||||
Vector2f(originScrollBar, paddingHori.yButtom()),
|
||||
Vector2f(lenScrollBar, 0));
|
||||
}
|
||||
}
|
||||
|
||||
boolean ewol::widget::Scroll::onEventInput( ewol::event::Input _event) {
|
||||
//ewol::event::Input _event = event;
|
||||
//_event.setType(KeyType::finger);
|
||||
Vector2f relativePos = relativePosition(_event.getPos());
|
||||
Vector2f scrollOffset(0,0);
|
||||
Vector2f scrollSize(0,0);
|
||||
if (this.subWidget != null) {
|
||||
scrollOffset = this.subWidget.getOffset();
|
||||
scrollSize = this.subWidget.getSize();
|
||||
}
|
||||
Log.verbose("Get Event on scroll : " + _event);
|
||||
relativePos.setY(this.size.y() - relativePos.y());
|
||||
if( _event.getType() == KeyType::mouse
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( this.highSpeedType == KeyType::unknow
|
||||
|| this.highSpeedType == KeyType::mouse) ) {
|
||||
if( _event.getId() == 1
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::down) {
|
||||
// check if selected the scrolling position whth the scrolling bar ...
|
||||
if (relativePos.x() >= (this.size.x()-SCROLL_BAR_SPACE)) {
|
||||
if( this.size.y() < scrollSize.y()
|
||||
|| scrollOffset.y() != 0) {
|
||||
this.highSpeedMode = speedModeEnableVertical;
|
||||
this.highSpeedType = KeyType::mouse;
|
||||
this.highSpeedStartPos.setX(relativePos.x());
|
||||
this.highSpeedStartPos.setY(scrollOffset.y() / scrollSize.y() * (this.size.y()-SCROLL_BAR_SPACE*2));
|
||||
this.highSpeedButton = 1;
|
||||
// force direct scrolling in this case
|
||||
scrollOffset.setY((int)(scrollSize.y() * (relativePos.y()-SCROLL_BAR_SPACE) / (this.size.y()-SCROLL_BAR_SPACE*2)));
|
||||
scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.y())));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else if (relativePos.y() >= (this.size.y()-SCROLL_BAR_SPACE)) {
|
||||
if( this.size.x() < scrollSize.x()
|
||||
|| scrollOffset.x()!=0) {
|
||||
this.highSpeedMode = speedModeEnableHorizontal;
|
||||
this.highSpeedType = KeyType::mouse;
|
||||
this.highSpeedStartPos.setX(scrollOffset.x() / scrollSize.x() * (this.size.x()-SCROLL_BAR_SPACE*2));
|
||||
this.highSpeedStartPos.setY(relativePos.y());
|
||||
this.highSpeedButton = 1;
|
||||
// force direct scrolling in this case
|
||||
scrollOffset.setX((int)(scrollSize.x() * (relativePos.x()-SCROLL_BAR_SPACE) / (this.size.x()-SCROLL_BAR_SPACE*2)));
|
||||
scrollOffset.setY(etk::avg(0.0f, scrollOffset.x(), (scrollSize.x() - this.size.x()*propertyLimit.x())));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if( _event.getId() == 4
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) {
|
||||
Log.verbose(" mode UP " + this.size.y() + "<" + scrollSize.y());
|
||||
if(this.size.y() < scrollSize.y()) {
|
||||
scrollOffset.setY(scrollOffset.y()-this.pixelScrolling);
|
||||
scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.y())));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else if( _event.getId() == 5
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) {
|
||||
Log.verbose(" mode DOWN " + this.size.y() + "<" + scrollSize.y());
|
||||
if(this.size.y() < scrollSize.y()) {
|
||||
scrollOffset.setY(scrollOffset.y()+this.pixelScrolling);
|
||||
scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.y())));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}else if (_event.getId() == 2) {
|
||||
if (_event.getStatus() == KeyStatus::down) {
|
||||
this.highSpeedMode = speedModeInit;
|
||||
this.highSpeedType = KeyType::mouse;
|
||||
this.highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
|
||||
this.highSpeedButton = 2;
|
||||
// not really use... == > just keep some informations
|
||||
return false;
|
||||
}
|
||||
} else if( this.highSpeedMode != speedModeDisable
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::leave) {
|
||||
this.highSpeedMode = speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
if ( _event.getId() == this.highSpeedButton
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.highSpeedMode != speedModeDisable) {
|
||||
if (_event.getStatus() == KeyStatus::up) {
|
||||
if (this.highSpeedMode == speedModeInit) {
|
||||
// TODO : generate back the down event ...
|
||||
this.highSpeedMode = speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
return false;
|
||||
} else {
|
||||
this.highSpeedMode = speedModeGrepEndEvent;
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
} else if (this.highSpeedMode == speedModeGrepEndEvent) {
|
||||
if (_event.getStatus() == KeyStatus::pressSingle) {
|
||||
this.highSpeedMode = speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
this.highSpeedButton = -1;
|
||||
markToRedraw();
|
||||
}
|
||||
return true;
|
||||
} else if( this.highSpeedMode == speedModeInit
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) {
|
||||
// wait that the cursor move more than 10 px to enable it :
|
||||
if( etk::abs(relativePos.x() - this.highSpeedStartPos.x()) > 10
|
||||
|| etk::abs(relativePos.y() - this.highSpeedStartPos.y()) > 10 ) {
|
||||
// the scrooling can start :
|
||||
// select the direction :
|
||||
if (relativePos.x() == this.highSpeedStartPos.x()) {
|
||||
this.highSpeedMode = speedModeEnableVertical;
|
||||
} else if (relativePos.y() == this.highSpeedStartPos.y()) {
|
||||
this.highSpeedMode = speedModeEnableHorizontal;
|
||||
} else {
|
||||
float coef = (relativePos.y() - this.highSpeedStartPos.y()) / (relativePos.x() - this.highSpeedStartPos.x());
|
||||
if (etk::abs(coef) <= 1 ) {
|
||||
this.highSpeedMode = speedModeEnableHorizontal;
|
||||
} else {
|
||||
this.highSpeedMode = speedModeEnableVertical;
|
||||
}
|
||||
}
|
||||
if (this.highSpeedMode == speedModeEnableHorizontal) {
|
||||
this.highSpeedStartPos.setX(scrollOffset.x() / scrollSize.x() * (this.size.x()-SCROLL_BAR_SPACE*2));
|
||||
} else {
|
||||
this.highSpeedStartPos.setY(scrollOffset.y() / scrollSize.y() * (this.size.y()-SCROLL_BAR_SPACE*2));
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.y())));
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if( this.highSpeedMode == speedModeEnableHorizontal
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) {
|
||||
scrollOffset.setX((int)(scrollSize.x() * (relativePos.x()-SCROLL_BAR_SPACE) / (this.size.x()-SCROLL_BAR_SPACE*2)));
|
||||
scrollOffset.setX(etk::avg(0.0f, scrollOffset.x(), (scrollSize.x() - this.size.x()*propertyLimit.x() )));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if( this.highSpeedMode == speedModeEnableVertical
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) {
|
||||
scrollOffset.setY((int)(scrollSize.y() * (relativePos.y()-SCROLL_BAR_SPACE) / (this.size.y()-SCROLL_BAR_SPACE*2)));
|
||||
scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.x())));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if( KeyType::finger == _event.getType()
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( KeyType::unknow == this.highSpeedType
|
||||
|| KeyType::finger == this.highSpeedType ) ) {
|
||||
if (1 == _event.getId()) {
|
||||
Log.verbose("event: " + _event);
|
||||
if (KeyStatus::down == _event.getStatus()) {
|
||||
this.highSpeedMode = speedModeInit;
|
||||
this.highSpeedType = KeyType::finger;
|
||||
this.highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
|
||||
Log.verbose("SCROOL == > INIT pos=" + this.highSpeedStartPos + " LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM curent scrollOffset=" + scrollOffset);
|
||||
return true;
|
||||
} else if (KeyStatus::upAfter == _event.getStatus()) {
|
||||
this.highSpeedMode = speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
Log.verbose("SCROOL == > DISABLE");
|
||||
markToRedraw();
|
||||
return true;
|
||||
} else if ( this.highSpeedMode == speedModeInit
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM KeyStatus::move == _event.getStatus()) {
|
||||
// wait that the cursor move more than 10 px to enable it :
|
||||
if( etk::abs(relativePos.x() - this.highSpeedStartPos.x()) > 10
|
||||
|| etk::abs(relativePos.y() - this.highSpeedStartPos.y()) > 10 ) {
|
||||
// the scrooling can start :
|
||||
// select the direction :
|
||||
this.highSpeedMode = speedModeEnableFinger;
|
||||
Log.verbose("SCROOL == > ENABLE");
|
||||
markToRedraw();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if ( this.highSpeedMode == speedModeEnableFinger
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM KeyStatus::move == _event.getStatus()) {
|
||||
Log.verbose("SCROOL == > INIT scrollOffset=" + scrollOffset.y() + " relativePos=" + relativePos.y() + " this.highSpeedStartPos=" + this.highSpeedStartPos.y());
|
||||
//scrollOffset.x = (int)(scrollSize.x * x / this.size.x);
|
||||
if (propertyLimit.x() != 0.0f) {
|
||||
scrollOffset.setX(scrollOffset.x() + (relativePos.x() - this.highSpeedStartPos.x()));
|
||||
scrollOffset.setX(etk::avg(0.0f, scrollOffset.x(), (scrollSize.x() - this.size.x()*propertyLimit.x())));
|
||||
}
|
||||
if (propertyLimit.y() != 0.0f) {
|
||||
scrollOffset.setY(scrollOffset.y() - (relativePos.y() - this.highSpeedStartPos.y()));
|
||||
scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.y())));
|
||||
}
|
||||
// update current position:
|
||||
this.highSpeedStartPos = relativePos;
|
||||
Log.verbose("SCROOL == > MOVE " + scrollOffset);
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.highSpeedMode == speedModeEnableFinger) {
|
||||
return true;
|
||||
}
|
||||
} else if ( this.highSpeedMode != speedModeDisable
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM KeyStatus::leave == _event.getStatus()) {
|
||||
this.highSpeedMode = speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
Log.verbose("SCROOL == > DISABLE");
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Widget ewol::widget::Scroll::getWidgetAtPos( Vector2f _pos) {
|
||||
Widget tmpWidget = ewol::widget::Container::getWidgetAtPos(_pos);
|
||||
if (tmpWidget != null) {
|
||||
return tmpWidget;
|
||||
}
|
||||
return ememory::dynamicPointerCast<Widget>(sharedFromThis());;
|
||||
}
|
||||
|
||||
void ewol::widget::Scroll::onChangePropertyLimit() {
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Scroll::onChangePropertyShapeVert() {
|
||||
this.shaperV.setSource(propertyShapeVert);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Scroll::onChangePropertyShapeHori() {
|
||||
this.shaperH.setSource(propertyShapeHori);
|
||||
markToRedraw();
|
||||
}
|
||||
|
@ -1,66 +0,0 @@
|
||||
/** @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/Container.hpp>
|
||||
#include <ewol/compositing/Compositing.hpp>
|
||||
#include <ewol/compositing/Shaper.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class Scroll;
|
||||
using Scroll = ememory::Ptr<ewol::widget::Scroll>;
|
||||
using ScrollWeak = ememory::WeakPtr<ewol::widget::Scroll>;
|
||||
class Scroll : public ewol::widget::Container {
|
||||
public: // properties
|
||||
eproperty::Range<Vector2f> propertyLimit; //!< Set the limitation of the ratio in the sreen
|
||||
eproperty::Value<etk::Uri> propertyShapeVert; //!< Vertical shaper name
|
||||
eproperty::Value<etk::Uri> propertyShapeHori; //!< Horizontal shaper name
|
||||
eproperty::Value<bool> propertyHover; //!< Horizontal shaper name
|
||||
public:
|
||||
enum highSpeedMode {
|
||||
speedModeDisable,
|
||||
speedModeInit,
|
||||
speedModeEnableFinger, // Specific for touchpad
|
||||
speedModeEnableHorizontal, // Specific for mouse
|
||||
speedModeEnableVertical, // Specific for mouse
|
||||
speedModeGrepEndEvent
|
||||
};
|
||||
private:
|
||||
ewol::compositing::Shaper this.shaperH; //!< Compositing theme Horizontal.
|
||||
ewol::compositing::Shaper this.shaperV; //!< Compositing theme Vertical.
|
||||
private:
|
||||
float this.pixelScrolling;
|
||||
Vector2f this.highSpeedStartPos;
|
||||
enum highSpeedMode this.highSpeedMode;
|
||||
int this.highSpeedButton;
|
||||
KeyType this.highSpeedType;
|
||||
protected:
|
||||
Scroll();
|
||||
void init() ;
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(Scroll, "Scroll");
|
||||
~Scroll();
|
||||
public:
|
||||
void onChangeSize() ;
|
||||
void calculateMinMaxSize() ;
|
||||
void onRegenerateDisplay() ;
|
||||
boolean onEventInput( ewol::event::Input _event) ;
|
||||
void systemDraw( ewol::DrawProperty _displayProp) ;
|
||||
Widget getWidgetAtPos( Vector2f _pos) ;
|
||||
protected:
|
||||
void onDraw() ;
|
||||
protected:
|
||||
void onChangePropertyLimit();
|
||||
void onChangePropertyShapeVert();
|
||||
void onChangePropertyShapeHori();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,68 +1,36 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
|
||||
/**
|
||||
* a composed Select is a Select with an inside composed with the specify XML element
|
||||
* ==> this permit to generate standard element simple
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/types.hpp>
|
||||
#include <ewol/widget/meta/SpinBase.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class Select;
|
||||
using Select = ememory::Ptr<ewol::widget::Select>;
|
||||
using SelectWeak = ememory::WeakPtr<ewol::widget::Select>;
|
||||
class Select extends SpinBase {
|
||||
public Signal<int> signalValue = new Signal<int>();
|
||||
protected int propertyValue; //!< Current state of the Select.
|
||||
/**
|
||||
* a composed Select is a Select with an inside composed with the specify XML element
|
||||
* ==> this permit to generate standard element simple
|
||||
* Constructor
|
||||
* @param _shaperName Shaper file properties
|
||||
*/
|
||||
class Select : public ewol::widget::SpinBase {
|
||||
public: // signals
|
||||
esignal::Signal<int> signalValue;
|
||||
public: // properties
|
||||
eproperty::Value<int> propertyValue; //!< Current state of the Select.
|
||||
protected:
|
||||
/**
|
||||
* Constructor
|
||||
* @param _shaperName Shaper file properties
|
||||
*/
|
||||
Select();
|
||||
public Select();
|
||||
protected class Element {
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(Select, "Select");
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Select();
|
||||
protected:
|
||||
class Element {
|
||||
public:
|
||||
int this.value;
|
||||
String this.name;
|
||||
boolean this.selected;
|
||||
public:
|
||||
// TODO: Remove this: due to the fact my List is not full implemented
|
||||
Element() {}
|
||||
Element(int _value, String _name, boolean _selected=false);
|
||||
};
|
||||
List<ewol::widget::Select::Element> this.listElement;
|
||||
int value;
|
||||
String name;
|
||||
boolean selected;
|
||||
public:
|
||||
void optionSelectDefault();
|
||||
void optionRemove(int _value);
|
||||
void optionClear();
|
||||
void optionAdd(int _value, String _name);
|
||||
protected:
|
||||
boolean loadXML( exml::Element _node) ;
|
||||
void updateGui() ;
|
||||
protected:
|
||||
void onCallbackOpenMenu();
|
||||
void onCallbackLabelPressed(int _value);
|
||||
protected:
|
||||
esignal::Connection this.connectionEntry;
|
||||
esignal::Connection this.connectionButton;
|
||||
protected:
|
||||
void onChangePropertyValue();
|
||||
// TODO: Remove this: due to the fact my List is not full implemented
|
||||
Element() {}
|
||||
Element(int _value, String _name, boolean _selected=false);
|
||||
};
|
||||
};
|
||||
};
|
||||
protected List<ewol::widget::Select::Element> this.listElement;
|
||||
public void optionSelectDefault();
|
||||
public void optionRemove(int _value);
|
||||
public void optionClear();
|
||||
public void optionAdd(int _value, String _name);
|
||||
protected boolean loadXML( exml::Element _node) ;
|
||||
protected void updateGui() ;
|
||||
protected void onCallbackOpenMenu();
|
||||
protected void onCallbackLabelPressed(int _value);
|
||||
protected esignal::Connection connectionEntry = null;
|
||||
protected esignal::Connection connectionButton = null;
|
||||
protected void onChangePropertyValue();
|
||||
}
|
||||
|
@ -75,15 +75,15 @@ void ewol::widget::Spin::updateGui() {
|
||||
ewol::widget::SpinBase::updateGui();
|
||||
|
||||
if ( this.widgetEntry != null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.connectionEntry.isConnected() == false) {
|
||||
&& this.connectionEntry.isConnected() == false) {
|
||||
|
||||
}
|
||||
if ( this.widgetButtonUp != null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.connectionButtonUp.isConnected() == false) {
|
||||
&& this.connectionButtonUp.isConnected() == false) {
|
||||
this.connectionButtonUp = this.widgetButtonUp.signalPressed.connect(this, ewol::widget::Spin::onCallbackUp);
|
||||
}
|
||||
if ( this.widgetButtonDown != null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.connectionButtonDown.isConnected() == false) {
|
||||
&& this.connectionButtonDown.isConnected() == false) {
|
||||
this.connectionButtonDown = this.widgetButtonDown.signalPressed.connect(this, ewol::widget::Spin::onCallbackDown);
|
||||
}
|
||||
Log.warning("updateGui [STOP]");
|
||||
|
@ -1,60 +1,36 @@
|
||||
/** @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 <etk/Color.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/widget/List.hpp>
|
||||
#include <ewol/compositing/Compositing.hpp>
|
||||
#include <fluorine/Variant.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class TreeView;
|
||||
using TreeView = ememory::Ptr<ewol::widget::TreeView>;
|
||||
using TreeViewWeak = ememory::WeakPtr<ewol::widget::TreeView>;
|
||||
|
||||
class TreeView extends WidgetList {
|
||||
public: // signals
|
||||
public: // properties
|
||||
eproperty::Value<float> propertyOffsetTreeView; //!< indentation betwwen every new element.
|
||||
eproperty::Value<float> propertyIconTreeViewSize; //!< Size of the icon.
|
||||
eproperty::Value<bool> propertyTextIsDecorated; //!< Size of the icon.
|
||||
protected:
|
||||
TreeView();
|
||||
void init() ;
|
||||
public:
|
||||
~TreeView();
|
||||
protected:
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
* Calculate an element size to extimate the render size.
|
||||
* @note Does not generate the with the same size.
|
||||
* @param _pos Position of colomn and Raw of the element.
|
||||
* @return The estimate size of the element.
|
||||
*/
|
||||
class TreeView : public ewol::widget::List {
|
||||
public: // signals
|
||||
public: // properties
|
||||
eproperty::Value<float> propertyOffsetTreeView; //!< indentation betwwen every new element.
|
||||
eproperty::Value<float> propertyIconTreeViewSize; //!< Size of the icon.
|
||||
eproperty::Value<bool> propertyTextIsDecorated; //!< Size of the icon.
|
||||
protected:
|
||||
TreeView();
|
||||
void init() ;
|
||||
public:
|
||||
~TreeView();
|
||||
protected:
|
||||
/**
|
||||
* Calculate an element size to extimate the render size.
|
||||
* @note Does not generate the with the same size.
|
||||
* @param _pos Position of colomn and Raw of the element.
|
||||
* @return The estimate size of the element.
|
||||
*/
|
||||
Vector2f calculateElementSize( Vector2i _pos) ;
|
||||
/**
|
||||
* Draw an element in the specific size and position.
|
||||
* @param _pos Position of colomn and Raw of the element.
|
||||
* @param _start Start display position.
|
||||
* @param _size Render raw size
|
||||
* @return The estimate size of the element.
|
||||
*/
|
||||
void drawElement( Vector2i _pos, Vector2f _start, Vector2f _size) ;
|
||||
protected:
|
||||
void onChangePropertyOffsetTreeView();
|
||||
void onChangePropertyTextDecorated();
|
||||
|
||||
boolean onItemEvent( ewol::event::Input _event, Vector2i _pos, Vector2f _mousePosition) ;
|
||||
void onItemExpandEvent( Vector2i _pos) { };
|
||||
};
|
||||
};
|
||||
};
|
||||
Vector2f calculateElementSize( Vector2i _pos) ;
|
||||
/**
|
||||
* Draw an element in the specific size and position.
|
||||
* @param _pos Position of colomn and Raw of the element.
|
||||
* @param _start Start display position.
|
||||
* @param _size Render raw size
|
||||
* @return The estimate size of the element.
|
||||
*/
|
||||
void drawElement( Vector2i _pos, Vector2f _start, Vector2f _size) ;
|
||||
protected:
|
||||
void onChangePropertyOffsetTreeView();
|
||||
void onChangePropertyTextDecorated();
|
||||
|
||||
boolean onItemEvent( ewol::event::Input _event, Vector2i _pos, Vector2f _mousePosition) ;
|
||||
void onItemExpandEvent( Vector2i _pos) { };
|
||||
}
|
||||
|
||||
|
@ -1,501 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/widget/WidgetScrolled.hpp>
|
||||
|
||||
#include <ewol/compositing/Drawing.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <gale/renderer/openGL/openGL.hpp>
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::WidgetScrolled);
|
||||
|
||||
ewol::widget::WidgetScrolled::WidgetScrolled() :
|
||||
propertyShapeVert(this, "shape-vert",
|
||||
etk::Uri("THEME_GUI:///WidgetScrolled.json?lib=ewol"),
|
||||
"shape for the vertical display",
|
||||
ewol::widget::WidgetScrolled::onChangePropertyShapeVert),
|
||||
propertyShapeHori(this, "shape-hori",
|
||||
etk::Uri("THEME_GUI:///WidgetScrolled.json?lib=ewol"),
|
||||
"shape for the horizonal display",
|
||||
ewol::widget::WidgetScrolled::onChangePropertyShapeHori),
|
||||
this.shaperH(),
|
||||
this.shaperV(),
|
||||
this.singleFingerMode(true) {
|
||||
addObjectType("ewol::widget::WidgetScrolled");
|
||||
this.originScrooled.setValue(0,0);
|
||||
this.pixelScrolling = 20;
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeDisable;
|
||||
this.scroollingMode = scroolModeNormal;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
this.highSpeedButton = -1;
|
||||
this.limitScrolling = Vector2f(0.5f, 0.5f);
|
||||
|
||||
this.fingerScoolActivated = false;
|
||||
for (int iii = 0; iii < CALCULATE_SIMULTANEOUS_FINGER; ++iii) {
|
||||
this.fingerPresent[iii] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::WidgetScrolled::init() {
|
||||
Widget::init();
|
||||
propertyShapeVert.notifyChange();
|
||||
propertyShapeHori.notifyChange();
|
||||
}
|
||||
|
||||
ewol::widget::WidgetScrolled::~WidgetScrolled() {
|
||||
|
||||
}
|
||||
|
||||
void ewol::widget::WidgetScrolled::onRegenerateDisplay() {
|
||||
this.shaperH.clear();
|
||||
this.shaperV.clear();
|
||||
if (this.scroollingMode == scroolModeGame) {
|
||||
// nothing to do ...
|
||||
return;
|
||||
}
|
||||
ewol::Padding paddingVert = this.shaperV.getPadding();
|
||||
ewol::Padding paddingHori = this.shaperH.getPadding();
|
||||
if( this.size.y() < this.maxSize.y()
|
||||
|| this.originScrooled.y()!=0) {
|
||||
float lenScrollBar = this.size.y()*this.size.y() / this.maxSize.y();
|
||||
lenScrollBar = etk::avg(10.0f, lenScrollBar, this.size.y());
|
||||
float originScrollBar = this.originScrooled.y() / (this.maxSize.y()-this.size.y()*this.limitScrolling.y());
|
||||
originScrollBar = etk::avg(0.0f, originScrollBar, 1.0f);
|
||||
originScrollBar *= (this.size.y()-lenScrollBar);
|
||||
this.shaperV.setShape(Vector2f(this.size.x() - paddingVert.x(), 0),
|
||||
Vector2f(paddingVert.x(), this.size.y()),
|
||||
Vector2f(this.size.x() - paddingVert.xRight(), this.size.y() - originScrollBar - lenScrollBar),
|
||||
Vector2f(0, lenScrollBar));
|
||||
}
|
||||
if( this.size.x() < this.maxSize.x()
|
||||
|| this.originScrooled.x()!=0) {
|
||||
float lenScrollBar = (this.size.x()-paddingHori.xLeft())*(this.size.x()-paddingVert.x()) / this.maxSize.x();
|
||||
lenScrollBar = etk::avg(10.0f, lenScrollBar, (this.size.x()-paddingVert.x()));
|
||||
float originScrollBar = this.originScrooled.x() / (this.maxSize.x()-this.size.x()*this.limitScrolling.x());
|
||||
originScrollBar = etk::avg(0.0f, originScrollBar, 1.0f);
|
||||
originScrollBar *= (this.size.x()-paddingHori.xRight()-lenScrollBar);
|
||||
this.shaperH.setShape(Vector2f(0, 0),
|
||||
Vector2f(this.size.x()-paddingVert.x(), paddingHori.y()),
|
||||
Vector2f(originScrollBar, paddingHori.yButtom()),
|
||||
Vector2f(lenScrollBar, 0));
|
||||
}
|
||||
}
|
||||
|
||||
boolean ewol::widget::WidgetScrolled::onEventInput( ewol::event::Input _event) {
|
||||
Log.verbose("event XXX " + _event);
|
||||
Vector2f relativePos = relativePosition(_event.getPos());
|
||||
// corection due to the open Gl invertion ...
|
||||
relativePos.setY(this.size.y() - relativePos.y());
|
||||
ewol::Padding paddingV = this.shaperV.getPadding();
|
||||
ewol::Padding paddingH = this.shaperH.getPadding();
|
||||
if (this.scroollingMode == scroolModeNormal) {
|
||||
if ( _event.getType() == KeyType::mouse
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( this.highSpeedType == KeyType::unknow
|
||||
|| this.highSpeedType == KeyType::mouse) ) {
|
||||
if ( _event.getId() == 1
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::down) {
|
||||
// check if selected the scrolling position whth the scrolling bar ...
|
||||
if (relativePos.x() >= (this.size.x()-paddingV.x())) {
|
||||
if( this.size.y() < this.maxSize.y()
|
||||
|| this.originScrooled.y() != 0) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeEnableVertical;
|
||||
this.highSpeedType = KeyType::mouse;
|
||||
this.highSpeedStartPos.setX(relativePos.x());
|
||||
this.highSpeedStartPos.setY(this.originScrooled.y() / this.maxSize.y() * (this.size.y()-paddingV.yButtom()*2));
|
||||
this.highSpeedButton = 1;
|
||||
// force direct scrolling in this case
|
||||
this.originScrooled.setY((int)(this.maxSize.y() * (relativePos.y()-paddingV.yButtom()) / (this.size.y()-paddingV.yButtom()*2)));
|
||||
this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
} else if (relativePos.y() >= (this.size.y()-paddingH.y())) {
|
||||
if( this.size.x() < this.maxSize.x()
|
||||
|| this.originScrooled.x()!=0) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal;
|
||||
this.highSpeedType = KeyType::mouse;
|
||||
this.highSpeedStartPos.setX(this.originScrooled.x() / this.maxSize.x() * (this.size.x()-paddingH.xLeft()*2));
|
||||
this.highSpeedStartPos.setY(relativePos.y());
|
||||
this.highSpeedButton = 1;
|
||||
// force direct scrolling in this case
|
||||
this.originScrooled.setX((int)(this.maxSize.x() * (relativePos.x()-paddingH.xLeft()) / (this.size.x()-paddingH.xLeft()*2)));
|
||||
this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if ( _event.getId() == 4
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) {
|
||||
if (true == _event.getSpecialKey().getCtrl()) {
|
||||
changeZoom(1);
|
||||
/*
|
||||
float zoom = getZoom()*1.1;
|
||||
zoom = etk::avg(0.1f, zoom, 5000.0f);
|
||||
setZoom(zoom);
|
||||
*/
|
||||
} else {
|
||||
if(this.size.y() < this.maxSize.y()
|
||||
|| this.originScrooled.y() != 0
|
||||
|| this.size.y()*this.limitScrolling.y() < this.maxSize.y() ) {
|
||||
this.originScrooled.setY(this.originScrooled.y()-this.pixelScrolling);
|
||||
this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if ( _event.getId() == 5
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) {
|
||||
if (true == _event.getSpecialKey().getCtrl()) {
|
||||
changeZoom(-1);
|
||||
/*
|
||||
float zoom = getZoom()*0.9;
|
||||
zoom = etk::avg(0.1f, zoom, 5000.0f);
|
||||
setZoom(zoom);
|
||||
*/
|
||||
} else {
|
||||
if(this.size.y() < this.maxSize.y()
|
||||
|| this.originScrooled.y()!=0
|
||||
|| this.size.y()*this.limitScrolling.y() < this.maxSize.y() ) {
|
||||
this.originScrooled.setY(this.originScrooled.y()+this.pixelScrolling);
|
||||
this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if ( _event.getId() == 11
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) {
|
||||
// Scrool Left
|
||||
if(this.size.x() < this.maxSize.x()
|
||||
|| this.originScrooled.x()!=0
|
||||
|| this.size.x()*this.limitScrolling.x() < this.maxSize.x() ) {
|
||||
this.originScrooled.setX(this.originScrooled.x()-this.pixelScrolling);
|
||||
this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
} else if ( _event.getId() == 10
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) {
|
||||
// Scrool Right
|
||||
if(this.size.x() < this.maxSize.x()
|
||||
|| this.originScrooled.x()!=0
|
||||
|| this.size.x()*this.limitScrolling.x() < this.maxSize.x() ) {
|
||||
this.originScrooled.setX(this.originScrooled.x()+this.pixelScrolling);
|
||||
this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}else if (_event.getId() == 2) {
|
||||
/*
|
||||
if (true == ewol::isSetCtrl()) {
|
||||
if (KeyStatus::down == typeEvent) {
|
||||
float zoom = 1.0;
|
||||
setZoom(zoom);
|
||||
}
|
||||
} else */{
|
||||
if (_event.getStatus() == KeyStatus::down) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeInit;
|
||||
this.highSpeedType = KeyType::mouse;
|
||||
this.highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
|
||||
this.highSpeedButton = 2;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if ( this.highSpeedMode != ewol::widget::Scroll::speedModeDisable
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::leave) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
if ( _event.getId() == this.highSpeedButton
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.highSpeedMode != ewol::widget::Scroll::speedModeDisable) {
|
||||
if (_event.getStatus() == KeyStatus::upAfter) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
return false;
|
||||
} else if (this.highSpeedMode == ewol::widget::Scroll::speedModeGrepEndEvent) {
|
||||
if (_event.getStatus() == KeyStatus::pressSingle) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
this.highSpeedButton = -1;
|
||||
markToRedraw();
|
||||
}
|
||||
return true;
|
||||
} else if (_event.getStatus() == KeyStatus::up) {
|
||||
return true;
|
||||
} else if ( this.highSpeedMode == ewol::widget::Scroll::speedModeInit
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) {
|
||||
// wait that the cursor move more than 10 px to enable it :
|
||||
if( etk::abs(relativePos.x() - this.highSpeedStartPos.x()) > 10
|
||||
|| etk::abs(relativePos.y() - this.highSpeedStartPos.y()) > 10 ) {
|
||||
// the scrooling can start :
|
||||
// select the direction :
|
||||
if (relativePos.x() == this.highSpeedStartPos.x()) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeEnableVertical;
|
||||
} else if (relativePos.y() == this.highSpeedStartPos.y()) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal;
|
||||
} else {
|
||||
float coef = (relativePos.y() - this.highSpeedStartPos.y()) / (relativePos.x() - this.highSpeedStartPos.x());
|
||||
if (etk::abs(coef) <= 1 ) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal;
|
||||
} else {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeEnableVertical;
|
||||
}
|
||||
}
|
||||
if (this.highSpeedMode == ewol::widget::Scroll::speedModeEnableHorizontal) {
|
||||
this.highSpeedStartPos.setX(this.originScrooled.x() / this.maxSize.x() * (this.size.x()-paddingV.x()));
|
||||
} else {
|
||||
this.highSpeedStartPos.setY(this.originScrooled.y() / this.maxSize.y() * (this.size.y()-paddingV.y()));
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y())));
|
||||
return true;
|
||||
}
|
||||
if ( this.highSpeedMode == ewol::widget::Scroll::speedModeEnableHorizontal
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) {
|
||||
this.originScrooled.setX((int)(this.maxSize.x() * (relativePos.x()-paddingH.xLeft()) / (this.size.x()-paddingH.x())));
|
||||
this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
if ( this.highSpeedMode == ewol::widget::Scroll::speedModeEnableVertical
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) {
|
||||
this.originScrooled.setY((int)(this.maxSize.y() * (relativePos.y()-paddingV.yButtom()) / (this.size.y()-paddingV.y())));
|
||||
this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if ( _event.getType() == KeyType::finger
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( this.highSpeedType == KeyType::unknow
|
||||
|| this.highSpeedType == KeyType::finger) ) {
|
||||
if (this.singleFingerMode == false) {
|
||||
// ***********************
|
||||
// ** Two finger mode : **
|
||||
// ***********************
|
||||
if (_event.getId() >= 3) {
|
||||
return false;
|
||||
}
|
||||
int idTable = _event.getId()-1;
|
||||
if (_event.getStatus() == KeyStatus::down) {
|
||||
this.fingerPresent[idTable] = true;
|
||||
} else if (_event.getStatus() == KeyStatus::upAfter) {
|
||||
this.fingerPresent[idTable] = false;
|
||||
}
|
||||
if (this.fingerScoolActivated == false) {
|
||||
this.fingerMoveStartPos[idTable] = relativePos;
|
||||
}
|
||||
if ( this.fingerPresent[0] == true
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.fingerPresent[1] == true
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.fingerScoolActivated == false) {
|
||||
this.fingerScoolActivated = true;
|
||||
Log.verbose("SCROOL == > START pos=" + this.fingerMoveStartPos);
|
||||
}
|
||||
if (this.fingerScoolActivated == true) {
|
||||
// 1: scroll...
|
||||
// 2: remove all unneeded sub event ... ==> maybe a better methode ...
|
||||
if (_event.getStatus() == KeyStatus::move) {
|
||||
this.originScrooled.setX(this.originScrooled.x() - (relativePos.x() - this.fingerMoveStartPos[idTable].x())*0.5f);
|
||||
this.originScrooled.setY(this.originScrooled.y() - (relativePos.y() - this.fingerMoveStartPos[idTable].y())*0.5f);
|
||||
this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x())));
|
||||
this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y())));
|
||||
this.fingerMoveStartPos[idTable] = relativePos;
|
||||
Log.verbose("SCROOL == > MOVE this.originScrooled=" + this.originScrooled + " " + relativePos + " " + this.highSpeedStartPos);
|
||||
markToRedraw();
|
||||
}
|
||||
if ( this.fingerPresent[0] == false
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.fingerPresent[1] == false) {
|
||||
if (_event.getStatus() == KeyStatus::upAfter) {
|
||||
// TODO : Reset event ...
|
||||
this.fingerScoolActivated = false;
|
||||
_event.reset();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// **************************
|
||||
// ** Single finger mode : **
|
||||
// **************************
|
||||
if (_event.getId() == 1) {
|
||||
Log.verbose("event 1 " + _event);
|
||||
if (_event.getStatus() == KeyStatus::down) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeInit;
|
||||
this.highSpeedType = KeyType::finger;
|
||||
this.highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
|
||||
Log.verbose("SCROOL == > INIT");
|
||||
return true;
|
||||
} else if (_event.getStatus() == KeyStatus::upAfter) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
Log.verbose("SCROOL == > DISABLE");
|
||||
markToRedraw();
|
||||
return true;
|
||||
} else if ( this.highSpeedMode == ewol::widget::Scroll::speedModeInit
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) {
|
||||
// wait that the cursor move more than 10 px to enable it :
|
||||
if( etk::abs(relativePos.x() - this.highSpeedStartPos.x()) > 10
|
||||
|| etk::abs(relativePos.y() - this.highSpeedStartPos.y()) > 10 ) {
|
||||
// the scrooling can start :
|
||||
// select the direction :
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeEnableFinger;
|
||||
Log.debug("SCROOL == > ENABLE");
|
||||
markToRedraw();
|
||||
}
|
||||
return true;
|
||||
} else if ( this.highSpeedMode == ewol::widget::Scroll::speedModeEnableFinger
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::pressSingle) {
|
||||
// Keep all event in the range of moving
|
||||
return true;
|
||||
} else if ( this.highSpeedMode == ewol::widget::Scroll::speedModeEnableFinger
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::pressDouble) {
|
||||
// Keep all event in the range of moving
|
||||
return true;
|
||||
} if ( this.highSpeedMode == ewol::widget::Scroll::speedModeEnableFinger
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) {
|
||||
//this.originScrooled.x = (int)(this.maxSize.x * x / this.size.x);
|
||||
this.originScrooled.setX(this.originScrooled.x() - (relativePos.x() - this.highSpeedStartPos.x()));
|
||||
this.originScrooled.setY(this.originScrooled.y() - (relativePos.y() - this.highSpeedStartPos.y()));
|
||||
this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x())));
|
||||
this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y())));
|
||||
this.highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
|
||||
Log.verbose("SCROOL == > MOVE this.originScrooled=" + this.originScrooled + " " + relativePos + " " + this.highSpeedStartPos);
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
} else if ( this.highSpeedMode == ewol::widget::Scroll::speedModeDisable
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::leave) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
Log.verbose("SCROOL == > DISABLE");
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (this.scroollingMode == scroolModeCenter) {
|
||||
if (_event.getType() == KeyType::mouse) {
|
||||
float tmp1=this.size.x() / this.maxSize.y();
|
||||
float tmp2=this.size.y() / this.maxSize.x();
|
||||
//Log.info(" elements Zoom : " + tmp1 + " " + tmp2);
|
||||
tmp1 = etk::min(tmp1, tmp2);
|
||||
if ( _event.getId() == 4
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) {
|
||||
this.zoom -= 0.1;
|
||||
if (tmp1 < 1.0) {
|
||||
this.zoom = etk::max(tmp1, this.zoom);
|
||||
} else {
|
||||
this.zoom = etk::max(1.0f, this.zoom);
|
||||
}
|
||||
markToRedraw();
|
||||
return true;
|
||||
} else if ( _event.getId() == 5
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) {
|
||||
this.zoom += 0.1;
|
||||
if (tmp1 > 1.0) {
|
||||
this.zoom = etk::min(tmp1, this.zoom);
|
||||
} else {
|
||||
this.zoom = etk::min(1.0f, this.zoom);
|
||||
}
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (this.scroollingMode == scroolModeGame) {
|
||||
|
||||
} else {
|
||||
Log.error("Scrolling mode unknow ... " + this.scroollingMode );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void ewol::widget::WidgetScrolled::onDraw() {
|
||||
this.shaperH.draw();
|
||||
this.shaperV.draw();
|
||||
}
|
||||
|
||||
void ewol::widget::WidgetScrolled::systemDraw( ewol::DrawProperty _displayProp) {
|
||||
gale::openGL::push();
|
||||
if (this.scroollingMode == scroolModeCenter) {
|
||||
// here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left
|
||||
gale::openGL::setViewPort(this.origin, this.size);
|
||||
Matrix4f tmpProjection = etk::matOrtho(-this.size.x()/2, this.size.x()/2, -this.size.y()/2, this.size.y()/2, -1, 1);
|
||||
Matrix4f tmpScale = etk::matScale(Vector3f(this.zoom, this.zoom, 1.0) );
|
||||
Matrix4f tmpTranslate = etk::matTranslate(Vector3f(-this.maxSize.x()/2, -this.maxSize.y()/2, -1.0) );
|
||||
Matrix4f tmpMat = tmpProjection * tmpScale * tmpTranslate;
|
||||
// set internal matrix system :
|
||||
gale::openGL::setMatrix(tmpMat);
|
||||
// Call the widget drawing methode
|
||||
onDraw();
|
||||
} if (this.scroollingMode == scroolModeGame) {
|
||||
// here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left
|
||||
gale::openGL::setViewPort(this.origin, this.size);
|
||||
Matrix4f tmpProjection = etk::matOrtho(-this.size.x()/2, this.size.x()/2, -this.size.y()/2, this.size.y()/2, -1, 1);
|
||||
Matrix4f tmpTranslate = etk::matTranslate(Vector3f( -this.maxSize.x()/2, -this.maxSize.y()/2, -1.0) );
|
||||
Matrix4f tmpMat = tmpProjection * tmpTranslate;
|
||||
// set internal matrix system :
|
||||
gale::openGL::setMatrix(tmpMat);
|
||||
// Call the widget drawing methode
|
||||
onDraw();
|
||||
} else {
|
||||
Widget::systemDraw(_displayProp);
|
||||
}
|
||||
gale::openGL::pop();
|
||||
}
|
||||
|
||||
void ewol::widget::WidgetScrolled::setScrollingPositionDynamic(Vector2f _borderWidth, Vector2f _currentPosition, boolean _center) {
|
||||
if (true == _center) {
|
||||
_borderWidth.setValue(this.size.x() / 2 - _borderWidth.x(),
|
||||
this.size.y() / 2 - _borderWidth.y() );
|
||||
}
|
||||
// check scrooling in X
|
||||
if (_currentPosition.x() < (this.originScrooled.x() + _borderWidth.x()) ) {
|
||||
this.originScrooled.setX(_currentPosition.x() - _borderWidth.x());
|
||||
this.originScrooled.setX(etk::max(0.0f, this.originScrooled.x()));
|
||||
} else if (_currentPosition.x() > (this.originScrooled.x()+this.size.x()-2*_borderWidth.x()) ) {
|
||||
this.originScrooled.setX(_currentPosition.x() - this.size.x() + 2*_borderWidth.x());
|
||||
this.originScrooled.setX(etk::max(0.0f, this.originScrooled.x()));
|
||||
}
|
||||
// check scrooling in Y
|
||||
if (_currentPosition.y() < (this.originScrooled.y() + _borderWidth.y()) ) {
|
||||
this.originScrooled.setY(_currentPosition.y() - _borderWidth.y());
|
||||
this.originScrooled.setY(etk::max(0.0f, this.originScrooled.y()));
|
||||
} else if (_currentPosition.y() > (this.originScrooled.y()+this.size.y()-2*_borderWidth.y()) ) {
|
||||
this.originScrooled.setY(_currentPosition.y() - this.size.y() + 2*_borderWidth.y());
|
||||
this.originScrooled.setY(etk::max(0.0f, this.originScrooled.y()));
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::WidgetScrolled::scroolingMode(enum scrollingMode _newMode) {
|
||||
this.scroollingMode = _newMode;
|
||||
if (this.scroollingMode == scroolModeGame) {
|
||||
// set the scene maximum size :
|
||||
this.maxSize.setValue(etk::max(this.size.x(), this.size.y()),
|
||||
this.maxSize.x());
|
||||
this.zoom = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::WidgetScrolled::setSingleFinger(boolean _status) {
|
||||
if (this.singleFingerMode == _status) {
|
||||
return;
|
||||
}
|
||||
this.singleFingerMode = _status;
|
||||
}
|
||||
|
||||
void ewol::widget::WidgetScrolled::onChangePropertyShapeVert() {
|
||||
this.shaperV.setSource(propertyShapeVert);
|
||||
markToRedraw();
|
||||
}
|
||||
void ewol::widget::WidgetScrolled::onChangePropertyShapeHori() {
|
||||
this.shaperH.setSource(propertyShapeHori);
|
||||
markToRedraw();
|
||||
}
|
||||
|
@ -1,142 +1,107 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
|
||||
/**
|
||||
* Widget to integrate a scrool bar in a widget. This is not a stadalone widget.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/widget/Widget.hpp>
|
||||
#include <ewol/widget/Scroll.hpp>
|
||||
#include <ewol/compositing/Shaper.hpp>
|
||||
|
||||
#define CALCULATE_SIMULTANEOUS_FINGER (5)
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class WidgetScrolled;
|
||||
using WidgetScrolled = ememory::Ptr<ewol::widget::WidgetScrolled>;
|
||||
using WidgetScrolledWeak = ememory::WeakPtr<ewol::widget::WidgetScrolled>;
|
||||
class WidgetScrolled extends Widget {
|
||||
public static final int CALCULATE_SIMULTANEOUS_FINGER = 5;
|
||||
protected etk::Uri propertyShapeVert; //!< Vertical shaper name
|
||||
protected etk::Uri propertyShapeHori; //!< Horizontal shaper name
|
||||
public enum scrollingMode {
|
||||
scroolModeNormal, //!< No Zoom , can UP and down, left and right
|
||||
scroolModeCenter, //!< Zoom enable, no move left and right
|
||||
scroolModeGame, //!< Zoom enable, no move left and right
|
||||
};
|
||||
private ewol::compositing::Shaper shaperH; //!< Compositing theme Horizontal.
|
||||
private ewol::compositing::Shaper shaperV; //!< Compositing theme Vertical.
|
||||
protected Vector2f originScrooled = Vector2f.ZERO; //!< pixel distance from the origin of the display (Bottum left)
|
||||
protected Vector2f maxSize; //!< Maximum size of the Widget ==> to display scrollbar
|
||||
protected Vector2f limitScrolling = Vector2f.ZERO; //!< Mimit scrolling represent the propertion of the minimel scrolling activate (0.2 ==> 20% migt all time be visible)
|
||||
// Mouse section :
|
||||
private enum scrollingMode scroollingMode = scrollingMode.scroolModeNormal; //!< mode of management of the scrooling
|
||||
private float pixelScrolling = 20;
|
||||
private Vector2f highSpeedStartPos;
|
||||
private enum Scroll::highSpeedMode highSpeedMode = Scroll::speedModeDisable;
|
||||
private int highSpeedButton = -1;
|
||||
private KeyType highSpeedType = KeyType.unknow;
|
||||
// finger section:
|
||||
private boolean singleFingerMode = true; //!< in many case the moving in a subwidget is done with one finger, it is enought ==> the user select...
|
||||
public
|
||||
/**
|
||||
* Widget to integrate a scrool bar in a widget. This is not a stadalone widget.
|
||||
* Set the single finger capabilities/
|
||||
* @param _status True if single inger mode, two otherwise/
|
||||
*/
|
||||
class WidgetScrolled : public Widget {
|
||||
public: // properties:
|
||||
eproperty::Value<etk::Uri> propertyShapeVert; //!< Vertical shaper name
|
||||
eproperty::Value<etk::Uri> propertyShapeHori; //!< Horizontal shaper name
|
||||
// TODO : All property
|
||||
public:
|
||||
enum scrollingMode {
|
||||
scroolModeNormal, //!< No Zoom , can UP and down, left and right
|
||||
scroolModeCenter, //!< Zoom enable, no move left and right
|
||||
scroolModeGame, //!< Zoom enable, no move left and right
|
||||
};
|
||||
private:
|
||||
ewol::compositing::Shaper this.shaperH; //!< Compositing theme Horizontal.
|
||||
ewol::compositing::Shaper this.shaperV; //!< Compositing theme Vertical.
|
||||
protected:
|
||||
Vector2f this.originScrooled; //!< pixel distance from the origin of the display (Bottum left)
|
||||
Vector2f this.maxSize; //!< Maximum size of the Widget ==> to display scrollbar
|
||||
Vector2f this.limitScrolling; //!< Mimit scrolling represent the propertion of the minimel scrolling activate (0.2 ==> 20% migt all time be visible)
|
||||
private: // Mouse section :
|
||||
enum scrollingMode this.scroollingMode; //!< mode of management of the scrooling
|
||||
float this.pixelScrolling;
|
||||
Vector2f this.highSpeedStartPos;
|
||||
enum Scroll::highSpeedMode this.highSpeedMode;
|
||||
int this.highSpeedButton;
|
||||
KeyType this.highSpeedType;
|
||||
private: // finger section:
|
||||
boolean this.singleFingerMode; //!< in many case the moving in a subwidget is done with one finger, it is enought ==> the user select...
|
||||
public:
|
||||
/**
|
||||
* Set the single finger capabilities/
|
||||
* @param _status True if single inger mode, two otherwise/
|
||||
*/
|
||||
void setSingleFinger(boolean _status);
|
||||
/**
|
||||
* Get the single finger capabilities
|
||||
* @return true The single finger mode is active
|
||||
* @return false The To finger mode is active
|
||||
*/
|
||||
boolean getSingleFinger() {
|
||||
return this.singleFingerMode;
|
||||
}
|
||||
/**
|
||||
* Reset the scoll of the subWidget
|
||||
*/
|
||||
void resetScrollOrigin() {
|
||||
this.originScrooled = Vector2f(0,0);
|
||||
}
|
||||
private:
|
||||
boolean this.fingerPresent[CALCULATE_SIMULTANEOUS_FINGER];
|
||||
boolean this.fingerScoolActivated;
|
||||
Vector2f this.fingerMoveStartPos[CALCULATE_SIMULTANEOUS_FINGER];
|
||||
protected:
|
||||
/**
|
||||
* Scroll Widget main ructor to be herited from an other widget (this is not a stand-alone widget)
|
||||
* @param _shaperName Shaper name if the scrolled widget.
|
||||
*/
|
||||
WidgetScrolled();
|
||||
void init() ;
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(WidgetScrolled, "WidgetScrolled");
|
||||
/**
|
||||
* Scroll widget destructor.
|
||||
*/
|
||||
~WidgetScrolled();
|
||||
protected:
|
||||
void onDraw() ;
|
||||
public:
|
||||
void onRegenerateDisplay() ;
|
||||
boolean onEventInput( ewol::event::Input _event) ;
|
||||
void systemDraw( ewol::DrawProperty _displayProp) ;
|
||||
protected:
|
||||
/**
|
||||
* For mouse event when we have a scrolling UP and dows, specify the number of pixel that we scrooled
|
||||
* @param _nbPixel number of pixel scrolling
|
||||
*/
|
||||
void setScrollingSize(float _nbPixel) {
|
||||
this.pixelScrolling = _nbPixel;
|
||||
};
|
||||
/**
|
||||
* Specify the mode of scrolling for this windows
|
||||
* @param _newMode the selected mode for the scrolling...
|
||||
*/
|
||||
void scroolingMode(enum scrollingMode _newMode);
|
||||
/**
|
||||
* set the specific mawimum size of the widget
|
||||
* @param _localSize new Maximum size
|
||||
*/
|
||||
void setMaxSize( Vector2f _localSize) {
|
||||
this.maxSize = _localSize;
|
||||
};
|
||||
/**
|
||||
* Request a specific position for the scrolling of the current windows.
|
||||
* @param _borderWidth size of the border that requested the element might not to be
|
||||
* @param _currentPosition Position that is requested to view
|
||||
* @param _center True if the position might be at the center of the widget
|
||||
*/
|
||||
void setScrollingPositionDynamic(Vector2f _borderWidth, Vector2f _currentPosition, boolean _center = false);
|
||||
/**
|
||||
* set the scrolling limit when arriving at he end of the widget
|
||||
* @param _poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end ...
|
||||
*/
|
||||
void setLimitScrolling(float _poucentageLimit) {
|
||||
_poucentageLimit = etk::avg(0.1f, _poucentageLimit,1.0f);
|
||||
this.limitScrolling = Vector2f(_poucentageLimit, _poucentageLimit);
|
||||
};
|
||||
/**
|
||||
* set the scrolling limit when arriving at he end of the widget
|
||||
* @param _poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end for axis specific...
|
||||
*/
|
||||
void setLimitScrolling( Vector2f _poucentageLimit) {
|
||||
this.limitScrolling = Vector2f(etk::avg(0.1f, _poucentageLimit.x(),1.0f), etk::avg(0.1f, _poucentageLimit.y(),1.0f));
|
||||
};
|
||||
protected:
|
||||
void onChangePropertyShapeVert();
|
||||
void onChangePropertyShapeHori();
|
||||
};
|
||||
void setSingleFinger(boolean _status);
|
||||
/**
|
||||
* Get the single finger capabilities
|
||||
* @return true The single finger mode is active
|
||||
* @return false The To finger mode is active
|
||||
*/
|
||||
boolean getSingleFinger() {
|
||||
return this.singleFingerMode;
|
||||
}
|
||||
/**
|
||||
* Reset the scoll of the subWidget
|
||||
*/
|
||||
void resetScrollOrigin() {
|
||||
this.originScrooled = Vector2f(0,0);
|
||||
}
|
||||
private boolean fingerPresent[] = {false, false, false, false, false};
|
||||
private boolean fingerScoolActivated = false;
|
||||
private Vector2f fingerMoveStartPos[] = new Vector2f[CALCULATE_SIMULTANEOUS_FINGER];
|
||||
/**
|
||||
* Scroll Widget main ructor to be herited from an other widget (this is not a stand-alone widget)
|
||||
* @param _shaperName Shaper name if the scrolled widget.
|
||||
*/
|
||||
public WidgetScrolled() {
|
||||
onChangePropertyShapeVert();
|
||||
onChangePropertyShapeHori();
|
||||
}
|
||||
protected void onDraw() ;
|
||||
public void onRegenerateDisplay() ;
|
||||
public boolean onEventInput( ewol::event::Input _event) ;
|
||||
public void systemDraw( ewol::DrawProperty _displayProp) ;
|
||||
/**
|
||||
* For mouse event when we have a scrolling UP and dows, specify the number of pixel that we scrooled
|
||||
* @param _nbPixel number of pixel scrolling
|
||||
*/
|
||||
protected void setScrollingSize(float _nbPixel) {
|
||||
this.pixelScrolling = _nbPixel;
|
||||
};
|
||||
/**
|
||||
* Specify the mode of scrolling for this windows
|
||||
* @param _newMode the selected mode for the scrolling...
|
||||
*/
|
||||
protected void scroolingMode(enum scrollingMode _newMode);
|
||||
/**
|
||||
* set the specific mawimum size of the widget
|
||||
* @param _localSize new Maximum size
|
||||
*/
|
||||
protected void setMaxSize( Vector2f _localSize) {
|
||||
this.maxSize = _localSize;
|
||||
};
|
||||
/**
|
||||
* Request a specific position for the scrolling of the current windows.
|
||||
* @param _borderWidth size of the border that requested the element might not to be
|
||||
* @param _currentPosition Position that is requested to view
|
||||
* @param _center True if the position might be at the center of the widget
|
||||
*/
|
||||
protected void setScrollingPositionDynamic(Vector2f _borderWidth, Vector2f _currentPosition, boolean _center = false);
|
||||
/**
|
||||
* set the scrolling limit when arriving at he end of the widget
|
||||
* @param _poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end ...
|
||||
*/
|
||||
protected void setLimitScrolling(float _poucentageLimit) {
|
||||
_poucentageLimit = etk::avg(0.1f, _poucentageLimit,1.0f);
|
||||
this.limitScrolling = Vector2f(_poucentageLimit, _poucentageLimit);
|
||||
};
|
||||
/**
|
||||
* set the scrolling limit when arriving at he end of the widget
|
||||
* @param _poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end for axis specific...
|
||||
*/
|
||||
protected void setLimitScrolling( Vector2f _poucentageLimit) {
|
||||
this.limitScrolling = Vector2f(etk::avg(0.1f, _poucentageLimit.x(),1.0f), etk::avg(0.1f, _poucentageLimit.y(),1.0f));
|
||||
};
|
||||
protected void onChangePropertyShapeVert();
|
||||
protected void onChangePropertyShapeHori();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package sample.atriasoft.ewol.sampleButton;
|
||||
|
||||
import org.atriasoft.etk.math.Vector3b;
|
||||
import org.atriasoft.ewol.widget.Button;
|
||||
import org.atriasoft.ewol.widget.Composer;
|
||||
import org.atriasoft.ewol.widget.Widget;
|
||||
|
||||
import sample.atriasoft.ewol.BasicWindows;
|
||||
|
||||
@ -9,10 +9,18 @@ public class MainWindows extends BasicWindows {
|
||||
|
||||
public MainWindows() {
|
||||
setPropertyTitle("Simple Button test");
|
||||
//final Widget data = Composer.composerGenerateString("<Composer><Label>hello, how are you</Label></Composer>");
|
||||
//final Widget data = Composer.composerGenerateString("<Composer><Button><Label gravity=\"center\">hello, how are you</Label></Button></Composer>");
|
||||
final Widget data = Composer.composerGenerateString("<Composer><Button toggle='true' fill='true,false,false' expand='true'>" + "<Label>hello, how are you</Label>"
|
||||
+ "<Label>You <br/>Click - Me <b>!!!</b></Label>" + "</Button></Composer>");
|
||||
this.setTestWidget(data);
|
||||
/*
|
||||
final Button simpleButton = Button
|
||||
.createLabelButton("1 - My <font color=\"red\">button <i>internal</i></font> <br/>2 - <b>label</b><br/>3 - an other text ...<br/>4 - and an other line to be sure ...");
|
||||
simpleButton.setPropertyExpand(Vector3b.TRUE);
|
||||
simpleButton.setPropertyFill(Vector3b.FALSE);
|
||||
this.setTestWidget(simpleButton);
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import org.atriasoft.etk.Configs;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.ewol.context.EwolApplication;
|
||||
import org.atriasoft.ewol.context.EwolContext;
|
||||
import org.atriasoft.ewol.widget.MainWindows;
|
||||
|
||||
import sample.atriasoft.ewol.Log;
|
||||
|
||||
|
@ -2,6 +2,7 @@ package sample.atriasoft.ewol.sampleEntry;
|
||||
|
||||
import org.atriasoft.etk.Uri;
|
||||
import org.atriasoft.ewol.Ewol;
|
||||
import org.atriasoft.ewol.widget.MainWindows;
|
||||
|
||||
public class SampleEntryMain {
|
||||
public static void main(final String[] args) {
|
||||
|
10
src/org/atriasoft/ewol/HighSpeedMode.java
Normal file
10
src/org/atriasoft/ewol/HighSpeedMode.java
Normal file
@ -0,0 +1,10 @@
|
||||
package org.atriasoft.ewol;
|
||||
|
||||
public enum HighSpeedMode {
|
||||
speedModeDisable, //
|
||||
speedModeInit, //
|
||||
speedModeEnableFinger, // Specific for touchpad
|
||||
speedModeEnableHorizontal, // Specific for mouse
|
||||
speedModeEnableVertical, // Specific for mouse
|
||||
speedModeGrepEndEvent
|
||||
}
|
@ -78,7 +78,7 @@ public class EwolContext extends GaleApplication {
|
||||
}
|
||||
|
||||
public void forceRedrawAllAsync() {
|
||||
Log.warning("force redraw ALL (ASYNC):");
|
||||
Log.verbose("force redraw ALL (ASYNC):");
|
||||
GaleContext.getContext().requestUpdateSize();
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import org.atriasoft.ewol.annotation.EwolDescription;
|
||||
import org.atriasoft.ewol.context.EwolContext;
|
||||
import org.atriasoft.ewol.internal.Log;
|
||||
import org.atriasoft.exml.annotation.XmlAttribute;
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
import org.atriasoft.exml.annotation.XmlDefaultManaged;
|
||||
import org.atriasoft.exml.annotation.XmlDefaultOptional;
|
||||
import org.atriasoft.exml.annotation.XmlIgnoreUnknow;
|
||||
@ -25,6 +26,7 @@ import org.atriasoft.exml.annotation.XmlName;
|
||||
*/
|
||||
@XmlDefaultManaged(value = false)
|
||||
@XmlDefaultOptional
|
||||
@XmlDefaultAttibute
|
||||
@XmlIgnoreUnknow
|
||||
public class EwolObject {
|
||||
private static Integer valUID = 0; //!< Static used for the unique ID definition
|
||||
|
@ -222,7 +222,7 @@ public class ResourceTexturedFont extends ResourceTexture2 {
|
||||
this.listElement[iii].add(tmpchar);
|
||||
}
|
||||
if (hasChange) {
|
||||
Log.error("All gliph added ====> request a redraw of all the GUI");
|
||||
Log.verbose("All gliph added ====> request a redraw of all the GUI");
|
||||
flush();
|
||||
Ewol.getContext().forceRedrawAllAsync();
|
||||
//IOgami.storePNG(new Uri("file", "fileFont.png"), this.data); // ==> for debug test only ...
|
||||
|
773
src/org/atriasoft/ewol/widget/Composer.java
Normal file
773
src/org/atriasoft/ewol/widget/Composer.java
Normal file
@ -0,0 +1,773 @@
|
||||
/*
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
package org.atriasoft.ewol.widget;
|
||||
|
||||
import org.atriasoft.etk.Dimension3f;
|
||||
import org.atriasoft.etk.Uri;
|
||||
import org.atriasoft.etk.math.Vector3b;
|
||||
import org.atriasoft.etk.math.Vector3f;
|
||||
import org.atriasoft.ewol.DrawProperty;
|
||||
import org.atriasoft.ewol.Gravity;
|
||||
import org.atriasoft.ewol.annotation.EwolDescription;
|
||||
import org.atriasoft.ewol.internal.Log;
|
||||
import org.atriasoft.ewol.object.EwolObject;
|
||||
import org.atriasoft.exml.Exml;
|
||||
import org.atriasoft.exml.annotation.XmlAttribute;
|
||||
import org.atriasoft.exml.annotation.XmlManaged;
|
||||
import org.atriasoft.exml.annotation.XmlName;
|
||||
import org.atriasoft.exml.exception.ExmlException;
|
||||
import org.atriasoft.exml.model.XmlElement;
|
||||
import org.atriasoft.gale.context.ClipboardList;
|
||||
import org.atriasoft.gale.context.Cursor;
|
||||
import org.atriasoft.gale.key.KeyKeyboard;
|
||||
import org.atriasoft.gale.key.KeySpecial;
|
||||
|
||||
/**
|
||||
* the composer widget is a widget that create a link on a string.file to parse the data and generate some widget tree
|
||||
*/
|
||||
public class Composer extends Container {
|
||||
public static Widget composerGenerateFile(final Uri data) {
|
||||
return composerGenerateFile(data, 0);
|
||||
}
|
||||
|
||||
public static Widget composerGenerateFile(final Uri uri, final long id) {
|
||||
|
||||
final byte[] elemData = Uri.getAllData(uri);
|
||||
if (elemData == null) {
|
||||
Log.error("Can not read the Stream : " + uri);
|
||||
return null;
|
||||
}
|
||||
final String dataToParse = new String(elemData);
|
||||
return composerGenerateString(dataToParse, id);
|
||||
/*
|
||||
String tmpData;
|
||||
if (etk::uri::readAll(_uri, tmpData) == false) {
|
||||
Log.error("Can not read the file: " + _uri);
|
||||
return null;
|
||||
}
|
||||
return ewol::widget::composerGenerateString(tmpData, _id);
|
||||
*/
|
||||
}
|
||||
|
||||
public static Widget composerGenerateString(final String data) {
|
||||
return composerGenerateString(data, 0);
|
||||
}
|
||||
|
||||
public static Widget composerGenerateString(final String data, final long id) {
|
||||
Widget[] result = null;
|
||||
try {
|
||||
result = Exml.parse(data, Composer.class, "Composer");//new WidgetXmlFactory());
|
||||
} catch (final ExmlException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return result[0];
|
||||
/*
|
||||
ewol::widget::Manager widgetManager = ewol::getContext().getWidgetManager();
|
||||
if (_data == "") {
|
||||
return null;
|
||||
}
|
||||
exml::Document doc;
|
||||
String tmpData = _data;
|
||||
// replace all elements:
|
||||
if (_id != 0) {
|
||||
tmpData.replace("{ID}", etk::toString(_id));
|
||||
}
|
||||
if (doc.parse(tmpData) == false) {
|
||||
Log.error(" can not load file XML string...");
|
||||
return null;
|
||||
}
|
||||
exml::Element root = doc.toElement();
|
||||
if (root.nodes.size() == 0) {
|
||||
Log.error(" (l ?) No node in the XML file/string.");
|
||||
return null;
|
||||
}
|
||||
if (root.nodes.size() > 1) {
|
||||
Log.warning(" (l ?) More than 1 node in the XML file/string. (JUST parse the first)");
|
||||
}
|
||||
exml::Element pNode = root.nodes[0].toElement();
|
||||
if (pNode.exist() == false) {
|
||||
Log.error(" (l ?) No node in the XML file/string. {2}");
|
||||
return null;
|
||||
}
|
||||
String widgetName = pNode.getValue();
|
||||
if (widgetManager.exist(widgetName) == false) {
|
||||
Log.error("(l " + pNode.getPos() + ") Unknown basic node='" + widgetName + "' not in : [" + widgetManager.list() + "]" );
|
||||
return null;
|
||||
}
|
||||
Log.debug("try to create subwidget : '" + widgetName + "'");
|
||||
Widget tmpWidget = widgetManager.create(widgetName);
|
||||
if (tmpWidget == null) {
|
||||
EWOL_ERROR ("(l " + pNode.getPos() + ") Can not create the widget : '" + widgetName + "'");
|
||||
return null;
|
||||
}
|
||||
if (tmpWidget.loadXML(pNode) == false) {
|
||||
EWOL_ERROR ("(l " + pNode.getPos() + ") can not load widget properties : '" + widgetName + "'");
|
||||
}
|
||||
return tmpWidget;
|
||||
*/
|
||||
}
|
||||
|
||||
protected boolean propertyRemoveIfUnderRemove; //!< Remove the composer if sub element request a remove
|
||||
|
||||
protected Uri propertySubFile; //!< If loading a sub-file, we must do it here ==> permit to configure it in the xml and not have wrong display
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public Composer() {
|
||||
// nothing to do...
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateMinMaxSize() {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.calculateMinMaxSize();
|
||||
return;
|
||||
}
|
||||
super.calculateMinMaxSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateSize() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.calculateSize();
|
||||
return;
|
||||
}
|
||||
super.calculateSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3b canExpand() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.canExpand();
|
||||
}
|
||||
return super.canExpand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3b canExpandIfFree() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.canExpandIfFree();
|
||||
}
|
||||
return super.canExpandIfFree();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3b canFill() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.canFill();
|
||||
}
|
||||
return super.canFill();
|
||||
}
|
||||
|
||||
@Override
|
||||
void changeZoom(final float range) {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.changeZoom(range);
|
||||
return;
|
||||
}
|
||||
super.changeZoom(range);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkMaxSize() {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.checkMaxSize();
|
||||
return;
|
||||
}
|
||||
super.checkMaxSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkMinSize() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.checkMinSize();
|
||||
return;
|
||||
}
|
||||
super.checkMinSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3f getCalculateMaxSize() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getCalculateMaxSize();
|
||||
}
|
||||
return super.getCalculateMaxSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3f getCalculateMinSize() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getCalculateMinSize();
|
||||
}
|
||||
return super.getCalculateMinSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor getCursor() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getCursor();
|
||||
}
|
||||
return super.getCursor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGrabStatus() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getGrabStatus();
|
||||
}
|
||||
return super.getGrabStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getKeyboardRepeat() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getKeyboardRepeat();
|
||||
}
|
||||
return super.getKeyboardRepeat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMouseLimit() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getMouseLimit();
|
||||
}
|
||||
return super.getMouseLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
Vector3f getOffset() {
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getOffset();
|
||||
}
|
||||
return super.getOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3f getOrigin() {
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getOrigin();
|
||||
}
|
||||
return super.getOrigin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPropertyCanFocus() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getPropertyCanFocus();
|
||||
}
|
||||
return super.getPropertyCanFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3b getPropertyExpand() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getPropertyExpand();
|
||||
}
|
||||
return super.getPropertyExpand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3b getPropertyExpandIfFree() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getPropertyExpandIfFree();
|
||||
}
|
||||
return super.getPropertyExpandIfFree();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3b getPropertyFill() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getPropertyFill();
|
||||
}
|
||||
return super.getPropertyFill();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Gravity getPropertyGravity() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getPropertyGravity();
|
||||
}
|
||||
return super.getPropertyGravity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPropertyHide() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getPropertyHide();
|
||||
}
|
||||
return super.getPropertyHide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension3f getPropertyMaxSize() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getPropertyMaxSize();
|
||||
}
|
||||
return super.getPropertyMaxSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension3f getPropertyMinSize() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getPropertyMinSize();
|
||||
}
|
||||
return super.getPropertyMinSize();
|
||||
}
|
||||
|
||||
@XmlManaged
|
||||
@XmlAttribute
|
||||
@XmlName(value = "sub-file")
|
||||
@EwolDescription(value = "compose with a subXML file")
|
||||
public Uri getPropertySubFile() {
|
||||
return this.propertySubFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3f getSize() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getSize();
|
||||
}
|
||||
return super.getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EwolObject getSubObjectNamed(final String objectName) {
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getSubObjectNamed(objectName);
|
||||
}
|
||||
return super.getSubObjectNamed(objectName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getZoom() {
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getZoom();
|
||||
}
|
||||
return super.getZoom();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void grabCursor() {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.grabCursor();
|
||||
return;
|
||||
}
|
||||
super.grabCursor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFocused() {
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.isFocused();
|
||||
}
|
||||
return super.isFocused();
|
||||
}
|
||||
|
||||
@XmlManaged
|
||||
@XmlAttribute
|
||||
@XmlName(value = "remove-if-under-remove")
|
||||
@EwolDescription(value = "Demand the remove iof the widget if the subObject demand a remove")
|
||||
public boolean isPropertyRemoveIfUnderRemove() {
|
||||
return this.propertyRemoveIfUnderRemove;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keepFocus() {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.keepFocus();
|
||||
return;
|
||||
}
|
||||
super.keepFocus();
|
||||
}
|
||||
|
||||
/**
|
||||
* load a composition with a file
|
||||
* @param _uri Name of the file
|
||||
* @param _id Unique ID that is used in replacing the balise "{ID}" inside the File (do nothing if == 0)
|
||||
* @return true == > all done OK
|
||||
* @return false == > some error occured
|
||||
*/
|
||||
public boolean loadFromFile(final Uri uri) {
|
||||
return loadFromFile(uri, 0);
|
||||
}
|
||||
|
||||
public boolean loadFromFile(final Uri uri, final long id) {
|
||||
/*
|
||||
String tmpData;
|
||||
if (etk::uri::readAll(_uri, tmpData) == false) {
|
||||
Log.error("Can not read the file: " + _uri);
|
||||
return false;
|
||||
}
|
||||
return loadFromString(tmpData, _id);
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* load a composition with a file
|
||||
* @param composerXmlString xml to parse directly
|
||||
* @param id Unique ID that is used in replacing the balise "{ID}" inside the String (do nothing if == 0)
|
||||
* @return true == > all done OK
|
||||
* @return false == > some error occured
|
||||
*/
|
||||
public boolean loadFromString(final String composerXmlString, final long id) {
|
||||
return false;
|
||||
/*
|
||||
XmlElement doc;
|
||||
String tmpData = _composerXmlString;
|
||||
// replace all elements:
|
||||
if (_id != 0) {
|
||||
tmpData.replace("{ID}", Long.toString(_id));
|
||||
}
|
||||
if (doc.parse(tmpData) == false) {
|
||||
Log.error(" can not load file XML string...");
|
||||
return false;
|
||||
}
|
||||
XmlElement root = doc.nodes["composer"];
|
||||
if (root.exist() == false) {
|
||||
// Maybe a multiple node XML for internal config:
|
||||
root = doc.toElement();
|
||||
if (root.exist() == false) {
|
||||
Log.error("[" + getId() + "] {" + getObjectType() + "} (l ?) main node not find: 'composer' ...");
|
||||
return false;
|
||||
}
|
||||
if (root.nodes.size() == 0) {
|
||||
Log.error("[" + getId() + "] {" + getObjectType() + "} (l ?) no node in the Container XML element.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// call upper class to parse his elements ...
|
||||
super.loadXML(root);
|
||||
if (this.subWidget == null) {
|
||||
Log.warning("Load data from composer and have no under Widget after loading");
|
||||
if (_composerXmlString.size() != 0) {
|
||||
Log.error("Error Loading XML data : " + _composerXmlString);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
requestUpdateSize();
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
|
||||
public boolean loadXML(final XmlElement node) {
|
||||
/*
|
||||
//Log.verbose("[" + getId() + "] t=" + getObjectType() + " Load XML (start)");
|
||||
if (_node != null) {
|
||||
return false;
|
||||
}
|
||||
// parse generic properties:
|
||||
super.loadXML(_node);
|
||||
// parse all the elements:
|
||||
if (_node.nodes.size() != 0) {
|
||||
Log.error("a composer Node Can not have Sub-element in XML ==> must be done in an external file and load it with attribute: 'sub-file'");
|
||||
}
|
||||
//drawWidgetTree();
|
||||
//Log.verbose("[" + getId() + "] t=" + getObjectType() + " Load XML (stop)");
|
||||
*
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markToRedraw() {
|
||||
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.calculateMinMaxSize();
|
||||
return;
|
||||
}
|
||||
super.markToRedraw();
|
||||
}
|
||||
|
||||
protected void onChangePropertySubFile() {
|
||||
Log.info("Load compositing form external file : " + this.propertySubFile);
|
||||
if (this.propertySubFile.isEmpty()) {
|
||||
// remove all elements:
|
||||
subWidgetRemove();
|
||||
return;
|
||||
}
|
||||
if (!loadFromFile(this.propertySubFile, getId())) {
|
||||
Log.error("Can not load Player GUI from file ... " + this.propertySubFile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeSize() {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.onChangeSize();
|
||||
return;
|
||||
}
|
||||
super.onChangeSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEventClipboard(final ClipboardList clipboardID) {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.onEventClipboard(clipboardID);
|
||||
return;
|
||||
}
|
||||
super.onEventClipboard(clipboardID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onEventShortCut(final KeySpecial special, final Character unicodeValue, final KeyKeyboard kbMove, final boolean isDown) {
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.onEventShortCut(special, unicodeValue, kbMove, isDown);
|
||||
}
|
||||
return super.onEventShortCut(special, unicodeValue, kbMove, isDown);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.onRegenerateDisplay();
|
||||
return;
|
||||
}
|
||||
super.onRegenerateDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3f relativePosition(final Vector3f pos) {
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.relativePosition(pos);
|
||||
}
|
||||
return super.relativePosition(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestDestroyFromChild(final EwolObject child) {
|
||||
super.requestDestroyFromChild(child);
|
||||
if (this.propertyRemoveIfUnderRemove) {
|
||||
Log.debug("Child widget remove ==> auto-remove");
|
||||
autoDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestUpdateSize() {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.requestUpdateSize();
|
||||
return;
|
||||
}
|
||||
super.requestUpdateSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rmFocus() {
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.rmFocus();
|
||||
}
|
||||
return super.rmFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCursor(final Cursor newCursor) {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setCursor(newCursor);
|
||||
return;
|
||||
}
|
||||
super.setCursor(newCursor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setFocus() {
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.setFocus();
|
||||
}
|
||||
return super.setFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMouseLimit(final int numberState) {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setMouseLimit(numberState);
|
||||
return;
|
||||
}
|
||||
super.setMouseLimit(numberState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoMaxSize() {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setNoMaxSize();
|
||||
return;
|
||||
}
|
||||
super.setNoMaxSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoMinSize() {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setNoMinSize();
|
||||
return;
|
||||
}
|
||||
super.setNoMinSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOffset(final Vector3f newVal) {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(newVal);
|
||||
return;
|
||||
}
|
||||
super.setOffset(newVal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrigin(final Vector3f pos) {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOrigin(pos);
|
||||
return;
|
||||
}
|
||||
super.setOrigin(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPropertyCanFocus(final boolean canFocus) {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setPropertyCanFocus(canFocus);
|
||||
return;
|
||||
}
|
||||
super.setPropertyCanFocus(canFocus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPropertyExpand(final Vector3b value) {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setPropertyExpand(value);
|
||||
return;
|
||||
}
|
||||
super.setPropertyExpand(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPropertyExpandIfFree(final Vector3b value) {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setPropertyExpandIfFree(value);
|
||||
return;
|
||||
}
|
||||
super.setPropertyExpandIfFree(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPropertyFill(final Vector3b value) {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setPropertyFill(value);
|
||||
return;
|
||||
}
|
||||
super.setPropertyFill(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPropertyGravity(final Gravity gravity) {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setPropertyGravity(gravity);
|
||||
return;
|
||||
}
|
||||
super.setPropertyGravity(gravity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPropertyHide(final boolean value) {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setPropertyHide(value);
|
||||
return;
|
||||
}
|
||||
super.setPropertyHide(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPropertyMaxSize(final Dimension3f value) {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setPropertyMaxSize(value);
|
||||
return;
|
||||
}
|
||||
super.setPropertyMaxSize(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPropertyMinSize(final Dimension3f value) {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setPropertyMinSize(value);
|
||||
return;
|
||||
}
|
||||
super.setPropertyMinSize(value);
|
||||
}
|
||||
|
||||
public void setPropertyRemoveIfUnderRemove(final boolean propertyRemoveIfUnderRemove) {
|
||||
if (this.propertyRemoveIfUnderRemove == propertyRemoveIfUnderRemove) {
|
||||
return;
|
||||
}
|
||||
this.propertyRemoveIfUnderRemove = propertyRemoveIfUnderRemove;
|
||||
}
|
||||
|
||||
public void setPropertySubFile(final Uri propertySubFile) {
|
||||
if (this.propertySubFile.equals(propertySubFile)) {
|
||||
return;
|
||||
}
|
||||
this.propertySubFile = propertySubFile;
|
||||
onChangePropertySubFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(final Vector3f value) {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setSize(value);
|
||||
return;
|
||||
}
|
||||
super.setSize(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZoom(final float newVal) {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setZoom(newVal);
|
||||
return;
|
||||
}
|
||||
super.setZoom(newVal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void systemDraw(final DrawProperty displayProp) {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.systemDraw(displayProp);
|
||||
return;
|
||||
}
|
||||
super.systemDraw(displayProp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unGrabCursor() {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.unGrabCursor();
|
||||
return;
|
||||
}
|
||||
super.unGrabCursor();
|
||||
}
|
||||
|
||||
}
|
@ -8,8 +8,12 @@ package org.atriasoft.ewol.widget;
|
||||
import org.atriasoft.etk.math.Vector3b;
|
||||
import org.atriasoft.etk.math.Vector3f;
|
||||
import org.atriasoft.ewol.DrawProperty;
|
||||
import org.atriasoft.ewol.annotation.EwolDescription;
|
||||
import org.atriasoft.ewol.internal.Log;
|
||||
import org.atriasoft.ewol.object.EwolObject;
|
||||
import org.atriasoft.exml.annotation.XmlAttribute;
|
||||
import org.atriasoft.exml.annotation.XmlFactory;
|
||||
import org.atriasoft.exml.annotation.XmlManaged;
|
||||
|
||||
/*
|
||||
* @ingroup ewolWidgetGroup
|
||||
@ -61,6 +65,10 @@ public class Container extends Widget {
|
||||
* get the main node widget
|
||||
* @return the requested pointer on the node
|
||||
*/
|
||||
@XmlManaged
|
||||
@XmlAttribute(false)
|
||||
@XmlFactory(WidgetXmlFactory.class)
|
||||
@EwolDescription(value = "Sub-node with multiple names...")
|
||||
public Widget getSubWidget() {
|
||||
return this.subWidget;
|
||||
}
|
||||
|
@ -267,6 +267,12 @@ public class ContainerToggle extends Widget {
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
public void setSubWidgets(final Widget[] newWidget) {
|
||||
for (int iii = 0; iii < Math.min(newWidget.length, 2); iii++) {
|
||||
setSubWidget(newWidget[iii], iii);
|
||||
}
|
||||
}
|
||||
|
||||
public void subWidgetRemove(final int idWidget) {
|
||||
if (this.subWidget[idWidget] != null) {
|
||||
Log.verbose("Remove widget : " + idWidget);
|
||||
|
@ -21,6 +21,7 @@ import org.atriasoft.ewol.resource.ResourceColorFile;
|
||||
import org.atriasoft.exml.annotation.XmlAttribute;
|
||||
import org.atriasoft.exml.annotation.XmlManaged;
|
||||
import org.atriasoft.exml.annotation.XmlName;
|
||||
import org.atriasoft.exml.annotation.XmlText;
|
||||
import org.atriasoft.gale.key.KeyStatus;
|
||||
|
||||
public class Label extends Widget {
|
||||
@ -210,8 +211,8 @@ public class Label extends Widget {
|
||||
}
|
||||
|
||||
@XmlManaged
|
||||
@XmlAttribute
|
||||
@XmlName(value = "value")
|
||||
@XmlText
|
||||
@XmlName(value = "ZZZZZZZZZ-ploppppppp")
|
||||
@EwolDescription(value = "Displayed value string")
|
||||
public void setPropertyValue(final String propertyValue) {
|
||||
if (this.propertyValue.equals(propertyValue)) {
|
||||
|
44
src/org/atriasoft/ewol/widget/Layer.java
Normal file
44
src/org/atriasoft/ewol/widget/Layer.java
Normal file
@ -0,0 +1,44 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2020, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
package org.atriasoft.ewol.widget;
|
||||
|
||||
import org.atriasoft.etk.math.Vector3f;
|
||||
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
*/
|
||||
class Layer extends ContainerN {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public Layer() {
|
||||
// nothing to do.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Widget getWidgetAtPos(final Vector3f pos) {
|
||||
if (this.propertyHide) {
|
||||
return null;
|
||||
}
|
||||
// for all element in the sizer ...
|
||||
for (final Widget it : this.subWidget) {
|
||||
if (it == null) {
|
||||
continue;
|
||||
}
|
||||
final Vector3f tmpSize = it.getSize();
|
||||
final Vector3f tmpOrigin = it.getOrigin();
|
||||
if ((tmpOrigin.x() <= pos.x() && tmpOrigin.x() + tmpSize.x() >= pos.x()) && (tmpOrigin.y() <= pos.y() && tmpOrigin.y() + tmpSize.y() >= pos.y())) {
|
||||
final Widget tmpWidget = it.getWidgetAtPos(pos);
|
||||
if (tmpWidget != null) {
|
||||
return tmpWidget;
|
||||
}
|
||||
// parse the next layer ...
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
475
src/org/atriasoft/ewol/widget/Scroll.java
Normal file
475
src/org/atriasoft/ewol/widget/Scroll.java
Normal file
@ -0,0 +1,475 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2020, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
package org.atriasoft.ewol.widget;
|
||||
|
||||
import org.atriasoft.etk.Uri;
|
||||
import org.atriasoft.etk.math.FMath;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.etk.math.Vector3b;
|
||||
import org.atriasoft.etk.math.Vector3f;
|
||||
import org.atriasoft.ewol.DrawProperty;
|
||||
import org.atriasoft.ewol.GravityVertical;
|
||||
import org.atriasoft.ewol.HighSpeedMode;
|
||||
import org.atriasoft.ewol.Padding;
|
||||
import org.atriasoft.ewol.annotation.EwolDescription;
|
||||
import org.atriasoft.ewol.compositing.GuiShape;
|
||||
import org.atriasoft.ewol.event.EventInput;
|
||||
import org.atriasoft.ewol.internal.Log;
|
||||
import org.atriasoft.exml.annotation.XmlAttribute;
|
||||
import org.atriasoft.exml.annotation.XmlManaged;
|
||||
import org.atriasoft.exml.annotation.XmlName;
|
||||
import org.atriasoft.gale.key.KeyStatus;
|
||||
import org.atriasoft.gale.key.KeyType;
|
||||
|
||||
class Scroll extends Container {
|
||||
protected static final int SCROLL_BAR_SPACE = 15;
|
||||
protected Vector3f propertyLimit = new Vector3f(0.15f, 0.5f, 0.0f); //!< Set the limitation of the ratio in the screen
|
||||
|
||||
protected Uri propertyShapeVert = new Uri("THEME_GUI", "WidgetScrolled.json", "ewol"); //!< Vertical shaper name
|
||||
|
||||
protected Uri propertyShapeHori = new Uri("THEME_GUI", "WidgetScrolled.json", "ewol"); //!< Horizontal shaper name
|
||||
|
||||
protected boolean propertyHover = true; //!< Horizontal shaper name
|
||||
|
||||
protected GuiShape shaperH; //!< Compositing theme Horizontal.
|
||||
|
||||
protected GuiShape shaperV; //!< Compositing theme Vertical.
|
||||
protected float pixelScrolling = 20;
|
||||
protected Vector3f highSpeedStartPos = Vector3f.ZERO;
|
||||
protected HighSpeedMode highSpeedMode = HighSpeedMode.speedModeDisable;
|
||||
protected int highSpeedButton = -1;
|
||||
protected KeyType highSpeedType = KeyType.unknow;
|
||||
|
||||
public Scroll() {
|
||||
/*
|
||||
// Remove gravity property: (only keep top/buttom)
|
||||
propertyGravity.remove("center");
|
||||
propertyGravity.remove("top-left");
|
||||
//propertyGravity.remove("top");
|
||||
propertyGravity.remove("top-right");
|
||||
propertyGravity.remove("right");
|
||||
propertyGravity.remove("buttom-right");
|
||||
//propertyGravity.remove("buttom");
|
||||
propertyGravity.remove("buttom-left");
|
||||
propertyGravity.remove("left");
|
||||
*/
|
||||
onChangePropertyShapeVert();
|
||||
onChangePropertyShapeHori();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateMinMaxSize() {
|
||||
// Note: No call of container ==> normal case ...
|
||||
super.calculateMinMaxSize();
|
||||
// call sub classes
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.calculateMinMaxSize();
|
||||
}
|
||||
}
|
||||
|
||||
@XmlManaged
|
||||
@XmlAttribute
|
||||
@XmlName(value = "limit")
|
||||
@EwolDescription(value = "Limit the scroll maximum position [0..1]% represent the free space in the scoll when arrive at the end")
|
||||
public Vector3f getPropertyLimit() {
|
||||
return this.propertyLimit;
|
||||
}
|
||||
|
||||
@XmlManaged
|
||||
@XmlAttribute
|
||||
@XmlName(value = "shape-hori")
|
||||
@EwolDescription(value = "shape for the horizontal display")
|
||||
public Uri getPropertyShapeHori() {
|
||||
return this.propertyShapeHori;
|
||||
}
|
||||
|
||||
@XmlManaged
|
||||
@XmlAttribute
|
||||
@XmlName(value = "shape-vert")
|
||||
@EwolDescription(value = "shape for the vertical display")
|
||||
public Uri getPropertyShapeVert() {
|
||||
return this.propertyShapeVert;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Widget getWidgetAtPos(final Vector3f pos) {
|
||||
final Widget tmpWidget = super.getWidgetAtPos(pos);
|
||||
if (tmpWidget != null) {
|
||||
return tmpWidget;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@XmlManaged
|
||||
@XmlAttribute
|
||||
@XmlName(value = "hover")
|
||||
@EwolDescription(value = "The display bar are hover the subWidget")
|
||||
public boolean isPropertyHover() {
|
||||
return this.propertyHover;
|
||||
}
|
||||
|
||||
void onChangePropertyLimit() {
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
protected void onChangePropertyShapeHori() {
|
||||
this.shaperH.setSource(this.propertyShapeHori);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
protected void onChangePropertyShapeVert() {
|
||||
this.shaperV.setSource(this.propertyShapeVert);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeSize() {
|
||||
// Note: No call of container ==> normal case ...
|
||||
super.onChangeSize();
|
||||
if (this.propertyHide) {
|
||||
return;
|
||||
}
|
||||
if (this.subWidget == null) {
|
||||
return;
|
||||
}
|
||||
// remove the bar if hover
|
||||
Vector3f basicSize = this.size;
|
||||
if (!this.propertyHover) {
|
||||
basicSize = basicSize.less(SCROLL_BAR_SPACE, SCROLL_BAR_SPACE, SCROLL_BAR_SPACE);
|
||||
}
|
||||
|
||||
Vector3f origin = this.origin.add(this.offset);
|
||||
Vector3f minSize = this.subWidget.getCalculateMinSize();
|
||||
final Vector3b expand = this.subWidget.propertyExpand;
|
||||
//The gravity is not set on the sub element ==> special use of the widget
|
||||
//origin += ewol::gravityGenerateDelta(propertyGravity.get(), minSize - this.size);
|
||||
if (expand.x() && minSize.x() < basicSize.x()) {
|
||||
minSize = minSize.withX(basicSize.x());
|
||||
}
|
||||
if (expand.y() && minSize.y() < basicSize.y()) {
|
||||
minSize = minSize.withY(basicSize.y());
|
||||
}
|
||||
this.subWidget.setSize(minSize);
|
||||
if (this.propertyGravity.y() == GravityVertical.TOP) {
|
||||
origin = origin.add(0.0f, basicSize.y() - minSize.y(), 0);
|
||||
if (!this.propertyHover) {
|
||||
origin = origin.add(0, SCROLL_BAR_SPACE, 0);
|
||||
}
|
||||
} else if (this.propertyGravity.y() == GravityVertical.BOTTOM) {
|
||||
// nothing to do ... origin +=
|
||||
} else {
|
||||
Log.error(" Not manage other gravity ...");
|
||||
}
|
||||
this.subWidget.setOrigin(origin);
|
||||
this.subWidget.onChangeSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw() {
|
||||
this.shaperH.draw();
|
||||
this.shaperV.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onEventInput(final EventInput event) {
|
||||
//ewol::event::Input _event = event;
|
||||
//_event.setType(KeyType.finger);
|
||||
Vector3f relativePos = relativePosition(new Vector3f(event.pos().x(), event.pos().y(), 0));
|
||||
Vector3f scrollOffset = Vector3f.ZERO;
|
||||
Vector3f scrollSize = Vector3f.ZERO;
|
||||
if (this.subWidget != null) {
|
||||
scrollOffset = this.subWidget.getOffset();
|
||||
scrollSize = this.subWidget.getSize();
|
||||
}
|
||||
Log.verbose("Get Event on scroll : " + event);
|
||||
relativePos = relativePos.withY(this.size.y() - relativePos.y());
|
||||
if (event.type() == KeyType.mouse && (this.highSpeedType == KeyType.unknow || this.highSpeedType == KeyType.mouse)) {
|
||||
if (event.inputId() == 1 && event.status() == KeyStatus.down) {
|
||||
// check if selected the scrolling position whth the scrolling bar ...
|
||||
if (relativePos.x() >= (this.size.x() - SCROLL_BAR_SPACE)) {
|
||||
if (this.size.y() < scrollSize.y() || scrollOffset.y() != 0) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeEnableVertical;
|
||||
this.highSpeedType = KeyType.mouse;
|
||||
this.highSpeedStartPos = this.highSpeedStartPos.withX(relativePos.x());
|
||||
this.highSpeedStartPos = this.highSpeedStartPos.withY(scrollOffset.y() / scrollSize.y() * (this.size.y() - SCROLL_BAR_SPACE * 2));
|
||||
this.highSpeedButton = 1;
|
||||
// force direct scrolling in this case
|
||||
scrollOffset = scrollOffset.withY((int) (scrollSize.y() * (relativePos.y() - SCROLL_BAR_SPACE) / (this.size.y() - SCROLL_BAR_SPACE * 2)));
|
||||
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y() * this.propertyLimit.y())));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else if (relativePos.y() >= (this.size.y() - SCROLL_BAR_SPACE)) {
|
||||
if (this.size.x() < scrollSize.x() || scrollOffset.x() != 0) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
|
||||
this.highSpeedType = KeyType.mouse;
|
||||
this.highSpeedStartPos = this.highSpeedStartPos.withX(scrollOffset.x() / scrollSize.x() * (this.size.x() - SCROLL_BAR_SPACE * 2));
|
||||
this.highSpeedStartPos = this.highSpeedStartPos.withY(relativePos.y());
|
||||
this.highSpeedButton = 1;
|
||||
// force direct scrolling in this case
|
||||
scrollOffset = scrollOffset.withX((int) (scrollSize.x() * (relativePos.x() - SCROLL_BAR_SPACE) / (this.size.x() - SCROLL_BAR_SPACE * 2)));
|
||||
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.x(), (scrollSize.x() - this.size.x() * this.propertyLimit.x())));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (event.inputId() == 4 && event.status() == KeyStatus.up) {
|
||||
Log.verbose(" mode UP " + this.size.y() + "<" + scrollSize.y());
|
||||
if (this.size.y() < scrollSize.y()) {
|
||||
scrollOffset = scrollOffset.withY(scrollOffset.y() - this.pixelScrolling);
|
||||
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y() * this.propertyLimit.y())));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else if (event.inputId() == 5 && event.status() == KeyStatus.up) {
|
||||
Log.verbose(" mode DOWN " + this.size.y() + "<" + scrollSize.y());
|
||||
if (this.size.y() < scrollSize.y()) {
|
||||
scrollOffset = scrollOffset.withY(scrollOffset.y() + this.pixelScrolling);
|
||||
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y() * this.propertyLimit.y())));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else if (event.inputId() == 2) {
|
||||
if (event.status() == KeyStatus.down) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeInit;
|
||||
this.highSpeedType = KeyType.mouse;
|
||||
this.highSpeedStartPos = new Vector3f(relativePos.x(), relativePos.y(), 0);
|
||||
this.highSpeedButton = 2;
|
||||
// not really use... == > just keep some informations
|
||||
return false;
|
||||
}
|
||||
} else if (this.highSpeedMode != HighSpeedMode.speedModeDisable && event.status() == KeyStatus.leave) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeDisable;
|
||||
this.highSpeedType = KeyType.unknow;
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
if (event.inputId() == this.highSpeedButton && this.highSpeedMode != HighSpeedMode.speedModeDisable) {
|
||||
if (event.status() == KeyStatus.up) {
|
||||
if (this.highSpeedMode == HighSpeedMode.speedModeInit) {
|
||||
// TODO : generate back the down event ...
|
||||
this.highSpeedMode = HighSpeedMode.speedModeDisable;
|
||||
this.highSpeedType = KeyType.unknow;
|
||||
return false;
|
||||
} else {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeGrepEndEvent;
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
} else if (this.highSpeedMode == HighSpeedMode.speedModeGrepEndEvent) {
|
||||
if (event.status() == KeyStatus.pressSingle) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeDisable;
|
||||
this.highSpeedType = KeyType.unknow;
|
||||
this.highSpeedButton = -1;
|
||||
markToRedraw();
|
||||
}
|
||||
return true;
|
||||
} else if (this.highSpeedMode == HighSpeedMode.speedModeInit && event.status() == KeyStatus.move) {
|
||||
// wait that the cursor move more than 10 px to enable it :
|
||||
if (FMath.abs(relativePos.x() - this.highSpeedStartPos.x()) > 10 || FMath.abs(relativePos.y() - this.highSpeedStartPos.y()) > 10) {
|
||||
// the scrooling can start :
|
||||
// select the direction :
|
||||
if (relativePos.x() == this.highSpeedStartPos.x()) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeEnableVertical;
|
||||
} else if (relativePos.y() == this.highSpeedStartPos.y()) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
|
||||
} else {
|
||||
final float coef = (relativePos.y() - this.highSpeedStartPos.y()) / (relativePos.x() - this.highSpeedStartPos.x());
|
||||
if (FMath.abs(coef) <= 1) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
|
||||
} else {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeEnableVertical;
|
||||
}
|
||||
}
|
||||
if (this.highSpeedMode == HighSpeedMode.speedModeEnableHorizontal) {
|
||||
this.highSpeedStartPos = this.highSpeedStartPos.withX(scrollOffset.x() / scrollSize.x() * (this.size.x() - SCROLL_BAR_SPACE * 2));
|
||||
} else {
|
||||
this.highSpeedStartPos = this.highSpeedStartPos.withY(scrollOffset.y() / scrollSize.y() * (this.size.y() - SCROLL_BAR_SPACE * 2));
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y() * this.propertyLimit.y())));
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.highSpeedMode == HighSpeedMode.speedModeEnableHorizontal && event.status() == KeyStatus.move) {
|
||||
scrollOffset = scrollOffset.withX((int) (scrollSize.x() * (relativePos.x() - SCROLL_BAR_SPACE) / (this.size.x() - SCROLL_BAR_SPACE * 2)));
|
||||
scrollOffset = scrollOffset.withX(FMath.avg(0.0f, scrollOffset.x(), (scrollSize.x() - this.size.x() * this.propertyLimit.x())));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.highSpeedMode == HighSpeedMode.speedModeEnableVertical && event.status() == KeyStatus.move) {
|
||||
scrollOffset = scrollOffset.withY((int) (scrollSize.y() * (relativePos.y() - SCROLL_BAR_SPACE) / (this.size.y() - SCROLL_BAR_SPACE * 2)));
|
||||
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y() * this.propertyLimit.x())));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (KeyType.finger == event.type() && (KeyType.unknow == this.highSpeedType || KeyType.finger == this.highSpeedType)) {
|
||||
if (1 == event.inputId()) {
|
||||
Log.verbose("event: " + event);
|
||||
if (KeyStatus.down == event.status()) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeInit;
|
||||
this.highSpeedType = KeyType.finger;
|
||||
this.highSpeedStartPos = new Vector3f(relativePos.x(), relativePos.y(), 0);
|
||||
Log.verbose("SCROOL == > INIT pos=" + this.highSpeedStartPos + " && curent scrollOffset=" + scrollOffset);
|
||||
return true;
|
||||
} else if (KeyStatus.upAfter == event.status()) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeDisable;
|
||||
this.highSpeedType = KeyType.unknow;
|
||||
Log.verbose("SCROOL == > DISABLE");
|
||||
markToRedraw();
|
||||
return true;
|
||||
} else if (this.highSpeedMode == HighSpeedMode.speedModeInit && KeyStatus.move == event.status()) {
|
||||
// wait that the cursor move more than 10 px to enable it :
|
||||
if (FMath.abs(relativePos.x() - this.highSpeedStartPos.x()) > 10 || FMath.abs(relativePos.y() - this.highSpeedStartPos.y()) > 10) {
|
||||
// the scrooling can start :
|
||||
// select the direction :
|
||||
this.highSpeedMode = HighSpeedMode.speedModeEnableFinger;
|
||||
Log.verbose("SCROOL == > ENABLE");
|
||||
markToRedraw();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.highSpeedMode == HighSpeedMode.speedModeEnableFinger && KeyStatus.move == event.status()) {
|
||||
Log.verbose("SCROOL == > INIT scrollOffset=" + scrollOffset.y() + " relativePos=" + relativePos.y() + " this.highSpeedStartPos=" + this.highSpeedStartPos.y());
|
||||
//scrollOffset.x = (int)(scrollSize.x * x / this.size.x);
|
||||
if (this.propertyLimit.x() != 0.0f) {
|
||||
scrollOffset = scrollOffset.withX(scrollOffset.x() + (relativePos.x() - this.highSpeedStartPos.x()));
|
||||
scrollOffset = scrollOffset.withX(FMath.avg(0.0f, scrollOffset.x(), (scrollSize.x() - this.size.x() * this.propertyLimit.x())));
|
||||
}
|
||||
if (this.propertyLimit.y() != 0.0f) {
|
||||
scrollOffset = scrollOffset.withY(scrollOffset.y() - (relativePos.y() - this.highSpeedStartPos.y()));
|
||||
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y() * this.propertyLimit.y())));
|
||||
}
|
||||
// update current position:
|
||||
this.highSpeedStartPos = relativePos;
|
||||
Log.verbose("SCROOL == > MOVE " + scrollOffset);
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.highSpeedMode == HighSpeedMode.speedModeEnableFinger) {
|
||||
return true;
|
||||
}
|
||||
} else if (this.highSpeedMode != HighSpeedMode.speedModeDisable && KeyStatus.leave == event.status()) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeDisable;
|
||||
this.highSpeedType = KeyType.unknow;
|
||||
Log.verbose("SCROOL == > DISABLE");
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
if (this.propertyHide) {
|
||||
return;
|
||||
}
|
||||
// call upper class
|
||||
super.onRegenerateDisplay();
|
||||
if (!needRedraw()) {
|
||||
return;
|
||||
}
|
||||
// clear all previous display
|
||||
this.shaperH.clear();
|
||||
this.shaperV.clear();
|
||||
final Padding paddingVert = this.shaperV.getPadding();
|
||||
final Padding paddingHori = this.shaperH.getPadding();
|
||||
Vector3f scrollOffset = Vector3f.ZERO;
|
||||
Vector3f scrollSize = Vector3f.ZERO;
|
||||
if (this.subWidget != null) {
|
||||
scrollOffset = this.subWidget.getOffset();
|
||||
scrollSize = this.subWidget.getSize();
|
||||
}
|
||||
if (this.size.y() < scrollSize.y() || scrollOffset.y() != 0) {
|
||||
float lenScrollBar = this.size.y() * this.size.y() / scrollSize.y();
|
||||
lenScrollBar = FMath.avg(10.0f, lenScrollBar, this.size.y());
|
||||
float originScrollBar = scrollOffset.y() / (scrollSize.y() - this.size.y() * this.propertyLimit.y());
|
||||
originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f);
|
||||
originScrollBar *= (this.size.y() - lenScrollBar);
|
||||
this.shaperV.setShape(new Vector2f(this.size.x() - paddingVert.x(), 0), new Vector2f(paddingVert.x(), this.size.y()),
|
||||
new Vector2f(this.size.x() - paddingVert.right(), this.size.y() - originScrollBar - lenScrollBar), new Vector2f(0, lenScrollBar));
|
||||
}
|
||||
if (this.size.x() < scrollSize.x() || scrollOffset.x() != 0) {
|
||||
float lenScrollBar = (this.size.x() - paddingHori.left()) * (this.size.x() - paddingVert.x()) / scrollSize.x();
|
||||
lenScrollBar = FMath.avg(10.0f, lenScrollBar, (this.size.x() - paddingVert.x()));
|
||||
float originScrollBar = scrollOffset.x() / (scrollSize.x() - this.size.x() * this.propertyLimit.x());
|
||||
originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f);
|
||||
originScrollBar *= (this.size.x() - paddingHori.right() - lenScrollBar);
|
||||
this.shaperH.setShape(Vector2f.ZERO, new Vector2f(this.size.x() - paddingVert.x(), paddingHori.y()), new Vector2f(originScrollBar, paddingHori.bottom()), new Vector2f(lenScrollBar, 0));
|
||||
}
|
||||
}
|
||||
|
||||
public void setPropertyHover(final boolean propertyHover) {
|
||||
if (propertyHover == this.propertyHover) {
|
||||
return;
|
||||
}
|
||||
this.propertyHover = propertyHover;
|
||||
}
|
||||
|
||||
public void setPropertyLimit(final Vector3f propertyLimit) {
|
||||
final Vector3f tmp = Vector3f.avg(Vector3f.ZERO, propertyLimit, Vector3f.ONE);
|
||||
if (tmp.equals(this.propertyLimit)) {
|
||||
return;
|
||||
}
|
||||
this.propertyLimit = propertyLimit;
|
||||
onChangePropertyLimit();
|
||||
}
|
||||
|
||||
public void setPropertyShapeHori(final Uri value) {
|
||||
if (this.propertyShapeHori.equals(value)) {
|
||||
return;
|
||||
}
|
||||
this.propertyShapeHori = value;
|
||||
onChangePropertyShapeHori();
|
||||
}
|
||||
|
||||
public void setPropertyShapeVert(final Uri value) {
|
||||
if (this.propertyShapeVert.equals(value)) {
|
||||
return;
|
||||
}
|
||||
this.propertyShapeVert = value;
|
||||
onChangePropertyShapeVert();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void systemDraw(final DrawProperty displayProp) {
|
||||
if (this.propertyHide) {
|
||||
return;
|
||||
}
|
||||
if (this.subWidget != null) {
|
||||
final DrawProperty prop = displayProp.withLimit(this.origin, this.size);
|
||||
this.subWidget.systemDraw(prop);
|
||||
}
|
||||
super.systemDraw(displayProp);
|
||||
}
|
||||
}
|
@ -80,14 +80,12 @@ public class Widget extends EwolObject {
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
protected boolean needRegenerateDisplay = true; //!< the display might be done the next regeneration
|
||||
protected Vector3f offset = Vector3f.ZERO; //!< Offset of the display in the view-port
|
||||
|
||||
protected Vector3f origin = Vector3f.ZERO; //!< internal ... I do not really known how if can use it ...
|
||||
|
||||
protected boolean propertyCanFocus = false; //!< the focus can be done on this widget
|
||||
protected Vector3b propertyExpand = Vector3b.FALSE; //!< the widget will expand if possible
|
||||
protected Vector3b propertyExpandIfFree = Vector3b.FALSE; //!< the widget will expand if possible
|
||||
protected Vector3b propertyFill = Vector3b.TRUE; //!< the widget will fill all the space provided by the parent.
|
||||
protected Gravity propertyGravity = Gravity.BOTTOM_LEFT; //!< Gravity of the widget
|
||||
protected Vector3b propertyFill = Vector3b.FALSE; //!< the widget will fill all the space provided by the parent.
|
||||
protected Gravity propertyGravity = Gravity.CENTER; //!< Gravity of the widget
|
||||
protected boolean propertyHide = false; //!< hide a widget on the display
|
||||
protected Dimension3f propertyMaxSize = new Dimension3f(Vector3f.MAX_VALUE, Distance.PIXEL); //!< user define the maximum size of the widget
|
||||
protected Dimension3f propertyMinSize = new Dimension3f(Vector3f.ZERO, Distance.PIXEL); //!< user define the minimum size of the widget
|
||||
@ -187,7 +185,7 @@ public class Widget extends EwolObject {
|
||||
}
|
||||
|
||||
public void drawWidgetTree(final int level) {
|
||||
StringBuilder space = new StringBuilder();
|
||||
final StringBuilder space = new StringBuilder();
|
||||
for (int iii = 0; iii < level; ++iii) {
|
||||
space.append(" ");
|
||||
}
|
||||
@ -941,7 +939,7 @@ public class Widget extends EwolObject {
|
||||
// Scale if needed (feature not validate)
|
||||
final Matrix4f tmpScale = Matrix4f.createMatrixScale(this.zoom, this.zoom, 1.0f);
|
||||
// create orthogonal projection for GUI ==> simple to manage staking
|
||||
Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-tmpSize.size().x() / 2, tmpSize.size().x() / 2, -tmpSize.size().y() / 2, tmpSize.size().y() / 2, -500, 500);
|
||||
final Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-tmpSize.size().x() / 2, tmpSize.size().x() / 2, -tmpSize.size().y() / 2, tmpSize.size().y() / 2, -500, 500);
|
||||
//Matrix4f tmpMat = tmpProjection.multiply(tmpScale).multiply(tmpTranslate);
|
||||
|
||||
OpenGL.push();
|
||||
@ -965,7 +963,7 @@ public class Widget extends EwolObject {
|
||||
* @return false if the event has not been used
|
||||
*/
|
||||
public boolean systemEventEntry(final EntrySystem event) {
|
||||
if (this.parent != null && this.parent.get() != null && this.parent.get() instanceof Widget up) {
|
||||
if (this.parent != null && this.parent.get() != null && this.parent.get() instanceof final Widget up) {
|
||||
if (up.systemEventEntry(event)) {
|
||||
return true;
|
||||
}
|
||||
|
142
src/org/atriasoft/ewol/widget/WidgetScrolled.hpp
Normal file
142
src/org/atriasoft/ewol/widget/WidgetScrolled.hpp
Normal file
@ -0,0 +1,142 @@
|
||||
/** @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/Widget.hpp>
|
||||
#include <ewol/widget/Scroll.hpp>
|
||||
#include <ewol/compositing/Shaper.hpp>
|
||||
|
||||
#define CALCULATE_SIMULTANEOUS_FINGER (5)
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class WidgetScrolled;
|
||||
using WidgetScrolledShared = ememory::SharedPtr<ewol::widget::WidgetScrolled>;
|
||||
using WidgetScrolledWeak = ememory::WeakPtr<ewol::widget::WidgetScrolled>;
|
||||
/**
|
||||
* @brief Widget to integrate a scrool bar in a widget. This is not a stadalone widget.
|
||||
*/
|
||||
class WidgetScrolled : public ewol::Widget {
|
||||
public: // properties:
|
||||
eproperty::Value<etk::Uri> propertyShapeVert; //!< Vertical shaper name
|
||||
eproperty::Value<etk::Uri> propertyShapeHori; //!< Horizontal shaper name
|
||||
// TODO : All property
|
||||
public:
|
||||
enum scrollingMode {
|
||||
scroolModeNormal, //!< No Zoom , can UP and down, left and right
|
||||
scroolModeCenter, //!< Zoom enable, no move left and right
|
||||
scroolModeGame, //!< Zoom enable, no move left and right
|
||||
};
|
||||
private:
|
||||
ewol::compositing::Shaper m_shaperH; //!< Compositing theme Horizontal.
|
||||
ewol::compositing::Shaper m_shaperV; //!< Compositing theme Vertical.
|
||||
protected:
|
||||
vec2 m_originScrooled; //!< pixel distance from the origin of the display (Bottum left)
|
||||
vec2 m_maxSize; //!< Maximum size of the Widget ==> to display scrollbar
|
||||
vec2 m_limitScrolling; //!< Mimit scrolling represent the propertion of the minimel scrolling activate (0.2 ==> 20% migt all time be visible)
|
||||
private: // Mouse section :
|
||||
enum scrollingMode m_scroollingMode; //!< mode of management of the scrooling
|
||||
float m_pixelScrolling;
|
||||
vec2 m_highSpeedStartPos;
|
||||
enum Scroll::highSpeedMode m_highSpeedMode;
|
||||
int32_t m_highSpeedButton;
|
||||
enum gale::key::type m_highSpeedType;
|
||||
private: // finger section:
|
||||
bool m_singleFingerMode; //!< in many case the moving in a subwidget is done with one finger, it is enought ==> the user select...
|
||||
public:
|
||||
/**
|
||||
* @brief Set the single finger capabilities/
|
||||
* @param[in] _status True if single inger mode, two otherwise/
|
||||
*/
|
||||
void setSingleFinger(bool _status);
|
||||
/**
|
||||
* @brief Get the single finger capabilities
|
||||
* @return true The single finger mode is active
|
||||
* @return false The To finger mode is active
|
||||
*/
|
||||
bool getSingleFinger() {
|
||||
return m_singleFingerMode;
|
||||
}
|
||||
/**
|
||||
* @brief Reset the scoll of the subWidget
|
||||
*/
|
||||
void resetScrollOrigin() {
|
||||
m_originScrooled = vec2(0,0);
|
||||
}
|
||||
private:
|
||||
bool m_fingerPresent[CALCULATE_SIMULTANEOUS_FINGER];
|
||||
bool m_fingerScoolActivated;
|
||||
vec2 m_fingerMoveStartPos[CALCULATE_SIMULTANEOUS_FINGER];
|
||||
protected:
|
||||
/**
|
||||
* @brief Scroll Widget main constructor to be herited from an other widget (this is not a stand-alone widget)
|
||||
* @param[in] _shaperName Shaper name if the scrolled widget.
|
||||
*/
|
||||
WidgetScrolled();
|
||||
void init() override;
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(WidgetScrolled, "WidgetScrolled");
|
||||
/**
|
||||
* @brief Scroll widget destructor.
|
||||
*/
|
||||
virtual ~WidgetScrolled();
|
||||
protected:
|
||||
void onDraw() override;
|
||||
public:
|
||||
void onRegenerateDisplay() override;
|
||||
bool onEventInput(const ewol::event::Input& _event) override;
|
||||
void systemDraw(const ewol::DrawProperty& _displayProp) override;
|
||||
protected:
|
||||
/**
|
||||
* @brief For mouse event when we have a scrolling UP and dows, specify the number of pixel that we scrooled
|
||||
* @param[in] _nbPixel number of pixel scrolling
|
||||
*/
|
||||
void setScrollingSize(float _nbPixel) {
|
||||
m_pixelScrolling = _nbPixel;
|
||||
};
|
||||
/**
|
||||
* @brief Specify the mode of scrolling for this windows
|
||||
* @param[in] _newMode the selected mode for the scrolling...
|
||||
*/
|
||||
void scroolingMode(enum scrollingMode _newMode);
|
||||
/**
|
||||
* @brief set the specific mawimum size of the widget
|
||||
* @param[in] _localSize new Maximum size
|
||||
*/
|
||||
void setMaxSize(const vec2& _localSize) {
|
||||
m_maxSize = _localSize;
|
||||
};
|
||||
/**
|
||||
* @brief Request a specific position for the scrolling of the current windows.
|
||||
* @param[in] _borderWidth size of the border that requested the element might not to be
|
||||
* @param[in] _currentPosition Position that is requested to view
|
||||
* @param[in] _center True if the position might be at the center of the widget
|
||||
*/
|
||||
void setScrollingPositionDynamic(vec2 _borderWidth, const vec2& _currentPosition, bool _center = false);
|
||||
/**
|
||||
* @brief set the scrolling limit when arriving at he end of the widget
|
||||
* @param[in] _poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end ...
|
||||
*/
|
||||
void setLimitScrolling(float _poucentageLimit) {
|
||||
_poucentageLimit = etk::avg(0.1f, _poucentageLimit,1.0f);
|
||||
m_limitScrolling = vec2(_poucentageLimit, _poucentageLimit);
|
||||
};
|
||||
/**
|
||||
* @brief set the scrolling limit when arriving at he end of the widget
|
||||
* @param[in] _poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end for axis specific...
|
||||
*/
|
||||
void setLimitScrolling(const vec2& _poucentageLimit) {
|
||||
m_limitScrolling = vec2(etk::avg(0.1f, _poucentageLimit.x(),1.0f), etk::avg(0.1f, _poucentageLimit.y(),1.0f));
|
||||
};
|
||||
protected:
|
||||
virtual void onChangePropertyShapeVert();
|
||||
virtual void onChangePropertyShapeHori();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
577
src/org/atriasoft/ewol/widget/WidgetScrolled.java
Normal file
577
src/org/atriasoft/ewol/widget/WidgetScrolled.java
Normal file
@ -0,0 +1,577 @@
|
||||
package org.atriasoft.ewol.widget;
|
||||
|
||||
import org.atriasoft.etk.Uri;
|
||||
import org.atriasoft.etk.math.FMath;
|
||||
import org.atriasoft.etk.math.Matrix4f;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.etk.math.Vector3f;
|
||||
import org.atriasoft.ewol.DrawProperty;
|
||||
import org.atriasoft.ewol.HighSpeedMode;
|
||||
import org.atriasoft.ewol.Padding;
|
||||
import org.atriasoft.ewol.annotation.EwolDescription;
|
||||
import org.atriasoft.ewol.compositing.GuiShape;
|
||||
import org.atriasoft.ewol.event.EventInput;
|
||||
import org.atriasoft.ewol.internal.Log;
|
||||
import org.atriasoft.exml.annotation.XmlAttribute;
|
||||
import org.atriasoft.exml.annotation.XmlManaged;
|
||||
import org.atriasoft.exml.annotation.XmlName;
|
||||
import org.atriasoft.gale.backend3d.OpenGL;
|
||||
import org.atriasoft.gale.key.KeyStatus;
|
||||
import org.atriasoft.gale.key.KeyType;
|
||||
|
||||
/**
|
||||
* Widget to integrate a scrool bar in a widget. This is not a stadalone widget.
|
||||
*/
|
||||
class WidgetScrolled extends Widget {
|
||||
public enum ScrollingMode {
|
||||
scroolModeNormal, //!< No Zoom , can UP and down, left and right
|
||||
scroolModeCenter, //!< Zoom enable, no move left and right
|
||||
scroolModeGame, //!< Zoom enable, no move left and right
|
||||
}
|
||||
|
||||
public static final int CALCULATE_SIMULTANEOUS_FINGER = 5;
|
||||
protected Uri propertyShapeVert = new Uri("THEME_GUI", "WidgetScrolled.json", "ewol"); //!< Vertical shaper name
|
||||
|
||||
protected Uri propertyShapeHori = new Uri("THEME_GUI", "WidgetScrolled.json", "ewol"); //!< Horizontal shaper name
|
||||
|
||||
private GuiShape shaperH; //!< Compositing theme Horizontal.
|
||||
|
||||
private GuiShape shaperV; //!< Compositing theme Vertical.
|
||||
|
||||
protected Vector2f originScrooled = Vector2f.ZERO; //!< pixel distance from the origin of the display (Bottum left)
|
||||
|
||||
protected Vector2f maxSize; //!< Maximum size of the Widget ==> to display scrollbar
|
||||
|
||||
protected Vector2f limitScrolling = Vector2f.ZERO; //!< Mimit scrolling represent the propertion of the minimel scrolling activate (0.2 ==> 20% migt all time be visible)
|
||||
// Mouse section :
|
||||
private ScrollingMode scroollingMode = ScrollingMode.scroolModeNormal; //!< mode of management of the scrooling
|
||||
private float pixelScrolling = 20;
|
||||
private Vector2f highSpeedStartPos;
|
||||
private HighSpeedMode highSpeedMode = HighSpeedMode.speedModeDisable;
|
||||
private int highSpeedButton = -1;
|
||||
private KeyType highSpeedType = KeyType.unknow;
|
||||
// finger section:
|
||||
private boolean singleFingerMode = true; //!< in many case the moving in a subwidget is done with one finger, it is enought ==> the user select...
|
||||
private final boolean[] fingerPresent = { false, false, false, false, false };
|
||||
private boolean fingerScoolActivated = false;
|
||||
private final Vector2f[] fingerMoveStartPos = new Vector2f[CALCULATE_SIMULTANEOUS_FINGER];
|
||||
|
||||
/**
|
||||
* Scroll Widget main ructor to be herited from an other widget (this is not a stand-alone widget)
|
||||
* @param _shaperName Shaper name if the scrolled widget.
|
||||
*/
|
||||
public WidgetScrolled() {
|
||||
onChangePropertyShapeVert();
|
||||
onChangePropertyShapeHori();
|
||||
}
|
||||
|
||||
@XmlManaged
|
||||
@XmlAttribute
|
||||
@XmlName(value = "shape-hori")
|
||||
@EwolDescription(value = "shape for the horizontal display")
|
||||
public Uri getPropertyShapeHori() {
|
||||
return this.propertyShapeHori;
|
||||
}
|
||||
|
||||
@XmlManaged
|
||||
@XmlAttribute
|
||||
@XmlName(value = "shape-vert")
|
||||
@EwolDescription(value = "shape for the vertical display")
|
||||
public Uri getPropertyShapeVert() {
|
||||
return this.propertyShapeVert;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the single finger capabilities
|
||||
* @return true The single finger mode is active
|
||||
* @return false The To finger mode is active
|
||||
*/
|
||||
public boolean getSingleFinger() {
|
||||
return this.singleFingerMode;
|
||||
}
|
||||
|
||||
protected void onChangePropertyShapeHori() {
|
||||
this.shaperH.setSource(this.propertyShapeHori);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
protected void onChangePropertyShapeVert() {
|
||||
this.shaperV.setSource(this.propertyShapeVert);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw() {
|
||||
this.shaperH.draw();
|
||||
this.shaperV.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onEventInput(final EventInput event) {
|
||||
Log.verbose("event XXX {}", event);
|
||||
Vector3f relativePos = relativePosition(new Vector3f(event.pos().x(), event.pos().y(), 0.0f));
|
||||
// Correction due to the open Gl insertion ...
|
||||
relativePos = relativePos.withY(this.size.y() - relativePos.y());
|
||||
final Padding paddingV = this.shaperV.getPadding();
|
||||
final Padding paddingH = this.shaperH.getPadding();
|
||||
if (this.scroollingMode == ScrollingMode.scroolModeNormal) {
|
||||
if (event.type() == KeyType.mouse && (this.highSpeedType == KeyType.unknow || this.highSpeedType == KeyType.mouse)) {
|
||||
if (event.inputId() == 1 && event.status() == KeyStatus.down) {
|
||||
// check if selected the scrolling position with the scrolling bar ...
|
||||
if (relativePos.x() >= (this.size.x() - paddingV.x())) {
|
||||
if (this.size.y() < this.maxSize.y() || this.originScrooled.y() != 0) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeEnableVertical;
|
||||
this.highSpeedType = KeyType.mouse;
|
||||
this.highSpeedStartPos = this.highSpeedStartPos.withX(relativePos.x());
|
||||
this.highSpeedStartPos = this.highSpeedStartPos.withY(this.originScrooled.y() / this.maxSize.y() * (this.size.y() - paddingV.y()));
|
||||
this.highSpeedButton = 1;
|
||||
// force direct scrolling in this case
|
||||
this.originScrooled = this.originScrooled.withY((int) (this.maxSize.y() * (relativePos.y() - paddingV.bottom()) / (this.size.y() - paddingV.bottom() * 2)));
|
||||
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y() * this.limitScrolling.y())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
} else if (relativePos.y() >= (this.size.y() - paddingH.y())) {
|
||||
if (this.size.x() < this.maxSize.x() || this.originScrooled.x() != 0) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
|
||||
this.highSpeedType = KeyType.mouse;
|
||||
this.highSpeedStartPos = this.highSpeedStartPos.withX(this.originScrooled.x() / this.maxSize.x() * (this.size.x() - paddingH.x()));
|
||||
this.highSpeedStartPos = this.highSpeedStartPos.withY(relativePos.y());
|
||||
this.highSpeedButton = 1;
|
||||
// force direct scrolling in this case
|
||||
this.originScrooled = this.originScrooled.withX((int) (this.maxSize.x() * (relativePos.x() - paddingH.left()) / (this.size.x() - paddingH.left() * 2)));
|
||||
this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x() * this.limitScrolling.x())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (event.inputId() == 4 && event.status() == KeyStatus.up) {
|
||||
if (event.specialKey().getCtrl()) {
|
||||
changeZoom(1);
|
||||
/*
|
||||
float zoom = getZoom()*1.1;
|
||||
zoom = FMath.avg(0.1f, zoom, 5000.0f);
|
||||
setZoom(zoom);
|
||||
*/
|
||||
} else {
|
||||
if (this.size.y() < this.maxSize.y() || this.originScrooled.y() != 0 || this.size.y() * this.limitScrolling.y() < this.maxSize.y()) {
|
||||
this.originScrooled = this.originScrooled.withY(this.originScrooled.y() - this.pixelScrolling);
|
||||
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y() * this.limitScrolling.y())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (event.inputId() == 5 && event.status() == KeyStatus.up) {
|
||||
if (event.specialKey().getCtrl()) {
|
||||
changeZoom(-1);
|
||||
/*
|
||||
float zoom = getZoom()*0.9;
|
||||
zoom = FMath.avg(0.1f, zoom, 5000.0f);
|
||||
setZoom(zoom);
|
||||
*/
|
||||
} else {
|
||||
if (this.size.y() < this.maxSize.y() || this.originScrooled.y() != 0 || this.size.y() * this.limitScrolling.y() < this.maxSize.y()) {
|
||||
this.originScrooled = this.originScrooled.withY(this.originScrooled.y() + this.pixelScrolling);
|
||||
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y() * this.limitScrolling.y())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (event.inputId() == 11 && event.status() == KeyStatus.up) {
|
||||
// Scrool Left
|
||||
if (this.size.x() < this.maxSize.x() || this.originScrooled.x() != 0 || this.size.x() * this.limitScrolling.x() < this.maxSize.x()) {
|
||||
this.originScrooled = this.originScrooled.withX(this.originScrooled.x() - this.pixelScrolling);
|
||||
this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x() * this.limitScrolling.x())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
} else if (event.inputId() == 10 && event.status() == KeyStatus.up) {
|
||||
// Scrool Right
|
||||
if (this.size.x() < this.maxSize.x() || this.originScrooled.x() != 0 || this.size.x() * this.limitScrolling.x() < this.maxSize.x()) {
|
||||
this.originScrooled = this.originScrooled.withX(this.originScrooled.x() + this.pixelScrolling);
|
||||
this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x() * this.limitScrolling.x())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
} else if (event.inputId() == 2) {
|
||||
/*
|
||||
if (true == ewol::isSetCtrl()) {
|
||||
if (KeyStatus.down == typeEvent) {
|
||||
float zoom = 1.0;
|
||||
setZoom(zoom);
|
||||
}
|
||||
} else */ {
|
||||
if (event.status() == KeyStatus.down) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeInit;
|
||||
this.highSpeedType = KeyType.mouse;
|
||||
this.highSpeedStartPos = new Vector2f(relativePos.x(), relativePos.y());
|
||||
this.highSpeedButton = 2;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (this.highSpeedMode != HighSpeedMode.speedModeDisable && event.status() == KeyStatus.leave) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeDisable;
|
||||
this.highSpeedType = KeyType.unknow;
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
if (event.inputId() == this.highSpeedButton && this.highSpeedMode != HighSpeedMode.speedModeDisable) {
|
||||
if (event.status() == KeyStatus.upAfter) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeDisable;
|
||||
this.highSpeedType = KeyType.unknow;
|
||||
return false;
|
||||
} else if (this.highSpeedMode == HighSpeedMode.speedModeGrepEndEvent) {
|
||||
if (event.status() == KeyStatus.pressSingle) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeDisable;
|
||||
this.highSpeedType = KeyType.unknow;
|
||||
this.highSpeedButton = -1;
|
||||
markToRedraw();
|
||||
}
|
||||
return true;
|
||||
} else if (event.status() == KeyStatus.up) {
|
||||
return true;
|
||||
} else if (this.highSpeedMode == HighSpeedMode.speedModeInit && event.status() == KeyStatus.move) {
|
||||
// wait that the cursor move more than 10 px to enable it :
|
||||
if (FMath.abs(relativePos.x() - this.highSpeedStartPos.x()) > 10 || FMath.abs(relativePos.y() - this.highSpeedStartPos.y()) > 10) {
|
||||
// the scrolling can start :
|
||||
// select the direction :
|
||||
if (relativePos.x() == this.highSpeedStartPos.x()) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeEnableVertical;
|
||||
} else if (relativePos.y() == this.highSpeedStartPos.y()) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
|
||||
} else {
|
||||
final float coef = (relativePos.y() - this.highSpeedStartPos.y()) / (relativePos.x() - this.highSpeedStartPos.x());
|
||||
if (FMath.abs(coef) <= 1) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
|
||||
} else {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeEnableVertical;
|
||||
}
|
||||
}
|
||||
if (this.highSpeedMode == HighSpeedMode.speedModeEnableHorizontal) {
|
||||
this.highSpeedStartPos = this.highSpeedStartPos.withX(this.originScrooled.x() / this.maxSize.x() * (this.size.x() - paddingV.x()));
|
||||
} else {
|
||||
this.highSpeedStartPos = this.highSpeedStartPos.withY(this.originScrooled.y() / this.maxSize.y() * (this.size.y() - paddingV.y()));
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y() * this.limitScrolling.y())));
|
||||
return true;
|
||||
}
|
||||
if (this.highSpeedMode == HighSpeedMode.speedModeEnableHorizontal && event.status() == KeyStatus.move) {
|
||||
this.originScrooled = this.originScrooled.withX((int) (this.maxSize.x() * (relativePos.x() - paddingH.left()) / (this.size.x() - paddingH.x())));
|
||||
this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x() * this.limitScrolling.x())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
if (this.highSpeedMode == HighSpeedMode.speedModeEnableVertical && event.status() == KeyStatus.move) {
|
||||
this.originScrooled = this.originScrooled.withY((int) (this.maxSize.y() * (relativePos.y() - paddingV.bottom()) / (this.size.y() - paddingV.y())));
|
||||
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y() * this.limitScrolling.y())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (event.type() == KeyType.finger && (this.highSpeedType == KeyType.unknow || this.highSpeedType == KeyType.finger)) {
|
||||
if (!this.singleFingerMode) {
|
||||
// ***********************
|
||||
// ** Two finger mode : **
|
||||
// ***********************
|
||||
if (event.inputId() >= 3) {
|
||||
return false;
|
||||
}
|
||||
final int idTable = event.inputId() - 1;
|
||||
if (event.status() == KeyStatus.down) {
|
||||
this.fingerPresent[idTable] = true;
|
||||
} else if (event.status() == KeyStatus.upAfter) {
|
||||
this.fingerPresent[idTable] = false;
|
||||
}
|
||||
if (!this.fingerScoolActivated) {
|
||||
this.fingerMoveStartPos[idTable] = new Vector2f(relativePos.x(), relativePos.y());
|
||||
}
|
||||
if (this.fingerPresent[0] && this.fingerPresent[1] && !this.fingerScoolActivated) {
|
||||
this.fingerScoolActivated = true;
|
||||
Log.verbose("SCROOL == > START pos=" + this.fingerMoveStartPos);
|
||||
}
|
||||
if (this.fingerScoolActivated) {
|
||||
// 1: HighSpeedMode...
|
||||
// 2: remove all unneeded sub event ... ==> maybe a better methode ...
|
||||
if (event.status() == KeyStatus.move) {
|
||||
this.originScrooled = this.originScrooled.withX(this.originScrooled.x() - (relativePos.x() - this.fingerMoveStartPos[idTable].x()) * 0.5f);
|
||||
this.originScrooled = this.originScrooled.withY(this.originScrooled.y() - (relativePos.y() - this.fingerMoveStartPos[idTable].y()) * 0.5f);
|
||||
this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x() * this.limitScrolling.x())));
|
||||
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y() * this.limitScrolling.y())));
|
||||
this.fingerMoveStartPos[idTable] = new Vector2f(relativePos.x(), relativePos.y());
|
||||
Log.verbose("SCROOL == > MOVE this.originScrooled=" + this.originScrooled + " " + relativePos + " " + this.highSpeedStartPos);
|
||||
markToRedraw();
|
||||
}
|
||||
if (!this.fingerPresent[0] && !this.fingerPresent[1]) {
|
||||
if (event.status() == KeyStatus.upAfter) {
|
||||
// TODO : Reset event ...
|
||||
this.fingerScoolActivated = false;
|
||||
// WTF ??? _event.reset();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// **************************
|
||||
// ** Single finger mode : **
|
||||
// **************************
|
||||
if (event.inputId() == 1) {
|
||||
Log.verbose("event 1 " + event);
|
||||
if (event.status() == KeyStatus.down) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeInit;
|
||||
this.highSpeedType = KeyType.finger;
|
||||
this.highSpeedStartPos = new Vector2f(relativePos.x(), relativePos.y());
|
||||
Log.verbose("SCROOL == > INIT");
|
||||
return true;
|
||||
} else if (event.status() == KeyStatus.upAfter) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeDisable;
|
||||
this.highSpeedType = KeyType.unknow;
|
||||
Log.verbose("SCROOL == > DISABLE");
|
||||
markToRedraw();
|
||||
return true;
|
||||
} else if (this.highSpeedMode == HighSpeedMode.speedModeInit && event.status() == KeyStatus.move) {
|
||||
// wait that the cursor move more than 10 px to enable it :
|
||||
if (FMath.abs(relativePos.x() - this.highSpeedStartPos.x()) > 10 || FMath.abs(relativePos.y() - this.highSpeedStartPos.y()) > 10) {
|
||||
// the scrooling can start :
|
||||
// select the direction :
|
||||
this.highSpeedMode = HighSpeedMode.speedModeEnableFinger;
|
||||
Log.debug("SCROOL == > ENABLE");
|
||||
markToRedraw();
|
||||
}
|
||||
return true;
|
||||
} else if (this.highSpeedMode == HighSpeedMode.speedModeEnableFinger && event.status() == KeyStatus.pressSingle) {
|
||||
// Keep all event in the range of moving
|
||||
return true;
|
||||
} else if (this.highSpeedMode == HighSpeedMode.speedModeEnableFinger && event.status() == KeyStatus.pressDouble) {
|
||||
// Keep all event in the range of moving
|
||||
return true;
|
||||
}
|
||||
if (this.highSpeedMode == HighSpeedMode.speedModeEnableFinger && event.status() == KeyStatus.move) {
|
||||
//this.originScrooled.x = (int)(this.maxSize.x * x / this.size.x);
|
||||
this.originScrooled = this.originScrooled.withX(this.originScrooled.x() - (relativePos.x() - this.highSpeedStartPos.x()));
|
||||
this.originScrooled = this.originScrooled.withY(this.originScrooled.y() - (relativePos.y() - this.highSpeedStartPos.y()));
|
||||
this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x() * this.limitScrolling.x())));
|
||||
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y() * this.limitScrolling.y())));
|
||||
this.highSpeedStartPos = new Vector2f(relativePos.x(), relativePos.y());
|
||||
Log.verbose("SCROOL == > MOVE this.originScrooled=" + this.originScrooled + " " + relativePos + " " + this.highSpeedStartPos);
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
} else if (this.highSpeedMode == HighSpeedMode.speedModeDisable && event.status() == KeyStatus.leave) {
|
||||
this.highSpeedMode = HighSpeedMode.speedModeDisable;
|
||||
this.highSpeedType = KeyType.unknow;
|
||||
Log.verbose("SCROOL == > DISABLE");
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (this.scroollingMode == ScrollingMode.scroolModeCenter) {
|
||||
if (event.type() == KeyType.mouse) {
|
||||
float tmp1 = this.size.x() / this.maxSize.y();
|
||||
final float tmp2 = this.size.y() / this.maxSize.x();
|
||||
//Log.info(" elements Zoom : " + tmp1 + " " + tmp2);
|
||||
tmp1 = FMath.min(tmp1, tmp2);
|
||||
if (event.inputId() == 4 && event.status() == KeyStatus.up) {
|
||||
this.zoom -= 0.1;
|
||||
if (tmp1 < 1.0) {
|
||||
this.zoom = FMath.max(tmp1, this.zoom);
|
||||
} else {
|
||||
this.zoom = FMath.max(1.0f, this.zoom);
|
||||
}
|
||||
markToRedraw();
|
||||
return true;
|
||||
} else if (event.inputId() == 5 && event.status() == KeyStatus.up) {
|
||||
this.zoom += 0.1;
|
||||
if (tmp1 > 1.0) {
|
||||
this.zoom = FMath.min(tmp1, this.zoom);
|
||||
} else {
|
||||
this.zoom = FMath.min(1.0f, this.zoom);
|
||||
}
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (this.scroollingMode == ScrollingMode.scroolModeGame) {
|
||||
|
||||
} else {
|
||||
Log.error("Scrolling mode unknow ... " + this.scroollingMode);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
this.shaperH.clear();
|
||||
this.shaperV.clear();
|
||||
if (this.scroollingMode == ScrollingMode.scroolModeGame) {
|
||||
// nothing to do ...
|
||||
return;
|
||||
}
|
||||
final Padding paddingVert = this.shaperV.getPadding();
|
||||
final Padding paddingHori = this.shaperH.getPadding();
|
||||
if (this.size.y() < this.maxSize.y() || this.originScrooled.y() != 0) {
|
||||
float lenScrollBar = this.size.y() * this.size.y() / this.maxSize.y();
|
||||
lenScrollBar = FMath.avg(10.0f, lenScrollBar, this.size.y());
|
||||
float originScrollBar = this.originScrooled.y() / (this.maxSize.y() - this.size.y() * this.limitScrolling.y());
|
||||
originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f);
|
||||
originScrollBar *= (this.size.y() - lenScrollBar);
|
||||
this.shaperV.setShape(new Vector2f(this.size.x() - paddingVert.x(), 0), new Vector2f(paddingVert.x(), this.size.y()),
|
||||
new Vector2f(this.size.x() - paddingVert.right(), this.size.y() - originScrollBar - lenScrollBar), new Vector2f(0, lenScrollBar));
|
||||
}
|
||||
if (this.size.x() < this.maxSize.x() || this.originScrooled.x() != 0) {
|
||||
float lenScrollBar = (this.size.x() - paddingHori.left()) * (this.size.x() - paddingVert.x()) / this.maxSize.x();
|
||||
lenScrollBar = FMath.avg(10.0f, lenScrollBar, (this.size.x() - paddingVert.x()));
|
||||
float originScrollBar = this.originScrooled.x() / (this.maxSize.x() - this.size.x() * this.limitScrolling.x());
|
||||
originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f);
|
||||
originScrollBar *= (this.size.x() - paddingHori.right() - lenScrollBar);
|
||||
this.shaperH.setShape(new Vector2f(0, 0), new Vector2f(this.size.x() - paddingVert.x(), paddingHori.y()), new Vector2f(originScrollBar, paddingHori.bottom()),
|
||||
new Vector2f(lenScrollBar, 0));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the scoll of the subWidget
|
||||
*/
|
||||
public void resetScrollOrigin() {
|
||||
this.originScrooled = new Vector2f(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the mode of scrolling for this windows
|
||||
* @param newMode the selected mode for the scrolling...
|
||||
*/
|
||||
protected void scroolingMode(final ScrollingMode newMode) {
|
||||
this.scroollingMode = newMode;
|
||||
if (this.scroollingMode == ScrollingMode.scroolModeGame) {
|
||||
// set the scene maximum size :
|
||||
this.maxSize = new Vector2f(FMath.max(this.size.x(), this.size.y()), this.maxSize.x());
|
||||
this.zoom = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set the scrolling limit when arriving at he end of the widget
|
||||
* @param poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end ...
|
||||
*/
|
||||
protected void setLimitScrolling(float poucentageLimit) {
|
||||
poucentageLimit = FMath.avg(0.1f, poucentageLimit, 1.0f);
|
||||
this.limitScrolling = new Vector2f(poucentageLimit, poucentageLimit);
|
||||
}
|
||||
|
||||
/**
|
||||
* set the scrolling limit when arriving at he end of the widget
|
||||
* @param poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end for axis specific...
|
||||
*/
|
||||
protected void setLimitScrolling(final Vector2f poucentageLimit) {
|
||||
this.limitScrolling = new Vector2f(FMath.avg(0.1f, poucentageLimit.x(), 1.0f), FMath.avg(0.1f, poucentageLimit.y(), 1.0f));
|
||||
}
|
||||
|
||||
/**
|
||||
* set the specific mawimum size of the widget
|
||||
* @param localSize new Maximum size
|
||||
*/
|
||||
protected void setMaxSize(final Vector2f localSize) {
|
||||
this.maxSize = localSize;
|
||||
}
|
||||
|
||||
public void setPropertyShapeHori(final Uri value) {
|
||||
if (this.propertyShapeHori.equals(value)) {
|
||||
return;
|
||||
}
|
||||
this.propertyShapeHori = value;
|
||||
onChangePropertyShapeHori();
|
||||
}
|
||||
|
||||
public void setPropertyShapeVert(final Uri value) {
|
||||
if (this.propertyShapeVert.equals(value)) {
|
||||
return;
|
||||
}
|
||||
this.propertyShapeVert = value;
|
||||
onChangePropertyShapeVert();
|
||||
}
|
||||
|
||||
/**
|
||||
* Request a specific position for the scrolling of the current windows.
|
||||
* @param borderWidth size of the border that requested the element might not to be
|
||||
* @param currentPosition Position that is requested to view
|
||||
* @param _center True if the position might be at the center of the widget
|
||||
*/
|
||||
protected void setScrollingPositionDynamic(final Vector2f borderWidth, final Vector2f currentPosition) {
|
||||
setScrollingPositionDynamic(borderWidth, currentPosition, false);
|
||||
}
|
||||
|
||||
protected void setScrollingPositionDynamic(Vector2f borderWidth, final Vector2f currentPosition, final boolean center) {
|
||||
if (center) {
|
||||
borderWidth = new Vector2f(this.size.x() / 2 - borderWidth.x(), this.size.y() / 2 - borderWidth.y());
|
||||
}
|
||||
// check scrolling in X
|
||||
if (currentPosition.x() < (this.originScrooled.x() + borderWidth.x())) {
|
||||
this.originScrooled = this.originScrooled.withX(currentPosition.x() - borderWidth.x());
|
||||
this.originScrooled = this.originScrooled.withX(FMath.max(0.0f, this.originScrooled.x()));
|
||||
} else if (currentPosition.x() > (this.originScrooled.x() + this.size.x() - 2 * borderWidth.x())) {
|
||||
this.originScrooled = this.originScrooled.withX(currentPosition.x() - this.size.x() + 2 * borderWidth.x());
|
||||
this.originScrooled = this.originScrooled.withX(FMath.max(0.0f, this.originScrooled.x()));
|
||||
}
|
||||
// check scrolling in Y
|
||||
if (currentPosition.y() < (this.originScrooled.y() + borderWidth.y())) {
|
||||
this.originScrooled = this.originScrooled.withY(currentPosition.y() - borderWidth.y());
|
||||
this.originScrooled = this.originScrooled.withY(FMath.max(0.0f, this.originScrooled.y()));
|
||||
} else if (currentPosition.y() > (this.originScrooled.y() + this.size.y() - 2 * borderWidth.y())) {
|
||||
this.originScrooled = this.originScrooled.withY(currentPosition.y() - this.size.y() + 2 * borderWidth.y());
|
||||
this.originScrooled = this.originScrooled.withY(FMath.max(0.0f, this.originScrooled.y()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For mouse event when we have a scrolling UP and dows, specify the number of pixel that we scrooled
|
||||
* @param nbPixel number of pixel scrolling
|
||||
*/
|
||||
protected void setScrollingSize(final float nbPixel) {
|
||||
this.pixelScrolling = nbPixel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the single finger capabilities/
|
||||
* @param status True if single inger mode, two otherwise/
|
||||
*/
|
||||
public void setSingleFinger(final boolean status) {
|
||||
if (this.singleFingerMode == status) {
|
||||
return;
|
||||
}
|
||||
this.singleFingerMode = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void systemDraw(final DrawProperty displayProp) {
|
||||
OpenGL.push();
|
||||
if (this.scroollingMode == ScrollingMode.scroolModeCenter) {
|
||||
// here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left
|
||||
OpenGL.setViewPort(this.origin, this.size);
|
||||
final Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-this.size.x() / 2, this.size.x() / 2, -this.size.y() / 2, this.size.y() / 2, -1, 1);
|
||||
final Matrix4f tmpScale = Matrix4f.createMatrixScale(new Vector3f(this.zoom, this.zoom, 1));
|
||||
final Matrix4f tmpTranslate = Matrix4f.createMatrixTranslate(new Vector3f(-this.maxSize.x() / 2, -this.maxSize.y() / 2, -1));
|
||||
final Matrix4f tmpMat = tmpProjection.multiply(tmpScale).multiply(tmpTranslate);
|
||||
// set internal matrix system :
|
||||
OpenGL.setMatrix(tmpMat);
|
||||
// Call the widget drawing methode
|
||||
onDraw();
|
||||
}
|
||||
if (this.scroollingMode == ScrollingMode.scroolModeGame) {
|
||||
// here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left
|
||||
OpenGL.setViewPort(this.origin, this.size);
|
||||
final Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-this.size.x() / 2, this.size.x() / 2, -this.size.y() / 2, this.size.y() / 2, -1, 1);
|
||||
final Matrix4f tmpTranslate = Matrix4f.createMatrixTranslate(new Vector3f(-this.maxSize.x() / 2, -this.maxSize.y() / 2, -1));
|
||||
final Matrix4f tmpMat = tmpProjection.multiply(tmpTranslate);
|
||||
// set internal matrix system :
|
||||
OpenGL.setMatrix(tmpMat);
|
||||
// Call the widget drawing methode
|
||||
onDraw();
|
||||
} else {
|
||||
super.systemDraw(displayProp);
|
||||
}
|
||||
OpenGL.pop();
|
||||
}
|
||||
}
|
@ -10,8 +10,8 @@ public class WidgetXmlFactory implements InterfaceXmlFactoryAccess {
|
||||
static {
|
||||
listWidgetAvaillable.put("Button", Button.class);
|
||||
listWidgetAvaillable.put("Sizer", Sizer.class);
|
||||
listWidgetAvaillable.put("Label", LabelOnSVG.class);
|
||||
//listWidgetAvaillable.put("CheckBox", CheckBox.class);
|
||||
listWidgetAvaillable.put("Label", Label.class);
|
||||
listWidgetAvaillable.put("CheckBox", CheckBox.class);
|
||||
listWidgetAvaillable.put("Tick", Tick.class);
|
||||
listWidgetAvaillable.put("Image", ImageDisplay.class);
|
||||
}
|
||||
@ -26,4 +26,9 @@ public class WidgetXmlFactory implements InterfaceXmlFactoryAccess {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Class<?>> getConversionMap() {
|
||||
return listWidgetAvaillable;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user