projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
TextComponent no longer overrides getBounds but rather calls setSize()
[Mograsim.git]
/
net.mograsim.logic.ui
/
src
/
net
/
mograsim
/
logic
/
ui
/
model
/
components
/
TextComponent.java
diff --git
a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/TextComponent.java
b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/TextComponent.java
index
871d4f9
..
b0138aa
100644
(file)
--- a/
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/TextComponent.java
+++ b/
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/TextComponent.java
@@
-10,6
+10,7
@@
import net.mograsim.logic.ui.modeladapter.ViewLogicModelAdapter;
import net.mograsim.logic.ui.modeladapter.componentadapters.NoLogicAdapter;
import net.mograsim.preferences.Preferences;
import net.mograsim.logic.ui.modeladapter.componentadapters.NoLogicAdapter;
import net.mograsim.preferences.Preferences;
+//TODO clean size calculation mess
public class TextComponent extends GUIComponent
{
private final String text;
public class TextComponent extends GUIComponent
{
private final String text;
@@
-18,20
+19,25
@@
public class TextComponent extends GUIComponent
{
super(model);
this.text = text;
{
super(model);
this.text = text;
+ // If size is unset, it defaults to 0, which could prohibit this component from being rendered, which would prohibit the size being
+ // set to a better guess
+ setSize(1, 1);
}
@Override
public void render(GeneralGC gc, Rectangle visibleRegion)
{
Point textExtent = gc.textExtent(text);
}
@Override
public void render(GeneralGC gc, Rectangle visibleRegion)
{
Point textExtent = gc.textExtent(text);
+ setSize(textExtent.x, textExtent.y);
+
Color textColor = Preferences.current().getColor("net.mograsim.logic.ui.color.text");
if (textColor != null)
gc.setForeground(textColor);
Color textColor = Preferences.current().getColor("net.mograsim.logic.ui.color.text");
if (textColor != null)
gc.setForeground(textColor);
- gc.drawText(text, getPosX()
- textExtent.x / 2, getPosY() - textExtent.y / 2
, true);
+ gc.drawText(text, getPosX()
, getPosY()
, true);
}
static
{
}
static
{
- ViewLogicModelAdapter.addComponentAdapter(
NoLogicAdapter.forClass
(TextComponent.class));
+ ViewLogicModelAdapter.addComponentAdapter(
new NoLogicAdapter<>
(TextComponent.class));
}
}
}
}