Browse Source

- Added support for local fields ($field)

- Fixed a couple minor issues & inefficiencies
- Added horizontal scrollbar to IDE (incomplete!)
Stan Hebben 6 years ago
parent
commit
3d9e3bdf03
56 changed files with 278 additions and 105 deletions
  1. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java
  2. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionParameter.java
  3. 2
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/GenericMapper.java
  4. 5
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/GenericName.java
  5. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/PreconditionAnnotationDefinition.java
  6. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/CompilingPackage.java
  7. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/CompilingType.java
  8. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/FileResolutionContext.java
  9. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/LocalTypeResolutionContext.java
  10. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/ModuleTypeResolutionContext.java
  11. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/TypeResolutionContext.java
  12. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ZSPackage.java
  13. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/Expression.java
  14. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionBuilder.java
  15. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ImplementationMember.java
  16. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/IPartialExpression.java
  17. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialGlobalExpression.java
  18. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialMemberGroupExpression.java
  19. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialPackageExpression.java
  20. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialStaticMemberGroupExpression.java
  21. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialTypeExpression.java
  22. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialVariantOptionExpression.java
  23. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/BaseScope.java
  24. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/BlockScope.java
  25. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/CompileTypeScope.java
  26. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/DefinitionScope.java
  27. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/ExpressionScope.java
  28. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/FileScope.java
  29. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/ForeachScope.java
  30. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/FunctionScope.java
  31. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/GenericFunctionScope.java
  32. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/GlobalScriptScope.java
  33. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/ImplementationScope.java
  34. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/LambdaScope.java
  35. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/LoopScope.java
  36. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/StatementScope.java
  37. 1
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/DefinitionTypeID.java
  38. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberGroup.java
  39. 9
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMembers.java
  40. 1
    1
      CompilerShared/src/main/java/org/openzen/zenscript/compiler/CompileScope.java
  41. 56
    20
      DrawableGui/src/main/java/org/openzen/drawablegui/scroll/DScrollBar.java
  42. 63
    20
      DrawableGui/src/main/java/org/openzen/drawablegui/scroll/DScrollPane.java
  43. 38
    12
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/SourceEditor.java
  44. 2
    0
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/TokenLine.java
  45. 1
    1
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaCompiledModule.java
  46. 7
    0
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpression.java
  47. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionFunction.java
  48. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionIndex.java
  49. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionMember.java
  50. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionVariable.java
  51. 47
    0
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedLocalVariableExpression.java
  52. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/statements/ParsedCatchClause.java
  53. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/statements/ParsedStatementSwitch.java
  54. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedNamedType.java
  55. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeGenericMap.java
  56. 1
    1
      Validator/src/main/java/org/openzen/zenscript/validator/visitors/DefinitionValidator.java

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java View File

@@ -322,7 +322,7 @@ public class FunctionHeader {
322 322
 			return false;
323 323
 		
324 324
 		for (int i = 0; i < parameters.length; i++) {
325
-			if (parameters[i].type != other.parameters[i].type)
325
+			if (!parameters[i].type.equals(other.parameters[i].type))
326 326
 				return false;
327 327
 		}
328 328
 		
@@ -370,9 +370,9 @@ public class FunctionHeader {
370 370
 		}
371 371
 	}
372 372
 	
373
-	public FunctionHeader withGenericArguments(GlobalTypeRegistry registry, GenericMapper mapper) {
373
+	public FunctionHeader withGenericArguments(GenericMapper mapper) {
374 374
 		if (typeParameters.length > 0)
375
-			mapper = mapper.getInner(registry, StoredType.getSelfMapping(registry, typeParameters));
375
+			mapper = mapper.getInner(mapper.registry, StoredType.getSelfMapping(mapper.registry, typeParameters));
376 376
 		
377 377
 		return instance(mapper);
378 378
 	}

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionParameter.java View File

@@ -62,7 +62,7 @@ public class FunctionParameter extends Taggable {
62 62
 	
63 63
 	public FunctionParameter withGenericArguments(GenericMapper mapper) {
64 64
 		StoredType instanced = type.instance(mapper);
65
-		if (instanced == type)
65
+		if (instanced.equals(type))
66 66
 			return this;
67 67
 		
68 68
 		FunctionParameter result = new FunctionParameter(instanced, name, defaultValue, variadic);

+ 2
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/GenericMapper.java View File

@@ -8,7 +8,6 @@ package org.openzen.zenscript.codemodel;
8 8
 import java.util.Collections;
9 9
 import java.util.HashMap;
10 10
 import java.util.Map;
11
-import org.openzen.zencode.shared.CodePosition;
12 11
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
13 12
 import org.openzen.zenscript.codemodel.type.GenericTypeID;
14 13
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
@@ -33,7 +32,7 @@ public class GenericMapper {
33 32
 		return mapping;
34 33
 	}
35 34
 	
36
-	public StoredType map(CodePosition position, StoredType original) {
35
+	public StoredType map(StoredType original) {
37 36
 		return mapping.isEmpty() ? original : original.instance(this);
38 37
 	}
39 38
 	
@@ -55,7 +54,7 @@ public class GenericMapper {
55 54
 	}
56 55
 	
57 56
 	public FunctionHeader map(FunctionHeader original) {
58
-		return mapping.isEmpty() ? original : original.withGenericArguments(registry, this);
57
+		return mapping.isEmpty() ? original : original.withGenericArguments(this);
59 58
 	}
60 59
 	
61 60
 	public GenericMapper getInner(GlobalTypeRegistry registry, Map<TypeParameter, StoredType> mapping) {

CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericName.java → CodeModel/src/main/java/org/openzen/zenscript/codemodel/GenericName.java View File

@@ -3,9 +3,13 @@
3 3
  * To change this template file, choose Tools | Templates
4 4
  * and open the template in the editor.
5 5
  */
6
-package org.openzen.zenscript.codemodel.type;
6
+package org.openzen.zenscript.codemodel;
7 7
 
8 8
 import java.util.List;
9
+import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
10
+import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
11
+import org.openzen.zenscript.codemodel.type.StoredType;
12
+import org.openzen.zenscript.codemodel.type.TypeID;
9 13
 
10 14
 /**
11 15
  *

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/PreconditionAnnotationDefinition.java View File

@@ -26,7 +26,7 @@ import org.openzen.zenscript.codemodel.scope.StatementScope;
26 26
 import org.openzen.zenscript.codemodel.serialization.CodeSerializationInput;
27 27
 import org.openzen.zenscript.codemodel.statement.Statement;
28 28
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
29
-import org.openzen.zenscript.codemodel.type.GenericName;
29
+import org.openzen.zenscript.codemodel.GenericName;
30 30
 import org.openzen.zenscript.codemodel.type.StringTypeID;
31 31
 import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
32 32
 

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/CompilingPackage.java View File

@@ -12,7 +12,7 @@ import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 12
 import org.openzen.zenscript.codemodel.Module;
13 13
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
14 14
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
15
-import org.openzen.zenscript.codemodel.type.GenericName;
15
+import org.openzen.zenscript.codemodel.GenericName;
16 16
 import org.openzen.zenscript.codemodel.type.TypeID;
17 17
 
18 18
 /**

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/CompilingType.java View File

@@ -8,7 +8,7 @@ package org.openzen.zenscript.codemodel.context;
8 8
 import java.util.List;
9 9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10 10
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
11
-import org.openzen.zenscript.codemodel.type.GenericName;
11
+import org.openzen.zenscript.codemodel.GenericName;
12 12
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
13 13
 
14 14
 /**

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/FileResolutionContext.java View File

@@ -12,7 +12,7 @@ import org.openzen.zencode.shared.CodePosition;
12 12
 import org.openzen.zencode.shared.CompileExceptionCode;
13 13
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
14 14
 import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
15
-import org.openzen.zenscript.codemodel.type.GenericName;
15
+import org.openzen.zenscript.codemodel.GenericName;
16 16
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
17 17
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
18 18
 import org.openzen.zenscript.codemodel.type.StoredType;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/LocalTypeResolutionContext.java View File

@@ -10,7 +10,7 @@ import org.openzen.zencode.shared.CodePosition;
10 10
 import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
11 11
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12 12
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
13
-import org.openzen.zenscript.codemodel.type.GenericName;
13
+import org.openzen.zenscript.codemodel.GenericName;
14 14
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
15 15
 import org.openzen.zenscript.codemodel.type.StoredType;
16 16
 import org.openzen.zenscript.codemodel.type.TypeID;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/ModuleTypeResolutionContext.java View File

@@ -12,7 +12,7 @@ import org.openzen.zencode.shared.CodePosition;
12 12
 import org.openzen.zencode.shared.CompileExceptionCode;
13 13
 import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
14 14
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
15
-import org.openzen.zenscript.codemodel.type.GenericName;
15
+import org.openzen.zenscript.codemodel.GenericName;
16 16
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
17 17
 import org.openzen.zenscript.codemodel.type.ISymbol;
18 18
 import org.openzen.zenscript.codemodel.type.StoredType;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/TypeResolutionContext.java View File

@@ -8,7 +8,7 @@ package org.openzen.zenscript.codemodel.context;
8 8
 import java.util.List;
9 9
 import org.openzen.zencode.shared.CodePosition;
10 10
 import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
11
-import org.openzen.zenscript.codemodel.type.GenericName;
11
+import org.openzen.zenscript.codemodel.GenericName;
12 12
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
13 13
 import org.openzen.zenscript.codemodel.type.StoredType;
14 14
 import org.openzen.zenscript.codemodel.type.TypeID;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ZSPackage.java View File

@@ -17,7 +17,7 @@ import org.openzen.zenscript.codemodel.partial.IPartialExpression;
17 17
 import org.openzen.zenscript.codemodel.partial.PartialPackageExpression;
18 18
 import org.openzen.zenscript.codemodel.partial.PartialTypeExpression;
19 19
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
20
-import org.openzen.zenscript.codemodel.type.GenericName;
20
+import org.openzen.zenscript.codemodel.GenericName;
21 21
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
22 22
 import org.openzen.zenscript.codemodel.type.TypeID;
23 23
 

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/Expression.java View File

@@ -17,7 +17,7 @@ import org.openzen.zenscript.codemodel.FunctionHeader;
17 17
 import org.openzen.zenscript.codemodel.OperatorType;
18 18
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
19 19
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
20
-import org.openzen.zenscript.codemodel.type.GenericName;
20
+import org.openzen.zenscript.codemodel.GenericName;
21 21
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
22 22
 import org.openzen.zenscript.codemodel.scope.TypeScope;
23 23
 import org.openzen.zenscript.codemodel.statement.Statement;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionBuilder.java View File

@@ -13,7 +13,7 @@ import org.openzen.zencode.shared.CompileExceptionCode;
13 13
 import org.openzen.zenscript.codemodel.OperatorType;
14 14
 import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
15 15
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
16
-import org.openzen.zenscript.codemodel.type.GenericName;
16
+import org.openzen.zenscript.codemodel.GenericName;
17 17
 import org.openzen.zenscript.codemodel.type.StoredType;
18 18
 import org.openzen.zenscript.codemodel.type.TypeID;
19 19
 import org.openzen.zenscript.codemodel.type.member.TypeMemberGroup;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ImplementationMember.java View File

@@ -41,7 +41,7 @@ public class ImplementationMember extends DefinitionMember {
41 41
 
42 42
 	@Override
43 43
 	public void registerTo(TypeMembers members, TypeMemberPriority priority, GenericMapper mapper) {
44
-		TypeID instancedType = mapper == null ? type : mapper.map(position, type.stored()).type;
44
+		TypeID instancedType = mapper == null ? type : mapper.map(type.stored()).type;
45 45
 		members.addImplementation(new ImplementationMemberRef(this, members.type, instancedType.stored(members.type.getSpecifiedStorage())), priority);
46 46
 		
47 47
 		TypeMembers interfaceTypeMembers = members.getMemberCache().get(instancedType.stored(members.type.getActualStorage()));

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/IPartialExpression.java View File

@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.expression.Expression;
16 16
 import org.openzen.zenscript.codemodel.expression.InvalidExpression;
17 17
 import org.openzen.zenscript.codemodel.expression.LambdaClosure;
18 18
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
19
-import org.openzen.zenscript.codemodel.type.GenericName;
19
+import org.openzen.zenscript.codemodel.GenericName;
20 20
 import org.openzen.zenscript.codemodel.scope.TypeScope;
21 21
 import org.openzen.zenscript.codemodel.type.StoredType;
22 22
 

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialGlobalExpression.java View File

@@ -14,7 +14,7 @@ import org.openzen.zenscript.codemodel.expression.Expression;
14 14
 import org.openzen.zenscript.codemodel.expression.GlobalCallExpression;
15 15
 import org.openzen.zenscript.codemodel.expression.GlobalExpression;
16 16
 import org.openzen.zenscript.codemodel.scope.TypeScope;
17
-import org.openzen.zenscript.codemodel.type.GenericName;
17
+import org.openzen.zenscript.codemodel.GenericName;
18 18
 import org.openzen.zenscript.codemodel.type.StoredType;
19 19
 
20 20
 /**

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialMemberGroupExpression.java View File

@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.expression.Expression;
16 16
 import org.openzen.zenscript.codemodel.expression.LambdaClosure;
17 17
 import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
18 18
 import org.openzen.zenscript.codemodel.type.member.TypeMemberGroup;
19
-import org.openzen.zenscript.codemodel.type.GenericName;
19
+import org.openzen.zenscript.codemodel.GenericName;
20 20
 import org.openzen.zenscript.codemodel.scope.TypeScope;
21 21
 import org.openzen.zenscript.codemodel.type.StoredType;
22 22
 import org.openzen.zenscript.codemodel.type.member.TypeMember;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialPackageExpression.java View File

@@ -14,7 +14,7 @@ import org.openzen.zenscript.codemodel.FunctionHeader;
14 14
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
15 15
 import org.openzen.zenscript.codemodel.expression.CallArguments;
16 16
 import org.openzen.zenscript.codemodel.expression.Expression;
17
-import org.openzen.zenscript.codemodel.type.GenericName;
17
+import org.openzen.zenscript.codemodel.GenericName;
18 18
 import org.openzen.zenscript.codemodel.scope.TypeScope;
19 19
 import org.openzen.zenscript.codemodel.type.StoredType;
20 20
 

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialStaticMemberGroupExpression.java View File

@@ -15,7 +15,7 @@ import org.openzen.zenscript.codemodel.expression.CallArguments;
15 15
 import org.openzen.zenscript.codemodel.expression.Expression;
16 16
 import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
17 17
 import org.openzen.zenscript.codemodel.type.member.TypeMemberGroup;
18
-import org.openzen.zenscript.codemodel.type.GenericName;
18
+import org.openzen.zenscript.codemodel.GenericName;
19 19
 import org.openzen.zenscript.codemodel.scope.TypeScope;
20 20
 import org.openzen.zenscript.codemodel.type.StoredType;
21 21
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialTypeExpression.java View File

@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.expression.CallArguments;
16 16
 import org.openzen.zenscript.codemodel.expression.Expression;
17 17
 import org.openzen.zenscript.codemodel.expression.InvalidExpression;
18 18
 import org.openzen.zenscript.codemodel.expression.LambdaClosure;
19
-import org.openzen.zenscript.codemodel.type.GenericName;
19
+import org.openzen.zenscript.codemodel.GenericName;
20 20
 import org.openzen.zenscript.codemodel.scope.TypeScope;
21 21
 import org.openzen.zenscript.codemodel.type.StoredType;
22 22
 import org.openzen.zenscript.codemodel.type.TypeID;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialVariantOptionExpression.java View File

@@ -18,7 +18,7 @@ import org.openzen.zenscript.codemodel.expression.InvalidExpression;
18 18
 import org.openzen.zenscript.codemodel.expression.VariantValueExpression;
19 19
 import org.openzen.zenscript.codemodel.member.ref.VariantOptionRef;
20 20
 import org.openzen.zenscript.codemodel.scope.TypeScope;
21
-import org.openzen.zenscript.codemodel.type.GenericName;
21
+import org.openzen.zenscript.codemodel.GenericName;
22 22
 import org.openzen.zenscript.codemodel.type.StoredType;
23 23
 
24 24
 /**

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/BaseScope.java View File

@@ -11,7 +11,7 @@ import org.openzen.zenscript.codemodel.FunctionHeader;
11 11
 import org.openzen.zenscript.codemodel.expression.Expression;
12 12
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
13 13
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
14
-import org.openzen.zenscript.codemodel.type.GenericName;
14
+import org.openzen.zenscript.codemodel.GenericName;
15 15
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
16 16
 import org.openzen.zenscript.codemodel.type.StoredType;
17 17
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/BlockScope.java View File

@@ -13,7 +13,7 @@ import org.openzen.zenscript.codemodel.FunctionHeader;
13 13
 import org.openzen.zenscript.codemodel.GenericMapper;
14 14
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
15 15
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
16
-import org.openzen.zenscript.codemodel.type.GenericName;
16
+import org.openzen.zenscript.codemodel.GenericName;
17 17
 import org.openzen.zenscript.codemodel.type.StoredType;
18 18
 import org.openzen.zenscript.codemodel.type.TypeID;
19 19
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/CompileTypeScope.java View File

@@ -17,7 +17,7 @@ import org.openzen.zenscript.codemodel.generic.TypeParameter;
17 17
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
18 18
 import org.openzen.zenscript.codemodel.partial.PartialTypeExpression;
19 19
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
20
-import org.openzen.zenscript.codemodel.type.GenericName;
20
+import org.openzen.zenscript.codemodel.GenericName;
21 21
 import org.openzen.zenscript.codemodel.type.StoredType;
22 22
 import org.openzen.zenscript.codemodel.type.TypeID;
23 23
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/DefinitionScope.java View File

@@ -27,7 +27,7 @@ import org.openzen.zenscript.codemodel.generic.TypeParameter;
27 27
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
28 28
 import org.openzen.zenscript.codemodel.partial.PartialTypeExpression;
29 29
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
30
-import org.openzen.zenscript.codemodel.type.GenericName;
30
+import org.openzen.zenscript.codemodel.GenericName;
31 31
 import org.openzen.zenscript.codemodel.type.StoredType;
32 32
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
33 33
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPreparer;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/ExpressionScope.java View File

@@ -24,7 +24,7 @@ import org.openzen.zenscript.codemodel.partial.IPartialExpression;
24 24
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
25 25
 import org.openzen.zenscript.codemodel.statement.VarStatement;
26 26
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
27
-import org.openzen.zenscript.codemodel.type.GenericName;
27
+import org.openzen.zenscript.codemodel.GenericName;
28 28
 import org.openzen.zenscript.codemodel.type.StoredType;
29 29
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
30 30
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPreparer;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/FileScope.java View File

@@ -20,7 +20,7 @@ import org.openzen.zenscript.codemodel.partial.IPartialExpression;
20 20
 import org.openzen.zenscript.codemodel.partial.PartialGlobalExpression;
21 21
 import org.openzen.zenscript.codemodel.partial.PartialTypeExpression;
22 22
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
23
-import org.openzen.zenscript.codemodel.type.GenericName;
23
+import org.openzen.zenscript.codemodel.GenericName;
24 24
 import org.openzen.zenscript.codemodel.type.ISymbol;
25 25
 import org.openzen.zenscript.codemodel.type.StoredType;
26 26
 import org.openzen.zenscript.codemodel.type.TypeID;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/ForeachScope.java View File

@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.partial.IPartialExpression;
16 16
 import org.openzen.zenscript.codemodel.statement.ForeachStatement;
17 17
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
18 18
 import org.openzen.zenscript.codemodel.statement.VarStatement;
19
-import org.openzen.zenscript.codemodel.type.GenericName;
19
+import org.openzen.zenscript.codemodel.GenericName;
20 20
 import org.openzen.zenscript.codemodel.type.StoredType;
21 21
 import org.openzen.zenscript.codemodel.type.TypeID;
22 22
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/FunctionScope.java View File

@@ -17,7 +17,7 @@ import org.openzen.zenscript.codemodel.generic.TypeParameter;
17 17
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
18 18
 import org.openzen.zenscript.codemodel.partial.PartialTypeExpression;
19 19
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
20
-import org.openzen.zenscript.codemodel.type.GenericName;
20
+import org.openzen.zenscript.codemodel.GenericName;
21 21
 import org.openzen.zenscript.codemodel.type.StoredType;
22 22
 import org.openzen.zenscript.codemodel.type.TypeID;
23 23
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/GenericFunctionScope.java View File

@@ -17,7 +17,7 @@ import org.openzen.zenscript.codemodel.generic.TypeParameter;
17 17
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
18 18
 import org.openzen.zenscript.codemodel.partial.PartialTypeExpression;
19 19
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
20
-import org.openzen.zenscript.codemodel.type.GenericName;
20
+import org.openzen.zenscript.codemodel.GenericName;
21 21
 import org.openzen.zenscript.codemodel.type.StoredType;
22 22
 import org.openzen.zenscript.codemodel.type.TypeID;
23 23
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/GlobalScriptScope.java View File

@@ -13,7 +13,7 @@ import org.openzen.zenscript.codemodel.FunctionHeader;
13 13
 import org.openzen.zenscript.codemodel.GenericMapper;
14 14
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
15 15
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
16
-import org.openzen.zenscript.codemodel.type.GenericName;
16
+import org.openzen.zenscript.codemodel.GenericName;
17 17
 import org.openzen.zenscript.codemodel.type.StoredType;
18 18
 import org.openzen.zenscript.codemodel.type.TypeID;
19 19
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/ImplementationScope.java View File

@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.member.ImplementationMember;
16 16
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
17 17
 import org.openzen.zenscript.codemodel.partial.PartialTypeExpression;
18 18
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
19
-import org.openzen.zenscript.codemodel.type.GenericName;
19
+import org.openzen.zenscript.codemodel.GenericName;
20 20
 import org.openzen.zenscript.codemodel.type.StoredType;
21 21
 import org.openzen.zenscript.codemodel.type.TypeID;
22 22
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/LambdaScope.java View File

@@ -19,7 +19,7 @@ import org.openzen.zenscript.codemodel.expression.LambdaClosure;
19 19
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
20 20
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
21 21
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
22
-import org.openzen.zenscript.codemodel.type.GenericName;
22
+import org.openzen.zenscript.codemodel.GenericName;
23 23
 import org.openzen.zenscript.codemodel.type.StoredType;
24 24
 import org.openzen.zenscript.codemodel.type.TypeID;
25 25
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/LoopScope.java View File

@@ -13,7 +13,7 @@ import org.openzen.zenscript.codemodel.FunctionHeader;
13 13
 import org.openzen.zenscript.codemodel.GenericMapper;
14 14
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
15 15
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
16
-import org.openzen.zenscript.codemodel.type.GenericName;
16
+import org.openzen.zenscript.codemodel.GenericName;
17 17
 import org.openzen.zenscript.codemodel.type.StoredType;
18 18
 import org.openzen.zenscript.codemodel.type.TypeID;
19 19
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/StatementScope.java View File

@@ -12,7 +12,7 @@ import org.openzen.zencode.shared.CompileException;
12 12
 import org.openzen.zenscript.codemodel.expression.GetLocalVariableExpression;
13 13
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
14 14
 import org.openzen.zenscript.codemodel.statement.VarStatement;
15
-import org.openzen.zenscript.codemodel.type.GenericName;
15
+import org.openzen.zenscript.codemodel.GenericName;
16 16
 
17 17
 /**
18 18
  *

+ 1
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/DefinitionTypeID.java View File

@@ -5,6 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.type;
7 7
 
8
+import org.openzen.zenscript.codemodel.GenericName;
8 9
 import java.util.Arrays;
9 10
 import java.util.HashMap;
10 11
 import java.util.List;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberGroup.java View File

@@ -270,7 +270,7 @@ public class TypeMemberGroup {
270 270
 				for (StoredType resultHint : typeHints) {
271 271
 					Map<TypeParameter, StoredType> mapping = header.getReturnType().inferTypeParameters(scope.getMemberCache(), resultHint);
272 272
 					if (mapping != null) {
273
-						header = header.withGenericArguments(scope.getTypeRegistry(), scope.getLocalTypeParameters().getInner(scope.getTypeRegistry(), mapping));
273
+						header = header.withGenericArguments(scope.getLocalTypeParameters().getInner(scope.getTypeRegistry(), mapping));
274 274
 						break;
275 275
 					}
276 276
 				}

+ 9
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMembers.java View File

@@ -44,7 +44,7 @@ import org.openzen.zenscript.codemodel.partial.PartialTypeExpression;
44 44
 import org.openzen.zenscript.codemodel.partial.PartialVariantOptionExpression;
45 45
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
46 46
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
47
-import org.openzen.zenscript.codemodel.type.GenericName;
47
+import org.openzen.zenscript.codemodel.GenericName;
48 48
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
49 49
 import org.openzen.zenscript.codemodel.scope.TypeScope;
50 50
 import org.openzen.zenscript.codemodel.type.StoredType;
@@ -333,6 +333,10 @@ public final class TypeMembers {
333 333
 		return members.get(name);
334 334
 	}
335 335
 	
336
+	public TypeMemberGroup getGroup(String name) {
337
+		return members.get(name);
338
+	}
339
+	
336 340
 	public TypeMemberGroup getOrCreateGroup(OperatorType operator) {
337 341
 		if (!operators.containsKey(operator))
338 342
 			operators.put(operator, new TypeMemberGroup(false, operator.operator + " operator"));
@@ -340,6 +344,10 @@ public final class TypeMembers {
340 344
 		return operators.get(operator);
341 345
 	}
342 346
 	
347
+	public TypeMemberGroup getGroup(OperatorType operator) {
348
+		return operators.get(operator);
349
+	}
350
+	
343 351
 	public void addEnumMember(EnumConstantMember member, TypeMemberPriority priority) {
344 352
 		enumMembers.put(member.name, member);
345 353
 	}

+ 1
- 1
CompilerShared/src/main/java/org/openzen/zenscript/compiler/CompileScope.java View File

@@ -14,7 +14,7 @@ import org.openzen.zenscript.codemodel.GenericMapper;
14 14
 import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
15 15
 import org.openzen.zenscript.codemodel.definition.ExpansionDefinition;
16 16
 import org.openzen.zenscript.codemodel.scope.TypeScope;
17
-import org.openzen.zenscript.codemodel.type.GenericName;
17
+import org.openzen.zenscript.codemodel.GenericName;
18 18
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
19 19
 import org.openzen.zenscript.codemodel.type.StoredType;
20 20
 import org.openzen.zenscript.codemodel.type.TypeID;

+ 56
- 20
DrawableGui/src/main/java/org/openzen/drawablegui/scroll/DScrollBar.java View File

@@ -28,8 +28,9 @@ public class DScrollBar implements DComponent {
28 28
 	private final MutableLiveObject<DSizing> sizing = DSizing.create();
29 29
 	
30 30
 	private final DStyleClass styleClass;
31
-	private final LiveInt targetHeight;
31
+	private final LiveInt targetSize;
32 32
 	private final LiveInt offset;
33
+	private final boolean horizontal;
33 34
 	
34 35
 	private final ListenerHandle<LiveInt.Listener> targetHeightListener;
35 36
 	private final ListenerHandle<LiveInt.Listener> offsetListener;
@@ -38,20 +39,21 @@ public class DScrollBar implements DComponent {
38 39
 	private DScrollBarStyle style;
39 40
 	private DIRectangle bounds;
40 41
 	
41
-	private int fromY = 0;
42
-	private int toY = 0;
42
+	private int from = 0;
43
+	private int to = 0;
43 44
 	private boolean hovering = false;
44 45
 	private boolean dragging = false;
45 46
 	private int dragStartOffset;
46
-	private int dragStartY;
47
+	private int dragStart;
47 48
 	
48 49
 	private DDrawnRectangle background;
49 50
 	private DDrawnShape bar;
50 51
 	
51
-	public DScrollBar(DStyleClass styleClass, LiveInt targetHeight, LiveInt offset) {
52
+	public DScrollBar(DStyleClass styleClass, LiveInt targetHeight, LiveInt offset, boolean horizontal) {
52 53
 		this.styleClass = styleClass;
53
-		this.targetHeight = targetHeight;
54
+		this.targetSize = targetHeight;
54 55
 		this.offset = offset;
56
+		this.horizontal = horizontal;
55 57
 		
56 58
 		targetHeightListener = targetHeight.addListener(new ScrollListener());
57 59
 		offsetListener = offset.addListener(new ScrollListener());
@@ -61,7 +63,12 @@ public class DScrollBar implements DComponent {
61 63
 	public void mount(DComponentContext parent) {
62 64
 		context = parent.getChildContext("scrollbar", styleClass);
63 65
 		style = context.getStyle(DScrollBarStyle::new);
64
-		sizing.setValue(new DSizing(style.width, 0));
66
+		
67
+		if (horizontal) {
68
+			sizing.setValue(new DSizing(0, style.width));
69
+		} else {
70
+			sizing.setValue(new DSizing(style.width, 0));
71
+		}
65 72
 		
66 73
 		background = context.fillRect(0, DIRectangle.EMPTY, style.scrollBarBackgroundColor);
67 74
 	}
@@ -118,18 +125,32 @@ public class DScrollBar implements DComponent {
118 125
 	@Override
119 126
 	public void onMouseDrag(DMouseEvent e) {
120 127
 		if (dragging) {
121
-			int deltaY = e.y - dragStartY;
122
-			int offsetForDelta = deltaY * targetHeight.getValue() / this.bounds.height;
123
-			offset.setValue(dragStartOffset + offsetForDelta);
128
+			if (horizontal) {
129
+				int deltaX = e.x - dragStart;
130
+				int offsetForDelta = deltaX * targetSize.getValue() / this.bounds.width;
131
+				offset.setValue(dragStartOffset + offsetForDelta);
132
+			} else {
133
+				int deltaY = e.y - dragStart;
134
+				int offsetForDelta = deltaY * targetSize.getValue() / this.bounds.height;
135
+				offset.setValue(dragStartOffset + offsetForDelta);
136
+			}
124 137
 		}
125 138
 	}
126 139
 	
127 140
 	@Override
128 141
 	public void onMouseDown(DMouseEvent e) {
129
-		if (e.y >= fromY && e.y < toY) {
130
-			dragStartOffset = offset.getValue();
131
-			dragStartY = e.y;
132
-			setDragging(true);
142
+		if (horizontal) {
143
+			if (e.x >= from && e.x < to) {
144
+				dragStartOffset = offset.getValue();
145
+				dragStart = e.x;
146
+				setDragging(true);
147
+			}
148
+		} else {
149
+			if (e.y >= from && e.y < to) {
150
+				dragStartOffset = offset.getValue();
151
+				dragStart = e.y;
152
+				setDragging(true);
153
+			}
133 154
 		}
134 155
 	}
135 156
 	
@@ -152,14 +173,18 @@ public class DScrollBar implements DComponent {
152 173
 			color = style.scrollBarHoverColor;
153 174
 		if (dragging)
154 175
 			color = style.scrollBarPressColor;		
155
-		if (targetHeight.getValue() <= this.bounds.height)
176
+		if (targetSize.getValue() <= this.bounds.height)
156 177
 			color = 0;
157 178
 		
158 179
 		bar.setColor(color);
159 180
 	}
160 181
 	
161 182
 	private void checkHover(DMouseEvent e) {
162
-		setHovering(e.y >= fromY && e.y < toY);
183
+		if (horizontal) {
184
+			setHovering(e.x >= from && e.x < to);
185
+		} else {
186
+			setHovering(e.y >= from && e.y < to);
187
+		}
163 188
 	}
164 189
 	
165 190
 	private void setHovering(boolean hovering) {
@@ -179,15 +204,26 @@ public class DScrollBar implements DComponent {
179 204
 	}
180 205
 	
181 206
 	private void recalculate() {
182
-		if (targetHeight.getValue() == 0 || bounds == null)
207
+		if (targetSize.getValue() == 0 || bounds == null)
183 208
 			return;
184 209
 		
185
-		fromY = bounds.y + this.bounds.height * offset.getValue() / targetHeight.getValue();
186
-		toY = bounds.y + this.bounds.height * (offset.getValue() + this.bounds.height) / targetHeight.getValue();
210
+		if (horizontal) {
211
+			from = bounds.x + this.bounds.width * offset.getValue() / targetSize.getValue();
212
+			to = bounds.x + this.bounds.width * (offset.getValue() + this.bounds.width) / targetSize.getValue();
213
+		} else {
214
+			from = bounds.y + this.bounds.height * offset.getValue() / targetSize.getValue();
215
+			to = bounds.y + this.bounds.height * (offset.getValue() + this.bounds.height) / targetSize.getValue();
216
+		}
187 217
 		
188 218
 		if (bar != null)
189 219
 			bar.close();
190
-		bar = context.fillPath(1, DPath.rectangle(bounds.x, fromY, bounds.width, toY - fromY), DTransform2D.IDENTITY, style.scrollBarNormalColor);
220
+		
221
+		if (horizontal) {
222
+			bar = context.fillPath(1, DPath.rectangle(from, bounds.y, to - from, bounds.height), DTransform2D.IDENTITY, style.scrollBarNormalColor);
223
+		} else {
224
+			bar = context.fillPath(1, DPath.rectangle(bounds.x, from, bounds.width, to - from), DTransform2D.IDENTITY, style.scrollBarNormalColor);
225
+		}
226
+		
191 227
 		updateBarColor();
192 228
 	}
193 229
 	

+ 63
- 20
DrawableGui/src/main/java/org/openzen/drawablegui/scroll/DScrollPane.java View File

@@ -28,13 +28,15 @@ import org.openzen.drawablegui.style.DStyleClass;
28 28
 public class DScrollPane implements DComponent, DScrollContext {
29 29
 	private final DStyleClass styleClass;
30 30
 	private final DComponent contents;
31
-	private final DScrollBar scrollBar;
31
+	private final DScrollBar verticalScrollBar;
32
+	private final DScrollBar horizontalScrollBar;
32 33
 	
33 34
 	private DComponentContext context;
34 35
 	private DScrollPaneStyle style;
35 36
 	private DIRectangle bounds;
36 37
 	
37 38
 	private DDrawnShape shape;
39
+	private final LiveInt contentsWidth;
38 40
 	private final LiveInt contentsHeight;
39 41
 	private final LiveInt offsetX;
40 42
 	private final LiveInt offsetY;
@@ -42,6 +44,7 @@ public class DScrollPane implements DComponent, DScrollContext {
42 44
 	private final SimpleLiveObject<DSizing> sizing = new SimpleLiveObject<>(DSizing.EMPTY);
43 45
 	private final LiveObject<DScalableSize> size;
44 46
 	
47
+	private final ListenerHandle<LiveInt.Listener> contentsWidthListener;
45 48
 	private final ListenerHandle<LiveInt.Listener> contentsHeightListener;
46 49
 	private final ListenerHandle<LiveInt.Listener> offsetXListener;
47 50
 	private final ListenerHandle<LiveInt.Listener> offsetYListener;
@@ -56,12 +59,15 @@ public class DScrollPane implements DComponent, DScrollContext {
56 59
 		this.styleClass = styleClass;
57 60
 		this.contents = contents;
58 61
 		
62
+		contentsWidth = new SimpleLiveInt(0);
59 63
 		contentsHeight = new SimpleLiveInt(0);
60 64
 		offsetX = new SimpleLiveInt(0);
61 65
 		offsetY = new SimpleLiveInt(0);
62 66
 		
63
-		scrollBar = new DScrollBar(DStyleClass.EMPTY, contentsHeight, offsetY);
67
+		verticalScrollBar = new DScrollBar(DStyleClass.EMPTY, contentsHeight, offsetY, false);
68
+		horizontalScrollBar = new DScrollBar(DStyleClass.EMPTY, contentsWidth, offsetX, true);
64 69
 		
70
+		contentsWidthListener = contentsWidth.addListener(new ScrollListener());
65 71
 		contentsHeightListener = contentsHeight.addListener(new ScrollListener());
66 72
 		offsetXListener = offsetX.addListener(new ScrollListener());
67 73
 		offsetYListener = offsetY.addListener(new ScrollListener());
@@ -83,7 +89,8 @@ public class DScrollPane implements DComponent, DScrollContext {
83 89
 		subSurface = context.createSubSurface(1);
84 90
 		DComponentContext newContext = new DComponentContext(this, context.path, 0, subSurface);
85 91
 		contents.mount(newContext);
86
-		scrollBar.mount(context);
92
+		horizontalScrollBar.mount(context);
93
+		verticalScrollBar.mount(context);
87 94
 		
88 95
 		sizing.setValue(new DSizing(
89 96
 				size.getValue().width.evalInt(parent.getUIContext()),
@@ -98,7 +105,8 @@ public class DScrollPane implements DComponent, DScrollContext {
98 105
 		style.border.close();
99 106
 		
100 107
 		contents.unmount();
101
-		scrollBar.unmount();
108
+		horizontalScrollBar.unmount();
109
+		verticalScrollBar.unmount();
102 110
 	}
103 111
 
104 112
 	@Override
@@ -125,16 +133,29 @@ public class DScrollPane implements DComponent, DScrollContext {
125 133
 		shape = context.shadowPath(0, style.shape.instance(style.margin.apply(bounds)), DTransform2D.IDENTITY, style.backgroundColor, style.shadow);
126 134
 		style.border.update(context, style.margin.apply(bounds));
127 135
 		
136
+		int width = Math.max(
137
+				bounds.width - style.border.getPaddingHorizontal(),
138
+				contents.getSizing().getValue().preferredWidth);
128 139
 		int height = Math.max(
129 140
 				bounds.height - style.border.getPaddingHorizontal(),
130 141
 				contents.getSizing().getValue().preferredHeight);
131
-		int scrollBarWidth = scrollBar.getSizing().getValue().preferredWidth;
132
-		scrollBar.setBounds(new DIRectangle(
142
+		int scrollBarWidth = verticalScrollBar.getSizing().getValue().preferredWidth;
143
+		int scrollBarHeight = horizontalScrollBar.getSizing().getValue().preferredHeight;
144
+
145
+		verticalScrollBar.setBounds(new DIRectangle(
133 146
 				bounds.x + bounds.width - scrollBarWidth - style.border.getPaddingRight() - style.margin.right,
134 147
 				bounds.y + style.border.getPaddingTop() + style.margin.top,
135 148
 				scrollBarWidth,
136 149
 				bounds.height - style.border.getPaddingVertical() - style.margin.getVertical()));
137
-		contents.setBounds(new DIRectangle(0, 0, bounds.width - scrollBar.getBounds().width, height));
150
+		
151
+		horizontalScrollBar.setBounds(new DIRectangle(
152
+				bounds.x + style.border.getPaddingLeft() + style.margin.left,
153
+				bounds.y + bounds.height - scrollBarHeight - style.border.getPaddingBottom() - style.margin.bottom,
154
+				bounds.width - style.border.getPaddingHorizontal() - style.margin.getHorizontal(),
155
+				scrollBarHeight));
156
+		
157
+		contents.setBounds(new DIRectangle(0, 0, width, height));
158
+		contentsWidth.setValue(width);
138 159
 		contentsHeight.setValue(height);
139 160
 		
140 161
 		subSurface.setOffset(bounds.x - offsetX.getValue(), bounds.y - offsetY.getValue());
@@ -152,8 +173,10 @@ public class DScrollPane implements DComponent, DScrollContext {
152 173
 	
153 174
 	@Override
154 175
 	public void onMouseEnter(DMouseEvent e) {
155
-		if (e.x >= scrollBar.getBounds().x) {
156
-			setHovering(scrollBar, e);
176
+		if (e.x >= verticalScrollBar.getBounds().x) {
177
+			setHovering(verticalScrollBar, e);
178
+		} else if (e.y >= horizontalScrollBar.getBounds().y) {
179
+			setHovering(horizontalScrollBar, e);
157 180
 		} else {
158 181
 			setHovering(contents, e);
159 182
 		}
@@ -166,11 +189,17 @@ public class DScrollPane implements DComponent, DScrollContext {
166 189
 	
167 190
 	@Override
168 191
 	public void onMouseMove(DMouseEvent e) {
169
-		if (e.x >= scrollBar.getBounds().x) {
170
-			if (hovering != scrollBar) {
171
-				setHovering(scrollBar, e);
192
+		if (e.x >= verticalScrollBar.getBounds().x) {
193
+			if (hovering != verticalScrollBar) {
194
+				setHovering(verticalScrollBar, e);
195
+			} else {
196
+				verticalScrollBar.onMouseMove(e);
197
+			}
198
+		} else if (e.y >= horizontalScrollBar.getBounds().y) {
199
+			if (hovering != horizontalScrollBar) {
200
+				setHovering(horizontalScrollBar, e);
172 201
 			} else {
173
-				scrollBar.onMouseMove(e);
202
+				horizontalScrollBar.onMouseMove(e);
174 203
 			}
175 204
 		} else {
176 205
 			if (hovering != contents) {
@@ -261,6 +290,11 @@ public class DScrollPane implements DComponent, DScrollContext {
261 290
 
262 291
 	@Override
263 292
 	public void scrollInView(int x, int y, int width, int height) {
293
+		if (x < offsetX.getValue())
294
+			offsetX.setValue(x);
295
+		if (x + width > offsetX.getValue() + bounds.width)
296
+			offsetX.setValue(x + width - bounds.width);
297
+		
264 298
 		if (y < offsetY.getValue())
265 299
 			offsetY.setValue(y);
266 300
 		if (y + height > offsetY.getValue() + bounds.height)
@@ -281,14 +315,23 @@ public class DScrollPane implements DComponent, DScrollContext {
281 315
 
282 316
 		@Override
283 317
 		public void onChanged(int oldValue, int newValue) {
284
-			int value = offsetY.getValue();
285
-			if (value > contentsHeight.getValue() - bounds.height)
286
-				value = contentsHeight.getValue() - bounds.height;
287
-			if (value < 0)
288
-				value = 0;
318
+			int valueX = offsetX.getValue();
319
+			if (valueX > contentsWidth.getValue() - bounds.width)
320
+				valueX = contentsWidth.getValue() - bounds.width;
321
+			if (valueX < 0)
322
+				valueX = 0;
323
+			
324
+			if (valueX != offsetX.getValue())
325
+				offsetX.setValue(valueX);
326
+			
327
+			int valueY = offsetY.getValue();
328
+			if (valueY > contentsHeight.getValue() - bounds.height)
329
+				valueY = contentsHeight.getValue() - bounds.height;
330
+			if (valueY < 0)
331
+				valueY = 0;
289 332
 			
290
-			if (value != offsetY.getValue())
291
-				offsetY.setValue(value);
333
+			if (valueY != offsetY.getValue())
334
+				offsetY.setValue(valueY);
292 335
 			
293 336
 			subSurface.setOffset(bounds.x - offsetX.getValue(), bounds.y - offsetY.getValue());
294 337
 		}

+ 38
- 12
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/SourceEditor.java View File

@@ -147,8 +147,6 @@ public class SourceEditor implements DComponent {
147 147
 		fullLineHeight = textLineHeight + fontMetrics.getLeading() + style.extraLineSpacing;
148 148
 		selectionLineHeight = textLineHeight + style.selectionPaddingTop + style.selectionPaddingBottom;
149 149
 		
150
-		sizing.setValue(new DSizing(0, fullLineHeight * tokens.getLineCount()));
151
-		
152 150
 		blinkTimer = context.getUIContext().setTimer(300, this::blink);
153 151
 		
154 152
 		selection = context.fillRect(2, DIRectangle.EMPTY, style.selectionColor);
@@ -158,11 +156,15 @@ public class SourceEditor implements DComponent {
158 156
 		for (int i = 0; i < tokens.getLineCount(); i++)
159 157
 			lineNumbers.add(context.drawText(3, font, style.lineBarTextColor, 0, 0, Integer.toString(i + 1)));
160 158
 		
161
-		for (TokenLine line : tokens.getLines())
159
+		for (TokenLine line : tokens.getLines()) {
162 160
 			drawnTokens.add(lineToTokens(line));
161
+			line.lengthInPixels = measureLineLength(line);
162
+		}
163 163
 		
164 164
 		window.aspectBar.toolbars.add(editToolbar);
165 165
 		window.aspectBar.active.setValue(editToolbar);
166
+		
167
+		updatePreferredSize();
166 168
 	}
167 169
 	
168 170
 	@Override
@@ -720,10 +722,6 @@ public class SourceEditor implements DComponent {
720 722
 		return token.type == ZSTokenType.T_WHITESPACE_TAB ? tab : token.content;
721 723
 	}
722 724
 	
723
-	private void onLinesUpdated() {
724
-		sizing.setValue(new DSizing(0, fullLineHeight * tokens.getLineCount()));
725
-	}
726
-	
727 725
 	private void layoutLines(int fromIndex) {
728 726
 		for (int i = fromIndex; i < drawnTokens.size(); i++) {
729 727
 			layoutLine(i);
@@ -750,35 +748,63 @@ public class SourceEditor implements DComponent {
750 748
 		return tokenLine;
751 749
 	}
752 750
 	
751
+	private int measureLineLength(TokenLine line) {
752
+		int result = 0;
753
+		for (ZSToken token : line.getTokens()) {
754
+			String content = getDisplayContent(token);
755
+			result += fontMetrics.getWidth(content);
756
+		}
757
+		return result;
758
+	}
759
+	
760
+	private void updatePreferredSize() {
761
+		int width = 0;
762
+		for (TokenLine line : tokens.getLines()) {
763
+			width = Math.max(width, line.lengthInPixels);
764
+		}
765
+		
766
+		DSizing sizing = new DSizing(width + lineBarWidth, fullLineHeight * tokens.getLineCount());
767
+		this.sizing.setValue(sizing);
768
+		System.out.println("Preferred size: " + sizing.preferredWidth + " x " + sizing.preferredHeight);
769
+	}
770
+	
753 771
 	private class TokenListener implements TokenModel.Listener {
754 772
 
755 773
 		@Override
756 774
 		public void onLineInserted(int index) {
757
-			onLinesUpdated();
758
-			
759 775
 			if (bounds != null) {
760 776
 				String str = Integer.toString(lineNumbers.size() + 1);
761 777
 				int x = bounds.x + lineBarWidth - style.lineBarSpacingRight - style.lineBarMargin - fontMetrics.getWidth(str);
762 778
 				int y = bounds.y + style.selectionPaddingTop + lineNumbers.size() * fullLineHeight + fontMetrics.getAscent();
763 779
 				lineNumbers.add(context.drawText(3, font, style.lineBarTextColor, x, y, str));
764 780
 				
765
-				drawnTokens.add(index, lineToTokens(tokens.getLine(index)));
781
+				TokenLine line = tokens.getLine(index);
782
+				drawnTokens.add(index, lineToTokens(line));
766 783
 				layoutLines(index);
784
+				
785
+				line.lengthInPixels = measureLineLength(line);
767 786
 			}
787
+			
788
+			updatePreferredSize();
768 789
 		}
769 790
 
770 791
 		@Override
771 792
 		public void onLineChanged(int index) {
772 793
 			if (bounds != null) {
773 794
 				Destructible.close(drawnTokens.get(index));
774
-				drawnTokens.set(index, lineToTokens(tokens.getLine(index)));
795
+				
796
+				TokenLine line = tokens.getLine(index);
797
+				drawnTokens.set(index, lineToTokens(line));
775 798
 				layoutLine(index);
799
+				
800
+				line.lengthInPixels = measureLineLength(line);
801
+				updatePreferredSize();
776 802
 			}
777 803
 		}
778 804
 
779 805
 		@Override
780 806
 		public void onLineDeleted(int index) {
781
-			onLinesUpdated();
807
+			updatePreferredSize();
782 808
 			
783 809
 			if (index >= lineNumbers.size())
784 810
 				return;

+ 2
- 0
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/TokenLine.java View File

@@ -19,6 +19,8 @@ public final class TokenLine {
19 19
 	private final List<ZSToken> tokens = new ArrayList<>();
20 20
 	private int length = 0;
21 21
 	
22
+	public int lengthInPixels = 0; // used by SourceEditor
23
+	
22 24
 	public List<ZSToken> getTokens() {
23 25
 		return Collections.unmodifiableList(tokens);
24 26
 	}

+ 1
- 1
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaCompiledModule.java View File

@@ -126,7 +126,7 @@ public class JavaCompiledModule {
126 126
 	public JavaMethod getMethodInfo(IDefinitionMember member) {
127 127
 		JavaMethod method = methods.get(member);
128 128
 		if (method == null)
129
-			throw new IllegalStateException("Missing field info for field " + member.getDefinition().name + "." + member.describe());
129
+			throw new IllegalStateException("Missing method info for method " + member.getDefinition().name + "." + member.describe());
130 130
 		
131 131
 		return method;
132 132
 	}

+ 7
- 0
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpression.java View File

@@ -445,9 +445,16 @@ public abstract class ParsedExpression {
445 445
 			}
446 446
 			case T_IDENTIFIER: {
447 447
 				String name = parser.next().content;
448
+				if (name.startsWith("@"))
449
+					name = name.substring(1);
450
+				
448 451
 				List<IParsedType> genericParameters = IParsedType.parseTypeArguments(parser);
449 452
 				return new ParsedExpressionVariable(position, name, genericParameters);
450 453
 			}
454
+			case T_LOCAL_IDENTIFIER: {
455
+				String name = parser.next().content.substring(1);
456
+				return new ParsedLocalVariableExpression(position, name);
457
+			}
451 458
 			case K_THIS:
452 459
 				parser.next();
453 460
 				return new ParsedExpressionThis(position);

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionFunction.java View File

@@ -93,7 +93,7 @@ public class ParsedExpressionFunction extends ParsedExpression {
93 93
 		}
94 94
 		
95 95
 		StoredType functionType = scope.getTypeRegistry()
96
-				.getFunction(genericHeader.withGenericArguments(scope.getTypeRegistry(), new GenericMapper(scope.getTypeRegistry(), scope.genericInferenceMap)))
96
+				.getFunction(genericHeader.withGenericArguments(new GenericMapper(scope.getTypeRegistry(), scope.genericInferenceMap)))
97 97
 				.stored(storage);
98 98
 		return new FunctionExpression(position, functionType, closure, header, statements);
99 99
 	}

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionIndex.java View File

@@ -15,7 +15,7 @@ import org.openzen.zenscript.codemodel.expression.CallArguments;
15 15
 import org.openzen.zenscript.codemodel.expression.Expression;
16 16
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
17 17
 import org.openzen.zenscript.codemodel.scope.TypeScope;
18
-import org.openzen.zenscript.codemodel.type.GenericName;
18
+import org.openzen.zenscript.codemodel.GenericName;
19 19
 import org.openzen.zenscript.codemodel.type.member.TypeMemberGroup;
20 20
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
21 21
 import org.openzen.zenscript.codemodel.type.StoredType;

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionMember.java View File

@@ -11,7 +11,7 @@ import org.openzen.zencode.shared.CodePosition;
11 11
 import org.openzen.zencode.shared.CompileException;
12 12
 import org.openzen.zencode.shared.CompileExceptionCode;
13 13
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
14
-import org.openzen.zenscript.codemodel.type.GenericName;
14
+import org.openzen.zenscript.codemodel.GenericName;
15 15
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
16 16
 import org.openzen.zenscript.codemodel.type.StoredType;
17 17
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionVariable.java View File

@@ -21,7 +21,7 @@ import org.openzen.zenscript.codemodel.expression.switchvalue.VariantOptionSwitc
21 21
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
22 22
 import org.openzen.zenscript.codemodel.member.ref.VariantOptionRef;
23 23
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
24
-import org.openzen.zenscript.codemodel.type.GenericName;
24
+import org.openzen.zenscript.codemodel.GenericName;
25 25
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
26 26
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
27 27
 import org.openzen.zenscript.codemodel.type.StoredType;

+ 47
- 0
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedLocalVariableExpression.java View File

@@ -0,0 +1,47 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.parser.expression;
7
+
8
+import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zencode.shared.CompileException;
10
+import org.openzen.zencode.shared.CompileExceptionCode;
11
+import org.openzen.zenscript.codemodel.expression.GetFieldExpression;
12
+import org.openzen.zenscript.codemodel.expression.ThisExpression;
13
+import org.openzen.zenscript.codemodel.partial.IPartialExpression;
14
+import org.openzen.zenscript.codemodel.scope.ExpressionScope;
15
+import org.openzen.zenscript.codemodel.type.member.TypeMemberGroup;
16
+import org.openzen.zenscript.codemodel.type.member.TypeMembers;
17
+
18
+/**
19
+ *
20
+ * @author Hoofdgebruiker
21
+ */
22
+public class ParsedLocalVariableExpression extends ParsedExpression {
23
+	private final String name;
24
+	
25
+	public ParsedLocalVariableExpression(CodePosition position, String name) {
26
+		super(position);
27
+		
28
+		this.name = name;
29
+	}
30
+
31
+	@Override
32
+	public IPartialExpression compile(ExpressionScope scope) throws CompileException {
33
+		TypeMembers members = scope.getTypeMembers(scope.getThisType());
34
+		TypeMemberGroup group = members.getGroup(name);
35
+		if (group == null)
36
+			throw new CompileException(position, CompileExceptionCode.NO_SUCH_MEMBER, "No such field: " + name);
37
+		if (group.getField() == null)
38
+			throw new CompileException(position, CompileExceptionCode.NO_SUCH_MEMBER, "No such field: " + name);
39
+		
40
+		return new GetFieldExpression(position, new ThisExpression(position, scope.getThisType()), group.getField());
41
+	}
42
+
43
+	@Override
44
+	public boolean hasStrongType() {
45
+		return true;
46
+	}
47
+}

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/statements/ParsedCatchClause.java View File

@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.partial.IPartialExpression;
16 16
 import org.openzen.zenscript.codemodel.statement.CatchClause;
17 17
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
18 18
 import org.openzen.zenscript.codemodel.statement.VarStatement;
19
-import org.openzen.zenscript.codemodel.type.GenericName;
19
+import org.openzen.zenscript.codemodel.GenericName;
20 20
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
21 21
 import org.openzen.zenscript.codemodel.scope.StatementScope;
22 22
 import org.openzen.zenscript.codemodel.statement.VariableID;

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/statements/ParsedStatementSwitch.java View File

@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.partial.IPartialExpression;
16 16
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
17 17
 import org.openzen.zenscript.codemodel.statement.Statement;
18 18
 import org.openzen.zenscript.codemodel.statement.SwitchStatement;
19
-import org.openzen.zenscript.codemodel.type.GenericName;
19
+import org.openzen.zenscript.codemodel.GenericName;
20 20
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
21 21
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
22 22
 import org.openzen.zenscript.codemodel.scope.StatementScope;

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedNamedType.java View File

@@ -11,7 +11,7 @@ import org.openzen.zencode.shared.CodePosition;
11 11
 import org.openzen.zencode.shared.CompileExceptionCode;
12 12
 import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
13 13
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
14
-import org.openzen.zenscript.codemodel.type.GenericName;
14
+import org.openzen.zenscript.codemodel.GenericName;
15 15
 import org.openzen.zenscript.codemodel.scope.BaseScope;
16 16
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
17 17
 import org.openzen.zenscript.codemodel.type.StoredType;

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeGenericMap.java View File

@@ -11,7 +11,7 @@ import org.openzen.zencode.shared.CompileExceptionCode;
11 11
 import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
12 12
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
13 13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
14
-import org.openzen.zenscript.codemodel.type.GenericName;
14
+import org.openzen.zenscript.codemodel.GenericName;
15 15
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
16 16
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
17 17
 import org.openzen.zenscript.codemodel.type.StoredType;

+ 1
- 1
Validator/src/main/java/org/openzen/zenscript/validator/visitors/DefinitionValidator.java View File

@@ -27,7 +27,7 @@ import org.openzen.zenscript.codemodel.definition.VariantDefinition;
27 27
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
28 28
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
29 29
 import org.openzen.zenscript.codemodel.scope.TypeScope;
30
-import org.openzen.zenscript.codemodel.type.GenericName;
30
+import org.openzen.zenscript.codemodel.GenericName;
31 31
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
32 32
 import org.openzen.zenscript.codemodel.type.StoredType;
33 33
 import org.openzen.zenscript.codemodel.type.TypeID;

Loading…
Cancel
Save