protected void updateSlider() { int max = 0; if(sliderActive) { slider.show(); max = slotCount / columns - rows + 1; // the assumption here is that for an active slider this always is >0 } else { slider.hide(); } slider.setPosition(guiLeft + xSize - slider.width, guiTop); slider.setSize(ySize); slider.setSliderParameters(0, max, 1); }
protected void updateSliderParameters() { // we assume slider not shown slider.hide(); int h = ySize - 2 * 5; // we use 5 as border thickness // check if we can display all lines if(calcNeededHeight() <= h) // can display all, stay hidden { return; } // we need the slider slider.show(); // check how many lines we can show int neededHeight = calcNeededHeight(); // recalc because width changed due to slider int hiddenRows = (neededHeight - h) / fontRenderer.FONT_HEIGHT; if((neededHeight - h) % fontRenderer.FONT_HEIGHT > 0) { hiddenRows++; } slider.setSliderParameters(0, hiddenRows, 1); }
slider.setSliderParameters(0, getTotalRows() - getDisplayedRows(), 1);