mirror of
https://gitlab.com/cc-ru/ocelot/ocelot-desktop.git
synced 2026-01-06 19:22:38 +01:00
Remove ComponentSelector*
Nothing uses these classes, apparently.
This commit is contained in:
parent
8efa8e84c1
commit
766f0e5ae6
@ -42,10 +42,6 @@ ContextMenuHover = #363636
|
||||
ContextMenuSeparator = #444444
|
||||
ContextMenuIcon = #7F7F7F
|
||||
|
||||
ComponentSelectorBackground = #222222cc
|
||||
ComponentSelectorBorder = #444444
|
||||
ComponentSelectorText = #b0b0b0
|
||||
|
||||
ComputerAddress = #333333
|
||||
|
||||
ScreenOff = #000000
|
||||
|
||||
@ -6,7 +6,6 @@ import ocelot.desktop.graphics.Graphics
|
||||
import ocelot.desktop.ui.UiHandler
|
||||
import ocelot.desktop.ui.event.KeyEvent
|
||||
import ocelot.desktop.ui.layout.{CopyLayout, LinearLayout}
|
||||
import ocelot.desktop.ui.widget.component.ComponentSelectors
|
||||
import ocelot.desktop.ui.widget.contextmenu.ContextMenus
|
||||
import ocelot.desktop.ui.widget.itemdrag.DraggedItemPool
|
||||
import ocelot.desktop.ui.widget.modal.ModalDialogPool
|
||||
@ -31,7 +30,6 @@ class RootWidget(setupDefaultWorkspace: Boolean = true) extends Widget {
|
||||
val draggedItemPool = new DraggedItemPool
|
||||
val tooltipPool = new TooltipPool
|
||||
val contextMenus = new ContextMenus
|
||||
val componentSelectors = new ComponentSelectors
|
||||
val menuBar = new MenuBar
|
||||
val statusBar = new StatusBar
|
||||
|
||||
@ -48,7 +46,6 @@ class RootWidget(setupDefaultWorkspace: Boolean = true) extends Widget {
|
||||
children :+= draggedItemPool
|
||||
children :+= tooltipPool
|
||||
children :+= contextMenus
|
||||
children :+= componentSelectors
|
||||
|
||||
private var isDebugViewVisible = false
|
||||
|
||||
|
||||
@ -1,55 +0,0 @@
|
||||
package ocelot.desktop.ui.widget.component
|
||||
|
||||
import ocelot.desktop.ColorScheme
|
||||
import ocelot.desktop.graphics.Graphics
|
||||
import ocelot.desktop.ui.layout.LinearLayout
|
||||
import ocelot.desktop.ui.widget.Widget
|
||||
import ocelot.desktop.util.animation.ValueAnimation
|
||||
import ocelot.desktop.util.animation.easing.{EaseInOutQuad, EaseOutQuad}
|
||||
import ocelot.desktop.util.{DrawUtils, Orientation}
|
||||
|
||||
class ComponentSelector extends Widget {
|
||||
override protected val layout = new LinearLayout(this, orientation = Orientation.Vertical)
|
||||
|
||||
private var isClosing = false
|
||||
private var isOpening = false
|
||||
private val alpha = new ValueAnimation(0f, 8f)
|
||||
|
||||
def isClosed: Boolean = {
|
||||
alpha.isAt(0f)
|
||||
}
|
||||
|
||||
def open(): Unit = {
|
||||
isClosing = false
|
||||
isOpening = true
|
||||
alpha.jump(0.001f)
|
||||
alpha.goto(1f)
|
||||
alpha.easing = EaseInOutQuad
|
||||
}
|
||||
|
||||
def close(): Unit = {
|
||||
isClosing = true
|
||||
isOpening = false
|
||||
alpha.goto(0f)
|
||||
alpha.easing = EaseOutQuad
|
||||
}
|
||||
|
||||
override def draw(g: Graphics): Unit = {
|
||||
alpha.update()
|
||||
if (alpha.value < 1f) g.beginGroupAlpha() else isOpening = false
|
||||
|
||||
val height = bounds.h * alpha.value
|
||||
|
||||
DrawUtils.shadow(g, bounds.x - 8, bounds.y - 8, bounds.w + 16, height + 20, 0.5f)
|
||||
|
||||
g.save()
|
||||
g.setScissor(bounds.x, bounds.y, bounds.w, height)
|
||||
g.rect(bounds, ColorScheme("ComponentSelectorBackground"))
|
||||
drawChildren(g)
|
||||
g.restore()
|
||||
|
||||
DrawUtils.ring(g, bounds.x, bounds.y, bounds.w, height, 1, ColorScheme("ComponentSelectorBorder"))
|
||||
|
||||
if (alpha.value < 1f) g.endGroupAlpha(alpha.value)
|
||||
}
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
package ocelot.desktop.ui.widget.component
|
||||
|
||||
import ocelot.desktop.ColorScheme
|
||||
import ocelot.desktop.color.Color
|
||||
import ocelot.desktop.geometry.Padding2D
|
||||
import ocelot.desktop.graphics.IconSource
|
||||
import ocelot.desktop.ui.layout.{AlignItems, Layout, LinearLayout}
|
||||
import ocelot.desktop.ui.widget.{Icon, Label, PaddingBox, Widget}
|
||||
|
||||
class ComponentSelectorEntry(label: String, icon: IconSource) extends Widget {
|
||||
children :+= new Widget {
|
||||
override val layout: Layout = new LinearLayout(this, alignItems = AlignItems.Center)
|
||||
|
||||
children :+= new PaddingBox(new Icon(icon), Padding2D(left = 4f, top = 2f, bottom = 2f))
|
||||
|
||||
children :+= new PaddingBox(new Label {
|
||||
override def text: String = label
|
||||
override def color: Color = ColorScheme("ComponentSelectorText")
|
||||
}, Padding2D(left = 8f, right = 8f))
|
||||
}
|
||||
|
||||
override def receiveMouseEvents: Boolean = true
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
package ocelot.desktop.ui.widget.component
|
||||
|
||||
import ocelot.desktop.geometry.Vector2D
|
||||
import ocelot.desktop.ui.UiHandler
|
||||
import ocelot.desktop.ui.event.{KeyEvent, MouseEvent}
|
||||
import ocelot.desktop.ui.layout.Layout
|
||||
import ocelot.desktop.ui.widget.Widget
|
||||
import org.lwjgl.input.Keyboard
|
||||
|
||||
import scala.collection.immutable.ArraySeq
|
||||
|
||||
class ComponentSelectors extends Widget {
|
||||
override protected val layout: Layout = new Layout(this)
|
||||
|
||||
private def selectors: ArraySeq[ComponentSelector] = children.map(_.asInstanceOf[ComponentSelector])
|
||||
|
||||
override def receiveAllMouseEvents: Boolean = true
|
||||
|
||||
eventHandlers += {
|
||||
case KeyEvent(KeyEvent.State.Press, Keyboard.KEY_ESCAPE, _) =>
|
||||
closeAll()
|
||||
|
||||
case MouseEvent(MouseEvent.State.Press, _) =>
|
||||
if (!selectors.map(_.bounds).exists(_.contains(UiHandler.mousePosition))) closeAll()
|
||||
}
|
||||
|
||||
def open(selector: ComponentSelector, openPos: Vector2D): Unit = {
|
||||
selector.position = openPos
|
||||
selector.open()
|
||||
children :+= selector
|
||||
}
|
||||
|
||||
def close(selector: ComponentSelector): Unit = {
|
||||
selector.close()
|
||||
}
|
||||
|
||||
def closeAll(): Unit = {
|
||||
for (child <- selectors) close(child)
|
||||
}
|
||||
|
||||
override def update(): Unit = {
|
||||
super.update()
|
||||
children = children.filterNot(_.asInstanceOf[ComponentSelector].isClosed)
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user