Skip to content

Commit

Permalink
update ui
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalgust committed Jun 15, 2024
1 parent 26894a0 commit d4326a0
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
12 changes: 10 additions & 2 deletions extlib/xgui/src/main/java/org/mini/gui/GListItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.mini.gui;

import org.mini.glfm.Glfm;
import org.mini.nanovg.Nanovg;

import static org.mini.glwrap.GLUtil.toCstyleBytes;
import static org.mini.gui.GToolkit.getStyle;
Expand Down Expand Up @@ -157,11 +158,17 @@ public boolean paint(long vg) {
float tx, ty;
tx = x + pad;
ty = y + pad * .5f;
float tw = w - (pad * 2);
float th = list.list_item_heigh - pad;

nvgSave(vg);
Nanovg.nvgScissor(vg, tx, ty, tw, th);


if (list.isSelected(getIndex())) {
GToolkit.drawRect(vg, tx, ty, w - (pad * 2), list.list_item_heigh - pad, GToolkit.getStyle().getSelectedColor());
GToolkit.drawRect(vg, tx, ty, tw, th, GToolkit.getStyle().getSelectedColor());
} else {
GToolkit.drawRect(vg, tx, ty, w - (pad * 2), list.list_item_heigh - pad, GToolkit.getStyle().getUnselectedColor());
GToolkit.drawRect(vg, tx, ty, tw, th, GToolkit.getStyle().getUnselectedColor());
}
float[] c = outOfFilter ? GToolkit.getStyle().getHintFontColor() : enable ? getColor() : getDisabledColor();

Expand Down Expand Up @@ -189,6 +196,7 @@ public boolean paint(long vg) {
}
nvgFillColor(vg, c);
GToolkit.drawTextLine(vg, tx + ((img == null && preicon_arr == null) ? 0 : thumb) + pad, ty + thumb / 2, getText(), list.getFontSize(), c, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE);
Nanovg.nvgRestore(vg);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion extlib/xgui/src/main/java/org/mini/gui/GObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ public void setBgImg(GImage bgImg) {
this.bgImg = bgImg;
}

public void setBgimgAlpha(float bgImgAlpha) {
public void setBgImgAlpha(float bgImgAlpha) {
this.bgImgAlpha = bgImgAlpha;
}

Expand Down
16 changes: 16 additions & 0 deletions extlib/xgui/src/main/java/org/mini/gui/GuiScriptLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public GuiScriptLib(GForm form) {
methodNames.put("deleteText".toLowerCase(), this::deleteText);//
methodNames.put("getCaretPos".toLowerCase(), this::getCaretPos);//
methodNames.put("showTitle".toLowerCase(), this::showTitle);//
methodNames.put("setBgImg".toLowerCase(), this::setBgImg);//

}
}
Expand Down Expand Up @@ -563,4 +564,19 @@ private DataType showTitle(ArrayList<DataType> para) {
}
return null;
}

private DataType setBgImg(ArrayList<DataType> para) {
String compont = Interpreter.popBackStr(para);
GObject gobj = GToolkit.getComponent(form, compont);
if (gobj != null) {
String imgpath = Interpreter.popBackStr(para);
gobj.setBgImg(GToolkit.getCachedImageFromJar(imgpath));
if (!para.isEmpty()) {
String alphaStr = Interpreter.popBackStr(para);
float f = Float.parseFloat(alphaStr);
gobj.setBgImgAlpha(f);
}
}
return null;
}
}
4 changes: 2 additions & 2 deletions extlib/xgui/src/main/java/org/mini/layout/XFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ protected void createAndSetGui() {
frame.setOnCloseScript(onCloseScript);
frame.setOnInitScript(onInitScript);
frame.getTitlePanel().setBgImg(GToolkit.getCachedImageFromJar(titleBgPic));
frame.getTitlePanel().setBgimgAlpha(titleBgPicAlpha);
frame.getTitlePanel().setBgImgAlpha(titleBgPicAlpha);
frame.getView().setBgImg(GToolkit.getCachedImageFromJar(viewBgPic));
frame.getView().setBgimgAlpha(viewBgPicAlpha);
frame.getView().setBgImgAlpha(viewBgPicAlpha);
frame.setTitleShow(titleShow);
} else {
frame.setLocation(x, y);
Expand Down
2 changes: 1 addition & 1 deletion extlib/xgui/src/main/java/org/mini/layout/XObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public final void initGuiMore() {
if (bgPic != null) {
GImage img = GToolkit.getCachedImageFromJar(bgPic);
gui.setBgImg(img);
gui.setBgimgAlpha(bgPicAlpha);
gui.setBgImgAlpha(bgPicAlpha);
}

if (gui instanceof GContainer) {
Expand Down

0 comments on commit d4326a0

Please sign in to comment.