mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-21 02:38:12 +08:00
Cleanup of variable naming
This commit is contained in:
@@ -193,7 +193,7 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import { makeModifiersBitfield } from "@/utilities/input";
|
||||
import { ResponseType, registerResponseHandler, Response, UpdateCanvas, SetActiveTool, ExportDocument, SetCanvasZoom, SetRotation } from "../../utilities/response-handler";
|
||||
import { ResponseType, registerResponseHandler, Response, UpdateCanvas, SetActiveTool, ExportDocument, SetCanvasZoom, SetCanvasRotation } from "../../utilities/response-handler";
|
||||
import LayoutRow from "../layout/LayoutRow.vue";
|
||||
import LayoutCol from "../layout/LayoutCol.vue";
|
||||
import WorkingColors from "../widgets/WorkingColors.vue";
|
||||
@@ -296,8 +296,8 @@ export default defineComponent({
|
||||
zoomWidget.setValue(updateData.new_zoom * 100);
|
||||
}
|
||||
});
|
||||
registerResponseHandler(ResponseType.SetRotation, (responseData: Response) => {
|
||||
const updateData = responseData as SetRotation;
|
||||
registerResponseHandler(ResponseType.SetCanvasRotation, (responseData: Response) => {
|
||||
const updateData = responseData as SetCanvasRotation;
|
||||
if (updateData) {
|
||||
const rotationWidget = this.$refs.rotation as typeof NumberInput;
|
||||
const newRotation = updateData.new_radians * (180 / Math.PI);
|
||||
|
||||
@@ -150,7 +150,7 @@ import Minimap from "../panels/Minimap.vue";
|
||||
import IconButton from "../widgets/buttons/IconButton.vue";
|
||||
import PopoverButton, { PopoverButtonIcon } from "../widgets/buttons/PopoverButton.vue";
|
||||
import { MenuDirection } from "../widgets/floating-menus/FloatingMenu.vue";
|
||||
import { ResponseType, registerResponseHandler, Response, PromptConfirmationToCloseDocument } from "../../utilities/response-handler";
|
||||
import { ResponseType, registerResponseHandler, Response, DisplayConfirmationToCloseDocument } from "../../utilities/response-handler";
|
||||
|
||||
const wasm = import("../../../wasm/pkg");
|
||||
|
||||
@@ -187,13 +187,11 @@ export default defineComponent({
|
||||
},
|
||||
mounted() {
|
||||
// TODO: Move these somewhere more appropriate to act upon all panels
|
||||
|
||||
registerResponseHandler(ResponseType.PromptConfirmationToCloseDocument, (responseData: Response) => {
|
||||
const promptData = responseData as PromptConfirmationToCloseDocument;
|
||||
this.closeDocumentWithConfirmation(promptData.document_index);
|
||||
registerResponseHandler(ResponseType.DisplayConfirmationToCloseDocument, (responseData: Response) => {
|
||||
const data = responseData as DisplayConfirmationToCloseDocument;
|
||||
this.closeDocumentWithConfirmation(data.document_index);
|
||||
});
|
||||
|
||||
registerResponseHandler(ResponseType.PromptConfirmationToCloseAllDocuments, (_responseData: Response) => {
|
||||
registerResponseHandler(ResponseType.DisplayConfirmationToCloseAllDocuments, (_responseData: Response) => {
|
||||
this.closeAllDocumentsWithConfirmation();
|
||||
});
|
||||
},
|
||||
|
||||
@@ -65,7 +65,6 @@ export default defineComponent({
|
||||
this.documents = documentListData.open_documents;
|
||||
}
|
||||
});
|
||||
|
||||
registerResponseHandler(ResponseType.SetActiveDocument, (responseData: Response) => {
|
||||
const documentData = responseData as SetActiveDocument;
|
||||
if (documentData) this.activeDocument = documentData.document_index;
|
||||
|
||||
@@ -21,9 +21,9 @@ export enum ResponseType {
|
||||
UpdateOpenDocumentsList = "UpdateOpenDocumentsList",
|
||||
UpdateWorkingColors = "UpdateWorkingColors",
|
||||
SetCanvasZoom = "SetCanvasZoom",
|
||||
SetRotation = "SetRotation",
|
||||
PromptConfirmationToCloseDocument = "PromptConfirmationToCloseDocument",
|
||||
PromptConfirmationToCloseAllDocuments = "PromptConfirmationToCloseAllDocuments",
|
||||
SetCanvasRotation = "SetCanvasRotation",
|
||||
DisplayConfirmationToCloseDocument = "DisplayConfirmationToCloseDocument",
|
||||
DisplayConfirmationToCloseAllDocuments = "DisplayConfirmationToCloseAllDocuments",
|
||||
}
|
||||
|
||||
export function registerResponseHandler(responseType: ResponseType, callback: ResponseCallback) {
|
||||
@@ -62,23 +62,23 @@ function parseResponse(responseType: string, data: any): Response {
|
||||
case "UpdateCanvas":
|
||||
return newUpdateCanvas(data.UpdateCanvas);
|
||||
case "SetCanvasZoom":
|
||||
return newSetZoom(data.SetCanvasZoom);
|
||||
case "SetRotation":
|
||||
return newSetRotation(data.SetRotation);
|
||||
return newSetCanvasZoom(data.SetCanvasZoom);
|
||||
case "SetCanvasRotation":
|
||||
return newSetCanvasRotation(data.SetCanvasRotation);
|
||||
case "ExportDocument":
|
||||
return newExportDocument(data.ExportDocument);
|
||||
case "UpdateWorkingColors":
|
||||
return newUpdateWorkingColors(data.UpdateWorkingColors);
|
||||
case "PromptConfirmationToCloseDocument":
|
||||
return newPromptConfirmationToCloseDocument(data.PromptConfirmationToCloseDocument);
|
||||
case "PromptConfirmationToCloseAllDocuments":
|
||||
return newPromptConfirmationToCloseAllDocuments(data.PromptConfirmationToCloseAllDocuments);
|
||||
case "DisplayConfirmationToCloseDocument":
|
||||
return newDisplayConfirmationToCloseDocument(data.DisplayConfirmationToCloseDocument);
|
||||
case "DisplayConfirmationToCloseAllDocuments":
|
||||
return newDisplayConfirmationToCloseAllDocuments(data.DisplayConfirmationToCloseAllDocuments);
|
||||
default:
|
||||
throw new Error(`Unrecognized origin/responseType pair: ${origin}, '${responseType}'`);
|
||||
}
|
||||
}
|
||||
|
||||
export type Response = SetActiveTool | UpdateCanvas | DocumentChanged | CollapseFolder | ExpandFolder | UpdateWorkingColors | SetCanvasZoom | SetRotation;
|
||||
export type Response = SetActiveTool | UpdateCanvas | DocumentChanged | CollapseFolder | ExpandFolder | UpdateWorkingColors | SetCanvasZoom | SetCanvasRotation;
|
||||
|
||||
export interface UpdateOpenDocumentsList {
|
||||
open_documents: Array<string>;
|
||||
@@ -127,16 +127,16 @@ function newSetActiveDocument(input: any): SetActiveDocument {
|
||||
};
|
||||
}
|
||||
|
||||
export interface PromptConfirmationToCloseDocument {
|
||||
export interface DisplayConfirmationToCloseDocument {
|
||||
document_index: number;
|
||||
}
|
||||
function newPromptConfirmationToCloseDocument(input: any): PromptConfirmationToCloseDocument {
|
||||
function newDisplayConfirmationToCloseDocument(input: any): DisplayConfirmationToCloseDocument {
|
||||
return {
|
||||
document_index: input.document_index,
|
||||
};
|
||||
}
|
||||
|
||||
function newPromptConfirmationToCloseAllDocuments(_input: any): {} {
|
||||
function newDisplayConfirmationToCloseAllDocuments(_input: any): {} {
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -186,16 +186,16 @@ function newExpandFolder(input: any): ExpandFolder {
|
||||
export interface SetCanvasZoom {
|
||||
new_zoom: number;
|
||||
}
|
||||
function newSetZoom(input: any): SetCanvasZoom {
|
||||
function newSetCanvasZoom(input: any): SetCanvasZoom {
|
||||
return {
|
||||
new_zoom: input.new_zoom,
|
||||
};
|
||||
}
|
||||
|
||||
export interface SetRotation {
|
||||
export interface SetCanvasRotation {
|
||||
new_radians: number;
|
||||
}
|
||||
function newSetRotation(input: any): SetRotation {
|
||||
function newSetCanvasRotation(input: any): SetCanvasRotation {
|
||||
return {
|
||||
new_radians: input.new_radians,
|
||||
};
|
||||
|
||||
@@ -182,7 +182,7 @@ pub fn set_zoom(new_zoom: f64) -> Result<(), JsValue> {
|
||||
/// Sets the rotation to the new value (in radians)
|
||||
#[wasm_bindgen]
|
||||
pub fn set_rotation(new_radians: f64) -> Result<(), JsValue> {
|
||||
let ev = DocumentMessage::SetRotation(new_radians);
|
||||
let ev = DocumentMessage::SetCanvasRotation(new_radians);
|
||||
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(ev)).map_err(convert_error)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user