Skip to content

Commit 956a7fb

Browse files
author
Dimitri van Heesch
committed
Improved performance of rendering large index pages, by replacing images in the tables by spans
1 parent d5fb697 commit 956a7fb

File tree

4 files changed

+136
-115
lines changed

4 files changed

+136
-115
lines changed

src/doxygen.css

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -670,12 +670,12 @@ span.mlabel {
670670

671671
/* @end */
672672

673-
/* these are for tree view when not used as main index */
673+
/* these are for tree view inside a (index) page */
674674

675675
div.directory {
676676
margin: 10px 0px;
677-
border-top: 1px solid #A8B8D9;
678-
border-bottom: 1px solid #A8B8D9;
677+
border-top: 1px solid ##AA;
678+
border-bottom: 1px solid ##AA;
679679
width: 100%;
680680
}
681681

@@ -734,6 +734,80 @@ div.directory {
734734
color: ##50;
735735
}
736736

737+
.arrow {
738+
color: ##AA;
739+
-webkit-user-select: none;
740+
-khtml-user-select: none;
741+
-moz-user-select: none;
742+
-ms-user-select: none;
743+
user-select: none;
744+
cursor: pointer;
745+
font-size: 80%;
746+
display: inline-block;
747+
width: 16px;
748+
height: 22px;
749+
}
750+
751+
.icon {
752+
font-family: Arial, Helvetica;
753+
font-weight: bold;
754+
font-size: 12px;
755+
height: 14px;
756+
width: 16px;
757+
display: inline-block;
758+
background-color: ##88;
759+
color: white;
760+
text-align: center;
761+
border-radius: 4px;
762+
margin-left: 2px;
763+
margin-right: 2px;
764+
}
765+
766+
.icona {
767+
width: 24px;
768+
height: 22px;
769+
display: inline-block;
770+
}
771+
772+
.iconfopen {
773+
width: 24px;
774+
height: 18px;
775+
margin-bottom: 4px;
776+
background-image:url('ftv2folderopen.png');
777+
background-position: 0px -4px;
778+
background-repeat: repeat-y;
779+
vertical-align:top;
780+
display: inline-block;
781+
}
782+
783+
.iconfclosed {
784+
width: 24px;
785+
height: 18px;
786+
margin-bottom: 4px;
787+
background-image:url('ftv2folderclosed.png');
788+
background-position: 0px -4px;
789+
background-repeat: repeat-y;
790+
vertical-align:top;
791+
display: inline-block;
792+
}
793+
794+
.icondoc {
795+
width: 24px;
796+
height: 18px;
797+
margin-bottom: 4px;
798+
background-image:url('ftv2doc.png');
799+
background-position: 0px -4px;
800+
background-repeat: repeat-y;
801+
vertical-align:top;
802+
display: inline-block;
803+
}
804+
805+
table.directory {
806+
font: 400 14px Roboto,sans-serif;
807+
}
808+
809+
/* @end */
810+
737811
div.dynheader {
738812
margin-top: 8px;
739813
-webkit-touch-callout: none;

src/dynsections.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,20 @@ function updateStripes()
2424
$('table.directory tr').
2525
removeClass('even').filter(':visible:even').addClass('even');
2626
}
27+
2728
function toggleLevel(level)
2829
{
29-
$('table.directory tr').each(function(){
30+
$('table.directory tr').each(function() {
3031
var l = this.id.split('_').length-1;
3132
var i = $('#img'+this.id.substring(3));
3233
var a = $('#arr'+this.id.substring(3));
3334
if (l<level+1) {
34-
i.attr('src','ftv2folderopen.png');
35-
a.attr('src','ftv2mnode.png');
35+
i.removeClass('iconfopen iconfclosed').addClass('iconfopen');
36+
a.html('&#9660;');
3637
$(this).show();
3738
} else if (l==level+1) {
38-
i.attr('src','ftv2folderclosed.png');
39-
a.attr('src','ftv2pnode.png');
39+
i.removeClass('iconfclosed iconfopen').addClass('iconfclosed');
40+
a.html('&#9658;');
4041
$(this).show();
4142
} else {
4243
$(this).hide();
@@ -47,34 +48,33 @@ function toggleLevel(level)
4748

4849
function toggleFolder(id)
4950
{
50-
//The clicked row
51+
// the clicked row
5152
var currentRow = $('#row_'+id);
52-
var currentRowImages = currentRow.find("img");
5353

54-
//All rows after the clicked row
54+
// all rows after the clicked row
5555
var rows = currentRow.nextAll("tr");
5656

57-
//Only match elements AFTER this one (can't hide elements before)
58-
var childRows = rows.filter(function() {
59-
var re = new RegExp('^row_'+id+'\\d+_$', "i"); //only one sub
60-
return this.id.match(re);
61-
});
57+
var re = new RegExp('^row_'+id+'\\d+_$', "i"); //only one sub
6258

63-
//First row is visible we are HIDING
64-
if (childRows.filter(':first').is(':visible')===true) {
65-
currentRowImages.filter("[id^=arr]").attr('src', 'ftv2pnode.png');
66-
currentRowImages.filter("[id^=img]").attr('src', 'ftv2folderclosed.png');
67-
rows.filter("[id^=row_"+id+"]").hide();
68-
} else { //We are SHOWING
69-
//All sub images
70-
var childImages = childRows.find("img");
71-
var childImg = childImages.filter("[id^=img]");
72-
var childArr = childImages.filter("[id^=arr]");
59+
// only match elements AFTER this one (can't hide elements before)
60+
var childRows = rows.filter(function() { return this.id.match(re); });
7361

74-
currentRow.find("[id^=arr]").attr('src', 'ftv2mnode.png'); //open row
75-
currentRow.find("[id^=img]").attr('src', 'ftv2folderopen.png'); //open row
76-
childImg.attr('src','ftv2folderclosed.png'); //children closed
77-
childArr.attr('src','ftv2pnode.png'); //children closed
62+
// first row is visible we are HIDING
63+
if (childRows.filter(':first').is(':visible')===true) {
64+
// replace down arrow by right arrow for current row
65+
var currentRowSpans = currentRow.find("span");
66+
currentRowSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
67+
currentRowSpans.filter(".arrow").html('&#9658;');
68+
rows.filter("[id^=row_"+id+"]").hide(); // hide all children
69+
} else { // we are SHOWING
70+
// replace right arrow by down arrow for current row
71+
var currentRowSpans = currentRow.find("span");
72+
currentRowSpans.filter(".iconfclosed").removeClass("iconfclosed").addClass("iconfopen");
73+
currentRowSpans.filter(".arrow").html('&#9660;');
74+
// replace down arrows by right arrows for child rows
75+
var childRowsSpans = childRows.find("span");
76+
childRowsSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
77+
childRowsSpans.filter(".arrow").html('&#9658;');
7878
childRows.show(); //show all children
7979
}
8080
updateStripes();

src/ftvhelp.cpp

Lines changed: 31 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ static unsigned char doc_a_png[528] =
234234
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
235235
};
236236

237+
#if 0
237238
static unsigned char module_png[528] =
238239
{
239240
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
@@ -338,6 +339,7 @@ static unsigned char letter_a_png[528] =
338339
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
339340
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
340341
};
342+
#endif
341343

342344

343345
static unsigned char arrow_right_png[352] =
@@ -507,6 +509,7 @@ struct FTVImageInfo
507509

508510
//extern FTVImageInfo image_info[];
509511

512+
#if 0
510513
#define FTVIMG_blank 0
511514
#define FTVIMG_doc 1
512515
#define FTVIMG_folderclosed 2
@@ -553,16 +556,17 @@ static FTVImageInfo image_info[] =
553556
{ "M", "ftv2mo.png", 0 /*ftv2vertline_png*/ /*,352*/,24,22 },
554557
{ 0, 0, 0 /*, 0*/, 0, 0 }
555558
};
559+
#endif
556560

557561
static ColoredImgDataItem ftv_image_data[] =
558562
{
559563
{ "ftv2blank.png", 16, 22, blank_png, blank_png },
560564
{ "ftv2doc.png", 24, 22, doc_png, doc_a_png },
561565
{ "ftv2folderclosed.png", 24, 22, folderclosed_png, folderclosed_a_png },
562566
{ "ftv2folderopen.png", 24, 22, folderopen_png, folderopen_a_png },
563-
{ "ftv2ns.png", 24, 22, namespace_png, letter_a_png },
564-
{ "ftv2mo.png", 24, 22, module_png, letter_a_png },
565-
{ "ftv2cl.png", 24, 22, class_png, letter_a_png },
567+
// { "ftv2ns.png", 24, 22, namespace_png, letter_a_png },
568+
// { "ftv2mo.png", 24, 22, module_png, letter_a_png },
569+
// { "ftv2cl.png", 24, 22, class_png, letter_a_png },
566570
{ "ftv2lastnode.png", 16, 22, blank_png, blank_png },
567571
{ "ftv2link.png", 24, 22, doc_png, doc_a_png },
568572
{ "ftv2mlastnode.png", 16, 22, arrow_down_png, arrow_down_a_png },
@@ -784,64 +788,23 @@ QCString FTVHelp::generateIndentLabel(FTVNode *n,int level)
784788
return result;
785789
}
786790

787-
void FTVHelp::generateIndent(FTextStream &t, FTVNode *n,int level, bool opened)
791+
void FTVHelp::generateIndent(FTextStream &t, FTVNode *n,bool opened)
788792
{
789-
if (n->parent)
793+
int indent=0;
794+
FTVNode *p = n->parent;
795+
while (p) { indent++; p=p->parent; }
796+
if (n->isDir)
790797
{
791-
generateIndent(t,n->parent,level+1,opened);
798+
QCString dir = opened ? "&#9660;" : "&#9658;";
799+
t << "<span style=\"width:" << (indent*16) << "px;display:inline-block;\">&#160;</span>"
800+
<< "<span id=\"arr_" << generateIndentLabel(n,0) << "\" class=\"arrow\" ";
801+
t << "onclick=\"toggleFolder('" << generateIndentLabel(n,0) << "')\"";
802+
t << ">" << dir
803+
<< "</span>";
792804
}
793-
// from the root up to node n do...
794-
if (level==0) // item before a dir or document
805+
else
795806
{
796-
if (n->isLast)
797-
{
798-
if (n->isDir)
799-
{
800-
t << "<img id=\"arr_" << generateIndentLabel(n,0)
801-
<< "\" ";
802-
if (opened)
803-
t << FTV_IMGATTRIBS(mlastnode);
804-
else
805-
t << FTV_IMGATTRIBS(plastnode);
806-
t << "onclick=\"toggleFolder('"
807-
<< generateIndentLabel(n,0)
808-
<< "')\"/>";
809-
}
810-
else
811-
{
812-
t << "<img " << FTV_IMGATTRIBS(lastnode) << "/>";
813-
}
814-
}
815-
else
816-
{
817-
if (n->isDir)
818-
{
819-
t << "<img id=\"arr_" << generateIndentLabel(n,0)
820-
<< "\" ";
821-
if (opened)
822-
t << FTV_IMGATTRIBS(mnode);
823-
else
824-
t << FTV_IMGATTRIBS(pnode);
825-
t << "onclick=\"toggleFolder('"
826-
<< generateIndentLabel(n,0)
827-
<< "')\"/>";
828-
}
829-
else
830-
{
831-
t << "<img " << FTV_IMGATTRIBS(node) << "/>";
832-
}
833-
}
834-
}
835-
else // item at another level
836-
{
837-
if (n->isLast)
838-
{
839-
t << "<img " << FTV_IMGATTRIBS(blank) << "/>";
840-
}
841-
else
842-
{
843-
t << "<img " << FTV_IMGATTRIBS(vertline) << "/>";
844-
}
807+
t << "<span style=\"width:" << ((indent+1)*16) << "px;display:inline-block;\">&#160;</span>";
845808
}
846809
}
847810

@@ -912,7 +875,7 @@ void FTVHelp::generateTree(FTextStream &t, const QList<FTVNode> &nl,int level,in
912875
index++;
913876
t << "><td class=\"entry\">";
914877
bool nodeOpened = level+1<maxLevel;
915-
generateIndent(t,n,0,nodeOpened);
878+
generateIndent(t,n,nodeOpened);
916879
if (n->isDir)
917880
{
918881
if (n->def && n->def->definitionType()==Definition::TypeGroup)
@@ -925,29 +888,19 @@ void FTVHelp::generateTree(FTextStream &t, const QList<FTVNode> &nl,int level,in
925888
}
926889
else if (n->def && n->def->definitionType()==Definition::TypeNamespace)
927890
{
928-
t << "<img ";
929-
t << FTV_IMGATTRIBS(ns);
930-
t << "/>";
891+
t << "<span class=\"icona\"><span class=\"icon\">N</span></span>";
931892
}
932893
else if (n->def && n->def->definitionType()==Definition::TypeClass)
933894
{
934-
t << "<img ";
935-
t << FTV_IMGATTRIBS(cl);
936-
t << "/>";
895+
t << "<span class=\"icona\"><span class=\"icon\">C</span></span>";
937896
}
938897
else
939898
{
940-
t << "<img ";
941-
t << "id=\"img_" << generateIndentLabel(n,0)
942-
<< "\" ";
943-
if (nodeOpened)
944-
t << FTV_IMGATTRIBS(folderopen);
945-
else
946-
t << FTV_IMGATTRIBS(folderclosed);
947-
t << "onclick=\"toggleFolder('"
948-
<< generateIndentLabel(n,0)
949-
<< "')\"";
950-
t << "/>";
899+
t << "<span id=\"img_" << generateIndentLabel(n,0)
900+
<< "\" class=\"iconf"
901+
<< (nodeOpened?"open":"closed")
902+
<< "\" onclick=\"toggleFolder('" << generateIndentLabel(n,0)
903+
<< "')\">&#160;</span>";
951904
}
952905
generateLink(t,n);
953906
t << "</td><td class=\"desc\">";
@@ -983,21 +936,15 @@ void FTVHelp::generateTree(FTextStream &t, const QList<FTVNode> &nl,int level,in
983936
}
984937
else if (n->def && n->def->definitionType()==Definition::TypeNamespace)
985938
{
986-
t << "<img ";
987-
t << FTV_IMGATTRIBS(ns);
988-
t << "/>";
939+
t << "<span class=\"icona\"><span class=\"icon\">N</span></span>";
989940
}
990941
else if (n->def && n->def->definitionType()==Definition::TypeClass)
991942
{
992-
t << "<img ";
993-
t << FTV_IMGATTRIBS(cl);
994-
t << "/>";
943+
t << "<span class=\"icona\"><span class=\"icon\">C</span></span>";
995944
}
996945
else
997946
{
998-
t << "<img ";
999-
t << FTV_IMGATTRIBS(doc);
1000-
t << "/>";
947+
t << "<span class=\"icondoc\"></span>";
1001948
}
1002949
if (srcRef)
1003950
{

src/ftvhelp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class FTVHelp : public IndexIntf
6464
//bool generateJSTree(FTextStream &tidx,FTextStream &t,const QList<FTVNode> &nl,int level,bool &first);
6565
//bool generateJSTreeTopLevel(FTextStream &tidx,FTextStream &t,const QList<FTVNode> &nl,int level,bool &first);
6666
QCString generateIndentLabel(FTVNode *n,int level);
67-
void generateIndent(FTextStream &t,FTVNode *n,int level,bool opened);
67+
void generateIndent(FTextStream &t,FTVNode *n,bool opened);
6868
void generateLink(FTextStream &t,FTVNode *n);
6969
//void generateJSLink(FTextStream &t,FTVNode *n);
7070
QList<FTVNode> *m_indentNodes;

0 commit comments

Comments
 (0)