I don't know if anyone has had this issue before but I'm sure someone can point me in the right path.
Here's a screenshot of a store I have; Notice how the title of the selected item is cut off by the Model View (I think) and then at the bottom the DButton is cutting off the label text that should say "Buy" though it says "B..."
[IMG]http://imgoid.tk/images/1352595793.png[/IMG]
I'm assuming that there is something wrong with the derma code. I've already tried inserting buttonPanel.useButton:SizeToContents() and this has not worked.
While hovering over the button my cursor changes to the hand, though I am not able to click the button. I have verified this by adding MsgN("Test") the the button's DoClick function and "Test" was never sent out to the console.
Thank you for your help! If any further explanation is needed please ask :)
Here's my code that creates the title and the button (Note that the width of rightPane is 292):
[CODE]
local titleObj = vgui.Create("DLabel", rightPane);
titleObj:SetText(itemData.name);
titleObj:SetFont("rpInventoryFont");
titleObj:SetExpensiveShadow(1, Color(0, 0, 0, 150));
titleObj:SetWide(self.rightPane:GetWide())
titleObj:SizeToContents()
self.rightPane:AddItem(titleObj);
local buttonPanel = vgui.Create("DPanel");
buttonPanel:SetTall(30)
buttonPanel.useButton = vgui.Create("DButton", buttonPanel);
buttonPanel.useButton:SetFont("rpInventoryFont")
buttonPanel.useButton:SetText("Buy");
buttonPanel.useButton:SetSize(buttonPanel:GetWide(), 30);
buttonPanel.useButton.DoClick = function()
RP.Command:Run("OrderItem", itemData.uniqueID);
self:ClearPane();
end;
self.rightPane:AddItem(buttonPanel);
[/CODE]
Now, I'm also using a custom Derma; here's the code for the DButton and the DLabel from said derma:
[CODE]function SKIN:DrawButtonBorder( x, y, w, h, depressed )
-- if ( !depressed ) then
-- // Highlight
-- surface.SetDrawColor( self.colButtonBorderHighlight )
-- surface.DrawRect( x+1, y+1, w-2, 1 )
-- surface.DrawRect( x+1, y+1, 1, h-2 )
-- // Corner
-- surface.DrawRect( x+2, y+2, 1, 1 )
-- // Shadow
-- surface.SetDrawColor( self.colButtonBorderShadow )
-- surface.DrawRect( w-2, y+2, 1, h-2 )
-- surface.DrawRect( x+2, h-2, w-2, 1 )
-- else
-- local col = self.colButtonBorderShadow
-- for i=1, 5 do
-- surface.SetDrawColor( col.r, col.g, col.b, (255 - i * (255/5) ) )
-- surface.DrawOutlinedRect( i, i, w-i, h-i )
-- end
-- end
surface.SetDrawColor(0, 0, 0, 255)
surface.DrawOutlinedRect(x, y, w, h);
end;
function SKIN:DrawDisabledButtonBorder(x, y, w, h, depressed)
surface.SetDrawColor(0, 0, 0, 150);
surface.DrawOutlinedRect(x, y, w, h);
end;
function SKIN:PaintButton(panel)
local width, height = panel:GetSize();
if (panel.m_bBackground) then
if (panel:GetDisabled()) then
-- surface.SetDrawColor(self.mainDark);
-- surface.DrawRect(0, 0, width, height);
self:DrawGradient(0, 0, width, height, self.mainDark);
surface.SetDrawColor(18, 18, 18, 255);
surface.DrawOutlinedRect(0, 0, width, height);
panel:SetTextColor(self.mainLight);
elseif (panel.Depressed) then --|| panel:GetSelected()) then
-- surface.SetDrawColor(self.mainLight);
-- surface.DrawRect(0, 0, width, height);
-- surface.SetDrawColor(self.buttonActive);
-- surface.SetTexture(self.gradientDown);
-- surface.DrawRect(0, 0, width, height);
self:DrawGradient(0, 0, width, height, self.buttonActive);
surface.SetDrawColor(18, 18, 18, 255);
surface.DrawOutlinedRect(0, 0, width, height);
panel:SetTextColor(Color(22, 22, 22, 255));
elseif (panel.Hovered) then
-- surface.SetDrawColor(self.buttonHighlight);
-- surface.DrawRect(0, 0, width, height);
self:DrawGradient(0, 0, width, height, self.buttonHighlight);
surface.SetDrawColor(18, 18, 18, 255);
surface.DrawOutlinedRect(0, 0, width, height);
panel:SetTextColor(Color(22, 255, 22, 255));
else
-- surface.SetDrawColor(self.buttonMain);
-- surface.DrawRect(0, 0, width, height);
self:DrawGradient(0, 0, width, height, self.buttonMain);
surface.SetDrawColor(18, 18, 18, 255);
surface.DrawOutlinedRect(0, 0, width, height);
panel:SetTextColor(self.mainLight);
end;
end;
end;
function SKIN:PaintOverButton(panel)
end;
function SKIN:SchemeButton(panel)
panel:SetFont(self.mainFont)
-- if (panel:GetDisabled()) then
-- panel:SetTextColor(self.mainDark);
-- else
-- panel:SetTextColor(self.mainLight);
-- end
DLabel.ApplySchemeSettings(panel);
end;
/* ===========
DLabel
=========== */
function SKIN:PaintLabel(panel)
return false;
end;
function SKIN:SchemeLabel(panel)
local col = nil
if (panel.Hovered && panel:GetTextColorHovered()) then
col = panel:GetTextColorHovered();
else
col = panel:GetTextColor();
end;
if (col) then
panel:SetFGColor(col.r, col.g, col.b, col.a);
else
panel:SetFGColor(self.mainLight);
end;
end;
function SKIN:LayoutLabel(panel)
panel:ApplySchemeSettings();
if (panel.m_bAutoStretchVertical) then
panel:SizeToContentsY();
end;
panel:SizeToContentsX();
end;
[/CODE]
[lua]buttonPanel.useButton:SetSize(buttonPanel:GetWide(), 30)[/lua]
You can't get the width of the panel when the width is never set.
[QUOTE=find me;38403434]
buttonPanel.useButton:SetSize(buttonPanel:GetWide(), 30)
You can't get the width of the panel when the width is never set.[/QUOTE]
This doesn't change the layout of the button, it's still stretched all the way across the bottom with the text as "B..."
buttonPanel.useButton:SizeToContents()?
[QUOTE=Banana Lord.;38407136]buttonPanel.useButton:SizeToContents()?[/QUOTE]
After doing this the button isn't visible at all :(
[IMG]http://i.imgur.com/qQHU2.jpg[/IMG]
are you setting the position [i]after[/i] setting thesize?
[QUOTE=Banana Lord.;38410713]are you setting the position [I]after[/I] setting thesize?[/QUOTE]
I've never set the position of the button as shouldn't the button fill the space it was given when I used buttonPanel.useButton:SetSize(buttonPanel:GetWide(), 30); therefore I wouldn't need to set the position?
This is what I have after putting in your suggestion above:
[code]
local buttonPanel = vgui.Create("DPanel");
buttonPanel:SetSize(self.rightPane:GetWide(), 30)
buttonPanel.useButton = vgui.Create("DButton", buttonPanel);
buttonPanel.useButton:SetFont("rpInventoryFont")
buttonPanel.useButton:SetText("Buy");
buttonPanel.useButton:SizeToContents()
buttonPanel.useButton.DoClick = function()
RP.Command:Run("OrderItem", itemData.uniqueID);
self:ClearPane();
end;
self.rightPane:AddItem(buttonPanel);[/code]
I'm confused, if you're setting it to a certain size then aren't you going to have the ... (which would be how it's supposed to work?)
[QUOTE=Banana Lord.;38410782]I'm confused, if you're setting it to a certain size then aren't you going to have the ... (which would be how it's supposed to work?)[/QUOTE]
I'll try and clarify a little more :S I'm setting it to a width of 292 (The width of rightPane as the button will be in the rightPane) and 30 for the height. Now, shouldn't this be ample enough space for the button not to cut off the "Buy" text with the "B..." text?
And on a side note, the mouse cursor changes to the hand when I go over the button like it should - yet I still can't click the button and have it's DoClick function ran. I assume this is related to the text being cut off as this shows that the DLabel in the button isn't being sized properly in the derma code. (Isn't a DButton just a panel with a DLabel in it handling the click function. Thus you have to click the label to run the function and not the panel?)
This'll probably get rated dumb, but, a mans gotta go what a mans gotta do - bump it. :suicide: I still haven't been able to solve this issue.
I had this issue before, a simple way around it would be to draw the text in the paint function using draw.SimpleText. [B][URL="http://wiki.garrysmod.com/page/Libraries/draw/SimpleText"]Libraries/draw/SimpleText[IMG]http://wiki.garrysmod.com/favicon.ico[/IMG][/URL][/B]
Holy shit, someone's using Omicron.
Cool story! That was exactly a year from now when I released that... then got banned from Facepunch for "leaking a private game-mode" when I was developing it. Always cool.
I know it's nothing to do with the way the label is created, but the theme. Because I'm sure it works fine without it.
Anyways, why not just get rid of the label painting in your skin..? You don't seem to be doing any changes that change it. Let me look at my skin for a gamemode.
[lua]
function SKIN:PaintLabel(panel)
return false
end
function SKIN:SchemeLabel(panel)
local color = nil
if (panel.Hovered and panel:GetTextColorHovered()) then
color = panel:GetTextColorHovered()
else
color = panel:GetTextColor()
end
if (color) then
panel:SetFGColor(color.r, color.g, color.b, color.a)
else
panel:SetFGColor(200, 200, 200, 255)
end
end
function SKIN:LayoutLabel(panel)
panel:ApplySchemeSettings()
if (panel.m_bAutoStretchVertical) then
panel:SizeToContentsY()
end
end
[/lua]
My LayoutLabel seems to be different. Try mine?
After trying both of your suggested solutions posted above, neither of them have fixed my issue. I've decided to use a Derma_Query() when the SpawnIcons are double clicked instead of having the buttons inside of the right column description area thus removing the problem. The Derma_Query() also looks pretty good with the skin I'm using. Anyways, thanks for all of your help! :downs:
Sorry, you need to Log In to post a reply to this thread.