-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
412 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
local CONTROL_BUTTON = {} | ||
function CONTROL_BUTTON:Init() | ||
self:SetText("") | ||
self:SetTooltipPanelOverride("Ponder.ControlTooltip") | ||
end | ||
|
||
local padding = 0 | ||
local paddingIfHover = -4 | ||
local paddingIfDepressed = 4 | ||
|
||
function CONTROL_BUTTON:SetImage(path) | ||
self.Material = Material(path, "mips smooth") | ||
end | ||
|
||
function CONTROL_BUTTON:Paint(w, h) | ||
local finalPadding = self.Depressed and paddingIfDepressed or self.Hovered and paddingIfHover or padding | ||
|
||
surface.SetDrawColor(255, 255, 255, 255) | ||
surface.SetMaterial(self.Material) | ||
surface.DrawTexturedRectRotated(w / 2, h / 2, 48 - finalPadding, 48 - finalPadding, 0) | ||
end | ||
|
||
function CONTROL_BUTTON:OnMousePressed(mousecode) | ||
DButton.OnMousePressed(self, mousecode) | ||
self.Depressed = true | ||
end | ||
|
||
function CONTROL_BUTTON:OnMouseReleased(mousecode) | ||
DButton.OnMouseReleased(self, mousecode) | ||
self.Depressed = false | ||
end | ||
|
||
|
||
derma.DefineControl("Ponder.ControlButton", "Control button", CONTROL_BUTTON, "DButton") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
local TOOLTIP = {} | ||
AccessorFunc(TOOLTIP, "_text", "Text", FORCE_STRING) | ||
AccessorFunc(TOOLTIP, "_font", "Font", FORCE_STRING) | ||
|
||
function TOOLTIP:Init() | ||
self.Birth = RealTime() | ||
|
||
self:SetText("") | ||
self:SetFont("DermaDefault") | ||
self:SetDrawOnTop(true) | ||
end | ||
|
||
function TOOLTIP:Lifetime() | ||
return RealTime() - self.Birth | ||
end | ||
|
||
function TOOLTIP:GetTextSize() | ||
surface.SetFont(self:GetFont()) | ||
return surface.GetTextSize(self:GetText()) | ||
end | ||
|
||
function TOOLTIP:Close() | ||
self:Remove() | ||
end | ||
|
||
function TOOLTIP:Think() | ||
local sW, sH = self:GetTextSize() | ||
self:SetTall(sH + 12) | ||
self:SetWide((sW * self:GetAlphaMult(0.7)) + 12) | ||
|
||
--local pX, pY = input.GetCursorPos() | ||
--self:SetPos(pX - (self:GetWide() / 2), pY - 8 - sH - 6) | ||
local target = self.Target | ||
local tpx, tpy = target:LocalToScreen(0, 0) | ||
tpx = tpx + (target:GetWide() / 2) | ||
self:SetPos(tpx - (self:GetWide() / 2), tpy - 8 - sH - 6) | ||
end | ||
|
||
function TOOLTIP:GetAlphaMult(min) | ||
return math.ease.InOutQuad(math.Clamp(math.Remap(self:Lifetime(), 0, 0.1, min or 0, 1), 0, 1)) | ||
end | ||
|
||
function TOOLTIP:Paint(w, h) | ||
surface.SetDrawColor(245, 245, 245, 220 * self:GetAlphaMult()) | ||
surface.DrawRect(0, 0, w, h) | ||
surface.SetDrawColor(25, 25, 25, 255 * self:GetAlphaMult()) | ||
surface.DrawOutlinedRect(0, 0, w, h) | ||
|
||
draw.SimpleText(self:GetText(), self:GetFont(), w / 2, h / 2, Color(25, 25, 25, 255 * self:GetAlphaMult()), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) | ||
end | ||
|
||
function TOOLTIP:OpenForPanel(pnl) | ||
self.Target = pnl | ||
end | ||
|
||
derma.DefineControl("Ponder.ControlTooltip", "Control tooltip", TOOLTIP, "DPanel") |
Oops, something went wrong.