Add background color to Containers

This commit is contained in:
johni0702
2015-10-11 10:37:40 +02:00
parent 4e901465fa
commit de322e4b6e
2 changed files with 20 additions and 0 deletions

View File

@@ -36,6 +36,7 @@ import net.minecraft.crash.CrashReportCategory;
import net.minecraft.util.ReportedException;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.util.Point;
import org.lwjgl.util.ReadableColor;
import org.lwjgl.util.ReadableDimension;
import org.lwjgl.util.ReadablePoint;
@@ -58,6 +59,8 @@ public abstract class AbstractGuiContainer<T extends AbstractGuiContainer<T>>
private Layout layout = DEFAULT_LAYOUT;
private ReadableColor backgroundColor;
public AbstractGuiContainer() {
}
@@ -140,6 +143,9 @@ public abstract class AbstractGuiContainer<T extends AbstractGuiContainer<T>>
});
throw new ReportedException(crashReport);
}
if (backgroundColor != null) {
renderer.drawRect(0, 0, size.getWidth(), size.getHeight(), backgroundColor);
}
for (final Map.Entry<GuiElement, Pair<ReadablePoint, ReadableDimension>> e : layedOutElements.entrySet()) {
GuiElement element = e.getKey();
if (element instanceof ComposedGuiElement) {
@@ -210,4 +216,15 @@ public abstract class AbstractGuiContainer<T extends AbstractGuiContainer<T>>
public ReadableDimension calcMinSize() {
return layout.calcMinSize(this);
}
@Override
public ReadableColor getBackgroundColor() {
return backgroundColor;
}
@Override
public T setBackgroundColor(ReadableColor backgroundColor) {
this.backgroundColor = backgroundColor;
return getThis();
}
}

View File

@@ -27,6 +27,7 @@ import de.johni0702.minecraft.gui.element.GuiElement;
import de.johni0702.minecraft.gui.layout.Layout;
import de.johni0702.minecraft.gui.layout.LayoutData;
import org.lwjgl.util.Point;
import org.lwjgl.util.ReadableColor;
import java.util.Map;
@@ -41,4 +42,6 @@ public interface GuiContainer<T extends GuiContainer<T>> extends ComposedGuiElem
T addElements(LayoutData layoutData, GuiElement...elements);
T removeElement(GuiElement element);
ReadableColor getBackgroundColor();
T setBackgroundColor(ReadableColor backgroundColor);
}