-
Hey there, I'm pretty new to this UI - so maybe this is a beginner kinda question, but I couldn't find any example in the UICatalog.UICatalogApp My usecase: I have a header that says something like "My App" in ascii art. And I'm either spacing it out horizontally or in two sections, depending on the size of the console... This is a helper class for my header:
So in my main window I'm creating the HeaderView like this:
(Most notably property being the And my FrameView class itself looks like this:
Now the problem is that the HeaderLabel() is only rendered once based on the initial size of the console. The How do I best go about accomplishing this? Do I have to trigger a redraw from somewhere? Edit: I'm using Version 2.0.0-pre.251 btw Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
Typically, changes that require re-calculating the layout of a view are signaled to the library by calling There are a ton of caveats, though, depending on what's being inherited from and what kind of position and dimensions are actually in use. If anything is absolute (inspect in the debugger to check what kind of Dim or Pos exists in all relevant properties), no amount of anything else will make it re-draw it any differently than currently set. I have a suspicion that absolute Pos/Dim combined with not signaling the need for re-layout may be the root of your issue, at first glance of the code provided. I'm assuming you're on a v1 Terminal.Gui release, yes? |
Beta Was this translation helpful? Give feedback.
-
private Label HeaderLabel()
{
var text = LayoutSizes.HorizontalLayout ?
"Biggggggggggggggggggggggggggggg Text" :
$"Virtical{Environment.NewLine}Spaced{Environment.NewLine}Label{Environment.NewLine}";
var label = new Label(text);
return label;
} This method looks like it returns a new using Terminal.Gui;
namespace Test
{
public class Program
{
static void Main()
{
Application.Init();
var w = new Window() { Title = "My Window" };
w.Add(new HeaderView
{
Width = Dim.Fill(),
Height = Dim.Fill(),
});
Application.Run(w);
Application.Shutdown();
return;
}
public class HeaderView : FrameView
{
public override void OnDrawContent(Rect contentArea)
{
base.OnDrawContent(contentArea);
string toAdd;
if(contentArea.Width > 20)
{
toAdd = "Biggggggggggggggggggggggggggggg Text";
}
else
{
toAdd = $"Virtical\nSpaced\nLabel";
}
int y = 0;
foreach (var l in toAdd.Split('\n'))
{
Move(0, y);
Driver.AddStr(l);
y++;
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
Ok, I simply got it to work now by creating this class: