[DEV] tree view start to be funny ==> now I can thing to to a browser
This commit is contained in:
parent
0d0cb02b85
commit
6ea7014244
66
data/theme/default/ChevronLeft.svg
Normal file
66
data/theme/default/ChevronLeft.svg
Normal file
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
width="64"
|
||||
height="64"
|
||||
viewBox="0 0 64 64"
|
||||
enable-background="new 0 0 24 24"
|
||||
xml:space="preserve"
|
||||
id="svg8"
|
||||
sodipodi:docname="ChevronLeft.svg"
|
||||
inkscape:version="0.92.2 2405546, 2018-03-11"><metadata
|
||||
id="metadata14"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs12" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1918"
|
||||
inkscape:window-height="1038"
|
||||
id="namedview10"
|
||||
showgrid="true"
|
||||
showguides="true"
|
||||
inkscape:zoom="27.812867"
|
||||
inkscape:cx="35.880854"
|
||||
inkscape:cy="43.550446"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="20"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg8"><inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid821" /></sodipodi:namedview>
|
||||
<g
|
||||
id="Bounding_Boxes"
|
||||
transform="translate(0,40)">
|
||||
<path
|
||||
d="M 0,0 H 24 V 24 H 0 Z"
|
||||
id="path2"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:none" />
|
||||
</g>
|
||||
<g
|
||||
id="Outline_1_"
|
||||
transform="matrix(4.1679329,0,0,4.1679329,-16.912008,-18.015195)">
|
||||
<path
|
||||
d="M 15.41,7.41 14,6 8,12 14,18 15.41,16.59 10.83,12 Z"
|
||||
id="path5"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.0 KiB |
66
data/theme/default/ChevronLess.svg
Normal file
66
data/theme/default/ChevronLess.svg
Normal file
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
width="64"
|
||||
height="64"
|
||||
viewBox="0 0 64 64"
|
||||
enable-background="new 0 0 24 24"
|
||||
xml:space="preserve"
|
||||
id="svg8"
|
||||
sodipodi:docname="ChevronLess.svg"
|
||||
inkscape:version="0.92.2 2405546, 2018-03-11"><metadata
|
||||
id="metadata14"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs12" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1918"
|
||||
inkscape:window-height="1038"
|
||||
id="namedview10"
|
||||
showgrid="true"
|
||||
showguides="true"
|
||||
inkscape:zoom="13.906433"
|
||||
inkscape:cx="45.005732"
|
||||
inkscape:cy="37.911807"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="20"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg8"><inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid821" /></sodipodi:namedview>
|
||||
<g
|
||||
id="Bounding_Boxes"
|
||||
transform="translate(0,40)">
|
||||
<path
|
||||
d="M 0,0 H 24 V 24 H 0 Z"
|
||||
id="path2"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:none" />
|
||||
</g>
|
||||
<g
|
||||
id="Outline_1_"
|
||||
transform="matrix(0,4.1679329,-4.1679329,0,81.888841,-16.785655)">
|
||||
<path
|
||||
d="M 15.41,7.41 14,6 8,12 14,18 15.41,16.59 10.83,12 Z"
|
||||
id="path5"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.0 KiB |
66
data/theme/default/ChevronMore.svg
Normal file
66
data/theme/default/ChevronMore.svg
Normal file
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
width="64"
|
||||
height="64"
|
||||
viewBox="0 0 64 64"
|
||||
enable-background="new 0 0 24 24"
|
||||
xml:space="preserve"
|
||||
id="svg8"
|
||||
sodipodi:docname="ChevronMore.svg"
|
||||
inkscape:version="0.92.2 2405546, 2018-03-11"><metadata
|
||||
id="metadata14"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs12" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1918"
|
||||
inkscape:window-height="1038"
|
||||
id="namedview10"
|
||||
showgrid="true"
|
||||
showguides="true"
|
||||
inkscape:zoom="13.906433"
|
||||
inkscape:cx="45.005732"
|
||||
inkscape:cy="37.911807"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="20"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg8"><inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid821" /></sodipodi:namedview>
|
||||
<g
|
||||
id="Bounding_Boxes"
|
||||
transform="translate(0,40)">
|
||||
<path
|
||||
d="M 0,0 H 24 V 24 H 0 Z"
|
||||
id="path2"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:none" />
|
||||
</g>
|
||||
<g
|
||||
id="Outline_1_"
|
||||
transform="matrix(0,-4.1679329,-4.1679329,0,81.888841,80.785654)">
|
||||
<path
|
||||
d="M 15.41,7.41 14,6 8,12 14,18 15.41,16.59 10.83,12 Z"
|
||||
id="path5"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.0 KiB |
66
data/theme/default/ChevronRight.svg
Normal file
66
data/theme/default/ChevronRight.svg
Normal file
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
width="64"
|
||||
height="64"
|
||||
viewBox="0 0 64 64"
|
||||
enable-background="new 0 0 24 24"
|
||||
xml:space="preserve"
|
||||
id="svg8"
|
||||
sodipodi:docname="ChevronRight.svg"
|
||||
inkscape:version="0.92.2 2405546, 2018-03-11"><metadata
|
||||
id="metadata14"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs12" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1918"
|
||||
inkscape:window-height="1038"
|
||||
id="namedview10"
|
||||
showgrid="true"
|
||||
showguides="true"
|
||||
inkscape:zoom="27.812867"
|
||||
inkscape:cx="35.880854"
|
||||
inkscape:cy="43.550446"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="20"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg8"><inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid821" /></sodipodi:namedview>
|
||||
<g
|
||||
id="Bounding_Boxes"
|
||||
transform="translate(0,40)">
|
||||
<path
|
||||
d="M 0,0 H 24 V 24 H 0 Z"
|
||||
id="path2"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:none" />
|
||||
</g>
|
||||
<g
|
||||
id="Outline_1_"
|
||||
transform="matrix(-4.1679329,0,0,4.1679329,80.659301,-18.015195)">
|
||||
<path
|
||||
d="M 15.41,7.41 14,6 8,12 14,18 15.41,16.59 10.83,12 Z"
|
||||
id="path5"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.0 KiB |
@ -26,6 +26,12 @@ ewol::widget::List::List() {
|
||||
m_limitScrolling = vec2(1, 0.5);
|
||||
}
|
||||
|
||||
|
||||
void ewol::widget::List::init() {
|
||||
ewol::widget::WidgetScrolled::init();
|
||||
}
|
||||
|
||||
|
||||
ewol::widget::List::~List() {
|
||||
//clean all the object
|
||||
for (size_t iii=0; iii<m_listOObject.size(); iii++) {
|
||||
@ -145,6 +151,7 @@ void ewol::widget::List::onRegenerateDisplay() {
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (propertyFill->y() == true) {
|
||||
int32_t fullSize = 0;
|
||||
for (auto &size: m_listSizeY) {
|
||||
@ -160,6 +167,7 @@ void ewol::widget::List::onRegenerateDisplay() {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
// -------------------------------------------------------
|
||||
// -- Calculate the start position size of each element
|
||||
// -------------------------------------------------------
|
||||
@ -277,30 +285,46 @@ bool ewol::widget::List::onEventInput(const ewol::event::Input& _event) {
|
||||
// nothing to do ... done on upper widet ...
|
||||
return true;
|
||||
}
|
||||
if (m_listSizeY.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
relativePos = vec2(relativePos.x(),m_size.y() - relativePos.y()) + m_originScrooled;
|
||||
// Find the colomn and the row
|
||||
ivec2 pos{-1,-1};
|
||||
int32_t offset = 0;
|
||||
ivec2 pos{0,0};
|
||||
float_t offsetY = 0;
|
||||
for (size_t iii=0; iii<m_listSizeY.size()-1; iii++) {
|
||||
int32_t previous = offset;
|
||||
offset += m_listSizeY[iii];
|
||||
if( relativePos.y() < offset
|
||||
&& relativePos.y() >= previous ) {
|
||||
int32_t previous = offsetY;
|
||||
offsetY += m_listSizeY[iii];
|
||||
if ( relativePos.y() < offsetY
|
||||
&& relativePos.y() >= previous ) {
|
||||
pos.setY(iii);
|
||||
offsetY = previous;
|
||||
break;
|
||||
}
|
||||
if ( iii == m_listSizeY.size()-2
|
||||
&& relativePos.y() >= offsetY ) {
|
||||
pos.setY(iii+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
offset = 0;
|
||||
float_t offsetX = 0;
|
||||
for (size_t iii=0; iii<m_listSizeX.size()-1; iii++) {
|
||||
int32_t previous = offset;
|
||||
offset += m_listSizeX[iii];
|
||||
if( relativePos.x() < offset
|
||||
&& relativePos.x() >= previous ) {
|
||||
int32_t previous = offsetX;
|
||||
offsetX += m_listSizeX[iii];
|
||||
if ( relativePos.x() < offsetX
|
||||
&& relativePos.x() >= previous ) {
|
||||
pos.setX(iii);
|
||||
offsetX = previous;
|
||||
break;
|
||||
}
|
||||
if ( iii == m_listSizeX.size()-2
|
||||
&& relativePos.x() >= offsetX ) {
|
||||
pos.setX(iii+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool isUsed = onItemEvent(_event.getId(), _event.getStatus(), pos, _event.getPos());
|
||||
vec2 posInternalMouse = relativePos - vec2(offsetX, offsetY);
|
||||
bool isUsed = onItemEvent(_event, pos, posInternalMouse);
|
||||
if (isUsed == true) {
|
||||
// TODO : this generate bugs ... I did not understand why ..
|
||||
//ewol::WidgetSharedManager::focusKeep(this);
|
||||
|
@ -39,6 +39,7 @@ namespace ewol {
|
||||
class List : public ewol::widget::WidgetScrolled {
|
||||
protected:
|
||||
List();
|
||||
void init() override;
|
||||
public:
|
||||
virtual ~List();
|
||||
void calculateMinMaxSize() override;
|
||||
@ -103,7 +104,7 @@ namespace ewol {
|
||||
*/
|
||||
virtual void drawBackground();
|
||||
|
||||
virtual bool onItemEvent(int32_t _IdInput, enum gale::key::status _typeEvent, const ivec2& _pos, const vec2& _mousePosition) {
|
||||
virtual bool onItemEvent(const ewol::event::Input& _event, const ivec2& _pos, const vec2& _mousePosition) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
|
@ -164,8 +164,7 @@ fluorine::Variant ewol::widget::ListFileSystem::getData(int32_t _role, const ive
|
||||
return fluorine::Variant();
|
||||
}
|
||||
|
||||
bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput,
|
||||
enum gale::key::status _typeEvent,
|
||||
bool ewol::widget::ListFileSystem::onItemEvent(const ewol::event::Input& _event,
|
||||
const ivec2& _pos,
|
||||
const vec2& _mousePosition) {
|
||||
int32_t offset = 0;
|
||||
@ -176,9 +175,9 @@ bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput,
|
||||
offset = 2;
|
||||
}
|
||||
}
|
||||
if (_typeEvent == gale::key::status::pressSingle) {
|
||||
EWOL_VERBOSE("Event on List : IdInput=" << _IdInput << " _pos=" << _pos );
|
||||
if (1 == _IdInput) {
|
||||
if (_event.getStatus() == gale::key::status::pressSingle) {
|
||||
EWOL_VERBOSE("Event on List : IdInput=" << _event.getId() << " _pos=" << _pos );
|
||||
if (1 == _event.getId()) {
|
||||
int32_t previousRaw = m_selectedLine;
|
||||
if (_pos.y() > (int32_t)m_list.size()+offset ) {
|
||||
m_selectedLine = -1;
|
||||
|
@ -46,7 +46,7 @@ namespace ewol {
|
||||
etk::Color<> getBasicBG() override;
|
||||
ivec2 getMatrixSize() const override;
|
||||
fluorine::Variant getData(int32_t _role, const ivec2& _pos) override;
|
||||
bool onItemEvent(int32_t _IdInput, enum gale::key::status _typeEvent, const ivec2& _pos, const vec2& _mousePosition) override;
|
||||
bool onItemEvent(const ewol::event::Input& _event, const ivec2& _pos, const vec2& _mousePosition) override;
|
||||
protected:
|
||||
// TODO: use shred_ptr
|
||||
etk::Vector<etk::FSNode *> m_list; //!< List of all element in the path. (they are filtered)
|
||||
|
@ -27,6 +27,11 @@ ewol::widget::TreeView::TreeView():
|
||||
addObjectType("ewol::widget::TreeView");
|
||||
}
|
||||
|
||||
void ewol::widget::TreeView::init() {
|
||||
ewol::widget::List::init();
|
||||
propertyFill.set(bvec2(true,false));
|
||||
}
|
||||
|
||||
ewol::widget::TreeView::~TreeView() {
|
||||
|
||||
}
|
||||
@ -37,6 +42,14 @@ vec2 ewol::widget::TreeView::calculateElementSize(const ivec2& _pos) {
|
||||
float_t treeOffset = 0;
|
||||
if (_pos.x() == 0) {
|
||||
treeOffset += getData(ListRole::DistanceToRoot, _pos).getSafeNumber() * propertyOffsetTreeView.get();
|
||||
#if 0
|
||||
bool haveChild = getData(ListRole::HaveChild, _pos).getSafeBoolean();
|
||||
if (haveChild == true) {
|
||||
treeOffset += propertyOffsetTreeView.get();
|
||||
}
|
||||
#else
|
||||
treeOffset += propertyOffsetTreeView.get();
|
||||
#endif
|
||||
}
|
||||
etk::String iconName;
|
||||
float_t iconSize = 0;
|
||||
@ -46,7 +59,7 @@ vec2 ewol::widget::TreeView::calculateElementSize(const ivec2& _pos) {
|
||||
iconSize += propertyIconTreeViewSize.get();
|
||||
}
|
||||
}
|
||||
vec3 textSize = tmpText.calculateSize(myTextToWrite);
|
||||
vec3 textSize = tmpText.calculateSizeDecorated(myTextToWrite);
|
||||
ivec2 count = getMatrixSize();
|
||||
return vec2(textSize.x() + treeOffset + iconSize,
|
||||
etk::max(textSize.y(), iconSize) + m_paddingSizeY*3
|
||||
@ -56,16 +69,33 @@ vec2 ewol::widget::TreeView::calculateElementSize(const ivec2& _pos) {
|
||||
void ewol::widget::TreeView::drawElement(const ivec2& _pos, const vec2& _start, const vec2& _size) {
|
||||
vec2 posStart = _start;
|
||||
etk::String iconName;
|
||||
etk::Color<> fg = getData(ListRole::FgColor, _pos).getSafeColor();
|
||||
if (_pos.x() == 0) {
|
||||
auto value = getData(ListRole::DistanceToRoot, _pos);
|
||||
if (value.isNumber() == true) {
|
||||
posStart.setX(posStart.x() + value.getSafeNumber() * propertyOffsetTreeView.get());
|
||||
}
|
||||
iconName = getData(ListRole::Icon, _pos).getSafeString();
|
||||
bool haveChild = getData(ListRole::HaveChild, _pos).getSafeBoolean();
|
||||
if (haveChild == true) {
|
||||
ewol::compositing::Image * tmpImage = null;
|
||||
if ( getData(ListRole::IsExpand, _pos).getSafeBoolean() == false) {
|
||||
tmpImage = ETK_NEW(ewol::compositing::Image, "{ewol}THEME:GUI:ChevronRight.svg");
|
||||
} else {
|
||||
tmpImage = ETK_NEW(ewol::compositing::Image, "{ewol}THEME:GUI:ChevronMore.svg");
|
||||
}
|
||||
if (tmpImage != null) {
|
||||
addOObject(tmpImage);
|
||||
tmpImage->setColor(fg);
|
||||
tmpImage->setPos(posStart);
|
||||
tmpImage->print(vec2(propertyIconTreeViewSize.get(), propertyIconTreeViewSize.get()));
|
||||
}
|
||||
}
|
||||
// move right
|
||||
posStart.setX(posStart.x() + propertyIconTreeViewSize.get());
|
||||
}
|
||||
|
||||
etk::String myTextToWrite = getData(ListRole::Text, _pos).getSafeString();
|
||||
etk::Color<> fg = getData(ListRole::FgColor, _pos).getSafeColor();
|
||||
auto backgroundVariant = getData(ListRole::BgColor, _pos);
|
||||
if (backgroundVariant.isColor() == true) {
|
||||
etk::Color<> bg = backgroundVariant.getColor();
|
||||
@ -95,7 +125,7 @@ void ewol::widget::TreeView::drawElement(const ivec2& _pos, const vec2& _start,
|
||||
addOObject(tmpText);
|
||||
tmpText->setColor(fg);
|
||||
tmpText->setPos(posStart);
|
||||
tmpText->print(myTextToWrite);;
|
||||
tmpText->printDecorated(myTextToWrite);;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -104,3 +134,36 @@ void ewol::widget::TreeView::onChangePropertyOffsetTreeView() {
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
bool ewol::widget::TreeView::onItemEvent(const ewol::event::Input& _event, const ivec2& _pos, const vec2& _mousePosition) {
|
||||
if (_event.getStatus() != gale::key::status::pressSingle) {
|
||||
return false;
|
||||
}
|
||||
if (_event.getId() != 1) {
|
||||
return false;
|
||||
}
|
||||
if (_pos.x() != 0) {
|
||||
return false;
|
||||
}
|
||||
//EWOL_INFO("event: " << _event);
|
||||
vec2 posStart = vec2(0,0);
|
||||
bool haveChild = getData(ListRole::HaveChild, _pos).getSafeBoolean();
|
||||
if (haveChild == false) {
|
||||
return false;
|
||||
}
|
||||
auto value = getData(ListRole::DistanceToRoot, _pos);
|
||||
if (value.isNumber() == true) {
|
||||
posStart.setX(posStart.x() + value.getSafeNumber() * propertyOffsetTreeView.get());
|
||||
}
|
||||
// Inverse the display of Y
|
||||
EWOL_VERBOSE("check: " << vec2(_mousePosition.x(), m_listSizeY[_pos.y()] - _mousePosition.y())
|
||||
<< " in " << posStart
|
||||
<< " -> " << (posStart+vec2(propertyIconTreeViewSize.get(),propertyIconTreeViewSize.get())));
|
||||
if ( _mousePosition.x() >= posStart.x()
|
||||
&& _mousePosition.x() <= posStart.x()+propertyIconTreeViewSize.get()
|
||||
&& m_listSizeY[_pos.y()] - _mousePosition.y() >= posStart.y()
|
||||
&& m_listSizeY[_pos.y()] - _mousePosition.y() <= propertyIconTreeViewSize.get() ) {
|
||||
onItemExpandEvent(_pos);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
@ -28,6 +28,7 @@ namespace ewol {
|
||||
eproperty::Value<float> propertyIconTreeViewSize; //!< Size of the icon.
|
||||
protected:
|
||||
TreeView();
|
||||
void init() override;
|
||||
public:
|
||||
virtual ~TreeView();
|
||||
protected:
|
||||
@ -48,6 +49,9 @@ namespace ewol {
|
||||
void drawElement(const ivec2& _pos, const vec2& _start, const vec2& _size) override;
|
||||
protected:
|
||||
virtual void onChangePropertyOffsetTreeView();
|
||||
|
||||
bool onItemEvent(const ewol::event::Input& _event, const ivec2& _pos, const vec2& _mousePosition) override;
|
||||
virtual void onItemExpandEvent(const ivec2& _pos) { };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -7,31 +7,48 @@
|
||||
#include "BasicTree.hpp"
|
||||
#include <etk/tool.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(appl::widget::BasicTree);
|
||||
|
||||
appl::widget::BasicTree::BasicTree() {
|
||||
addObjectType("appl::widget::BasicTree");
|
||||
}
|
||||
|
||||
void appl::widget::BasicTree::init() {
|
||||
ewol::widget::TreeView::init();
|
||||
setMouseLimit(1);
|
||||
m_tree = NodeElement::create(TreeElement("root", false, true));
|
||||
m_tree = etk::TreeNode<TreeElement>::create(TreeElement("root", false, true));
|
||||
for (size_t iii=0; iii<10; ++iii) {
|
||||
auto elem_iii = NodeElement::create(TreeElement("elem_" + etk::toString(iii)));
|
||||
auto elem_iii = etk::TreeNode<TreeElement>::create(TreeElement("elem_" + etk::toString(iii), false, false));
|
||||
m_tree->addChild(elem_iii);
|
||||
for (size_t jjj=0; jjj<iii; ++jjj) {
|
||||
auto elem_iii_jjj = NodeElement::create(TreeElement("elem_" + etk::toString(iii) + "____" + etk::toString(jjj)));
|
||||
elem_iii->addChild(elem_iii_jjj);
|
||||
if (jjj%3 == 0) {
|
||||
auto elem_iii_jjj = etk::TreeNode<TreeElement>::create(TreeElement("elem_" + etk::toString(iii) + "____" + etk::toString(jjj) + "<br/> an other line ...", false, false));
|
||||
elem_iii->addChild(elem_iii_jjj);
|
||||
} else {
|
||||
auto elem_iii_jjj = etk::TreeNode<TreeElement>::create(TreeElement("elem_" + etk::toString(iii) + "____" + etk::toString(jjj), false, false));
|
||||
elem_iii->addChild(elem_iii_jjj);
|
||||
}
|
||||
}
|
||||
}
|
||||
updateFlatTree();
|
||||
}
|
||||
|
||||
|
||||
void appl::widget::BasicTree::updateFlatTree() {
|
||||
m_flatTree.setRoot(m_tree,
|
||||
[&](TreeElement* _value){
|
||||
[&](const TreeElement& _value){
|
||||
return true;
|
||||
},
|
||||
[&](TreeElement* _value){
|
||||
[&](const TreeElement& _value){
|
||||
return _value.m_isExpand;
|
||||
});
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
appl::widget::BasicTree::~BasicTree() {
|
||||
|
||||
}
|
||||
@ -59,6 +76,10 @@ fluorine::Variant appl::widget::BasicTree::getData(int32_t _role, const ivec2& _
|
||||
return "value: " + etk::toString(_pos);
|
||||
case ewol::widget::ListRole::DistanceToRoot:
|
||||
return uint_t(elem->countToRoot());
|
||||
case ewol::widget::ListRole::HaveChild:
|
||||
return elem->haveChild();
|
||||
case ewol::widget::ListRole::IsExpand:
|
||||
return value.m_isExpand;
|
||||
case ewol::widget::ListRole::Icon:
|
||||
if (elem->countToRoot() == 0) {
|
||||
return "{ewol}THEME:GUI:Home.svg";
|
||||
@ -73,88 +94,16 @@ fluorine::Variant appl::widget::BasicTree::getData(int32_t _role, const ivec2& _
|
||||
case ewol::widget::ListRole::FgColor:
|
||||
return etk::Color<>(0,0,0,0xFF);
|
||||
case ewol::widget::ListRole::BgColor:
|
||||
if ((_pos.y()%2) == 0) {
|
||||
return etk::Color<>(0,0,0,0x15);
|
||||
}
|
||||
return fluorine::Variant();
|
||||
}
|
||||
return fluorine::Variant();
|
||||
}
|
||||
|
||||
bool appl::widget::BasicTree::onItemEvent(int32_t _IdInput,
|
||||
enum gale::key::status _typeEvent,
|
||||
const ivec2& _pos,
|
||||
const vec2& _mousePosition) {
|
||||
/*
|
||||
int32_t offset = 0;
|
||||
if (*propertyShowFolder == true) {
|
||||
if (*propertyPath == "/") {
|
||||
offset = 1;
|
||||
} else {
|
||||
offset = 2;
|
||||
}
|
||||
}
|
||||
if (_typeEvent == gale::key::status::pressSingle) {
|
||||
EWOL_VERBOSE("Event on List : IdInput=" << _IdInput << " _pos=" << _pos );
|
||||
if (1 == _IdInput) {
|
||||
int32_t previousRaw = m_selectedLine;
|
||||
if (_pos.y() > (int32_t)m_list.size()+offset ) {
|
||||
m_selectedLine = -1;
|
||||
} else {
|
||||
m_selectedLine = _pos.y();
|
||||
}
|
||||
if (previousRaw != m_selectedLine) {
|
||||
if( *propertyShowFolder == true
|
||||
&& m_selectedLine == 0) {
|
||||
// "." folder
|
||||
signalFolderSelect.emit(".");
|
||||
} else if ( *propertyShowFolder == true
|
||||
&& m_selectedLine == 1) {
|
||||
// ".." folder
|
||||
signalFolderSelect.emit("..");
|
||||
} else if( m_selectedLine-offset >= 0
|
||||
&& m_selectedLine-offset < (int32_t)m_list.size()
|
||||
&& null != m_list[m_selectedLine-offset] ) {
|
||||
// generate event extern :
|
||||
switch(m_list[m_selectedLine-offset]->getNodeType()) {
|
||||
case etk::typeNode_file :
|
||||
signalFileSelect.emit(m_list[m_selectedLine-offset]->getNameFile());
|
||||
break;
|
||||
case etk::typeNode_folder :
|
||||
signalFolderSelect.emit(m_list[m_selectedLine-offset]->getNameFile());
|
||||
break;
|
||||
default:
|
||||
EWOL_ERROR("Can not generate event on an unknow type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if( *propertyShowFolder == true
|
||||
&& m_selectedLine == 0) {
|
||||
// "." folder
|
||||
signalFolderValidate.emit(".");
|
||||
} else if ( *propertyShowFolder == true
|
||||
&& m_selectedLine == 1) {
|
||||
// ".." folder
|
||||
signalFolderValidate.emit("..");
|
||||
} else if( m_selectedLine-offset >= 0
|
||||
&& m_selectedLine-offset < (int32_t)m_list.size()
|
||||
&& null != m_list[m_selectedLine-offset] ) {
|
||||
switch(m_list[m_selectedLine-offset]->getNodeType()) {
|
||||
case etk::typeNode_file :
|
||||
signalFileValidate.emit(m_list[m_selectedLine-offset]->getNameFile());
|
||||
break;
|
||||
case etk::typeNode_folder :
|
||||
signalFolderValidate.emit(m_list[m_selectedLine-offset]->getNameFile());
|
||||
break;
|
||||
default:
|
||||
EWOL_ERROR("Can not generate event on an unknow type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// need to regenerate the display of the list :
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
void appl::widget::BasicTree::onItemExpandEvent(const ivec2& _pos) {
|
||||
TEST_WARNING("Event on expand on " << _pos);
|
||||
m_flatTree[_pos.y()]->getData().m_isExpand = m_flatTree[_pos.y()]->getData().m_isExpand?false:true;
|
||||
updateFlatTree();
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace appl {
|
||||
using BasicTreeWeak = ememory::WeakPtr<appl::widget::BasicTree>;
|
||||
class TreeElement {
|
||||
public:
|
||||
TreeElement(const etk::String& _display="", bool _isSelected = false, bool m_isExpand=false):
|
||||
TreeElement(const etk::String& _display="", bool _isSelected = false, bool _isExpand=false):
|
||||
m_display(_display),
|
||||
m_isSelected(_isSelected),
|
||||
m_isExpand(_isExpand) {
|
||||
@ -27,23 +27,25 @@ namespace appl {
|
||||
etk::String m_display;
|
||||
bool m_isSelected = false;
|
||||
bool m_isExpand = false;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @brief Generic display folder class. This widget display the content of a single folder :
|
||||
*/
|
||||
class BasicTree : public ewol::widget::TreeView {
|
||||
protected:
|
||||
BasicTree();
|
||||
void init() override;
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(BasicTree, "BasicTree");
|
||||
virtual ~BasicTree();
|
||||
protected:
|
||||
void updateFlatTree();
|
||||
etk::Color<> getBasicBG() override;
|
||||
ivec2 getMatrixSize() const override;
|
||||
fluorine::Variant getData(int32_t _role, const ivec2& _pos) override;
|
||||
bool onItemEvent(int32_t _IdInput, enum gale::key::status _typeEvent, const ivec2& _pos, const vec2& _mousePosition) override;
|
||||
|
||||
ememory::SharedPtr<etk::TreeNode<NodeElement>> m_tree;
|
||||
//bool onItemEvent(const ewol::event::Input& _event, const ivec2& _pos, const vec2& _mousePosition) override;
|
||||
void onItemExpandEvent(const ivec2& _pos) override;
|
||||
ememory::SharedPtr<etk::TreeNode<TreeElement>> m_tree;
|
||||
etk::FlatTree<TreeElement> m_flatTree;
|
||||
};
|
||||
};
|
||||
|
@ -34,7 +34,8 @@ def configure(target, my_module):
|
||||
'appl/widget/BasicTree.cpp',
|
||||
])
|
||||
my_module.add_depend([
|
||||
'ewol'
|
||||
'ewol',
|
||||
'test-debug',
|
||||
])
|
||||
my_module.add_flag('c++', [
|
||||
"-DPROJECT_NAME=\"\\\""+my_module.get_name()+"\\\"\"",
|
||||
|
Loading…
x
Reference in New Issue
Block a user