@@ -36,8 +36,6 @@ public class CTabFolderRenderer {
3636
3737 private Font chevronFont = null ;
3838
39- private static final int [] EMPTY_CORNER = new int [] {0 ,0 };
40-
4139 static final RGB CLOSE_FILL = new RGB (240 , 64 , 64 );
4240
4341 static final int BUTTON_SIZE = 16 ;
@@ -799,30 +797,14 @@ void drawLeftUnselectedBorder(GC gc, Rectangle bounds, int state) {
799797 int y = bounds .y ;
800798 int height = bounds .height ;
801799
802- int [] shape = null ;
800+ int [] shape = new int [4 ];
801+ shape [0 ] = shape [2 ] = x ;
803802 if (parent .onBottom ) {
804- int [] left = EMPTY_CORNER ;
805-
806- shape = new int [left .length + 2 ];
807- int index = 0 ;
808- shape [index ++] = x ;
809- shape [index ++] = y - 1 ;
810- for (int i = 0 ; i < left .length / 2 ; i ++) {
811- shape [index ++] = x + left [2 * i ];
812- shape [index ++] = y + height + left [2 * i + 1 ] - 1 ;
813- }
803+ shape [1 ] = y - 1 ;
804+ shape [3 ] = y + height - 1 ;
814805 } else {
815- int [] left = EMPTY_CORNER ;
816-
817- shape = new int [left .length + 2 ];
818- int index = 0 ;
819- shape [index ++] = x ;
820- shape [index ++] = y + height ;
821- for (int i = 0 ; i < left .length / 2 ; i ++) {
822- shape [index ++] = x + left [2 * i ];
823- shape [index ++] = y + left [2 * i + 1 ];
824- }
825-
806+ shape [1 ] = y + height ;
807+ shape [3 ] = y ;
826808 }
827809
828810 drawBorder (gc , shape );
@@ -940,31 +922,19 @@ void drawRightUnselectedBorder(GC gc, Rectangle bounds, int state) {
940922 int startX = x + width - 1 ;
941923
942924 if (parent .onBottom ) {
943- int [] right = EMPTY_CORNER ;
944-
945- shape = new int [right .length + 2 ];
925+ shape = new int [4 ];
946926 int index = 0 ;
947-
948- for (int i = 0 ; i < right .length / 2 ; i ++) {
949- shape [index ++] = startX + right [2 * i ];
950- shape [index ++] = y + height + right [2 * i + 1 ] - 1 ;
951- }
927+ shape [index ++] = startX ;
928+ shape [index ++] = y + height - 1 ;
952929 shape [index ++] = startX ;
953930 shape [index ++] = y - 1 ;
954931 } else {
955- int [] right = EMPTY_CORNER ;
956-
957- shape = new int [right .length + 2 ];
932+ shape = new int [4 ];
958933 int index = 0 ;
959-
960- for (int i = 0 ; i < right .length / 2 ; i ++) {
961- shape [index ++] = startX + right [2 * i ];
962- shape [index ++] = y + right [2 * i + 1 ];
963- }
964-
934+ shape [index ++] = startX ;
935+ shape [index ++] = y ;
965936 shape [index ++] = startX ;
966937 shape [index ++] = y + height ;
967-
968938 }
969939
970940 drawBorder (gc , shape );
@@ -1016,52 +986,40 @@ void drawSelected(int itemIndex, GC gc, Rectangle bounds, int state ) {
1016986 }
1017987
1018988 // draw selected tab background and outline
1019- shape = null ;
989+ shape = new int [ 12 ] ;
1020990 if (parent .onBottom ) {
1021- int [] left = EMPTY_CORNER ;
1022- int [] right = EMPTY_CORNER ;
1023- if (borderLeft == 0 && itemIndex == parent .firstIndex ) {
1024- left = new int []{x , y +height };
1025- }
1026- shape = new int [left .length +right .length +8 ];
1027991 int index = 0 ;
1028992 shape [index ++] = x ; // first point repeated here because below we reuse shape to draw outline
1029993 shape [index ++] = y - 1 ;
1030994 shape [index ++] = x ;
1031995 shape [index ++] = y - 1 ;
1032- for (int i = 0 ; i < left .length /2 ; i ++) {
1033- shape [index ++] = x + left [2 *i ];
1034- shape [index ++] = y + height + left [2 *i +1 ] - 1 ;
1035- }
1036- for (int i = 0 ; i < right .length /2 ; i ++) {
1037- shape [index ++] = rightEdge - 1 + right [2 *i ];
1038- shape [index ++] = y + height + right [2 *i +1 ] - 1 ;
996+ shape [index ++] = x ;
997+ shape [index ++] = y + height ;
998+ if (borderLeft == 0 && itemIndex == parent .firstIndex ) {
999+ shape [index - 2 ] += x ;
1000+ shape [index - 1 ] += y + height ;
10391001 }
10401002 shape [index ++] = rightEdge - 1 ;
1003+ shape [index ++] = y + height - 1 ;
1004+ shape [index ++] = rightEdge - 1 ;
10411005 shape [index ++] = y - 1 ;
10421006 shape [index ++] = rightEdge - 1 ;
10431007 shape [index ++] = y - 1 ;
10441008 } else {
1045- int [] left = EMPTY_CORNER ;
1046- int [] right = EMPTY_CORNER ;
1047- if (borderLeft == 0 && itemIndex == parent .firstIndex ) {
1048- left = new int []{x , y };
1049- }
1050- shape = new int [left .length +right .length +8 ];
10511009 int index = 0 ;
10521010 shape [index ++] = x ; // first point repeated here because below we reuse shape to draw outline
10531011 shape [index ++] = y + height + 1 ;
10541012 shape [index ++] = x ;
10551013 shape [index ++] = y + height + 1 ;
1056- for (int i = 0 ; i < left .length /2 ; i ++) {
1057- shape [index ++] = x + left [2 *i ];
1058- shape [index ++] = y + left [2 *i +1 ];
1059- }
1060- for (int i = 0 ; i < right .length /2 ; i ++) {
1061- shape [index ++] = rightEdge - 1 + right [2 *i ];
1062- shape [index ++] = y + right [2 *i +1 ];
1014+ shape [index ++] = x ;
1015+ shape [index ++] = y ;
1016+ if (borderLeft == 0 && itemIndex == parent .firstIndex ) {
1017+ shape [index - 2 ] += x ;
1018+ shape [index - 1 ] += y ;
10631019 }
10641020 shape [index ++] = rightEdge - 1 ;
1021+ shape [index ++] = y ;
1022+ shape [index ++] = rightEdge - 1 ;
10651023 shape [index ++] = y + height + 1 ;
10661024 shape [index ++] = rightEdge - 1 ;
10671025 shape [index ++] = y + height + 1 ;
@@ -1198,7 +1156,6 @@ private int getLeftTextMargin(CTabItem item) {
11981156
11991157 void drawTabArea (GC gc , Rectangle bounds , int state ) {
12001158 Point size = parent .getSize ();
1201- int [] shape = null ;
12021159 Color borderColor = parent .getDisplay ().getSystemColor (BORDER1_COLOR );
12031160 int tabHeight = parent .tabHeight ;
12041161 int style = parent .getStyle ();
@@ -1218,7 +1175,7 @@ void drawTabArea(GC gc, Rectangle bounds, int state) {
12181175 int y2 = parent .onBottom ? size .y - borderBottom : borderTop ;
12191176 if (borderLeft > 0 && parent .onBottom ) y2 -= 1 ;
12201177
1221- shape = new int [] {x1 , y1 , x1 ,y2 , x2 ,y2 , x2 ,y1 };
1178+ int [] shape = new int [] {x1 , y1 , x1 ,y2 , x2 ,y2 , x2 ,y1 };
12221179
12231180 // If horizontal gradient, show gradient across the whole area
12241181 if (selectedIndex != -1 && parent .selectionGradientColors != null && parent .selectionGradientColors .length > 1 && !parent .selectionGradientVertical ) {
@@ -1242,55 +1199,32 @@ void drawTabArea(GC gc, Rectangle bounds, int state) {
12421199 int y = parent .onBottom ? size .y - borderBottom - tabHeight : borderTop ;
12431200 int width = size .x - borderLeft - borderRight + 1 ;
12441201 int height = tabHeight - 1 ;
1202+ int [] shape = new int [8 ];
12451203 // Draw Tab Header
12461204 if (parent .onBottom ) {
1247- int [] left , right ;
1248- if ((style & SWT .BORDER ) != 0 ) {
1249- left = EMPTY_CORNER ;
1250- right = EMPTY_CORNER ;
1251- } else {
1252- left = EMPTY_CORNER ;
1253- right = EMPTY_CORNER ;
1254- }
1255- shape = new int [left .length + right .length + 4 ];
12561205 int index = 0 ;
12571206 shape [index ++] = x ;
1258- shape [index ++] = y -highlight_header ;
1259- for (int i = 0 ; i < left .length /2 ; i ++) {
1260- shape [index ++] = x +left [2 *i ];
1261- shape [index ++] = y +height +left [2 *i +1 ];
1262- if (borderLeft == 0 ) shape [index -1 ] += 1 ;
1263- }
1264- for (int i = 0 ; i < right .length /2 ; i ++) {
1265- shape [index ++] = x +width +right [2 *i ];
1266- shape [index ++] = y +height +right [2 *i +1 ];
1267- if (borderLeft == 0 ) shape [index -1 ] += 1 ;
1268- }
1269- shape [index ++] = x +width ;
1270- shape [index ++] = y -highlight_header ;
1207+ shape [index ++] = y - highlight_header ;
1208+ shape [index ++] = x ;
1209+ shape [index ++] = y + height ;
1210+ if (borderLeft == 0 )
1211+ shape [index - 1 ] += 1 ;
1212+ shape [index ++] = x + width ;
1213+ shape [index ++] = y + height ;
1214+ if (borderLeft == 0 )
1215+ shape [index - 1 ] += 1 ;
1216+ shape [index ++] = x + width ;
1217+ shape [index ++] = y - highlight_header ;
12711218 } else {
1272- int [] left , right ;
1273- if ((style & SWT .BORDER ) != 0 ) {
1274- left = EMPTY_CORNER ;
1275- right = EMPTY_CORNER ;
1276- } else {
1277- left = EMPTY_CORNER ;
1278- right = EMPTY_CORNER ;
1279- }
1280- shape = new int [left .length + right .length + 4 ];
12811219 int index = 0 ;
12821220 shape [index ++] = x ;
1283- shape [index ++] = y +height +highlight_header + 1 ;
1284- for (int i = 0 ; i < left .length /2 ; i ++) {
1285- shape [index ++] = x +left [2 *i ];
1286- shape [index ++] = y +left [2 *i +1 ];
1287- }
1288- for (int i = 0 ; i < right .length /2 ; i ++) {
1289- shape [index ++] = x +width +right [2 *i ];
1290- shape [index ++] = y +right [2 *i +1 ];
1291- }
1292- shape [index ++] = x +width ;
1293- shape [index ++] = y +height +highlight_header + 1 ;
1221+ shape [index ++] = y + height + highlight_header + 1 ;
1222+ shape [index ++] = x ;
1223+ shape [index ++] = y ;
1224+ shape [index ++] = x + width ;
1225+ shape [index ++] = y ;
1226+ shape [index ++] = x + width ;
1227+ shape [index ++] = y + height + highlight_header + 1 ;
12941228 }
12951229 // Fill in background
12961230 boolean single = parent .single ;
0 commit comments