Skip to content

Commit

Permalink
Optimize ui
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalgust committed Aug 14, 2024
1 parent 4f3e3d2 commit d0e5b31
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 56 deletions.
4 changes: 2 additions & 2 deletions extlib/xgui/src/main/java/org/mini/apploader/AppManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@ void mainPanelShowLeft() {
appList.setSelectedIndex(-1);
curSelectedJarName = null;
}
mainSlot.moveTo(0, 200);
mainSlot.moveTo(0, 100);
}

void mainPanelShowRight() {
mainSlot.moveTo(1, 200);
mainSlot.moveTo(1, 100);
}

GHomeButton getFloatButton() {
Expand Down
4 changes: 4 additions & 0 deletions extlib/xgui/src/main/java/org/mini/gui/GObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@ public float[] getColor() {
return color;
}


public void setPreiconColor(float[] preiconColor) {
}

/**
* @param r
* @param g
Expand Down
2 changes: 1 addition & 1 deletion extlib/xgui/src/main/java/org/mini/gui/GViewPort.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public float getInnerH() {

@Override
public void setInnerLocation(float x, float y) {
super.setLocation(x, y);
//super.setLocation(x, y);
if (getOutOfViewWidth() > 0) setScrollX(-x / getOutOfViewWidth());
if (getOutOfViewHeight() > 0) setScrollY(-y / getOutOfViewHeight());
}
Expand Down
20 changes: 10 additions & 10 deletions extlib/xgui/src/main/java/org/mini/gui/GViewSlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ boolean canMoveToDown() {

protected float dragBeginX, dragBeginY;

static final int SWAP_PERIOD = 16;

public GViewSlot(GForm form, float w, float h, int scrollMod) {
this(form, 0, 0, w, h, scrollMod);
}
Expand Down Expand Up @@ -168,7 +170,7 @@ public void moveTo(GObject go, long timeInMils) {
GObject curGo = getElementsImpl().get(active);
if (curGo != null && go != null) {
SlotSwaper swaper = new SlotSwaper(this, curGo, go, timeInMils);
GForm.timer.schedule(swaper, 0, (long) 16);
GForm.timer.schedule(swaper, 0, (long) SWAP_PERIOD);
this.active = getElementsImpl().indexOf(go);
//notify
doStateChanged(this);
Expand All @@ -178,8 +180,7 @@ public void moveTo(GObject go, long timeInMils) {

class SlotSwaper extends TimerTask {

long curTime;
long startAt;
int counter = 0, maxCounter;
long timeInMils;

float distX, distY;
Expand All @@ -202,24 +203,23 @@ public SlotSwaper(GViewSlot slots, GObject from, GObject to, long timeInMils) {
timeInMils = 1;
}
this.timeInMils = timeInMils;
startAt = System.currentTimeMillis();
maxCounter = (int) (timeInMils / SWAP_PERIOD);

}

public void run() {
try {
curTime = System.currentTimeMillis();
long goTime = curTime - startAt;

if ((distX == 0 && scrollMode == SCROLL_MODE_HORIZONTAL)
|| (distY == 0 && scrollMode == SCROLL_MODE_VERTICAL)) {
cancel();
return;
}

counter++;
float curX, curY;
if (goTime < timeInMils) {
curX = slotOrignalX - distX * goTime / timeInMils;
curY = slotOrignalY - distY * goTime / timeInMils;
if (counter <= maxCounter) {
curX = slotOrignalX - distX * counter / maxCounter;
curY = slotOrignalY - distY * counter / maxCounter;
} else {
curX = slotOrignalX - distX;
curY = slotOrignalY - distY;
Expand Down
27 changes: 27 additions & 0 deletions extlib/xgui/src/main/java/org/mini/gui/guilib/GuiScriptLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public GuiScriptLib(GForm form) {
methodNames.put("setAttachInt".toLowerCase(), this::setAttachInt);//
methodNames.put("setBgColorHexStr".toLowerCase(), this::setBgColorHexStr);// set background color
methodNames.put("setColorHexStr".toLowerCase(), this::setColorHexStr);// set color
methodNames.put("setPreIconColor".toLowerCase(), this::setPreIconColor);// set color
methodNames.put("clearPreIconColor".toLowerCase(), this::clearPreIconColor);// set color
methodNames.put("getListIdx".toLowerCase(), this::getListIdx);//
methodNames.put("setImgAlphaStr".toLowerCase(), this::setImgAlphaStr);//
methodNames.put("setEnable".toLowerCase(), this::setEnable);//
Expand Down Expand Up @@ -187,6 +189,31 @@ public DataType setColorHexStr(ArrayList<DataType> para) {
return null;
}

public DataType setPreIconColor(ArrayList<DataType> para) {
String compont = Interpreter.popBackStr(para);
GObject gobj = GToolkit.getComponent(form, compont);
if (gobj != null) {
float[] color;
String rgbaStr = Interpreter.popBackStr(para);
try {
int c = (int) Long.parseLong(rgbaStr, 16);
color = Nanovg.nvgRGBA((byte) ((c >> 24) & 0xff), (byte) ((c >> 16) & 0xff), (byte) ((c >> 8) & 0xff), (byte) ((c >> 0) & 0xff));
gobj.setPreiconColor(color);
} catch (Exception e) {
}
}
return null;
}

public DataType clearPreIconColor(ArrayList<DataType> para) {
String compont = Interpreter.popBackStr(para);
GObject gobj = GToolkit.getComponent(form, compont);
if (gobj != null) {
gobj.setPreiconColor(GToolkit.getStyle().getTextFontColor());
}
return null;
}


public DataType setText(ArrayList<DataType> para) {
String compont = Interpreter.popBackStr(para);
Expand Down
8 changes: 4 additions & 4 deletions extlib/xgui/src/main/resource/res/base.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ sver=2
from=ysbit
appid=minipack
appzone=0
#policyUrl=http://p.ysbit.cn:20005/account/policy
policyUrl=http://p.ysbit.cn:20005/account/policy
#policyUrl=https://p.ysbit.cn/account/policy
#policyUrl=http://127.0.0.1:30005/account/policy
#policyUrl=http://192.168.31.29:30005/account/policy
policyUrl=http://10.0.99.152:30005/account/policy
#policyUrl=http://127.0.0.1:20005/account/policy
#policyUrl=http://192.168.31.29:20005/account/policy
#policyUrl=http://10.0.99.152:20005/account/policy
68 changes: 34 additions & 34 deletions extlib/xgui/src/main/resource/res/lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@
],
"RETRIEVE_PWD": [
"Retrieve password",
"找回",
"找回"
"找回密码",
"找回密码"
],
"ACCOUNT_PWD_NO_EMPTY": [
"Account or password can not be empty",
Expand All @@ -251,9 +251,9 @@
"账号不能为空"
],
"NOTICE_INPUT_EMAIL_MOBILE": [
"Input your account: email or mobile",
"请输入账号: 邮箱或手机",
"请输入账号: 邮箱或手机"
"Input email or mobile",
"请输入邮箱或手机号码",
"请输入邮箱或手机号码"
],
"SEND_CODE": [
"Send code",
Expand All @@ -272,8 +272,8 @@
],
"EMAIL_OR_MOBILE": [
"email or mobile",
"邮箱或手机",
"邮箱或手机"
"只可为邮箱或手机",
"只可为邮箱或手机"
],
"OLD_PASSWORD": [
"Old password",
Expand All @@ -286,39 +286,39 @@
"新密码"
],
"PASSWORD_6_32": [
"6-32 char password",
"密码",
"密码"
"password length 6-32",
"密码长6-32字符",
"密码长6-32字符"
],
"I_WANT_CHG_PWD": [
"I want to change my password",
"我要改变我的密码",
"我要改变我的密码"
],
"AAA": [
"AAA",
"BBB",
"CCC"
],
"AAA": [
"AAA",
"BBB",
"CCC"
],
"AAA": [
"AAA",
"BBB",
"CCC"
],
"AAA": [
"AAA",
"BBB",
"CCC"
],
"AAA": [
"AAA",
"BBB",
"CCC"
"STR_SIGNIN_ALREADY": [
"Signed in",
"已登录",
"已登录"
],
"STR_NEED_SIGNIN": [
"Sign in",
"去登录",
"去登录"
],
"STR_MESSAGE": [
"Message",
"消息",
"消息"
],
"STR_SUCCESS": [
"Success",
"成功",
"成功"
],
"STR_FAIL": [
"Fail",
"失败",
"失败"
]
}
}
33 changes: 28 additions & 5 deletions extlib/xgui/src/main/resource/res/ui/AppManager.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
if(!isDef("ENCRYPTED_KEY"))
def("ENCRYPTED_KEY","L7%d9&3jw5f")
eif
token=getEnv("TOKEN")
if(strlen(token)>0)
uid=getEnv("USERNAME")
setText("LAB_USERNAME",uid+" {SignIned} >")
eif
getPolicy()
signInAuto() '自动登录
ret
sub getQueryPara()
Expand Down Expand Up @@ -44,6 +40,25 @@
eif
ret
sub signInAuto() '登录
logintype=getEnv("LOGINTYPE")
loginUid=getEnv("USERNAME")
ep=getEnv("USERPASS")
loginPwd=decrypt(ep,ENCRYPTED_KEY)
if(strlen(loginUid)=0 | strlen(loginPwd)=0)
ret
else
encryptPwd=encrypt(loginPwd,ENCRYPTED_KEY)
println(encryptPwd)
accBaseUrl=getEnv("ACCOUNT_BASE_URL")
url=accBaseUrl + "/login?usr=" + loginUid + "&pwd=" + encryptPwd +"&logintype="+ logintype +"&"+ getQueryPara()
httpRequest(url,"ROOT_PAN.onCallBack")
eif
ret
sub showDiscovery() '显示发现
showSlot("SLOT_MGR", 3)
if(!uiExist("DIS_HOME")) 'if there is not a discovery panel then show it
Expand All @@ -58,6 +73,14 @@
sub showMy() '显示我的
showSlot("SLOT_MGR", 4)
token=getEnv("TOKEN")
if(strlen(token)>0)
uid=getEnv("USERNAME")
setText("LAB_USERNAME",uid+" {STR_SIGNIN_ALREADY} >")
else
setText("LAB_USERNAME","{STR_NEED_SIGNIN} >")
eif
ret
sub showProfile() '显示我的
Expand Down

0 comments on commit d0e5b31

Please sign in to comment.